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:com.thoughtworks.go.config.GoConfigMigrationIntegrationTest.java

private String migrateXmlString(String content, int fromVersion, int toVersion)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    GoConfigMigration upgrader = new GoConfigMigration(new TimeProvider(),
            ConfigElementImplementationRegistryMother.withNoPlugins());
    Method upgrade = upgrader.getClass().getDeclaredMethod("upgrade", String.class, Integer.TYPE, Integer.TYPE);
    upgrade.setAccessible(true);/*  w w  w  .  j a  v a  2 s  .c  o m*/
    return (String) upgrade.invoke(upgrader, content, fromVersion, toVersion);
}

From source file:com.ferdi2005.secondgram.voip.VoIPService.java

public boolean hasEarpiece() {
    if (((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
            .getPhoneType() != TelephonyManager.PHONE_TYPE_NONE)
        return true;
    if (mHasEarpiece != null) {
        return mHasEarpiece;
    }/*from  w w w  . j a v  a 2  s  . com*/

    // not calculated yet, do it now
    try {
        AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
        Method method = AudioManager.class.getMethod("getDevicesForStream", Integer.TYPE);
        Field field = AudioManager.class.getField("DEVICE_OUT_EARPIECE");
        int earpieceFlag = field.getInt(null);
        int bitmaskResult = (int) method.invoke(am, AudioManager.STREAM_VOICE_CALL);

        // check if masked by the earpiece flag
        if ((bitmaskResult & earpieceFlag) == earpieceFlag) {
            mHasEarpiece = Boolean.TRUE;
        } else {
            mHasEarpiece = Boolean.FALSE;
        }
    } catch (Throwable error) {
        FileLog.e("Error while checking earpiece! ", error);
        mHasEarpiece = Boolean.TRUE;
    }

    return mHasEarpiece;
}

From source file:org.apache.geode.internal.InternalDataSerializer.java

/**
 * Writes the type code for a primitive type Class to {@code DataOutput}.
 */// www  .  ja  v  a  2 s .co  m
public static void writePrimitiveClass(Class c, DataOutput out) throws IOException {
    if (c == Boolean.TYPE) {
        out.writeByte(BOOLEAN_TYPE);
    } else if (c == Character.TYPE) {
        out.writeByte(CHARACTER_TYPE);
    } else if (c == Byte.TYPE) {
        out.writeByte(BYTE_TYPE);
    } else if (c == Short.TYPE) {
        out.writeByte(SHORT_TYPE);
    } else if (c == Integer.TYPE) {
        out.writeByte(INTEGER_TYPE);
    } else if (c == Long.TYPE) {
        out.writeByte(LONG_TYPE);
    } else if (c == Float.TYPE) {
        out.writeByte(FLOAT_TYPE);
    } else if (c == Double.TYPE) {
        out.writeByte(DOUBLE_TYPE);
    } else if (c == Void.TYPE) {
        out.writeByte(VOID_TYPE);
    } else if (c == null) {
        out.writeByte(NULL);
    } else {
        throw new InternalGemFireError(LocalizedStrings.InternalDataSerializer_UNKNOWN_PRIMITIVE_TYPE_0
                .toLocalizedString(c.getName()));
    }
}

From source file:org.apache.geode.internal.InternalDataSerializer.java

public static Class decodePrimitiveClass(byte typeCode) {
    switch (typeCode) {
    case BOOLEAN_TYPE:
        return Boolean.TYPE;
    case CHARACTER_TYPE:
        return Character.TYPE;
    case BYTE_TYPE:
        return Byte.TYPE;
    case SHORT_TYPE:
        return Short.TYPE;
    case INTEGER_TYPE:
        return Integer.TYPE;
    case LONG_TYPE:
        return Long.TYPE;
    case FLOAT_TYPE:
        return Float.TYPE;
    case DOUBLE_TYPE:
        return Double.TYPE;
    case VOID_TYPE:
        return Void.TYPE;
    case NULL:/*from  w  w  w  . j  a v a 2s . co m*/
        return null;
    default:
        throw new InternalGemFireError(
                LocalizedStrings.InternalDataSerializer_UNEXPECTED_TYPECODE_0.toLocalizedString(typeCode));
    }
}

From source file:org.fornax.cartridges.sculptor.smartclient.server.ScServlet.java

public Object[] prepareMethodParam(HashMap<String, ? extends Object> jsData, boolean applyNull,
        String[] paramNames, Class[] parameterTypes) throws ApplicationException {
    boolean hasMapping = false;
    Object[] realParams = new Object[paramNames.length];
    try {//from ww w  .  ja v a2 s.  c om
        hasMapping = true;
        for (int i = 0; i < parameterTypes.length; i++) {
            Class<?> paramType = parameterTypes[i];
            //Object paramObject=jsData.get(paramNames[i]) == null ? jsData : jsData.get(paramNames[i]);
            Object paramObject = jsData.get(paramNames[i]);

            if (paramType.equals(ServiceContext.class)) {
                realParams[i] = ServiceContextStore.get();
            } else if (paramType.equals(PagingParameter.class)) {
                String sRow = (String) jsData.get("_startRow");
                int startRow = sRow == null ? 0 : Integer.parseInt(sRow);
                String eRow = (String) jsData.get("_endRow");
                int endRow = eRow == null ? 0 : Integer.parseInt(eRow);

                realParams[i] = PagingParameter.rowAccess(startRow, endRow, LOOK_AHEAD);
            } else if (paramType.equals(String.class)) {
                realParams[i] = (String) paramObject;
            } else if (paramType.equals(Integer.class) || paramType.equals(Integer.TYPE)) {
                realParams[i] = paramObject == null ? null
                        : Integer.parseInt(((String) paramObject).replaceAll("\"", ""));
            } else if (paramType.equals(Long.class) || paramType.equals(Long.TYPE)) {
                realParams[i] = paramObject == null ? null
                        : Long.parseLong(((String) paramObject).replaceAll("\"", ""));
            } else if (paramType.equals(Double.class) || paramType.equals(Double.TYPE)) {
                realParams[i] = paramObject == null ? null
                        : Double.parseDouble(((String) paramObject).replaceAll("\"", ""));
            } else if (paramType.equals(Date.class)) {
                realParams[i] = paramObject == null ? null : dateFormat.parse((String) paramObject);
            } else if (paramType.equals(Boolean.class) || paramType.equals(Boolean.TYPE)) {
                realParams[i] = ("true".equals(paramObject));
            } else if (paramObject instanceof HashMap || (paramObject == null && jsData instanceof HashMap)) {
                HashMap<String, Object> objData = (HashMap<String, Object>) (paramObject == null ? jsData
                        : paramObject);
                ServiceDescription service = findServiceByClassName(paramType.getName());
                if (objData.get("id") != null && service != null) {
                    Long id = Long.parseLong((String) objData.get("id"));
                    realParams[i] = service.getFindById().invoke(service.getInstance(),
                            ServiceContextStore.get(), id);
                } else {
                    realParams[i] = makeNewInstance(paramType, objData);
                }
                mapRequestToObj(objData, paramType, realParams[i]);
            } else if (findServiceByClassName(paramType.getName()) != null) {
                ServiceDescription service = findServiceByClassName(paramType.getName());
                Long recId = Long.parseLong((String) paramObject);
                realParams[i] = service.getFindById().invoke(service.getInstance(), ServiceContextStore.get(),
                        recId);
            } else if (Enum.class.isAssignableFrom(paramType)) {
                try {
                    Method fromValueMethod = paramType.getMethod("fromValue", String.class);
                    realParams[i] = fromValueMethod.invoke(null, paramObject);
                } catch (Exception ex) {
                }

                try {
                    if (realParams[i] == null) {
                        Method valueOfMethod = paramType.getMethod("valueOf", String.class);
                        realParams[i] = valueOfMethod.invoke(null, paramObject);
                    }
                } catch (Exception ex) {
                }

                if (realParams[i] == null) {
                    hasMapping = false;
                    break;
                }
            } else if (applyNull) {
                realParams[i] = null;
            } else {
                hasMapping = false;
                break;
            }
        }
    } catch (ApplicationException appEx) {
        throw appEx;
    } catch (Exception ex) {
        throw new ApplicationException(ex.getMessage(), "ERR9001", ex);
    }

    return hasMapping ? realParams : null;
}

From source file:org.apache.geode.internal.InternalDataSerializer.java

public static Object basicReadObject(final DataInput in) throws IOException, ClassNotFoundException {
    checkIn(in);/*ww w. j a  va2 s  . com*/

    // Read the header byte
    byte header = in.readByte();
    if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
        logger.trace(LogMarker.SERIALIZER, "basicReadObject: header={}", header);
    }
    switch (header) {
    case DS_FIXED_ID_BYTE:
        return DSFIDFactory.create(in.readByte(), in);
    case DS_FIXED_ID_SHORT:
        return DSFIDFactory.create(in.readShort(), in);
    case DS_FIXED_ID_INT:
        return DSFIDFactory.create(in.readInt(), in);
    case DS_NO_FIXED_ID:
        return readDataSerializableFixedID(in);
    case NULL:
        return null;
    case NULL_STRING:
    case STRING:
    case HUGE_STRING:
    case STRING_BYTES:
    case HUGE_STRING_BYTES:
        return readString(in, header);
    case CLASS:
        return readClass(in);
    case DATE:
        return readDate(in);
    case FILE:
        return readFile(in);
    case INET_ADDRESS:
        return readInetAddress(in);
    case BOOLEAN:
        return readBoolean(in);
    case CHARACTER:
        return readCharacter(in);
    case BYTE:
        return readByte(in);
    case SHORT:
        return readShort(in);
    case INTEGER:
        return readInteger(in);
    case LONG:
        return readLong(in);
    case FLOAT:
        return readFloat(in);
    case DOUBLE:
        return readDouble(in);
    case BYTE_ARRAY:
        return readByteArray(in);
    case ARRAY_OF_BYTE_ARRAYS:
        return readArrayOfByteArrays(in);
    case SHORT_ARRAY:
        return readShortArray(in);
    case STRING_ARRAY:
        return readStringArray(in);
    case INT_ARRAY:
        return readIntArray(in);
    case LONG_ARRAY:
        return readLongArray(in);
    case FLOAT_ARRAY:
        return readFloatArray(in);
    case DOUBLE_ARRAY:
        return readDoubleArray(in);
    case BOOLEAN_ARRAY:
        return readBooleanArray(in);
    case CHAR_ARRAY:
        return readCharArray(in);
    case OBJECT_ARRAY:
        return readObjectArray(in);
    case ARRAY_LIST:
        return readArrayList(in);
    case LINKED_LIST:
        return readLinkedList(in);
    case HASH_SET:
        return readHashSet(in);
    case LINKED_HASH_SET:
        return readLinkedHashSet(in);
    case HASH_MAP:
        return readHashMap(in);
    case IDENTITY_HASH_MAP:
        return readIdentityHashMap(in);
    case HASH_TABLE:
        return readHashtable(in);
    case CONCURRENT_HASH_MAP:
        return readConcurrentHashMap(in);
    case PROPERTIES:
        return readProperties(in);
    case TIME_UNIT:
        return readTimeUnit(in);
    case USER_CLASS:
        return readUserObject(in, in.readByte());
    case USER_CLASS_2:
        return readUserObject(in, in.readShort());
    case USER_CLASS_4:
        return readUserObject(in, in.readInt());
    case VECTOR:
        return readVector(in);
    case STACK:
        return readStack(in);
    case TREE_MAP:
        return readTreeMap(in);
    case TREE_SET:
        return readTreeSet(in);
    case BOOLEAN_TYPE:
        return Boolean.TYPE;
    case CHARACTER_TYPE:
        return Character.TYPE;
    case BYTE_TYPE:
        return Byte.TYPE;
    case SHORT_TYPE:
        return Short.TYPE;
    case INTEGER_TYPE:
        return Integer.TYPE;
    case LONG_TYPE:
        return Long.TYPE;
    case FLOAT_TYPE:
        return Float.TYPE;
    case DOUBLE_TYPE:
        return Double.TYPE;
    case VOID_TYPE:
        return Void.TYPE;

    case USER_DATA_SERIALIZABLE:
        return readUserDataSerializable(in, in.readByte());
    case USER_DATA_SERIALIZABLE_2:
        return readUserDataSerializable(in, in.readShort());
    case USER_DATA_SERIALIZABLE_4:
        return readUserDataSerializable(in, in.readInt());

    case DATA_SERIALIZABLE:
        return readDataSerializable(in);

    case SERIALIZABLE: {
        final boolean isDebugEnabled_SERIALIZER = logger.isTraceEnabled(LogMarker.SERIALIZER);
        Object serializableResult;
        if (in instanceof DSObjectInputStream) {
            serializableResult = ((DSObjectInputStream) in).readObject();
        } else {
            InputStream stream;
            if (in instanceof InputStream) {
                stream = (InputStream) in;
            } else {
                stream = new InputStream() {
                    @Override
                    public int read() throws IOException {
                        try {
                            return in.readUnsignedByte(); // fix for bug 47249
                        } catch (EOFException ignored) {
                            return -1;
                        }
                    }

                };
            }

            ObjectInput ois = new DSObjectInputStream(stream);
            if (stream instanceof VersionedDataStream) {
                Version v = ((VersionedDataStream) stream).getVersion();
                if (v != null && v != Version.CURRENT) {
                    ois = new VersionedObjectInput(ois, v);
                }
            }

            serializableResult = ois.readObject();

            if (isDebugEnabled_SERIALIZER) {
                logger.trace(LogMarker.SERIALIZER, "Read Serializable object: {}", serializableResult);
            }
        }
        if (isDebugEnabled_SERIALIZER) {
            logger.trace(LogMarker.SERIALIZER, "deserialized instanceof {}", serializableResult.getClass());
        }
        return serializableResult;
    }
    case PDX:
        return readPdxSerializable(in);
    case PDX_ENUM:
        return readPdxEnum(in);
    case GEMFIRE_ENUM:
        return readGemFireEnum(in);
    case PDX_INLINE_ENUM:
        return readPdxInlineEnum(in);
    case BIG_INTEGER:
        return readBigInteger(in);
    case BIG_DECIMAL:
        return readBigDecimal(in);
    case UUID:
        return readUUID(in);
    case TIMESTAMP:
        return readTimestamp(in);
    default:
        String s = "Unknown header byte: " + header;
        throw new IOException(s);
    }
}

From source file:com.inmobi.rendering.RenderView.java

public void m1987o() {
    Logger.m1744a(InternalLogLevel.INTERNAL, f1748a, "disableHardwareAcceleration called.");
    this.f1762M = false;
    String str = "setLayerType";
    if (VERSION.SDK_INT >= 14) {
        try {/*from  w w  w  .  j a  v a  2 s  . c  o  m*/
            getClass().getMethod("setLayerType", new Class[] { Integer.TYPE, Paint.class }).invoke(this,
                    new Object[] { Integer.valueOf(1), null });
        } catch (Throwable e) {
            Logger.m1745a(InternalLogLevel.INTERNAL, f1748a, "disableHardwareAcceleration failed.", e);
        } catch (Throwable e2) {
            Logger.m1745a(InternalLogLevel.INTERNAL, f1748a, "disableHardwareAcceleration failed.", e2);
        } catch (Throwable e22) {
            Logger.m1745a(InternalLogLevel.INTERNAL, f1748a, "disableHardwareAcceleration failed.", e22);
        } catch (Throwable e222) {
            Logger.m1745a(InternalLogLevel.INTERNAL, f1748a, "disableHardwareAcceleration failed.", e222);
        }
    }
}

From source file:net.ravendb.client.connection.ServerClient.java

private boolean assertNonConflictedDocumentAndCheckIfNeedToReload(OperationMetadata operationMetadata,
        RavenJObject docResult, Function1<String, ConflictException> onClictedQueryResult) {
    if (docResult == null) {
        return false;
    }//from  w w w .j a  v a  2  s. co  m
    RavenJToken metadata = docResult.get(Constants.METADATA);
    if (metadata == null) {
        return false;
    }

    if (metadata.value(Integer.TYPE, "@Http-Status-Code") == 409) {
        ConflictException concurrencyException = tryResolveConflictOrCreateConcurrencyException(
                operationMetadata, metadata.value(String.class, "@id"), docResult,
                HttpExtensions.etagHeaderToEtag(metadata.value(String.class, "@etag")));
        if (concurrencyException == null) {
            return true;
        }
        throw concurrencyException;
    }

    if (metadata.value(Boolean.TYPE, Constants.RAVEN_REPLICATION_CONFLICT) && onClictedQueryResult != null) {
        throw onClictedQueryResult.apply(metadata.value(String.class, "@id"));
    }

    return false;
}

From source file:com.clark.func.Functions.java

/**
 * <p>/*  w  ww  .  j  av a2  s. c  o m*/
 * Checks if one <code>Class</code> can be assigned to a variable of another
 * <code>Class</code>.
 * </p>
 * 
 * <p>
 * Unlike the {@link Class#isAssignableFrom(java.lang.Class)} method, this
 * method takes into account widenings of primitive classes and
 * <code>null</code>s.
 * </p>
 * 
 * <p>
 * Primitive widenings allow an int to be assigned to a long, float or
 * double. This method returns the correct result for these cases.
 * </p>
 * 
 * <p>
 * <code>Null</code> may be assigned to any reference type. This method will
 * return <code>true</code> if <code>null</code> is passed in and the
 * toClass is non-primitive.
 * </p>
 * 
 * <p>
 * Specifically, this method tests whether the type represented by the
 * specified <code>Class</code> parameter can be converted to the type
 * represented by this <code>Class</code> object via an identity conversion
 * widening primitive or widening reference conversion. See
 * <em><a href="http://java.sun.com/docs/books/jls/">The Java Language Specification</a></em>
 * , sections 5.1.1, 5.1.2 and 5.1.4 for details.
 * </p>
 * 
 * @param cls
 *            the Class to check, may be null
 * @param toClass
 *            the Class to try to assign into, returns false if null
 * @param autoboxing
 *            whether to use implicit autoboxing/unboxing between primitives
 *            and wrappers
 * @return <code>true</code> if assignment possible
 */
public static boolean isAssignable(Class<?> cls, Class<?> toClass, boolean autoboxing) {
    if (toClass == null) {
        return false;
    }
    // have to check for null, as isAssignableFrom doesn't
    if (cls == null) {
        return !(toClass.isPrimitive());
    }
    // autoboxing:
    if (autoboxing) {
        if (cls.isPrimitive() && !toClass.isPrimitive()) {
            cls = primitiveToWrapper(cls);
            if (cls == null) {
                return false;
            }
        }
        if (toClass.isPrimitive() && !cls.isPrimitive()) {
            cls = wrapperToPrimitive(cls);
            if (cls == null) {
                return false;
            }
        }
    }
    if (cls.equals(toClass)) {
        return true;
    }
    if (cls.isPrimitive()) {
        if (toClass.isPrimitive() == false) {
            return false;
        }
        if (Integer.TYPE.equals(cls)) {
            return Long.TYPE.equals(toClass) || Float.TYPE.equals(toClass) || Double.TYPE.equals(toClass);
        }
        if (Long.TYPE.equals(cls)) {
            return Float.TYPE.equals(toClass) || Double.TYPE.equals(toClass);
        }
        if (Boolean.TYPE.equals(cls)) {
            return false;
        }
        if (Double.TYPE.equals(cls)) {
            return false;
        }
        if (Float.TYPE.equals(cls)) {
            return Double.TYPE.equals(toClass);
        }
        if (Character.TYPE.equals(cls)) {
            return Integer.TYPE.equals(toClass) || Long.TYPE.equals(toClass) || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
        }
        if (Short.TYPE.equals(cls)) {
            return Integer.TYPE.equals(toClass) || Long.TYPE.equals(toClass) || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
        }
        if (Byte.TYPE.equals(cls)) {
            return Short.TYPE.equals(toClass) || Integer.TYPE.equals(toClass) || Long.TYPE.equals(toClass)
                    || Float.TYPE.equals(toClass) || Double.TYPE.equals(toClass);
        }
        // should never get here
        return false;
    }
    return toClass.isAssignableFrom(cls);
}