List of usage examples for java.lang Character TYPE
Class TYPE
To view the source code for java.lang Character TYPE.
Click Source Link
From source file:org.gradle.internal.reflect.JavaReflectionUtil.java
public static Class<?> getWrapperTypeForPrimitiveType(Class<?> type) { if (type == Character.TYPE) { return Character.class; } else if (type == Boolean.TYPE) { return Boolean.class; } else if (type == Long.TYPE) { return Long.class; } else if (type == Integer.TYPE) { return Integer.class; } else if (type == Short.TYPE) { return Short.class; } else if (type == Byte.TYPE) { return Byte.class; } else if (type == Float.TYPE) { return Float.class; } else if (type == Double.TYPE) { return Double.class; }// w w w . ja va 2 s . co m throw new IllegalArgumentException( String.format("Don't know the wrapper type for primitive type %s.", type)); }
From source file:com.link_intersystems.lang.Conversions.java
/** * short to byte or char//from ww w .ja v a2s . co m */ private static boolean isPrimitiveShortNarrowing(Class<?> to) { boolean isNarrowing = false; isNarrowing |= isIdentity(to, Byte.TYPE); isNarrowing |= isIdentity(to, Character.TYPE); return isNarrowing; }
From source file:com.nfwork.dbfound.json.JSONDynaBean.java
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;/*w w w .java2 s.c o m*/ } 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; }
From source file:org.cocoa4android.util.sbjson.SBJsonWriter.java
/** * /*from w w w.ja v a2 s .c om*/ * @param clazz * @return */ public static boolean isString(Class<?> clazz) { return (clazz != null) && ((String.class.isAssignableFrom(clazz)) || (Character.TYPE.isAssignableFrom(clazz)) || (Character.class.isAssignableFrom(clazz))); }
From source file:org.kuali.rice.krad.data.jpa.Filter.java
/** * Coerces the {@code attributeValue} using the given {@code type}. * * @param type the type to use to coerce the value. * @param attributeName the attribute name of the field to coerce. * @param attributeValue the value to coerce. * @return the coerced value./*from ww w. j a v a 2 s . c o m*/ */ private static Object coerceValue(Class<?> type, String attributeName, String attributeValue) { try { if (Character.TYPE.equals(type) || Character.class.isAssignableFrom(type)) { return Character.valueOf(attributeValue.charAt(0)); } else if (Boolean.TYPE.equals(type) || Boolean.class.isAssignableFrom(type)) { return Boolean.valueOf(attributeValue); } else if (Short.TYPE.equals(type) || Short.class.isAssignableFrom(type)) { return Short.valueOf(attributeValue); } else if (Integer.TYPE.equals(type) || Integer.class.isAssignableFrom(type)) { return Integer.valueOf(attributeValue); } else if (Long.TYPE.equals(type) || Long.class.isAssignableFrom(type)) { return Long.valueOf(attributeValue); } else if (Double.TYPE.equals(type) || Double.class.isAssignableFrom(type)) { return Double.valueOf(attributeValue); } else if (Float.TYPE.equals(type) || Float.class.isAssignableFrom(type)) { return Float.valueOf(attributeValue); } } catch (NumberFormatException nfe) { LOG.error("Could not coerce the value " + attributeValue + " for the field " + attributeName, nfe); } return attributeValue; }
From source file:org.openflexo.antar.binding.TypeUtils.java
public static boolean isChar(Type type) { if (type == null) { return false; }/*w w w . j a v a2s. c o m*/ return type.equals(Character.class) || type.equals(Character.TYPE); }
From source file:com.cyclopsgroup.waterview.utils.TypeUtils.java
private static synchronized Map getTypeMap() { if (typeMap == null) { typeMap = new Hashtable(); typeMap.put("boolean", Boolean.TYPE); typeMap.put("byte", Byte.TYPE); typeMap.put("char", Character.TYPE); typeMap.put("short", Short.TYPE); typeMap.put("int", Integer.TYPE); typeMap.put("long", Long.TYPE); typeMap.put("float", Float.TYPE); typeMap.put("double", Double.TYPE); typeMap.put("string", String.class); typeMap.put("date", Date.class); }//from w ww.j av a2 s . c o m return typeMap; }
From source file:nl.strohalm.cyclos.services.ads.AdImportServiceImpl.java
@Override public AdImport importAds(AdImport adImport, final InputStream data) { // Validate and save the import getValidator().validate(adImport);/*from w w w . jav a 2 s .c o m*/ final Currency currency = fetchService.fetch(adImport.getCurrency()); adImport.setCurrency(currency); adImport.setBy(LoggedUser.<Administrator>element()); adImport.setDate(Calendar.getInstance()); adImport = adImportDao.insert(adImport); // Find out the custom fields final List<AdCustomField> customFields = adCustomFieldService.list(); final Map<String, CustomField> customFieldMap = new HashMap<String, CustomField>(customFields.size()); for (final AdCustomField customField : customFields) { customFieldMap.put(customField.getInternalName().toLowerCase(), fetchService.fetch(customField, CustomField.Relationships.POSSIBLE_VALUES)); } // Find the existing advertisement categories final Map<String, AdCategory> existingAdCategoryMap = new LinkedHashMap<String, AdCategory>(); final List<AdCategory> rootCategories = adCategoryService.listRoot(); for (final AdCategory adCategory : rootCategories) { appendCategory(adCategory, existingAdCategoryMap); } final Map<String, ImportedAdCategory> importedAdCategoryMap = new LinkedHashMap<String, ImportedAdCategory>(); // Get the settings final LocalSettings localSettings = settingsService.getLocalSettings(); final char stringQuote = CoercionHelper.coerce(Character.TYPE, localSettings.getCsvStringQuote().getValue()); final char valueSeparator = CoercionHelper.coerce(Character.TYPE, localSettings.getCsvValueSeparator().getValue()); // Read the headers BufferedReader in = null; List<String> headers; try { in = new BufferedReader(new InputStreamReader(data, localSettings.getCharset())); headers = CSVReader.readLine(in, stringQuote, valueSeparator); } catch (final Exception e) { throw new ValidationException("adImport.invalidFormat"); } // Import each ad try { final CacheCleaner cacheCleaner = new CacheCleaner(fetchService); int lineNumber = 2; // The first line is the header List<String> values; while ((values = CSVReader.readLine(in, stringQuote, valueSeparator)) != null) { if (values.isEmpty()) { continue; } importAd(adImport, lineNumber, existingAdCategoryMap, importedAdCategoryMap, customFieldMap, localSettings, headers, values); lineNumber++; cacheCleaner.clearCache(); } } catch (final IOException e) { throw new ValidationException("adImport.errorReading"); } finally { IOUtils.closeQuietly(in); } return adImport; }
From source file:com.link_intersystems.lang.Conversions.java
/** * int to byte, short, or char/*from w w w . j a va2 s. c o m*/ */ private static boolean isPrimitiveIntegerNarrowing(Class<?> to) { boolean isNarrowing = isPrimitiveCharacterNarrowing(to); isNarrowing |= isIdentity(to, Character.TYPE); return isNarrowing; }
From source file:org.seedstack.seed.core.internal.application.ConfigurationMembersInjector.java
@SuppressWarnings("unchecked") private void writeArrayField(T instance) { ConfigurationConverter<?> converter; Class<?> componentType = field.getType().getComponentType(); converter = findConverter(instance, componentType); String[] values = configuration.getStringArray(annotation.value()); if ((values == null || values.length == 0) && annotation.defaultValue().length > 0) { values = annotation.defaultValue(); }//from ww w .j a v a2 s .c o m if (values != null && values.length > 0) { if (componentType.isPrimitive()) { if (componentType == Short.TYPE) { writeField(instance, convertToShortValues(values, (ConfigurationConverter<Short>) converter)); } if (componentType == Integer.TYPE) { writeField(instance, convertToIntegerValues(values, (ConfigurationConverter<Integer>) converter)); } if (componentType == Boolean.TYPE) { writeField(instance, convertToBooleanValues(values, (ConfigurationConverter<Boolean>) converter)); } if (componentType == Byte.TYPE) { writeField(instance, convertToByteValues(values, (ConfigurationConverter<Byte>) converter)); } if (componentType == Long.TYPE) { writeField(instance, convertToLongValues(values, (ConfigurationConverter<Long>) converter)); } if (componentType == Float.TYPE) { writeField(instance, convertToFloatValues(values, (ConfigurationConverter<Float>) converter)); } if (componentType == Double.TYPE) { writeField(instance, convertToDoubleValues(values, (ConfigurationConverter<Double>) converter)); } if (componentType == Character.TYPE) { writeField(instance, convertToCharacterValues(values, (ConfigurationConverter<Character>) converter)); } } else { Object[] convertedValues; try { convertedValues = (Object[]) Array.newInstance(field.getType().getComponentType(), values.length); } catch (Exception e) { throw SeedException.wrap(e, ApplicationErrorCode.UNABLE_TO_INSTANTIATE_CONFIGURATION_ARRAY); } for (int i = 0; i < values.length; i++) { convertedValues[i] = converter.convert(values[i]); } writeField(instance, convertedValues); } } else { LOGGER.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, annotation.value()); } }