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:nl.strohalm.cyclos.controls.groups.EditGroupAction.java
private void initBasic(final BeanBinder<? extends Group> groupBinder, final BeanBinder<? extends BasicGroupSettings> basicSettingsBinder) { groupBinder.registerBinder("basicSettings", basicSettingsBinder); groupBinder.registerBinder("id", PropertyBinder.instance(Long.class, "id", IdConverter.instance())); groupBinder.registerBinder("name", PropertyBinder.instance(String.class, "name")); groupBinder.registerBinder("description", PropertyBinder.instance(String.class, "description")); groupBinder.registerBinder("status", PropertyBinder.instance(Group.Status.class, "status")); basicSettingsBinder.registerBinder("passwordLength", DataBinderHelper.rangeConstraintBinder("passwordLength")); basicSettingsBinder.registerBinder("passwordPolicy", PropertyBinder.instance(PasswordPolicy.class, "passwordPolicy")); basicSettingsBinder.registerBinder("maxPasswordWrongTries", PropertyBinder.instance(Integer.TYPE, "maxPasswordWrongTries")); basicSettingsBinder.registerBinder("deactivationAfterMaxPasswordTries", DataBinderHelper.timePeriodBinder("deactivationAfterMaxPasswordTries")); basicSettingsBinder.registerBinder("passwordExpiresAfter", DataBinderHelper.timePeriodBinder("passwordExpiresAfter")); basicSettingsBinder.registerBinder("transactionPassword", PropertyBinder.instance(TransactionPassword.class, "transactionPassword")); basicSettingsBinder.registerBinder("transactionPasswordLength", PropertyBinder.instance(Integer.TYPE, "transactionPasswordLength")); basicSettingsBinder.registerBinder("maxTransactionPasswordWrongTries", PropertyBinder.instance(Integer.TYPE, "maxTransactionPasswordWrongTries")); basicSettingsBinder.registerBinder("hideCurrencyOnPayments", PropertyBinder.instance(Boolean.TYPE, "hideCurrencyOnPayments")); }
From source file:com.l2jfree.gameserver.gameobjects.templates.L2NpcTemplate.java
public Constructor<?> getDefaultConstructor() throws NoSuchMethodException, SecurityException { return _clazz.getConstructor(Integer.TYPE, L2NpcTemplate.class); }
From source file:javadz.beanutils.ConvertUtilsBean.java
/** * Register the converters for primitive types. * </p>//from ww w . ja v a 2 s . c o m * This method registers the following converters: * <ul> * <li><code>Boolean.TYPE</code> - {@link BooleanConverter}</li> * <li><code>Byte.TYPE</code> - {@link ByteConverter}</li> * <li><code>Character.TYPE</code> - {@link CharacterConverter}</li> * <li><code>Double.TYPE</code> - {@link DoubleConverter}</li> * <li><code>Float.TYPE</code> - {@link FloatConverter}</li> * <li><code>Integer.TYPE</code> - {@link IntegerConverter}</li> * <li><code>Long.TYPE</code> - {@link LongConverter}</li> * <li><code>Short.TYPE</code> - {@link ShortConverter}</li> * </ul> * @param throwException <code>true</code> if the converters should * throw an exception when a conversion error occurs, otherwise <code> * <code>false</code> if a default value should be used. */ private void registerPrimitives(boolean throwException) { register(Boolean.TYPE, throwException ? new BooleanConverter() : new BooleanConverter(Boolean.FALSE)); register(Byte.TYPE, throwException ? new ByteConverter() : new ByteConverter(ZERO)); register(Character.TYPE, throwException ? new CharacterConverter() : new CharacterConverter(SPACE)); register(Double.TYPE, throwException ? new DoubleConverter() : new DoubleConverter(ZERO)); register(Float.TYPE, throwException ? new FloatConverter() : new FloatConverter(ZERO)); register(Integer.TYPE, throwException ? new IntegerConverter() : new IntegerConverter(ZERO)); register(Long.TYPE, throwException ? new LongConverter() : new LongConverter(ZERO)); register(Short.TYPE, throwException ? new ShortConverter() : new ShortConverter(ZERO)); }
From source file:org.apache.struts.action.DynaActionForm.java
/** * <p>Indicates if an object of the source class is assignable to the * destination class.</p>/*from w w w .j a v a2s .c o m*/ * * @param dest Destination class * @param source Source class * @return <code>true</code> if the source is assignable to the * destination; <code>false</code> otherwise. */ protected boolean isDynaAssignable(Class dest, Class source) { if (dest.isAssignableFrom(source) || ((dest == Boolean.TYPE) && (source == Boolean.class)) || ((dest == Byte.TYPE) && (source == Byte.class)) || ((dest == Character.TYPE) && (source == Character.class)) || ((dest == Double.TYPE) && (source == Double.class)) || ((dest == Float.TYPE) && (source == Float.class)) || ((dest == Integer.TYPE) && (source == Integer.class)) || ((dest == Long.TYPE) && (source == Long.class)) || ((dest == Short.TYPE) && (source == Short.class))) { return (true); } else { return (false); } }
From source file:bammerbom.ultimatecore.bukkit.resources.utils.BossbarUtil.java
public Object getWatcher() { Class<?> Entity = Util.getCraftClass("Entity"); Class<?> DataWatcher = Util.getCraftClass("DataWatcher"); Object watcher = null;/* ww w. ja v a 2 s.c om*/ try { watcher = DataWatcher.getConstructor(new Class[] { Entity }).newInstance(new Object[] { this.dragon }); Method a = Util.getMethod(DataWatcher, "a", new Class[] { Integer.TYPE, Object.class }); a.invoke(watcher, new Object[] { Integer.valueOf(0), Byte.valueOf(isVisible() ? (byte) 0 : (byte) 32) }); a.invoke(watcher, new Object[] { Integer.valueOf(6), Float.valueOf(this.health) }); a.invoke(watcher, new Object[] { Integer.valueOf(7), Integer.valueOf(0) }); a.invoke(watcher, new Object[] { Integer.valueOf(8), Byte.valueOf((byte) 0) }); a.invoke(watcher, new Object[] { Integer.valueOf(10), this.name }); a.invoke(watcher, new Object[] { Integer.valueOf(11), Byte.valueOf((byte) 1) }); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } return watcher; }
From source file:ResultSetIterator.java
/** * ResultSet.getObject() returns an Integer object for an INT column. The * setter method for the property might take an Integer or a primitive int. * This method returns true if the value can be successfully passed into * the setter method. Remember, Method.invoke() handles the unwrapping * of Integer into an int.// ww w . java 2 s .c o m * * @param value The value to be passed into the setter method. * @param type The setter's parameter type. * @return boolean True if the value is compatible. */ private boolean isCompatibleType(Object value, Class type) { // Do object check first, then primitives if (value == null || type.isInstance(value)) { return true; } else if (type.equals(Integer.TYPE) && Integer.class.isInstance(value)) { return true; } else if (type.equals(Long.TYPE) && Long.class.isInstance(value)) { return true; } else if (type.equals(Double.TYPE) && Double.class.isInstance(value)) { return true; } else if (type.equals(Float.TYPE) && Float.class.isInstance(value)) { return true; } else if (type.equals(Short.TYPE) && Short.class.isInstance(value)) { return true; } else if (type.equals(Byte.TYPE) && Byte.class.isInstance(value)) { return true; } else if (type.equals(Character.TYPE) && Character.class.isInstance(value)) { return true; } else if (type.equals(Boolean.TYPE) && Boolean.class.isInstance(value)) { return true; } else { return false; } }
From source file:net.sourceforge.pmd.typeresolution.ClassTypeResolverTest.java
@Test public void testUnaryNumericOperators() throws JaxenException { ASTCompilationUnit acu = parseAndTypeResolveForClass15(Operators.class); List<TypeNode> expressions = new ArrayList<>(); expressions.addAll(convertList(acu.findChildNodesWithXPath( "//Block[preceding-sibling::MethodDeclarator[@Image = 'unaryNumericOperators']]//Expression"), TypeNode.class)); expressions.addAll(convertList(acu.findChildNodesWithXPath( "//Block[preceding-sibling::MethodDeclarator[@Image = 'unaryNumericOperators']]//PostfixExpression"), TypeNode.class)); expressions.addAll(convertList(acu.findChildNodesWithXPath( "//Block[preceding-sibling::MethodDeclarator[@Image = 'unaryNumericOperators']]//PreIncrementExpression"), TypeNode.class)); expressions.addAll(convertList(acu.findChildNodesWithXPath( "//Block[preceding-sibling::MethodDeclarator[@Image = 'unaryNumericOperators']]//PreDecrementExpression"), TypeNode.class)); int index = 0; assertEquals(Integer.TYPE, expressions.get(index++).getType()); assertEquals(Integer.TYPE, expressions.get(index++).getType()); assertEquals(Double.TYPE, expressions.get(index++).getType()); assertEquals(Double.TYPE, expressions.get(index++).getType()); assertEquals(Double.TYPE, expressions.get(index++).getType()); assertEquals(Double.TYPE, expressions.get(index++).getType()); // Make sure we got them all. assertEquals("All expressions not tested", index, expressions.size()); }
From source file:com.sun.faces.config.ManagedBeanFactory.java
/** * <li><p> Call the property getter, if it exists.</p></li> * <p/>//from w w w. j av a 2 s . c om * <li><p>If the getter returns null or doesn't exist, create a * java.util.ArrayList(), otherwise use the returned Object (an array or * a java.util.List).</p></li> * <p/> * <li><p>If a List was returned or created in step 2), add all * elements defined by nested <value> elements in the order * they are listed, converting values defined by nested * <value> elements to the type defined by * <value-class>. If a <value-class> is not defined, use * the value as-is (i.e., as a java.lang.String). Add null for each * <null-value> element.</p></li> * <p/> * <li><p> If an array was returned in step 2), create a * java.util.ArrayList and copy all elements from the returned array to * the new List, auto-boxing elements of a primitive type. Add all * elements defined by nested <value> elements as described in step * 3).</p></li> * <p/> * <li><p> If a new java.util.List was created in step 2) and the * property is of type List, set the property by calling the setter * method, or log an error if there is no setter method.</p></li> * <p/> * <li><p> If a new java.util.List was created in step 4), convert * the * List to array of the same type as the property and set the * property by * calling the setter method, or log an error if there * is no setter * method.</p></li> */ private void setArrayOrListPropertiesIntoBean(Object bean, ManagedPropertyBean property) throws Exception { Object result = null; boolean getterIsNull = true, getterIsArray = false; List valuesForBean = null; Class valueType = java.lang.String.class, propertyType = null; String propertyName = property.getPropertyName(); try { // see if there is a getter result = PropertyUtils.getProperty(bean, propertyName); getterIsNull = (null == result) ? true : false; propertyType = PropertyUtils.getPropertyType(bean, propertyName); getterIsArray = propertyType.isArray(); } catch (NoSuchMethodException nsme) { // it's valid to not have a getter. } // the property has to be either a List or Array if (!getterIsArray) { if (null != propertyType && !java.util.List.class.isAssignableFrom(propertyType)) { throw new FacesException( Util.getExceptionMessageString(Util.MANAGED_BEAN_CANNOT_SET_LIST_ARRAY_PROPERTY_ID, new Object[] { propertyName, managedBean.getManagedBeanName() })); } } // // Deal with the possibility of the getter returning existing // values. // // if the getter returned non-null if (!getterIsNull) { // if what it returned was an array if (getterIsArray) { valuesForBean = new ArrayList(); for (int i = 0, len = Array.getLength(result); i < len; i++) { // add the existing values valuesForBean.add(Array.get(result, i)); } } else { // if what it returned was not a List if (!(result instanceof List)) { // throw an exception throw new FacesException( Util.getExceptionMessageString(Util.MANAGED_BEAN_EXISTING_VALUE_NOT_LIST_ID, new Object[] { propertyName, managedBean.getManagedBeanName() })); } valuesForBean = (List) result; } } else { // getter returned null result = valuesForBean = new ArrayList(); } // at this point valuesForBean contains the existing values from // the bean, or no values if the bean had no values. In any // case, we can proceed to add values from the config file. valueType = copyListEntriesFromConfigToList(property.getListEntries(), valuesForBean); // at this point valuesForBean has the values to be set into the // bean. if (getterIsArray) { // convert back to Array result = Array.newInstance(valueType, valuesForBean.size()); for (int i = 0, len = valuesForBean.size(); i < len; i++) { if (valueType == Boolean.TYPE) { Array.setBoolean(result, i, ((Boolean) valuesForBean.get(i)).booleanValue()); } else if (valueType == Byte.TYPE) { Array.setByte(result, i, ((Byte) valuesForBean.get(i)).byteValue()); } else if (valueType == Double.TYPE) { Array.setDouble(result, i, ((Double) valuesForBean.get(i)).doubleValue()); } else if (valueType == Float.TYPE) { Array.setFloat(result, i, ((Float) valuesForBean.get(i)).floatValue()); } else if (valueType == Integer.TYPE) { Array.setInt(result, i, ((Integer) valuesForBean.get(i)).intValue()); } else if (valueType == Character.TYPE) { Array.setChar(result, i, ((Character) valuesForBean.get(i)).charValue()); } else if (valueType == Short.TYPE) { Array.setShort(result, i, ((Short) valuesForBean.get(i)).shortValue()); } else if (valueType == Long.TYPE) { Array.setLong(result, i, ((Long) valuesForBean.get(i)).longValue()); } else { Array.set(result, i, valuesForBean.get(i)); } } } else { result = valuesForBean; } if (getterIsNull || getterIsArray) { PropertyUtils.setProperty(bean, propertyName, result); } }
From source file:com.aliyun.fs.oss.utils.OSSClientAgent.java
@SuppressWarnings("unchecked") private UploadPartResult uploadPart(String uploadId, String bucket, String key, Long partSize, Long beginIndex, int partNumber, File file, Configuration conf, boolean retry) throws IOException, ServiceException, ClientException { InputStream instream = null;/*from w w w. j a v a 2 s .com*/ try { instream = new FileInputStream(file); instream.skip(beginIndex); Class UploadPartRequestClz = ResourceLoader.getInstance().getUrlClassLoader(conf) .loadClass("com.aliyun.oss.model.UploadPartRequest"); Constructor cons = UploadPartRequestClz.getConstructor(); Object uploadPartRequest = cons.newInstance(); Method method0 = UploadPartRequestClz.getMethod("setBucketName", String.class); method0.invoke(uploadPartRequest, bucket); Method method1 = UploadPartRequestClz.getMethod("setKey", String.class); method1.invoke(uploadPartRequest, key); Method method2 = UploadPartRequestClz.getMethod("setUploadId", String.class); method2.invoke(uploadPartRequest, uploadId); Method method3 = UploadPartRequestClz.getMethod("setInputStream", InputStream.class); method3.invoke(uploadPartRequest, instream); Method method4 = UploadPartRequestClz.getMethod("setPartSize", Long.TYPE); method4.invoke(uploadPartRequest, partSize); Method method5 = UploadPartRequestClz.getMethod("setPartNumber", Integer.TYPE); method5.invoke(uploadPartRequest, partNumber); Method method = this.ossClientClz.getMethod("uploadPart", UploadPartRequestClz); Object ret = method.invoke(this.ossClient, uploadPartRequest); return gson.fromJson(gson.toJson(ret), UploadPartResult.class); } catch (Exception e) { if (retry && updateOSSClient(e)) { return uploadPart(uploadId, bucket, key, partSize, beginIndex, partNumber, file, conf, false); } else { handleException(e); return null; } } finally { if (instream != null) { try { instream.close(); } catch (IOException e) { e.printStackTrace(); } } } }