List of usage examples for java.lang Integer TYPE
Class TYPE
To view the source code for java.lang Integer TYPE.
Click Source Link
From source file:MethodHashing.java
static String getTypeString(Class cl) { if (cl == Byte.TYPE) { return "B"; } else if (cl == Character.TYPE) { return "C"; } else if (cl == Double.TYPE) { return "D"; } else if (cl == Float.TYPE) { return "F"; } else if (cl == Integer.TYPE) { return "I"; } else if (cl == Long.TYPE) { return "J"; } else if (cl == Short.TYPE) { return "S"; } else if (cl == Boolean.TYPE) { return "Z"; } else if (cl == Void.TYPE) { return "V"; } else if (cl.isArray()) { return "[" + getTypeString(cl.getComponentType()); } else {/*from w w w .java 2 s . c o m*/ return "L" + cl.getName().replace('.', '/') + ";"; } }
From source file:com.gsbabil.antitaintdroid.UtilityFunctions.java
@SuppressLint("NewApi") public String runRemoteDex(String fullClassName, String methodName, String in) { String out = new String(); @SuppressWarnings("unused") Class<?> noparams[] = {}; Class<?>[] paramStr = new Class[1]; paramStr[0] = String.class; Class<?>[] paramInt = new Class[1]; paramInt[0] = Integer.TYPE; String path = MyApp.context.getFilesDir() + File.separator + MyApp.REMOTE_DEX_URL.substring(MyApp.REMOTE_DEX_URL.lastIndexOf('/') + 1); try {/*from www. j av a 2 s.c om*/ DexClassLoader classLoader = new DexClassLoader(path, MyApp.context.getFilesDir().getAbsolutePath(), null, MyApp.context.getClassLoader()); Class<?> remoteClass = classLoader.loadClass("com.gsbabil.remotedex.UntaintTricks"); Method remoteMethod = remoteClass.getDeclaredMethod("encodingTrick", paramStr); Object obj = remoteClass.newInstance(); out = (String) remoteMethod.invoke(obj, in); } catch (Exception e) { Log.d(MyApp.TAG, e.getMessage().toString()); } return out; }
From source file:org.briljantframework.data.vector.Convert.java
@SuppressWarnings("unchecked") private static <T> T convertLogical(Class<T> cls, Logical log) { if (cls.equals(Double.class) || cls.equals(Double.TYPE)) { return (T) (Double) (log == Logical.TRUE ? 1.0 : 0.0); } else if (cls.equals(Float.class) || cls.equals(Float.TYPE)) { return (T) (Float) (log == Logical.TRUE ? 1.0f : 0.0f); } else if (cls.equals(Long.class) || cls.equals(Long.TYPE)) { return (T) (Long) (log == Logical.TRUE ? 1l : 0l); } else if (cls.equals(Integer.class) || cls.equals(Integer.TYPE)) { return (T) (Integer) (log == Logical.TRUE ? 1 : 0); } else if (cls.equals(Short.class) || cls.equals(Short.TYPE)) { return (T) (Short) (log == Logical.TRUE ? (short) 1 : (short) 0); } else if (cls.equals(Byte.class) || cls.equals(Byte.TYPE)) { return (T) (Byte) (log == Logical.TRUE ? (byte) 1 : (byte) 0); } else if (Complex.class.equals(cls)) { return cls.cast(log == Logical.TRUE ? Complex.ONE : Complex.ZERO); } else if (Boolean.class.equals(cls)) { return cls.cast(log == Logical.TRUE); } else {/*www. ja v a2 s. c om*/ return Na.of(cls); } }
From source file:net.sourceforge.pmd.lang.java.ast.Java12Test.java
@Test public void testSwitchExpressions() { ASTCompilationUnit compilationUnit = ParserTstUtil.parseAndTypeResolveJava("12", loadSource("SwitchExpressions.java")); Assert.assertNotNull(compilationUnit); ASTSwitchExpression switchExpression = compilationUnit.getFirstDescendantOfType(ASTSwitchExpression.class); Assert.assertEquals(6, switchExpression.jjtGetNumChildren()); Assert.assertTrue(switchExpression.jjtGetChild(0) instanceof ASTExpression); Assert.assertEquals(5, switchExpression.findChildrenOfType(ASTSwitchLabeledRule.class).size()); ASTLocalVariableDeclaration localVar = compilationUnit .findDescendantsOfType(ASTLocalVariableDeclaration.class).get(1); ASTVariableDeclarator localVarDecl = localVar.getFirstChildOfType(ASTVariableDeclarator.class); Assert.assertEquals(Integer.TYPE, localVarDecl.getType()); Assert.assertEquals(Integer.TYPE, switchExpression.getType()); }
From source file:com.lenox.common.exec.ManagedProcess.java
private int chmod(String filename, int mode) { try {/*from ww w . j a v a 2 s . co m*/ Class<?> fspClass = Class.forName("java.util.prefs.FileSystemPreferences"); Method chmodMethod = fspClass.getDeclaredMethod("chmod", String.class, Integer.TYPE); chmodMethod.setAccessible(true); return (Integer) chmodMethod.invoke(null, filename, mode); } catch (Throwable ex) { return -1; } }
From source file:org.apache.pig.builtin.Invoker.java
private static Class<?> unPrimitivize(Class<?> klass) { if (klass.equals(Integer.TYPE)) { return Integer.class; }/* www.j a v a 2 s. c o m*/ if (klass.equals(Long.TYPE)) { return Long.class; } else if (klass.equals(Float.TYPE)) { return Float.class; } else if (klass.equals(Double.TYPE)) { return Double.class; } else { return klass; } }
From source file:org.ow2.chameleon.everest.servlet.RelationSerializationTest.java
@Test public void testRelationWithTwoParameters() throws IllegalResourceException, IOException { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getScheme()).thenReturn("http"); when(request.getServerName()).thenReturn("server"); when(request.getServerPort()).thenReturn(1234); Relation relation = new DefaultRelation(Path.from("/foo/bar"), Action.READ, "test", "description", new DefaultParameter().name("param").description("my param").type(String.class), new DefaultParameter().name("param2").description("my second param").type(Integer.TYPE) .optional(true));/*from w w w .j av a2 s .c o m*/ Resource resource = new DefaultResource.Builder().fromPath(Path.from("/foo")).with(relation).build(); EverestServlet servlet = new EverestServlet(); JsonNode node = servlet.toJSON(request, resource); System.out.println(node); assertThat(node.get("__relations")).isNotNull(); final JsonNode rel = node.get("__relations").get("test"); assertThat(rel).isNotNull(); assertThat(rel.get("href").asText()).isEqualTo("http://server:1234/everest/foo/bar"); assertThat(rel.get("action").asText()).isEqualTo("READ"); assertThat(rel.get("name").asText()).isEqualTo("test"); assertThat(rel.get("description").asText()).isEqualTo("description"); final JsonNode param0 = rel.get("parameters").get(0); assertThat(param0.get("name").asText()).isEqualTo("param"); assertThat(param0.get("description").asText()).isEqualTo("my param"); assertThat(param0.get("type").asText()).isEqualTo(String.class.getName()); assertThat(param0.get("optional").asBoolean()).isFalse(); final JsonNode param1 = rel.get("parameters").get(1); assertThat(param1.get("name").asText()).isEqualTo("param2"); assertThat(param1.get("description").asText()).isEqualTo("my second param"); assertThat(param1.get("type").asText()).isEqualTo(Integer.TYPE.getName()); assertThat(param1.get("optional").asBoolean()).isTrue(); }
From source file:org.jcommon.com.util.config.ConfigLoader.java
public static void loadConf4xml(InputStream is, BaseConfigMBean config) throws FileNotFoundException { if (is == null) throw new FileNotFoundException(); try {/* w w w .j ava 2s. co m*/ Document doc = new SAXReader().read(is); Element root = doc.getRootElement(); String element = null; Class<?> type = null; java.lang.reflect.Field[] fs = config.getClass().getDeclaredFields(); for (java.lang.reflect.Field f : fs) { element = f.getName(); String value = getTextFromElement(root, element); if (value == null) continue; type = f.getType(); Object args = null; java.lang.reflect.Method m = getMethod(config.getClass(), "set" + element); if (m == null) m = getMethod(config.getClass(), "is" + element); if (m != null) { if (notNull(value)) { if (String.class == type) { args = value; } else if (java.lang.Integer.class == type || Integer.TYPE == type) { args = Integer.valueOf(value); } else if (java.lang.Boolean.class == type || Boolean.TYPE == type) { args = Boolean.parseBoolean(value); } else if (java.lang.Long.class == type || Long.TYPE == type) { args = Long.valueOf(value); } else if (java.lang.Float.class == type || Float.TYPE == type) { args = Float.valueOf(value); } else if (java.util.Collection.class.isAssignableFrom(type)) { args = loadCollection(root, element, f); } else if (java.util.Map.class.isAssignableFrom(type)) { args = loadMap(root, element, f); } else { logger.info("not map Class:" + type); continue; } } try { m.invoke(config, args); logger.info(element + ":" + value); } catch (Exception e) { logger.warn(e); continue; } } else if (notNull(value)) logger.warn("can't find element:" + value); } try { is.close(); } catch (Exception e) { } logger.info(String.format("Read config file: %s", is)); } catch (Throwable t) { logger.error("read config file error:" + is + "\n" + t.getMessage()); } }
From source file:com.l2jfree.gameserver.model.skills.funcs.FuncTemplate.java
public FuncTemplate(Condition pApplayCond, String pFunc, Stats pStat, int pOrder, double pLambda) { Class<?> clazz;//ww w.jav a 2 s. co m try { final StringBuilder sb = new StringBuilder(); sb.append(IFuncMarker.class.getPackage().getName()); sb.append(".Func"); sb.append(pFunc); clazz = Class.forName(sb.toString()); } catch (Exception e) { throw new RuntimeException(e); } // Ugly fixes for DP errors switch (pStat) { case CRITICAL_DAMAGE_ADD: { if (clazz != FuncAdd.class && clazz != FuncSub.class) { throwException(pFunc, pStat, pOrder, pLambda); pStat = Stats.CRITICAL_DAMAGE; } break; } case CRITICAL_DAMAGE: { if (clazz == FuncAdd.class || clazz == FuncSub.class) { throwException(pFunc, pStat, pOrder, pLambda); pStat = Stats.CRITICAL_DAMAGE_ADD; } break; } case CRITICAL_RATE: { if (clazz == FuncMul.class) { //throwException(pFunc, pStat, pOrder, pLambda); clazz = FuncBaseMul.class; pLambda = (pLambda - 1.0); } else if (clazz == FuncDiv.class) { //throwException(pFunc, pStat, pOrder, pLambda); clazz = FuncBaseMul.class; pLambda = ((1.0 / pLambda) - 1.0); } break; } case MCRITICAL_RATE: { if (clazz == FuncMul.class) { //throwException(pFunc, pStat, pOrder, pLambda); clazz = FuncBaseMul.class; pLambda = (pLambda - 1.0); } else if (clazz == FuncDiv.class) { //throwException(pFunc, pStat, pOrder, pLambda); clazz = FuncBaseMul.class; pLambda = ((1.0 / pLambda) - 1.0); } break; } } if (pStat.isMultiplicativeResist()) { if (clazz != FuncMul.class && clazz != FuncDiv.class) throwException(pFunc, pStat, pOrder, pLambda); if (pLambda > 2 || pLambda < 0) throwException(pFunc, pStat, pOrder, pLambda); } if (pStat.isAdditiveResist()) { if (clazz != FuncAdd.class && clazz != FuncSub.class) throwException(pFunc, pStat, pOrder, pLambda); if ((int) pLambda != pLambda) // it wasn't an integer value throwException(pFunc, pStat, pOrder, pLambda); } if (clazz == FuncEnchant.class) { switch (pStat) { case MAGIC_DEFENCE: case POWER_DEFENCE: case SHIELD_DEFENCE: case MAGIC_ATTACK: case POWER_ATTACK: break; default: throwException(pFunc, pStat, pOrder, pLambda); } } else if (clazz == FuncBaseMul.class) { switch (pStat) { case CRITICAL_RATE: case MCRITICAL_RATE: break; default: throwException(pFunc, pStat, pOrder, pLambda); } } stat = pStat; order = pOrder; lambda = pLambda; applayCond = pApplayCond; try { _constructor = clazz.getConstructor(Stats.class, Integer.TYPE, FuncOwner.class, Double.TYPE, Condition.class); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:io.qdb.server.controller.JsonService.java
private ObjectMapper createMapper(boolean prettyPrint, boolean datesAsTimestamps, boolean borg) { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); mapper.configure(SerializationFeature.INDENT_OUTPUT, prettyPrint); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, datesAsTimestamps); SimpleModule module = new SimpleModule(); module.addDeserializer(Date.class, dateDeserializer); module.addDeserializer(Integer.class, integerJsonDeserializer); module.addDeserializer(Integer.TYPE, integerJsonDeserializer); module.addDeserializer(Long.class, longJsonDeserializer); module.addDeserializer(Long.TYPE, longJsonDeserializer); if (!borg) {/*from www. ja v a 2 s .co m*/ module.addSerializer(Integer.TYPE, integerSerializer); module.addSerializer(Integer.class, integerSerializer); module.addSerializer(Long.TYPE, longSerializer); module.addSerializer(Long.class, longSerializer); } if (!datesAsTimestamps) module.addSerializer(Date.class, new ISO8601DateSerializer()); mapper.registerModule(module); return mapper; }