List of usage examples for java.lang Long TYPE
Class TYPE
To view the source code for java.lang Long TYPE.
Click Source Link
From source file:com.netspective.commons.lang.ValueBeanGeneratorClassLoader.java
/** * Convert runtime java.lang.Class to BCEL Type object. * * @param cl Java class// w w w. j a v a2 s. com * * @return corresponding Type object */ public static Type getBCELType(java.lang.Class cl) { if (cl == null) { throw new IllegalArgumentException("Class must not be null"); } /* That's an amzingly easy case, because getName() returns * the signature. That's what we would have liked anyway. */ if (cl.isArray()) { return Type.getType(cl.getName()); } else if (cl.isPrimitive()) { if (cl == Integer.TYPE) { return Type.INT; } else if (cl == Void.TYPE) { return Type.VOID; } else if (cl == Double.TYPE) { return Type.DOUBLE; } else if (cl == Float.TYPE) { return Type.FLOAT; } else if (cl == Boolean.TYPE) { return Type.BOOLEAN; } else if (cl == Byte.TYPE) { return Type.BYTE; } else if (cl == Short.TYPE) { return Type.SHORT; } else if (cl == Long.TYPE) { return Type.LONG; } else if (cl == Character.TYPE) { return Type.CHAR; } else { throw new IllegalStateException("Ooops, what primitive type is " + cl); } } else { // "Real" class return new ObjectType(cl.getName()); } }
From source file:org.jcommon.com.util.config.ConfigLoader.java
@SuppressWarnings("unchecked") private static StringBuilder updateString(InputStream is, BaseConfigMBean config) throws FileNotFoundException { StringBuilder sb = new StringBuilder(); if (is == null) throw new FileNotFoundException(); try {// w ww .ja v a 2 s . c o m boolean empty = false; Document doc = null; try { doc = new SAXReader().read(is); } catch (Exception e) { empty = true; doc = DocumentHelper.createDocument(); } Element root = doc.getRootElement(); String element = null; Class<?> type = null; java.lang.reflect.Field[] fs = config.getClass().getDeclaredFields(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n").append("<config>\n"); for (java.lang.reflect.Field f : fs) { element = f.getName(); if (getTextFromElement(root, element) == null && !empty) continue; Object value = null; type = f.getType(); java.lang.reflect.Method m = getMethod(config.getClass(), "get" + element); if (m == null) m = getMethod(config.getClass(), "is" + element); if (m != null) { try { value = m.invoke(config); logger.info(element + ":" + value); } catch (Exception e) { logger.warn(e); continue; } if (String.class == type) { String data = String.valueOf(value); if (data.startsWith("{")) { org.json.JSONObject jsonO = JsonUtils.getJSONObject(data); if (jsonO != null) { Iterator<String> it = jsonO.keys(); sb.append(" <" + element + " "); for (; it != null && it.hasNext();) { String k = it.next(); String v = jsonO.getString(k); sb.append(k).append("=").append("\"" + v + "\" "); } sb.append("/>\n"); continue; } } sb.append(" <" + element + ">").append(data).append("</" + element + ">\n"); } else if ((java.lang.Integer.class == type || Integer.TYPE == type) || (java.lang.Boolean.class == type || Boolean.TYPE == type) || (java.lang.Long.class == type || Long.TYPE == type) || (java.lang.Float.class == type || Float.TYPE == type)) { sb.append(" <" + element + ">").append(String.valueOf(value)) .append("</" + element + ">\n"); } else if (java.util.Collection.class.isAssignableFrom(type)) { Collection<String> list = (Collection<String>) value; for (String s : list) { sb.append(" <" + element + ">").append(s).append("</" + element + ">\n"); } } else if (java.util.Map.class.isAssignableFrom(type)) { Map<String, String> map = (Map<String, String>) value; for (String s : map.keySet()) { String v = map.get(s); sb.append(" <" + element).append(" key=\"" + s + "\"").append(" value=\"" + v + "\"") .append(" />\n"); } } else { logger.info("not map Class:" + type); continue; } } else logger.warn("can't find element:" + element); } sb.append("</config>"); logger.info(String.format("Read config file: %s", is)); } catch (Throwable t) { //t.printStackTrace(); logger.error("read config file error:" + is + "\n" + t.getMessage()); } return sb; }
From source file:Main.java
/** * <p>Copies the given array and adds the given element at the end of the new array.</p> * * <p>The new array contains the same elements of the input * array plus the given element in the last position. The component type of * the new array is the same as that of the input array.</p> * * <p>If the input array is {@code null}, a new one element array is returned * whose component type is the same as the element.</p> * * <pre>/* ww w. j ava2 s . c om*/ * ArrayUtils.add(null, 0) = [0] * ArrayUtils.add([1], 0) = [1, 0] * ArrayUtils.add([1, 0], 1) = [1, 0, 1] * </pre> * * @param array the array to copy and add the element to, may be {@code null} * @param element the object to add at the last index of the new array * @return A new array containing the existing elements plus the new element * @since 2.1 */ public static long[] add(final long[] array, final long element) { final long[] newArray = (long[]) copyArrayGrow1(array, Long.TYPE); newArray[newArray.length - 1] = element; return newArray; }
From source file:us.mn.state.health.lims.testanalyte.form.TestAnalyteTestResultActionForm.java
/** * <p>//from w ww.ja v a 2 s.co m * Return the value of a simple property with the specified name. * </p> * * @param name * Name of the property whose value is to be retrieved * * @exception IllegalArgumentException * if there is no property of the specified name * @exception NullPointerException * if the type specified for the property is invalid */ public Object get(String name) { // Return any non-null value for the specified property Object value = dynaValues.get(name); //System.out.println("I am in get(String name) " + name + " " + value); if (value != null) { return (value); } // Return a null value for a non-primitive property Class type = getDynaProperty(name).getType(); if (type == null) { throw new NullPointerException("The type for property " + name + " is invalid"); } if (!type.isPrimitive()) { return (value); } // Manufacture default values for primitive properties if (type == Boolean.TYPE) { return (Boolean.FALSE); } else if (type == Byte.TYPE) { return (new Byte((byte) 0)); } else if (type == Character.TYPE) { return (new Character((char) 0)); } else if (type == Double.TYPE) { return (new Double(0.0)); } else if (type == Float.TYPE) { return (new Float((float) 0.0)); } else if (type == Integer.TYPE) { return (new Integer(0)); } else if (type == Long.TYPE) { return (new Long(0)); } else if (type == Short.TYPE) { return (new Short((short) 0)); } else { return (null); } }
From source file:com.opengamma.language.definition.JavaTypeInfo.java
private static Class<?> findClass(final String className) throws ClassNotFoundException { if ("boolean".equals(className)) { return Boolean.TYPE; } else if ("char".equals(className)) { return Character.TYPE; } else if ("double".equals(className)) { return Double.TYPE; } else if ("float".equals(className)) { return Float.TYPE; } else if ("int".equals(className)) { return Integer.TYPE; } else if ("long".equals(className)) { return Long.TYPE; } else if ("short".equals(className)) { return Short.TYPE; } else {/*from w ww .j a v a 2s . c om*/ return Class.forName(className); } }
From source file:com.mawujun.util.AnnotationUtils.java
/** * Helper method for comparing two objects of an array type. * * @param componentType the component type of the array * @param o1 the first object/*from www. ja va 2 s . c om*/ * @param o2 the second object * @return a flag whether these objects are equal */ private static boolean arrayMemberEquals(Class<?> componentType, Object o1, Object o2) { if (componentType.isAnnotation()) { return annotationArrayMemberEquals((Annotation[]) o1, (Annotation[]) o2); } if (componentType.equals(Byte.TYPE)) { return Arrays.equals((byte[]) o1, (byte[]) o2); } if (componentType.equals(Short.TYPE)) { return Arrays.equals((short[]) o1, (short[]) o2); } if (componentType.equals(Integer.TYPE)) { return Arrays.equals((int[]) o1, (int[]) o2); } if (componentType.equals(Character.TYPE)) { return Arrays.equals((char[]) o1, (char[]) o2); } if (componentType.equals(Long.TYPE)) { return Arrays.equals((long[]) o1, (long[]) o2); } if (componentType.equals(Float.TYPE)) { return Arrays.equals((float[]) o1, (float[]) o2); } if (componentType.equals(Double.TYPE)) { return Arrays.equals((double[]) o1, (double[]) o2); } if (componentType.equals(Boolean.TYPE)) { return Arrays.equals((boolean[]) o1, (boolean[]) o2); } return Arrays.equals((Object[]) o1, (Object[]) o2); }
From source file:com.xwtec.xwserver.util.json.util.JSONUtils.java
/** * Tests if Class represents a primitive number or wrapper.<br> *//*from ww w . j av a 2 s. com*/ public static boolean isNumber(Class clazz) { return clazz != null && (Byte.TYPE.isAssignableFrom(clazz) || Short.TYPE.isAssignableFrom(clazz) || Integer.TYPE.isAssignableFrom(clazz) || Long.TYPE.isAssignableFrom(clazz) || Float.TYPE.isAssignableFrom(clazz) || Double.TYPE.isAssignableFrom(clazz) || Number.class.isAssignableFrom(clazz)); }
From source file:org.lunarray.model.descriptor.converter.def.AbstractDefaultConverterTool.java
/** * Populates the simple converters./* ww w . j ava2s .com*/ */ private void populateSimpleConverters() { // Primitives. this.converters.put(Integer.TYPE, new IntegerConverter()); this.converters.put(Double.TYPE, new DoubleConverter()); this.converters.put(Float.TYPE, new FloatConverter()); this.converters.put(Long.TYPE, new LongConverter()); this.converters.put(Byte.TYPE, new ByteConverter()); this.converters.put(Short.TYPE, new ShortConverter()); this.converters.put(Character.TYPE, new CharacterConverter()); this.converters.put(Boolean.TYPE, new BooleanConverter()); // Date types. this.addConverter(new CalendarConverter()); this.addConverter(new DateConverter()); // SQL Date types. this.addConverter(new SqlDateConverter()); this.addConverter(new SqlTimeConverter()); this.addConverter(new SqlTimestampConverter()); // String. this.addConverter(new IdempotentConverter()); // Numbers. this.addConverter(new IntegerConverter()); this.addConverter(new DoubleConverter()); this.addConverter(new FloatConverter()); this.addConverter(new LongConverter()); this.addConverter(new ByteConverter()); this.addConverter(new ShortConverter()); // Character. this.addConverter(new CharacterConverter()); // Math types. this.addConverter(new BigDecimalConverter()); this.addConverter(new BigIntegerConverter()); // Boolean. this.addConverter(new BooleanConverter()); }
From source file:org.javelin.sws.ext.bind.internal.BuiltInMappings.java
/** * @param patterns/*from ww w. j ava2s . c o m*/ */ public static <T> void initialize(Map<Class<?>, TypedPattern<?>> patterns, Map<QName, TypedPattern<?>> patternsForTypeQNames) { // see: com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl<T> and inner // com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.StringImpl<T> implementations // we have two places where XSD -> Java mapping is defined: // - JAX-RPC 1.1, section 4.2.1 Simple Types // - JAXB 2, section 6.2.2 Atomic Datatype // XML Schema (1.0) Part 2: Datatypes Second Edition, or/and // W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes // conversion of primitive types should be base on "Lexical Mapping" of simple types defined in XSD part 2 // 3.2 Special Built-in Datatypes (#special-datatypes) // 3.2.1 anySimpleType (#anySimpleType) // 3.2.2 anyAtomicType (#anyAtomicType) // 3.3 Primitive Datatypes (#built-in-primitive-datatypes) // 3.3.1 string (#string) { SimpleContentPattern<String> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_STRING, String.class); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); } // 3.3.2 boolean (#boolean) { SimpleContentPattern<Boolean> pattern = SimpleContentPattern .newValuePattern(SweJaxbConstants.XSD_BOOLEAN, Boolean.class); patterns.put(Boolean.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Boolean>() { @Override public String print(Boolean object, Locale locale) { return Boolean.toString(object); } @Override public Boolean parse(String text, Locale locale) throws ParseException { // TODO: should allow "true", "false", "1", "0" return Boolean.parseBoolean(text); } }); } // 3.3.3 decimal (#decimal) { SimpleContentPattern<BigDecimal> pattern = SimpleContentPattern .newValuePattern(SweJaxbConstants.XSD_DECIMAL, BigDecimal.class); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<BigDecimal>() { @Override public String print(BigDecimal object, Locale locale) { return object.toPlainString(); } @Override public BigDecimal parse(String text, Locale locale) throws ParseException { // TODO: should allow (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+) return new BigDecimal(text); } }); } // 3.3.4 float (#float) { SimpleContentPattern<Float> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_FLOAT, Float.class); patterns.put(Float.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Float>() { @Override public String print(Float object, Locale locale) { return Float.toString(object); } @Override public Float parse(String text, Locale locale) throws ParseException { // TODO: should allow (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?|(\+|-)?INF|NaN return Float.parseFloat(text); } }); } // 3.3.5 double (#double) { SimpleContentPattern<Double> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_DOUBLE, Double.class); patterns.put(Double.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Double>() { @Override public String print(Double object, Locale locale) { return Double.toString(object); } @Override public Double parse(String text, Locale locale) throws ParseException { // TODO: should allow (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?|(\+|-)?INF|NaN return Double.parseDouble(text); } }); } // 3.3.6 duration (#duration) // 3.3.7 dateTime (#dateTime) { SimpleContentPattern<DateTime> pattern = SimpleContentPattern .newValuePattern(SweJaxbConstants.XSD_DATETIME, DateTime.class); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<DateTime>() { private final DateTimeFormatter DTMS = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZZ"); private final DateTimeFormatter DT = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZZ"); private final DateTimeFormatter DTZMS = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); private final DateTimeFormatter DTZ = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'"); @Override public DateTime parse(String text, Locale locale) throws ParseException { return null; } @Override public String print(DateTime object, Locale locale) { if (object.getMillisOfSecond() == 0) { return object.getZone() == DateTimeZone.UTC ? DTZ.print(object) : DT.print(object); } else { return object.getZone() == DateTimeZone.UTC ? DTZMS.print(object) : DTMS.print(object); } } }); } // 3.3.8 time (#time) { SimpleContentPattern<DateTime> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_TIME, DateTime.class); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<DateTime>() { private final DateTimeFormatter TMS = DateTimeFormat.forPattern("HH:mm:ss.SSS"); private final DateTimeFormatter T = DateTimeFormat.forPattern("HH:mm:ss"); @Override public DateTime parse(String text, Locale locale) throws ParseException { return null; } @Override public String print(DateTime object, Locale locale) { // TODO: should allow (([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))? if (object.getMillisOfSecond() == 0) return T.print(object); else return TMS.print(object); } }); } // 3.3.9 date (#date) { SimpleContentPattern<DateTime> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_DATE, DateTime.class); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<DateTime>() { private final DateTimeFormatter DT = DateTimeFormat.forPattern("yyyy-MM-ddZZ"); private final DateTimeFormatter DTZ = DateTimeFormat.forPattern("yyyy-MM-dd'Z'"); @Override public DateTime parse(String text, Locale locale) throws ParseException { return null; } @Override public String print(DateTime object, Locale locale) { return object.getZone() == DateTimeZone.UTC ? DTZ.print(object) : DT.print(object); } }); } // 3.3.10 gYearMonth (#gYearMonth) // 3.3.11 gYear (#gYear) // 3.3.12 gMonthDay (#gMonthDay) // 3.3.13 gDay (#gDay) // 3.3.14 gMonth (#gMonth) // 3.3.15 hexBinary (#hexBinary) // 3.3.16 base64Binary (#base64Binary) // 3.3.17 anyURI (#anyURI) // 3.3.18 QName (#QName) // 3.3.19 NOTATION (#NOTATION) // 3.4 Other Built-in Datatypes (#ordinary-built-ins) // 3.4.1 normalizedString (#normalizedString) // 3.4.2 token (#token) // 3.4.3 language (#language) // 3.4.4 NMTOKEN (#NMTOKEN) // 3.4.5 NMTOKENS (#NMTOKENS) // 3.4.6 Name (#Name) // 3.4.7 NCName (#NCName) // 3.4.8 ID (#ID) // 3.4.9 IDREF (#IDREF) // 3.4.10 IDREFS (#IDREFS) // 3.4.11 ENTITY (#ENTITY) // 3.4.12 ENTITIES (#ENTITIES) // 3.4.13 integer (#integer) // 3.4.14 nonPositiveInteger (#nonPositiveInteger) // 3.4.15 negativeInteger (#negativeInteger) // 3.4.16 long (#long) { SimpleContentPattern<Long> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_LONG, Long.class); patterns.put(Long.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Long>() { @Override public String print(Long object, Locale locale) { return Long.toString(object); } @Override public Long parse(String text, Locale locale) throws ParseException { return Long.parseLong(text); } }); } // 3.4.17 int (#int) { SimpleContentPattern<Integer> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_INT, Integer.class); patterns.put(Integer.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Integer>() { @Override public String print(Integer object, Locale locale) { return Integer.toString(object); } @Override public Integer parse(String text, Locale locale) throws ParseException { return Integer.parseInt(text); } }); } // 3.4.18 short (#short) { SimpleContentPattern<Short> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_SHORT, Short.class); patterns.put(Short.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Short>() { @Override public String print(Short object, Locale locale) { return Short.toString(object); } @Override public Short parse(String text, Locale locale) throws ParseException { return Short.parseShort(text); } }); } // 3.4.19 byte (#byte) { SimpleContentPattern<Byte> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_BYTE, Byte.class); patterns.put(Byte.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Byte>() { @Override public String print(Byte object, Locale locale) { return Byte.toString(object); } @Override public Byte parse(String text, Locale locale) throws ParseException { return Byte.parseByte(text); } }); } // 3.4.20 nonNegativeInteger (#nonNegativeInteger) // 3.4.21 unsignedLong (#unsignedLong) // 3.4.22 unsignedInt (#unsignedInt) // 3.4.23 unsignedShort (#unsignedShort) // 3.4.24 unsignedByte (#unsignedByte) // 3.4.25 positiveInteger (#positiveInteger) // 3.4.26 yearMonthDuration (#yearMonthDuration) // 3.4.27 dayTimeDuration (#dayTimeDuration) // 3.4.28 dateTimeStamp (#dateTimeStamp) // other simple types // JAXB2 (static): /* class [B class char class java.awt.Image class java.io.File class java.lang.Character class java.lang.Class class java.lang.Void class java.math.BigDecimal class java.math.BigInteger class java.net.URI class java.net.URL class java.util.Calendar class java.util.Date class java.util.GregorianCalendar class java.util.UUID class javax.activation.DataHandler class javax.xml.datatype.Duration class javax.xml.datatype.XMLGregorianCalendar class javax.xml.namespace.QName interface javax.xml.transform.Source class void */ // JAXB2 (additional mappings available at runtime): /* * class com.sun.xml.bind.api.CompositeStructure * class java.lang.Object * class javax.xml.bind.JAXBElement */ }
From source file:net.sf.json.JSONDynaBean.java
/** * DOCUMENT ME!//from w w w . jav a2 s. c o m * * @param dest DOCUMENT ME! * @param src DOCUMENT ME! * * @return DOCUMENT ME! */ protected boolean isDynaAssignable(Class dest, Class src) { boolean assignable = dest.isAssignableFrom(src); assignable = ((dest == Boolean.TYPE) && (src == Boolean.class)) ? true : assignable; assignable = ((dest == Byte.TYPE) && (src == Byte.class)) ? true : assignable; assignable = ((dest == Character.TYPE) && (src == Character.class)) ? true : assignable; assignable = ((dest == Short.TYPE) && (src == Short.class)) ? true : assignable; assignable = ((dest == Integer.TYPE) && (src == Integer.class)) ? true : assignable; assignable = ((dest == Long.TYPE) && (src == Long.class)) ? true : assignable; assignable = ((dest == Float.TYPE) && (src == Float.class)) ? true : assignable; assignable = ((dest == Double.TYPE) && (src == Double.class)) ? true : assignable; if ((src == Double.TYPE) || Double.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest) || isFloat(dest)) ? true : assignable; } if ((src == Float.TYPE) || Float.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest)) ? true : assignable; } if ((src == Long.TYPE) || Long.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest)) ? true : assignable; } if ((src == Integer.TYPE) || Integer.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest)) ? true : assignable; } if ((src == Short.TYPE) || Short.class.isAssignableFrom(src)) { assignable = (isByte(dest)) ? true : assignable; } return assignable; }