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:com.github.steveash.typedconfig.resolver.type.simple.IntegerValueResolverFactory.java
@Override public boolean canResolveFor(ConfigBinding configBinding) { return configBinding.getDataType().isAssignableFrom(Integer.class) || configBinding.getDataType().isAssignableFrom(Integer.TYPE); }
From source file:clientapi.command.executor.parser.impl.NumberParser.java
@Override public final boolean isTarget(Type type) { if (!(type instanceof Class)) { return false; }/*w w w .ja v a 2 s . com*/ Class c = (Class) type; // Check all NumberUtils#createNumber(String) supported types // Integer -> BigInteger // Float -> BigDecimal return Integer.class.isAssignableFrom(c) || Long.class.isAssignableFrom(c) || BigInteger.class.isAssignableFrom(c) || Float.class.isAssignableFrom(c) || Double.class.isAssignableFrom(c) || BigDecimal.class.isAssignableFrom(c) || Integer.TYPE.isAssignableFrom(c) || Long.TYPE.isAssignableFrom(c) || Float.TYPE.isAssignableFrom(c) || Double.TYPE.isAssignableFrom(c); }
From source file:com.swtxml.util.parser.ConstantParser.java
private Map<String, Integer> extractConstants(Class<?> cl) { Map<String, Integer> constants = new HashMap<String, Integer>(); try {// ww w . j a va2 s . co m Collection<Field> fields = Reflector.findFields(Visibility.PUBLIC, Subclasses.NONE).isStatic(true) .type(Integer.TYPE).all(cl); for (Field field : fields) { constants.put(field.getName(), field.getInt(cl)); } } catch (Exception e) { throw new ReflectorException(e); } return constants; }
From source file:com.ngdata.hbaseindexer.indexer.SolrClientFactory.java
public static Sharder createSharder(Map<String, String> connectionParams, int numShards) throws SharderException { String sharderType = connectionParams.get(SolrConnectionParams.SHARDER_TYPE); if (sharderType == null || sharderType.equals("default")) { return new HashSharder(numShards); } else {/*from w ww .j a v a2 s . co m*/ try { return (Sharder) Class.forName(sharderType).getConstructor(Integer.TYPE).newInstance(numShards); } catch (ClassNotFoundException e) { throw new SharderException("failed to initialize sharder", e); } catch (InvocationTargetException e) { throw new SharderException("failed to initialize sharder", e); } catch (NoSuchMethodException e) { throw new SharderException("failed to initialize sharder", e); } catch (InstantiationException e) { throw new SharderException("failed to initialize sharder", e); } catch (IllegalAccessException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. throw new SharderException("failed to initialize sharder", e); } } }
From source file:com.threerings.media.tile.tools.xml.UniformTileSetRuleSet.java
@Override public void addRuleInstances(Digester digester) { super.addRuleInstances(digester); digester.addCallMethod(_path + "/width", "setWidth", 0, new Class<?>[] { java.lang.Integer.TYPE }); digester.addCallMethod(_path + "/height", "setHeight", 0, new Class<?>[] { java.lang.Integer.TYPE }); }
From source file:com.csipsimple.backup.Columns.java
public Columns(String[] names, Class<?>[] classes) { this.names = new ArrayList<String>(Arrays.asList(names)); types = new ArrayList<Type>(names.length); for (int i = 0; i < names.length; i++) { if (classes[i] == String.class) { types.add(i, Type.STRING); } else if (classes[i] == Integer.TYPE || classes[i] == Integer.class) { types.add(i, Type.INT); } else if (classes[i] == Long.TYPE || classes[i] == Long.class) { types.add(i, Type.LONG); } else if (classes[i] == Float.TYPE || classes[i] == Float.class) { types.add(i, Type.FLOAT); } else if (classes[i] == Double.TYPE || classes[i] == Double.class) { types.add(i, Type.DOUBLE); } else if (classes[i] == Boolean.TYPE || classes[i] == Boolean.class) { types.add(i, Type.BOOLEAN); }/*from ww w .j a v a 2 s . c o m*/ } }
From source file:Main.java
/** * <p>Inserts the specified element at the specified position in the array. * Shifts the element currently at that position (if any) and any subsequent * elements to the right (adds one to their indices).</p> * * <p>This method returns a new array with the same elements of the input * array plus the given element on the specified position. The component * type of the returned array is always the same as that of the input * array.</p>/* www.j a va2 s.co m*/ * * <p>If the input array is <code>null</code>, a new one element array is returned * whose component type is the same as the element.</p> * * <pre> * ArrayUtils.add([1], 0, 2) = [2, 1] * ArrayUtils.add([2, 6], 2, 10) = [2, 6, 10] * ArrayUtils.add([2, 6], 0, -4) = [-4, 2, 6] * ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3] * </pre> * * @param array the array to add the element to, may be <code>null</code> * @param index the position of the new object * @param element the object to add * @return A new array containing the existing elements and the new element * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index > array.length). */ public static int[] add(int[] array, int index, int element) { return (int[]) add(array, index, new Integer(element), Integer.TYPE); }
From source file:Main.java
private static boolean isAssignableFrom(Class<?> parameterType, Object value) { if (parameterType.isPrimitive()) { if (value == null) { return false; }/*from w w w .j av a2 s . c o m*/ Class<?> valueClass = value.getClass(); if (parameterType == Boolean.TYPE) { return valueClass == Boolean.class; } else if (parameterType == Byte.TYPE) { return valueClass == Byte.class; } else if (parameterType == Character.TYPE) { return valueClass == Character.class; } else if (parameterType == Short.TYPE) { return valueClass == Short.class || valueClass == Byte.class; } else if (parameterType == Integer.TYPE) { return valueClass == Integer.class || valueClass == Character.class || valueClass == Short.class || valueClass == Byte.class; } else if (parameterType == Long.TYPE) { return valueClass == Long.class || valueClass == Integer.class || valueClass == Character.class || valueClass == Short.class || valueClass == Byte.class; } else if (parameterType == Float.TYPE) { return valueClass == Float.class || valueClass == Long.class || valueClass == Integer.class || valueClass == Character.class || valueClass == Short.class || valueClass == Byte.class; } else if (parameterType == Double.TYPE) { return valueClass == Double.class || valueClass == Float.class || valueClass == Long.class || valueClass == Integer.class || valueClass == Character.class || valueClass == Short.class || valueClass == Byte.class; } else { return false; } } else { return value == null || parameterType.isAssignableFrom(value.getClass()); } }
From source file:org.apache.lens.ml.AlgoArgParser.java
/** * Extracts feature names. If the algo has any parameters associated with @AlgoParam annotation, those are set * as well./*from w w w. j a v a 2 s . co m*/ * * @param algo the algo * @param args the args * @return List of feature column names. */ public static List<String> parseArgs(MLAlgo algo, String[] args) { List<String> featureColumns = new ArrayList<String>(); Class<? extends MLAlgo> algoClass = algo.getClass(); // Get param fields Map<String, Field> fieldMap = new HashMap<String, Field>(); for (Field fld : algoClass.getDeclaredFields()) { fld.setAccessible(true); AlgoParam paramAnnotation = fld.getAnnotation(AlgoParam.class); if (paramAnnotation != null) { fieldMap.put(paramAnnotation.name(), fld); } } for (int i = 0; i < args.length; i += 2) { String key = args[i].trim(); String value = args[i + 1].trim(); try { if ("feature".equalsIgnoreCase(key)) { featureColumns.add(value); } else if (fieldMap.containsKey(key)) { Field f = fieldMap.get(key); if (String.class.equals(f.getType())) { f.set(algo, value); } else if (Integer.TYPE.equals(f.getType())) { f.setInt(algo, Integer.parseInt(value)); } else if (Double.TYPE.equals(f.getType())) { f.setDouble(algo, Double.parseDouble(value)); } else if (Long.TYPE.equals(f.getType())) { f.setLong(algo, Long.parseLong(value)); } else { // check if the algo provides a deserializer for this param String customParserClass = algo.getConf().getProperties().get("lens.ml.args." + key); if (customParserClass != null) { Class<? extends CustomArgParser<?>> clz = (Class<? extends CustomArgParser<?>>) Class .forName(customParserClass); CustomArgParser<?> parser = clz.newInstance(); f.set(algo, parser.parse(value)); } else { LOG.warn("Ignored param " + key + "=" + value + " as no parser found"); } } } } catch (Exception exc) { LOG.error("Error while setting param " + key + " to " + value + " for algo " + algo); } } return featureColumns; }
From source file:net.jetrix.config.ChannelsRuleSet.java
public void addRuleInstances(Digester digester) { digester.addCallMethod("tetrinet-channels/motd", "setMessageOfTheDay", 0); // default game settings digester.addObjectCreate("tetrinet-channels/default-settings", "net.jetrix.config.Settings"); digester.addSetNext("tetrinet-channels/default-settings", "setDefaultSettings", "net.jetrix.config.Settings"); // channel settings digester.addObjectCreate("*/channel/settings", "net.jetrix.config.Settings"); digester.addSetNext("*/channel/settings", "setSettings", "net.jetrix.config.Settings"); // any game settings digester.addCallMethod("*/starting-level", "setStartingLevel", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/lines-per-level", "setLinesPerLevel", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/level-increase", "setLevelIncrease", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/lines-per-special", "setLinesPerSpecial", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/special-added", "setSpecialAdded", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/special-capacity", "setSpecialCapacity", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/classic-rules", "setClassicRules", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/average-levels", "setAverageLevels", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/same-blocks", "setSameBlocks", 0, new Class[] { Boolean.TYPE }); // block occurancy digester.addObjectCreate("*/block-occurancy", Occurancy.class.getName()); digester.addCallMethod("*/block-occurancy", "normalize", 0, (Class[]) null); digester.addSetNext("*/block-occurancy", "setBlockOccurancy", Occurancy.class.getName()); for (Block block : Block.values()) { digester.addRule("*/block-occurancy/" + block.getCode(), new OccurancyRule<Block>(digester, block)); }//from ww w . j a v a2 s.c om // special occurancy digester.addObjectCreate("*/special-occurancy", Occurancy.class.getName()); digester.addCallMethod("*/special-occurancy", "normalize", 0, (Class[]) null); digester.addSetNext("*/special-occurancy", "setSpecialOccurancy", Occurancy.class.getName()); for (Special special : Special.values()) { digester.addRule("*/special-occurancy/" + special.getCode(), new OccurancyRule<Special>(digester, special)); } digester.addCallMethod("*/sudden-death/time", "setSuddenDeathTime", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/sudden-death/message", "setSuddenDeathMessage", 0); digester.addCallMethod("*/sudden-death/delay", "setSuddenDeathDelay", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/sudden-death/lines-added", "setSuddenDeathLinesAdded", 0, new Class[] { Integer.TYPE }); // channel configuration digester.addObjectCreate("*/channel", "net.jetrix.config.ChannelConfig"); digester.addSetNext("*/channel", "addChannel", "net.jetrix.config.ChannelConfig"); digester.addCallMethod("*/channel", "setName", 1); digester.addCallParam("*/channel", 0, "name"); digester.addRule("*/channel/speed", new Rule(digester) { public void body(String text) throws Exception { getDigester().push(Speed.valueOf(text.toUpperCase())); } public void end() throws Exception { getDigester().pop(); } }); digester.addSetNext("*/channel/speed", "setSpeed"); digester.addCallMethod("*/channel/password", "setPassword", 0); digester.addCallMethod("*/channel/access-level", "setAccessLevel", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/channel/idle", "setIdleAllowed", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/channel/visible", "setVisible", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/channel/description", "setDescription", 0); digester.addCallMethod("*/channel/topic", "setTopic", 0); digester.addCallMethod("*/channel/max-players", "setMaxPlayers", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/channel/max-spectators", "setMaxSpectators", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/channel/winlist", "setWinlistId", 1); digester.addCallParam("*/channel/winlist", 0, "name"); // filter configuration digester.addObjectCreate("*/filter", "net.jetrix.config.FilterConfig"); digester.addSetNext("*/filter", "addFilter", "net.jetrix.config.FilterConfig"); digester.addCallMethod("*/filter", "setName", 1); digester.addCallParam("*/filter", 0, "name"); digester.addCallMethod("*/filter", "setClassname", 1); digester.addCallParam("*/filter", 0, "class"); digester.addCallMethod("*/filter/param", "setParameter", 2); digester.addCallParam("*/filter/param", 0, "name"); digester.addCallParam("*/filter/param", 1, "value"); // filter definitions digester.addCallMethod("tetrinet-channels/filter-definitions/alias", "addFilterAlias", 2); digester.addCallParam("tetrinet-channels/filter-definitions/alias", 0, "name"); digester.addCallParam("tetrinet-channels/filter-definitions/alias", 1, "class"); // winlists digester.addObjectCreate("tetrinet-channels/winlists/winlist", "net.jetrix.config.WinlistConfig"); digester.addSetNext("tetrinet-channels/winlists/winlist", "addWinlist", "net.jetrix.config.WinlistConfig"); digester.addCallMethod("tetrinet-channels/winlists/winlist", "setName", 1); digester.addCallParam("tetrinet-channels/winlists/winlist", 0, "name"); digester.addCallMethod("tetrinet-channels/winlists/winlist", "setClassname", 1); digester.addCallParam("tetrinet-channels/winlists/winlist", 0, "class"); digester.addCallMethod("tetrinet-channels/winlists/winlist/param", "setParameter", 2); digester.addCallParam("tetrinet-channels/winlists/winlist/param", 0, "name"); digester.addCallParam("tetrinet-channels/winlists/winlist/param", 1, "value"); }