List of usage examples for java.lang Class isEnum
public boolean isEnum()
From source file:org.wrml.runtime.schema.generator.SchemaGenerator.java
public Choices generateChoices(final Class<?> nativeChoicesEnumClass) { if (nativeChoicesEnumClass == null || !nativeChoicesEnumClass.isEnum()) { return null; }/*from w w w . j a va 2 s . c o m*/ final SchemaLoader schemaLoader = getSchemaLoader(); final Choices choices = getContext().newModel(schemaLoader.getChoicesSchemaUri()); final URI choicesUri = schemaLoader.getTypeUri(nativeChoicesEnumClass); choices.setUri(choicesUri); final UniqueName choicesUniqueName = schemaLoader.getTypeUniqueName(choicesUri); choices.setUniqueName(choicesUniqueName); final Object[] enumConstants = nativeChoicesEnumClass.getEnumConstants(); if (enumConstants != null && enumConstants.length > 0) { final LinkedHashSet choiceSet = new LinkedHashSet(enumConstants.length); for (final Object enumConstant : enumConstants) { final String choice = String.valueOf(enumConstant); choiceSet.add(enumConstant); } choices.getList().addAll(choiceSet); } return choices; }
From source file:org.apache.hadoop.hbase.security.access.HbaseObjectWritableFor96Migration.java
/** * Read a {@link Writable}, {@link String}, primitive type, or an array of * the preceding.//from ww w . j a v a 2 s. c o m * @param in * @param objectWritable * @param conf * @return the object * @throws IOException */ @SuppressWarnings("unchecked") static Object readObject(DataInput in, HbaseObjectWritableFor96Migration objectWritable, Configuration conf) throws IOException { Class<?> declaredClass = CODE_TO_CLASS.get(WritableUtils.readVInt(in)); Object instance; if (declaredClass.isPrimitive()) { // primitive types if (declaredClass == Boolean.TYPE) { // boolean instance = Boolean.valueOf(in.readBoolean()); } else if (declaredClass == Character.TYPE) { // char instance = Character.valueOf(in.readChar()); } else if (declaredClass == Byte.TYPE) { // byte instance = Byte.valueOf(in.readByte()); } else if (declaredClass == Short.TYPE) { // short instance = Short.valueOf(in.readShort()); } else if (declaredClass == Integer.TYPE) { // int instance = Integer.valueOf(in.readInt()); } else if (declaredClass == Long.TYPE) { // long instance = Long.valueOf(in.readLong()); } else if (declaredClass == Float.TYPE) { // float instance = Float.valueOf(in.readFloat()); } else if (declaredClass == Double.TYPE) { // double instance = Double.valueOf(in.readDouble()); } else if (declaredClass == Void.TYPE) { // void instance = null; } else { throw new IllegalArgumentException("Not a primitive: " + declaredClass); } } else if (declaredClass.isArray()) { // array if (declaredClass.equals(byte[].class)) { instance = Bytes.readByteArray(in); } else { int length = in.readInt(); instance = Array.newInstance(declaredClass.getComponentType(), length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } } else if (declaredClass.equals(Array.class)) { //an array not declared in CLASS_TO_CODE Class<?> componentType = readClass(conf, in); int length = in.readInt(); instance = Array.newInstance(componentType, length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } else if (List.class.isAssignableFrom(declaredClass)) { // List int length = in.readInt(); instance = new ArrayList(length); for (int i = 0; i < length; i++) { ((ArrayList) instance).add(readObject(in, conf)); } } else if (declaredClass == String.class) { // String instance = Text.readString(in); } else if (declaredClass.isEnum()) { // enum instance = Enum.valueOf((Class<? extends Enum>) declaredClass, Text.readString(in)); } else if (declaredClass == Message.class) { String className = Text.readString(in); try { declaredClass = getClassByName(conf, className); instance = tryInstantiateProtobuf(declaredClass, in); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else if (Scan.class.isAssignableFrom(declaredClass)) { int length = in.readInt(); byte[] scanBytes = new byte[length]; in.readFully(scanBytes); ClientProtos.Scan.Builder scanProto = ClientProtos.Scan.newBuilder(); instance = ProtobufUtil.toScan(scanProto.mergeFrom(scanBytes).build()); } else { // Writable or Serializable Class instanceClass = null; int b = (byte) WritableUtils.readVInt(in); if (b == NOT_ENCODED) { String className = Text.readString(in); try { instanceClass = getClassByName(conf, className); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else { instanceClass = CODE_TO_CLASS.get(b); } if (Writable.class.isAssignableFrom(instanceClass)) { Writable writable = WritableFactories.newInstance(instanceClass, conf); try { writable.readFields(in); } catch (Exception e) { LOG.error("Error in readFields", e); throw new IOException("Error in readFields", e); } instance = writable; if (instanceClass == NullInstance.class) { // null declaredClass = ((NullInstance) instance).declaredClass; instance = null; } } else { int length = in.readInt(); byte[] objectBytes = new byte[length]; in.readFully(objectBytes); ByteArrayInputStream bis = null; ObjectInputStream ois = null; try { bis = new ByteArrayInputStream(objectBytes); ois = new ObjectInputStream(bis); instance = ois.readObject(); } catch (ClassNotFoundException e) { LOG.error("Class not found when attempting to deserialize object", e); throw new IOException("Class not found when attempting to " + "deserialize object", e); } finally { if (bis != null) bis.close(); if (ois != null) ois.close(); } } } if (objectWritable != null) { // store values objectWritable.declaredClass = declaredClass; objectWritable.instance = instance; } return instance; }
From source file:org.apache.drill.jdbc.proxy.InvocationReporterImpl.java
private String formatValue(final Object value) { final String result; if (null == value) { result = "null"; } else {/* www . j av a 2 s . c o m*/ final Class<?> rawActualType = value.getClass(); if (String.class == rawActualType) { result = formatString((String) value); } else if (rawActualType.isArray() && !rawActualType.getComponentType().isPrimitive()) { // Array of non-primitive type final StringBuilder buffer = new StringBuilder(); /* Decide whether to includes this: buffer.append( formatType( elemType ) ); buffer.append( "[] " ); */ buffer.append("{ "); boolean first = true; for (Object elemVal : (Object[]) value) { if (!first) { buffer.append(", "); } first = false; buffer.append(formatValue(elemVal)); } buffer.append(" }"); result = buffer.toString(); } else if (DriverPropertyInfo.class == rawActualType) { result = formatDriverPropertyInfo((DriverPropertyInfo) value); } else if ( // Is type seen and whose toString() renders value well. false || rawActualType == java.lang.Boolean.class || rawActualType == java.lang.Byte.class || rawActualType == java.lang.Double.class || rawActualType == java.lang.Float.class || rawActualType == java.lang.Integer.class || rawActualType == java.lang.Long.class || rawActualType == java.lang.Short.class || rawActualType == java.math.BigDecimal.class || rawActualType == java.lang.Class.class || rawActualType == java.sql.Date.class || rawActualType == java.sql.Timestamp.class) { result = value.toString(); } else if ( // Is type seen and whose toString() has rendered value well--in cases // seen so far. false || rawActualType == java.util.Properties.class || rawActualType.isEnum()) { result = value.toString(); } else if ( // Is type to warn about (one case). false || rawActualType == org.apache.drill.jdbc.DrillResultSet.class) { printWarningLine("Class " + rawActualType.getName() + " should be an interface." + " (While it's a class, it can't be proxied, and some methods can't" + " be traced.)"); result = value.toString(); } else if ( // Is type to warn about (second case). false || rawActualType == org.apache.hadoop.io.Text.class || rawActualType == org.joda.time.Period.class || rawActualType == org.apache.drill.exec.vector.accessor.sql.TimePrintMillis.class) { printWarningLine("Should " + rawActualType + " be appearing at JDBC interface?"); result = value.toString(); } else { // Is other type--unknown whether it already formats well. // (No handled yet: byte[].) printWarningLine("Unnoted type encountered in formatting (value might" + " not render well): " + rawActualType + "."); result = value.toString(); } } return result; }
From source file:com.boylesoftware.web.impl.UserInputControllerMethodArgHandler.java
/** * Create new handler./* www . jav a 2s.c o m*/ * * @param validatorFactory Validator factory. * @param beanClass User input bean class. * @param validationGroups Validation groups to apply during bean * validation, or empty array to use the default group. * * @throws UnavailableException If an error happens. */ UserInputControllerMethodArgHandler(final ValidatorFactory validatorFactory, final Class<?> beanClass, final Class<?>[] validationGroups) throws UnavailableException { this.validatorFactory = validatorFactory; this.beanClass = beanClass; this.validationGroups = validationGroups; try { final BeanInfo beanInfo = Introspector.getBeanInfo(this.beanClass); final PropertyDescriptor[] propDescs = beanInfo.getPropertyDescriptors(); final List<FieldDesc> beanFields = new ArrayList<>(); for (final PropertyDescriptor propDesc : propDescs) { final String propName = propDesc.getName(); final Class<?> propType = propDesc.getPropertyType(); final Method propGetter = propDesc.getReadMethod(); final Method propSetter = propDesc.getWriteMethod(); if ((propGetter == null) || (propSetter == null)) continue; Field propField = null; for (Class<?> c = this.beanClass; !c.equals(Object.class); c = c.getSuperclass()) { try { propField = c.getDeclaredField(propName); break; } catch (final NoSuchFieldException e) { // nothing, continue the loop } } final boolean noTrim = (((propField != null) && propField.isAnnotationPresent(NoTrim.class)) || (propGetter.isAnnotationPresent(NoTrim.class))); Class<? extends Binder> binderClass = null; String format = null; String errorMessage = Bind.DEFAULT_MESSAGE; Bind bindAnno = null; if (propField != null) bindAnno = propField.getAnnotation(Bind.class); if (bindAnno == null) bindAnno = propGetter.getAnnotation(Bind.class); if (bindAnno != null) { binderClass = bindAnno.binder(); format = bindAnno.format(); errorMessage = bindAnno.message(); } if (binderClass == null) { if ((String.class).isAssignableFrom(propType)) binderClass = StringBinder.class; else if ((Boolean.class).isAssignableFrom(propType) || propType.equals(Boolean.TYPE)) binderClass = BooleanBinder.class; else if ((Integer.class).isAssignableFrom(propType) || propType.equals(Integer.TYPE)) binderClass = IntegerBinder.class; else if (propType.isEnum()) binderClass = EnumBinder.class; else // TODO: add more standard binders throw new UnavailableException( "Unsupported user input bean field type " + propType.getName() + "."); } beanFields.add(new FieldDesc(propDesc, noTrim, binderClass.newInstance(), format, errorMessage)); } this.beanFields = beanFields.toArray(new FieldDesc[beanFields.size()]); } catch (final IntrospectionException e) { this.log.error("error introspecting user input bean", e); throw new UnavailableException("Specified user input bean" + " class could not be introspected."); } catch (final IllegalAccessException | InstantiationException e) { this.log.error("error instatiating binder", e); throw new UnavailableException("Used user input bean field binder" + " could not be instantiated."); } this.beanPool = new FastPool<>(new PoolableObjectFactory<PoolableUserInput>() { @Override public PoolableUserInput makeNew(final FastPool<PoolableUserInput> pool, final int pooledObjectId) { try { return new PoolableUserInput(pool, pooledObjectId, beanClass.newInstance()); } catch (final InstantiationException | IllegalAccessException e) { throw new RuntimeException("Error instatiating user input bean.", e); } } }, "UserInputBeansPool_" + beanClass.getSimpleName()); }
From source file:org.apache.bval.jsr.xml.ValidationMappingParser.java
private Object convertToResultType(Class<?> returnType, String value, String defaultPackage) { /**//from ww w. j ava 2s . com * Class is represented by the fully qualified class name of the class. * spec: Note that if the raw string is unqualified, * default package is taken into account. */ if (returnType.equals(Class.class)) { value = toQualifiedClassName(value, defaultPackage); } if (Byte.class.equals(returnType) || byte.class.equals(returnType)) { // spec mandates it return Byte.parseByte(value); } if (Short.class.equals(returnType) || short.class.equals(returnType)) { return Short.parseShort(value); } if (Integer.class.equals(returnType) || int.class.equals(returnType)) { return Integer.parseInt(value); } if (Long.class.equals(returnType) || long.class.equals(returnType)) { return Long.parseLong(value); } if (Float.class.equals(returnType) || float.class.equals(returnType)) { return Float.parseFloat(value); } if (Double.class.equals(returnType) || double.class.equals(returnType)) { return Double.parseDouble(value); } if (Boolean.class.equals(returnType) || boolean.class.equals(returnType)) { return Boolean.parseBoolean(value); } if (Character.class.equals(returnType) || char.class.equals(returnType)) { if (value.length() > 1) { throw new IllegalArgumentException("a char has a length of 1"); } return value.charAt(0); } /* Converter lookup */ Converter converter = ConvertUtils.lookup(returnType); if (converter == null && returnType.isEnum()) { converter = EnumerationConverter.getInstance(); } if (converter == null) { return converter; } return converter.convert(returnType, value); }
From source file:org.apache.hadoop.hbase.io.HbaseObjectWritable.java
/** * Read a {@link Writable}, {@link String}, primitive type, or an array of * the preceding.//from w ww.j a v a2 s . c om * @param in * @param objectWritable * @param conf * @return the object * @throws IOException */ @SuppressWarnings("unchecked") public static Object readObject(DataInput in, HbaseObjectWritable objectWritable, Configuration conf) throws IOException { Class<?> declaredClass = CODE_TO_CLASS.get(WritableUtils.readVInt(in)); Object instance; if (declaredClass.isPrimitive()) { // primitive types if (declaredClass == Boolean.TYPE) { // boolean instance = Boolean.valueOf(in.readBoolean()); } else if (declaredClass == Character.TYPE) { // char instance = Character.valueOf(in.readChar()); } else if (declaredClass == Byte.TYPE) { // byte instance = Byte.valueOf(in.readByte()); } else if (declaredClass == Short.TYPE) { // short instance = Short.valueOf(in.readShort()); } else if (declaredClass == Integer.TYPE) { // int instance = Integer.valueOf(in.readInt()); } else if (declaredClass == Long.TYPE) { // long instance = Long.valueOf(in.readLong()); } else if (declaredClass == Float.TYPE) { // float instance = Float.valueOf(in.readFloat()); } else if (declaredClass == Double.TYPE) { // double instance = Double.valueOf(in.readDouble()); } else if (declaredClass == Void.TYPE) { // void instance = null; } else { throw new IllegalArgumentException("Not a primitive: " + declaredClass); } } else if (declaredClass.isArray()) { // array if (declaredClass.equals(byte[].class)) { instance = Bytes.readByteArray(in); } else if (declaredClass.equals(Result[].class)) { instance = Result.readArray(in); } else { int length = in.readInt(); instance = Array.newInstance(declaredClass.getComponentType(), length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } } else if (declaredClass.equals(Array.class)) { //an array not declared in CLASS_TO_CODE Class<?> componentType = readClass(conf, in); int length = in.readInt(); instance = Array.newInstance(componentType, length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } else if (List.class.isAssignableFrom(declaredClass)) { // List int length = in.readInt(); instance = new ArrayList(length); for (int i = 0; i < length; i++) { ((ArrayList) instance).add(readObject(in, conf)); } } else if (declaredClass == String.class) { // String instance = Text.readString(in); } else if (declaredClass.isEnum()) { // enum instance = Enum.valueOf((Class<? extends Enum>) declaredClass, Text.readString(in)); } else if (declaredClass == Message.class) { String className = Text.readString(in); try { declaredClass = getClassByName(conf, className); instance = tryInstantiateProtobuf(declaredClass, in); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else { // Writable or Serializable Class instanceClass = null; int b = (byte) WritableUtils.readVInt(in); if (b == NOT_ENCODED) { String className = Text.readString(in); try { instanceClass = getClassByName(conf, className); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else { instanceClass = CODE_TO_CLASS.get(b); } if (Writable.class.isAssignableFrom(instanceClass)) { Writable writable = WritableFactories.newInstance(instanceClass, conf); try { writable.readFields(in); } catch (Exception e) { LOG.error("Error in readFields", e); throw new IOException("Error in readFields", e); } instance = writable; if (instanceClass == NullInstance.class) { // null declaredClass = ((NullInstance) instance).declaredClass; instance = null; } } else { int length = in.readInt(); byte[] objectBytes = new byte[length]; in.readFully(objectBytes); ByteArrayInputStream bis = null; ObjectInputStream ois = null; try { bis = new ByteArrayInputStream(objectBytes); ois = new ObjectInputStream(bis); instance = ois.readObject(); } catch (ClassNotFoundException e) { LOG.error("Class not found when attempting to deserialize object", e); throw new IOException("Class not found when attempting to " + "deserialize object", e); } finally { if (bis != null) bis.close(); if (ois != null) ois.close(); } } } if (objectWritable != null) { // store values objectWritable.declaredClass = declaredClass; objectWritable.instance = instance; } return instance; }
From source file:com.cloudera.sqoop.SqoopOptions.java
/** * Return a Properties instance that encapsulates all the "sticky" * state of this SqoopOptions that should be written to a metastore * to restore the job later./* w w w .j a v a 2 s. c o m*/ */ public Properties writeProperties() { Properties props = new Properties(); try { Field[] fields = getClass().getDeclaredFields(); for (Field f : fields) { if (f.isAnnotationPresent(StoredAsProperty.class)) { Class typ = f.getType(); StoredAsProperty storedAs = f.getAnnotation(StoredAsProperty.class); String propName = storedAs.value(); if (typ.equals(int.class)) { putProperty(props, propName, Integer.toString(f.getInt(this))); } else if (typ.equals(boolean.class)) { putProperty(props, propName, Boolean.toString(f.getBoolean(this))); } else if (typ.equals(long.class)) { putProperty(props, propName, Long.toString(f.getLong(this))); } else if (typ.equals(String.class)) { putProperty(props, propName, (String) f.get(this)); } else if (typ.equals(Integer.class)) { putProperty(props, propName, f.get(this) == null ? "null" : f.get(this).toString()); } else if (typ.isEnum()) { putProperty(props, propName, f.get(this).toString()); } else { throw new RuntimeException("Could not set property " + propName + " for type: " + typ); } } } } catch (IllegalAccessException iae) { throw new RuntimeException("Illegal access to field in property setter", iae); } if (this.getConf().getBoolean(METASTORE_PASSWORD_KEY, METASTORE_PASSWORD_DEFAULT)) { // If the user specifies, we may store the password in the metastore. putProperty(props, "db.password", this.password); putProperty(props, "db.require.password", "false"); } else if (this.password != null) { // Otherwise, if the user has set a password, we just record // a flag stating that the password will need to be reentered. putProperty(props, "db.require.password", "true"); } else { // No password saved or required. putProperty(props, "db.require.password", "false"); } putProperty(props, "db.column.list", arrayToList(this.columns)); setDelimiterProperties(props, "codegen.input.delimiters", this.inputDelimiters); setDelimiterProperties(props, "codegen.output.delimiters", this.outputDelimiters); setArgArrayProperties(props, "tool.arguments", this.extraArgs); return props; }
From source file:org.cloudata.core.common.io.CObjectWritable.java
/** Read a {@link CWritable}, {@link String}, primitive type, or an array of * the preceding. *//*ww w .ja v a 2s . c o m*/ @SuppressWarnings("unchecked") public static Object readObject(DataInput in, CObjectWritable objectWritable, CloudataConf conf, boolean arrayComponent, Class componentClass) throws IOException { String className; if (arrayComponent) { className = componentClass.getName(); } else { className = CUTF8.readString(in); //SANGCHUL // System.out.println("SANGCHUL] className:" + className); } Class<?> declaredClass = PRIMITIVE_NAMES.get(className); if (declaredClass == null) { try { declaredClass = conf.getClassByName(className); } catch (ClassNotFoundException e) { //SANGCHUL e.printStackTrace(); throw new RuntimeException("readObject can't find class[className=" + className + "]", e); } } Object instance; if (declaredClass.isPrimitive()) { // primitive types if (declaredClass == Boolean.TYPE) { // boolean instance = Boolean.valueOf(in.readBoolean()); } else if (declaredClass == Character.TYPE) { // char instance = Character.valueOf(in.readChar()); } else if (declaredClass == Byte.TYPE) { // byte instance = Byte.valueOf(in.readByte()); } else if (declaredClass == Short.TYPE) { // short instance = Short.valueOf(in.readShort()); } else if (declaredClass == Integer.TYPE) { // int instance = Integer.valueOf(in.readInt()); } else if (declaredClass == Long.TYPE) { // long instance = Long.valueOf(in.readLong()); } else if (declaredClass == Float.TYPE) { // float instance = Float.valueOf(in.readFloat()); } else if (declaredClass == Double.TYPE) { // double instance = Double.valueOf(in.readDouble()); } else if (declaredClass == Void.TYPE) { // void instance = null; } else { throw new IllegalArgumentException("Not a primitive: " + declaredClass); } } else if (declaredClass.isArray()) { // array //System.out.println("SANGCHUL] is array"); int length = in.readInt(); //System.out.println("SANGCHUL] array length : " + length); //System.out.println("Read:in.readInt():" + length); if (declaredClass.getComponentType() == Byte.TYPE) { byte[] bytes = new byte[length]; in.readFully(bytes); instance = bytes; } else if (declaredClass.getComponentType() == ColumnValue.class) { instance = readColumnValue(in, conf, declaredClass, length); } else { Class componentType = declaredClass.getComponentType(); // SANGCHUL //System.out.println("SANGCHUL] componentType : " + componentType.getName()); instance = Array.newInstance(componentType, length); for (int i = 0; i < length; i++) { Object arrayComponentInstance = readObject(in, null, conf, !componentType.isArray(), componentType); Array.set(instance, i, arrayComponentInstance); //Array.set(instance, i, readObject(in, conf)); } } } else if (declaredClass == String.class) { // String instance = CUTF8.readString(in); } else if (declaredClass.isEnum()) { // enum instance = Enum.valueOf((Class<? extends Enum>) declaredClass, CUTF8.readString(in)); } else if (declaredClass == ColumnValue.class) { //ColumnValue? ?? ?? ? ? ?. //? ? ? ? ? ? . Class instanceClass = null; try { short typeDiff = in.readShort(); if (typeDiff == TYPE_DIFF) { instanceClass = conf.getClassByName(CUTF8.readString(in)); } else { instanceClass = declaredClass; } } catch (ClassNotFoundException e) { throw new RuntimeException("readObject can't find class", e); } ColumnValue columnValue = new ColumnValue(); columnValue.readFields(in); instance = columnValue; } else { // Writable Class instanceClass = null; try { short typeDiff = in.readShort(); // SANGCHUL //System.out.println("SANGCHUL] typeDiff : " + typeDiff); //System.out.println("Read:in.readShort():" + typeDiff); if (typeDiff == TYPE_DIFF) { // SANGCHUL String classNameTemp = CUTF8.readString(in); //System.out.println("SANGCHUL] typeDiff : " + classNameTemp); instanceClass = conf.getClassByName(classNameTemp); //System.out.println("Read:UTF8.readString(in):" + instanceClass.getClass()); } else { instanceClass = declaredClass; } } catch (ClassNotFoundException e) { // SANGCHUL e.printStackTrace(); throw new RuntimeException("readObject can't find class", e); } CWritable writable = CWritableFactories.newInstance(instanceClass, conf); writable.readFields(in); //System.out.println("Read:writable.readFields(in)"); instance = writable; if (instanceClass == NullInstance.class) { // null declaredClass = ((NullInstance) instance).declaredClass; instance = null; } } if (objectWritable != null) { // store values objectWritable.declaredClass = declaredClass; objectWritable.instance = instance; } return instance; }
From source file:org.cruxframework.crux.tools.schema.DefaultSchemaGenerator.java
/** * /*from ww w. ja v a 2 s . co m*/ * @param type * @param library * @return */ @SuppressWarnings("unchecked") private String getSchemaType(Class<?> type, String library, boolean supportsBinding) { if (String.class.isAssignableFrom(type)) { return "xs:string"; } else if (Boolean.class.isAssignableFrom(type)) { return supportsBinding ? "c:_bindableBoolean" : "xs:boolean"; } else if (Integer.class.isAssignableFrom(type)) { return supportsBinding ? "c:_bindableInt" : "xs:int"; } else if (Short.class.isAssignableFrom(type)) { return supportsBinding ? "c:_bindableInt" : "xs:short"; } else if (Long.class.isAssignableFrom(type)) { return supportsBinding ? "c:_bindableInt" : "xs:long"; } else if (Double.class.isAssignableFrom(type)) { return supportsBinding ? "c:_bindableFloat" : "xs:double"; } else if (Float.class.isAssignableFrom(type)) { return supportsBinding ? "c:_bindableFloat" : "xs:float"; } else if (Character.class.isAssignableFrom(type)) { return "xs:string"; } else if (type.isEnum()) { String typeName = type.getCanonicalName().replace('.', '_'); this.enumTypes.put(typeName, type); return typeName; } else if (WidgetCreator.class.isAssignableFrom(type)) { DeclarativeFactory annot = type.getAnnotation(DeclarativeFactory.class); if (annot != null) { if (annot.library().equals(library)) { return "T" + annot.id(); } else { return "_" + annot.library() + ":T" + annot.id(); } } } else if (WidgetChildProcessor.class.isAssignableFrom(type)) { String typeName = type.getCanonicalName().replace('.', '_'); this.subTagTypes.add((Class<? extends WidgetChildProcessor<?>>) type); return typeName; } else if (AnyTag.class.isAssignableFrom(type)) { return "xs:anyType"; } else if (HTMLTag.class.isAssignableFrom(type)) { return "xs:anyType"; } else if (ResourcePrototype.class.isAssignableFrom(type)) { return "xs:string"; } return null; }