List of usage examples for java.lang Boolean TYPE
Class TYPE
To view the source code for java.lang Boolean TYPE.
Click Source Link
From source file:org.exolab.castor.xml.parsing.primitive.objects.PrimitiveObjectFactory.java
private PrimitiveObjectFactory() { typeHandlers.put(String.class, PrimitiveString.class); typeHandlers.put(Enum.class, PrimitiveEnum.class); typeHandlers.put(Integer.TYPE, PrimitiveInteger.class); typeHandlers.put(Integer.class, PrimitiveInteger.class); typeHandlers.put(Boolean.TYPE, PrimitiveBoolean.class); typeHandlers.put(Boolean.class, PrimitiveBoolean.class); typeHandlers.put(Double.TYPE, PrimitiveDouble.class); typeHandlers.put(Double.class, PrimitiveDouble.class); typeHandlers.put(Long.TYPE, PrimitiveLong.class); typeHandlers.put(Long.class, PrimitiveLong.class); typeHandlers.put(Character.TYPE, PrimitiveChar.class); typeHandlers.put(Character.class, PrimitiveChar.class); typeHandlers.put(Short.TYPE, PrimitiveShort.class); typeHandlers.put(Short.class, PrimitiveShort.class); typeHandlers.put(Float.TYPE, PrimitiveFloat.class); typeHandlers.put(Float.class, PrimitiveFloat.class); typeHandlers.put(Byte.TYPE, PrimitiveByte.class); typeHandlers.put(Byte.class, PrimitiveByte.class); typeHandlers.put(BigInteger.class, PrimitiveBigInteger.class); typeHandlers.put(BigDecimal.class, PrimitiveBigDecimal.class); }
From source file:com.autonomy.aci.client.annotations.ConversionServiceImpl.java
public ConversionServiceImpl() { registerConverter(new StringToDoubleConverter(), String.class, Double.class); registerConverter(new StringToDoubleConverter(), String.class, Double.TYPE); registerConverter(new StringToByteConverter(), String.class, Byte.class); registerConverter(new StringToByteConverter(), String.class, Byte.TYPE); registerConverter(new StringToIntegerConverter(), String.class, Integer.class); registerConverter(new StringToIntegerConverter(), String.class, Integer.TYPE); registerConverter(new StringToFloatConverter(), String.class, Float.class); registerConverter(new StringToFloatConverter(), String.class, Float.TYPE); registerConverter(new StringToShortConverter(), String.class, Short.class); registerConverter(new StringToShortConverter(), String.class, Short.TYPE); registerConverter(new StringToCharacterConverter(), String.class, Character.class); registerConverter(new StringToCharacterConverter(), String.class, Character.TYPE); registerConverter(new StringToBooleanConverter(), String.class, Boolean.class); registerConverter(new StringToBooleanConverter(), String.class, Boolean.TYPE); registerConverter(new StringToLongConverter(), String.class, Long.class); registerConverter(new StringToLongConverter(), String.class, Long.TYPE); }
From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.ShutdownCommand.java
@Override public void execute(ApplicationContext currentContext) throws CLIException { HttpGet request = new HttpGet(currentContext.getResourceUrl("shutdown")); HttpResponseWrapper response = execute(request, currentContext); if (statusCode(OK) == statusCode(response)) { boolean success = readValue(response, Boolean.TYPE, currentContext); resultStack(currentContext).push(success); if (success) { writeLine(currentContext, "%s", "Resource manager shutdown successfully."); } else {//from ww w. j a v a 2 s .co m writeLine(currentContext, "%s", "Cannot shutdown resource manager."); } } else { handleError("An error occurred while shutting down:", response, currentContext); } }
From source file:net.sf.ij_plugins.util.DialogUtil.java
/** * Utility to automatically create ImageJ's GenericDialog for editing bean properties. It uses BeanInfo to extract * display names for each field. If a fields type is not supported irs name will be displayed with a tag * "[Unsupported type: class_name]"./*from w w w . j a va 2 s.com*/ * * @param bean * @return <code>true</code> if user closed bean dialog using OK button, <code>false</code> otherwise. */ static public boolean showGenericDialog(final Object bean, final String title) { final BeanInfo beanInfo; try { beanInfo = Introspector.getBeanInfo(bean.getClass()); } catch (IntrospectionException e) { throw new IJPluginsRuntimeException("Error extracting bean info.", e); } final GenericDialog genericDialog = new GenericDialog(title); // Create generic dialog fields for each bean's property final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); try { for (int i = 0; i < propertyDescriptors.length; i++) { final PropertyDescriptor pd = propertyDescriptors[i]; final Class type = pd.getPropertyType(); if (type.equals(Class.class) && "class".equals(pd.getName())) { continue; } final Object o = PropertyUtils.getSimpleProperty(bean, pd.getName()); if (type.equals(Boolean.TYPE)) { boolean value = ((Boolean) o).booleanValue(); genericDialog.addCheckbox(pd.getDisplayName(), value); } else if (type.equals(Integer.TYPE)) { int value = ((Integer) o).intValue(); genericDialog.addNumericField(pd.getDisplayName(), value, 0); } else if (type.equals(Float.TYPE)) { double value = ((Float) o).doubleValue(); genericDialog.addNumericField(pd.getDisplayName(), value, 6, 10, ""); } else if (type.equals(Double.TYPE)) { double value = ((Double) o).doubleValue(); genericDialog.addNumericField(pd.getDisplayName(), value, 6, 10, ""); } else { genericDialog.addMessage(pd.getDisplayName() + "[Unsupported type: " + type + "]"); } } } catch (IllegalAccessException e) { throw new IJPluginsRuntimeException(e); } catch (InvocationTargetException e) { throw new IJPluginsRuntimeException(e); } catch (NoSuchMethodException e) { throw new IJPluginsRuntimeException(e); } // final Panel helpPanel = new Panel(); // helpPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); // final Button helpButton = new Button("Help"); //// helpButton.addActionListener(this); // helpPanel.add(helpButton); // genericDialog.addPanel(helpPanel, GridBagConstraints.EAST, new Insets(15,0,0,0)); // Show modal dialog genericDialog.showDialog(); if (genericDialog.wasCanceled()) { return false; } // Read fields from generic dialog into bean's properties. try { for (int i = 0; i < propertyDescriptors.length; i++) { final PropertyDescriptor pd = propertyDescriptors[i]; final Class type = pd.getPropertyType(); final Object propertyValue; if (type.equals(Boolean.TYPE)) { boolean value = genericDialog.getNextBoolean(); propertyValue = Boolean.valueOf(value); } else if (type.equals(Integer.TYPE)) { int value = (int) Math.round(genericDialog.getNextNumber()); propertyValue = new Integer(value); } else if (type.equals(Float.TYPE)) { double value = genericDialog.getNextNumber(); propertyValue = new Float(value); } else if (type.equals(Double.TYPE)) { double value = genericDialog.getNextNumber(); propertyValue = new Double(value); } else { continue; } PropertyUtils.setProperty(bean, pd.getName(), propertyValue); } } catch (IllegalAccessException e) { throw new IJPluginsRuntimeException(e); } catch (InvocationTargetException e) { throw new IJPluginsRuntimeException(e); } catch (NoSuchMethodException e) { throw new IJPluginsRuntimeException(e); } return true; }
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>//from ww w . ja v a 2 s . c o 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(null, 0, true) = [true] * ArrayUtils.add([true], 0, false) = [false, true] * ArrayUtils.add([false], 1, true) = [false, true] * ArrayUtils.add([true, false], 1, true) = [true, true, false] * </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 boolean[] add(boolean[] array, int index, boolean element) { return (boolean[]) add(array, index, element, Boolean.TYPE); }
From source file:com.base.dao.sql.ReflectionUtils.java
public static Object convertValue(Object value, Class toType) { Object result = null;//w w w . j a v a 2 s . c o m if (value != null) { if (value.getClass().isArray() && toType.isArray()) { Class componentType = toType.getComponentType(); result = Array.newInstance(componentType, Array.getLength(value)); for (int i = 0, icount = Array.getLength(value); i < icount; i++) { Array.set(result, i, convertValue(Array.get(value, i), componentType)); } } else { if ((toType == Integer.class) || (toType == Integer.TYPE)) result = Integer.valueOf((int) longValue(value)); if ((toType == Double.class) || (toType == Double.TYPE)) result = new Double(doubleValue(value)); if ((toType == Boolean.class) || (toType == Boolean.TYPE)) result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE; if ((toType == Byte.class) || (toType == Byte.TYPE)) result = Byte.valueOf((byte) longValue(value)); if ((toType == Character.class) || (toType == Character.TYPE)) result = new Character((char) longValue(value)); if ((toType == Short.class) || (toType == Short.TYPE)) result = Short.valueOf((short) longValue(value)); if ((toType == Long.class) || (toType == Long.TYPE)) result = Long.valueOf(longValue(value)); if ((toType == Float.class) || (toType == Float.TYPE)) result = new Float(doubleValue(value)); if (toType == BigInteger.class) result = bigIntValue(value); if (toType == BigDecimal.class) result = bigDecValue(value); if (toType == String.class) result = stringValue(value); if (toType == Date.class) { result = DateUtils.toDate(stringValue(value)); } if (Enum.class.isAssignableFrom(toType)) result = enumValue((Class<Enum>) toType, value); } } else { if (toType.isPrimitive()) { result = primitiveDefaults.get(toType); } } return result; }
From source file:org.ralasafe.db.JavaBeanColumnAdapter.java
private void initSetterMethod(Object o) throws Exception { Class valueClass;/*w w w . ja v a 2 s .c om*/ Class clas = o.getClass(); if (className.equals("int")) valueClass = Integer.TYPE; else if (className.equals("float")) valueClass = Float.TYPE; else if (className.equals("long")) valueClass = Long.TYPE; else if (className.equals("double")) valueClass = Double.TYPE; else if (className.equals("boolean")) valueClass = Boolean.TYPE; else valueClass = Class.forName(className); setter = clas.getMethod(setterStr, new Class[] { valueClass }); }
From source file:Main.java
/** Evaluates an XPath returning null if not found. <br> * <br>//from w w w.ja va 2 s .c om * This is intended for use with pre-defined XPaths stored as constants, * where runtime exceptions should not be possible. * @param expression The XPath expression to evaluate. * @param item The {@link Node} or other item to evaluate the XPath on. * @param type The type to return, this must be one of the following: * {@link String}, {@link CharSequence}, {@link Boolean}, * {@link Node}, {@link NodeList}, {@link Double}, or * {@link Number}. * @throws AssertionError If the nested call to <tt>XPath.newInstance(path)</tt> * throws an {@link XPathExpressionException}. */ public static <T> T evalXPath(String expression, Object item, Class<T> type) { Object val; if (type == String.class) val = evalXPath(expression, item, XPathConstants.STRING); else if (type == CharSequence.class) val = evalXPath(expression, item, XPathConstants.STRING); else if (type == Boolean.class) val = evalXPath(expression, item, XPathConstants.BOOLEAN); else if (type == Boolean.TYPE) val = evalXPath(expression, item, XPathConstants.BOOLEAN); else if (type == Node.class) val = evalXPath(expression, item, XPathConstants.NODE); else if (type == NodeList.class) val = evalXPath(expression, item, XPathConstants.NODESET); else if (type == Double.class) val = evalXPath(expression, item, XPathConstants.NUMBER); else if (type == Double.TYPE) val = evalXPath(expression, item, XPathConstants.NUMBER); else if (type == Number.class) val = evalXPath(expression, item, XPathConstants.NUMBER); else throw new IllegalArgumentException("Invalid type given " + type); return type.cast(val); }
From source file:com.puppycrawl.tools.checkstyle.api.AutomaticBean.java
/** * Creates a BeanUtilsBean that is configured to use * type converters that throw a ConversionException * instead of using the default value when something * goes wrong.//from w w w .j a v a 2 s.c om * * @return a configured BeanUtilsBean */ private static BeanUtilsBean createBeanUtilsBean() { final ConvertUtilsBean cub = new ConvertUtilsBean(); cub.register(new BooleanConverter(), Boolean.TYPE); cub.register(new BooleanConverter(), Boolean.class); cub.register(new ArrayConverter(boolean[].class, new BooleanConverter()), boolean[].class); cub.register(new ByteConverter(), Byte.TYPE); cub.register(new ByteConverter(), Byte.class); cub.register(new ArrayConverter(byte[].class, new ByteConverter()), byte[].class); cub.register(new CharacterConverter(), Character.TYPE); cub.register(new CharacterConverter(), Character.class); cub.register(new ArrayConverter(char[].class, new CharacterConverter()), char[].class); cub.register(new DoubleConverter(), Double.TYPE); cub.register(new DoubleConverter(), Double.class); cub.register(new ArrayConverter(double[].class, new DoubleConverter()), double[].class); cub.register(new FloatConverter(), Float.TYPE); cub.register(new FloatConverter(), Float.class); cub.register(new ArrayConverter(float[].class, new FloatConverter()), float[].class); cub.register(new IntegerConverter(), Integer.TYPE); cub.register(new IntegerConverter(), Integer.class); cub.register(new ArrayConverter(int[].class, new IntegerConverter()), int[].class); cub.register(new LongConverter(), Long.TYPE); cub.register(new LongConverter(), Long.class); cub.register(new ArrayConverter(long[].class, new LongConverter()), long[].class); cub.register(new ShortConverter(), Short.TYPE); cub.register(new ShortConverter(), Short.class); cub.register(new ArrayConverter(short[].class, new ShortConverter()), short[].class); cub.register(new RelaxedStringArrayConverter(), String[].class); // BigDecimal, BigInteger, Class, Date, String, Time, TimeStamp // do not use defaults in the default configuration of ConvertUtilsBean return new BeanUtilsBean(cub, new PropertyUtilsBean()); }
From source file:org.lunarray.model.descriptor.util.PrimitiveUtil.java
/** * Default constructor.// w w w. j a va 2 s . co m */ private PrimitiveUtil() { this.primitivesToClasses = new HashMap<Class<?>, Class<?>>(); this.primitivesToClasses.put(Byte.TYPE, Byte.class); this.primitivesToClasses.put(Integer.TYPE, Integer.class); this.primitivesToClasses.put(Double.TYPE, Double.class); this.primitivesToClasses.put(Float.TYPE, Float.class); this.primitivesToClasses.put(Long.TYPE, Long.class); this.primitivesToClasses.put(Short.TYPE, Short.class); this.primitivesToClasses.put(Character.TYPE, Character.class); this.primitivesToClasses.put(Boolean.TYPE, Boolean.class); }