Example usage for java.lang Integer TYPE

List of usage examples for java.lang Integer TYPE

Introduction

In this page you can find the example usage for java.lang Integer TYPE.

Prototype

Class TYPE

To view the source code for java.lang Integer TYPE.

Click Source Link

Document

The Class instance representing the primitive type int .

Usage

From source file:it.scoppelletti.mobilepower.app.AbstractDialogFragment.java

public Member resolveMember(Class<?> clazz, int memberCode) {
    Member member;/*from  www.j  ava  2 s. c  o m*/

    try {
        switch (memberCode) {
        case AbstractDialogFragment.CTOR_ALERTDIALOGBUILDER:
            member = clazz.getConstructor(Context.class, Integer.TYPE);
            break;

        default:
            throw new NoSuchMethodException(String.format("Unexpected memberCode %1$d.", memberCode));
        }
    } catch (Exception ex) {
        throw new UnsupportedOperationException(ex.getMessage(), ex);
    }

    return member;
}

From source file:com.anaplan.client.transport.JCIFSEngine.java

/** {@inheritDoc} */
@Override/* w w w  . j  ava2 s  .co  m*/
public String generateType3Msg(String username, String password, String domain, String workstation,
        String challenge) throws NTLMEngineException {
    if (domain == null) {
        throw new NTLMEngineException("Domain must be specified with user name");
    }
    try {
        byte[] byteArray = (byte[]) BASE64.getMethod("decode", String.class).invoke(null, challenge);
        Object type2Message = TYPE_2_MESSAGE.getConstructor(byteArray.getClass()).newInstance(byteArray);
        Integer type2Flags = (Integer) TYPE_2_MESSAGE.getMethod("getFlags").invoke(type2Message);
        int type3Flags = type2Flags & (0xffffffff ^ (NTLMSSP_TARGET_TYPE_DOMAIN | NTLMSSP_TARGET_TYPE_SERVER));
        Object type3Message = TYPE_3_MESSAGE
                .getConstructor(TYPE_2_MESSAGE, String.class, String.class, String.class, String.class,
                        Integer.TYPE)
                .newInstance(type2Message, password, domain, username, workstation, type3Flags);
        byte[] type3ByteArray = (byte[]) TYPE_3_MESSAGE.getMethod("toByteArray").invoke(type3Message);
        return (String) BASE64.getMethod("encode", type3ByteArray.getClass()).invoke(null, type3ByteArray);
    } catch (Exception thrown) {
        throw new NTLMEngineException("Failed to generate NTLM type 3 message", thrown);
    }
}

From source file:com.tingtingapps.securesms.mms.LegacyMmsConnection.java

@SuppressWarnings("TryWithIdenticalCatches")
protected static boolean checkRouteToHost(Context context, String host, boolean usingMmsRadio)
        throws IOException {
    InetAddress inetAddress = InetAddress.getByName(host);
    if (!usingMmsRadio) {
        if (inetAddress.isSiteLocalAddress()) {
            throw new IOException("RFC1918 address in non-MMS radio situation!");
        }/*from   www .  j  av a2 s  . com*/
        Log.w(TAG, "returning vacuous success since MMS radio is not in use");
        return true;
    }

    if (inetAddress == null) {
        throw new IOException("Unable to lookup host: InetAddress.getByName() returned null.");
    }

    byte[] ipAddressBytes = inetAddress.getAddress();
    if (ipAddressBytes == null) {
        Log.w(TAG, "resolved IP address bytes are null, returning true to attempt a connection anyway.");
        return true;
    }

    Log.w(TAG, "Checking route to address: " + host + ", " + inetAddress.getHostAddress());
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    try {
        final Method requestRouteMethod = manager.getClass().getMethod("requestRouteToHostAddress",
                Integer.TYPE, InetAddress.class);
        final boolean routeToHostObtained = (Boolean) requestRouteMethod.invoke(manager,
                MmsRadio.TYPE_MOBILE_MMS, inetAddress);
        Log.w(TAG, "requestRouteToHostAddress(" + inetAddress + ") -> " + routeToHostObtained);
        return routeToHostObtained;
    } catch (NoSuchMethodException nsme) {
        Log.w(TAG, nsme);
    } catch (IllegalAccessException iae) {
        Log.w(TAG, iae);
    } catch (InvocationTargetException ite) {
        Log.w(TAG, ite);
    }

    final int ipAddress = Conversions.byteArrayToIntLittleEndian(ipAddressBytes, 0);
    final boolean routeToHostObtained = manager.requestRouteToHost(MmsRadio.TYPE_MOBILE_MMS, ipAddress);
    Log.w(TAG, "requestRouteToHost(" + ipAddress + ") -> " + routeToHostObtained);
    return routeToHostObtained;
}

From source file:RenderingUtils.java

private static Method getMethodDrawStringUnderlineCharAt() {
    try {//from w w  w .  j  a v  a2  s . c om
        Class clazz = Class.forName(SWING_UTILITIES2_NAME);
        return clazz.getMethod("drawStringUnderlineCharAt", new Class[] { JComponent.class, Graphics.class,
                String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE });
    } catch (ClassNotFoundException e) {
        // returns null
    } catch (SecurityException e) {
        // returns null
    } catch (NoSuchMethodException e) {
        // returns null
    }
    return null;
}

From source file:com.link_intersystems.lang.Conversions.java

/**
 * char to int, long, float, or double/*  w w w .  j  a v a2s. c  o m*/
 */
private static boolean isPrimitiveCharacterWidening(Class<?> to) {
    boolean isWidening = isPrimitiveIntegerWidening(to);

    isWidening |= isIdentity(to, Integer.TYPE);

    return isWidening;
}

From source file:org.briljantframework.data.Na.java

/**
 * Returns the {@code NA} value for the class {@code T}. For reference types (excluding
 * {@link Complex} and {@link Logical}) {@code NA} is represented as {@code null}, but for
 * primitive types a special convention is used.
 *
 * <ul>/*from   w  ww.j  av a2 s . c  o m*/
 * <li>{@code double}: {@link Na#DOUBLE}</li>
 * <li>{@code int}: {@link Na#INT}</li>
 * <li>{@code long}: {@link Long#MAX_VALUE}</li>
 * <li>{@link Logical}: {@link Logical#NA}</li>
 * <li>{@link Complex}: {@link Na#COMPLEX}</li>
 * </ul>
 *
 * @param cls the class
 * @param <T> the type of {@code cls}
 * @return a {@code NA} value of type {@code T}
 */
@SuppressWarnings("unchecked")
public static <T> T of(Class<T> cls) {
    if (cls == null) {
        return null;
    } else if (Double.class.equals(cls) || Double.TYPE.equals(cls)) {
        return (T) BOXED_DOUBLE;
    } else if (Float.class.equals(cls) || Float.TYPE.equals(cls)) {
        return (T) BOXED_FLOAT;
    } else if (Long.class.equals(cls) || Long.TYPE.equals(cls)) {
        return (T) BOXED_LONG;
    } else if (Integer.class.equals(cls) || Integer.TYPE.equals(cls)) {
        return (T) BOXED_INT;
    } else if (Short.class.equals(cls) || Short.TYPE.equals(cls)) {
        return (T) BOXED_SHORT;
    } else if (Byte.class.equals(cls) || Byte.TYPE.equals(cls)) {
        return (T) BOXED_BYTE;
    } else if (Character.class.equals(cls) || Character.TYPE.equals(cls)) {
        return (T) BOXED_CHAR;
    } else if (Logical.class.equals(cls)) {
        return (T) Logical.NA;
    } else if (Complex.class.equals(cls)) {
        return (T) COMPLEX;
    } else {
        return null;
    }
}

From source file:Main.java

/**
 * renderArray returns an array similar to a List. If the array type is an
 * object they are rendered with "render(object)" for each. If the array
 * type is a primitive each element is added directly to the string buffer
 * collecting the result.//  w w w.  j a  va  2  s  .c o m
 * 
 * @param o
 * @param objectClass
 * @return
 */
private static StringBuffer renderArray(Object o, Class<?> objectClass) {
    Class<?> componentType = objectClass.getComponentType();
    StringBuffer sb = new StringBuffer(ARRAY_PREFIX);

    if (componentType.isPrimitive() == false) {
        Object[] oa = (Object[]) o;
        for (int i = 0; i < oa.length; i++) {
            if (i > 0) {
                sb.append(ELEMENT_SEPARATOR);
            }
            sb.append(render(oa[i]));
        }
    } else {
        if (Boolean.TYPE.equals(componentType)) {
            boolean[] ba = (boolean[]) o;
            for (int i = 0; i < ba.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ba[i]);
            }
        } else if (Integer.TYPE.equals(componentType)) {
            int[] ia = (int[]) o;
            for (int i = 0; i < ia.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ia[i]);
            }

        } else if (Long.TYPE.equals(componentType)) {
            long[] ia = (long[]) o;
            for (int i = 0; i < ia.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ia[i]);
            }
        } else if (Double.TYPE.equals(componentType)) {
            double[] ia = (double[]) o;
            for (int i = 0; i < ia.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ia[i]);
            }
        } else if (Float.TYPE.equals(componentType)) {
            float[] ia = (float[]) o;
            for (int i = 0; i < ia.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ia[i]);
            }
        } else if (Character.TYPE.equals(componentType)) {
            char[] ia = (char[]) o;
            for (int i = 0; i < ia.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ia[i]);
            }
        } else if (Short.TYPE.equals(componentType)) {
            short[] ia = (short[]) o;
            for (int i = 0; i < ia.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ia[i]);
            }
        } else if (Byte.TYPE.equals(componentType)) {
            byte[] ia = (byte[]) o;
            for (int i = 0; i < ia.length; i++) {
                if (i > 0) {
                    sb.append(ELEMENT_SEPARATOR);
                }
                sb.append(ia[i]);
            }
        }
    }
    sb.append(ARRAY_SUFFIX);
    return sb;
}

From source file:com.projity.util.ClassUtils.java

/**
 * Given a type, return its default value.  If type is unknown, a new one is constructed
 * @param clazz//from   w w w .ja v  a2s.c om
 * @return
 */
public static Object getDefaultValueForType(Class clazz) {
    if (clazz == String.class)
        return defaultString;
    else if (clazz == Double.class || clazz == Double.TYPE)
        return defaultDouble;
    else if (clazz == Integer.class || clazz == Integer.TYPE)
        return defaultInteger;
    else if (clazz == Long.class || clazz == Long.TYPE)
        return defaultLong;
    else if (clazz == Float.class || clazz == Float.TYPE)
        return defaultFloat;
    else if (clazz == Boolean.class)
        return defaultBoolean;
    else if (clazz == Rate.class)
        return defaultRate;
    else {
        try {
            System.out.println("making default for class" + clazz);
            return clazz.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}

From source file:org.apache.hadoop.hbase.regionserver.wal.SequenceFileLogWriter.java

@Override
public void init(FileSystem fs, Path path, Configuration conf, boolean overwritable) throws IOException {
    super.init(fs, path, conf, overwritable);
    boolean compress = initializeCompressionContext(conf, path);
    // Create a SF.Writer instance.
    try {//  w  w w  .j  a v  a2 s  .c  om
        // reflection for a version of SequenceFile.createWriter that doesn't
        // automatically create the parent directory (see HBASE-2312)
        this.writer = (SequenceFile.Writer) SequenceFile.class
                .getMethod("createWriter",
                        new Class[] { FileSystem.class, Configuration.class, Path.class, Class.class,
                                Class.class, Integer.TYPE, Short.TYPE, Long.TYPE, Boolean.TYPE,
                                CompressionType.class, CompressionCodec.class, Metadata.class })
                .invoke(null,
                        new Object[] { fs, conf, path, HLogKey.class, WALEdit.class,
                                Integer.valueOf(FSUtils.getDefaultBufferSize(fs)),
                                Short.valueOf((short) conf.getInt("hbase.regionserver.hlog.replication",
                                        FSUtils.getDefaultReplication(fs, path))),
                                Long.valueOf(conf.getLong("hbase.regionserver.hlog.blocksize",
                                        FSUtils.getDefaultBlockSize(fs, path))),
                                Boolean.valueOf(false) /*createParent*/, SequenceFile.CompressionType.NONE,
                                new DefaultCodec(), createMetadata(conf, compress) });
    } catch (InvocationTargetException ite) {
        // function was properly called, but threw it's own exception
        throw new IOException(ite.getCause());
    } catch (Exception e) {
        // ignore all other exceptions. related to reflection failure
    }

    // if reflection failed, use the old createWriter
    if (this.writer == null) {
        LOG.debug("new createWriter -- HADOOP-6840 -- not available");
        this.writer = SequenceFile.createWriter(fs, conf, path, HLogKey.class, WALEdit.class,
                FSUtils.getDefaultBufferSize(fs),
                (short) conf.getInt("hbase.regionserver.hlog.replication",
                        FSUtils.getDefaultReplication(fs, path)),
                conf.getLong("hbase.regionserver.hlog.blocksize", FSUtils.getDefaultBlockSize(fs, path)),
                SequenceFile.CompressionType.NONE, new DefaultCodec(), null, createMetadata(conf, compress));
    } else {
        if (LOG.isTraceEnabled())
            LOG.trace("Using new createWriter -- HADOOP-6840");
    }

    this.writer_out = getSequenceFilePrivateFSDataOutputStreamAccessible();
    if (LOG.isTraceEnabled())
        LOG.trace("Path=" + path + ", compression=" + compress);
}

From source file:com.l2jfree.config.L2Properties.java

@SuppressWarnings("unchecked")
public Object getProperty(Class<?> expectedType, ConfigProperty configProperty) {
    final String name = configProperty.name();
    final String defaultValue = configProperty.value();

    if (expectedType == Boolean.class || expectedType == Boolean.TYPE) {
        return getBool(name, defaultValue);
    } else if (expectedType == Long.class || expectedType == Long.TYPE) {
        return getLong(name, defaultValue);
    } else if (expectedType == Integer.class || expectedType == Integer.TYPE) {
        return getInteger(name, defaultValue);
    } else if (expectedType == Short.class || expectedType == Short.TYPE) {
        return getShort(name, defaultValue);
    } else if (expectedType == Byte.class || expectedType == Byte.TYPE) {
        return getByte(name, defaultValue);
    } else if (expectedType == Double.class || expectedType == Double.TYPE) {
        return getDouble(name, defaultValue);
    } else if (expectedType == Float.class || expectedType == Float.TYPE) {
        return getFloat(name, defaultValue);
    } else if (expectedType == String.class) {
        return getString(name, defaultValue);
    } else if (expectedType.isEnum()) {
        return getEnum(name, (Class<? extends Enum>) expectedType, defaultValue);
    } else {//from   ww w .j  a v a 2s .  c  om
        throw new IllegalStateException();
    }
}