public String getSchema ( Class < ? > clazz ) { if ( clazz == Integer . class || clazz == Integer . TYPE ) { return "integer [" + Integer . MIN_VALUE + " to " + Integer . MAX_VALUE + "]" ; } else if ( clazz == Long . class || clazz == Long . TYPE ) { return "long [" + Long . MIN_VALUE + " to " + Long . MAX_VALUE + "]" ; } else if ( clazz == Double . class || clazz == Double . TYPE ) { return "double [" + Double . MIN_VALUE + " to " + Double . MAX_VALUE + "]" ; } else if ( clazz == Boolean . class || clazz == Boolean . TYPE ) { return "boolean [true, false]" ; } else if ( clazz == Void . class ) { return "void" ; } else if ( clazz == Byte [ ] . class || clazz == byte [ ] . class ) { return "binary stream" ; } else if ( clazz . isEnum ( ) ) { return "enum " + Arrays . asList ( clazz . getEnumConstants ( ) ) ; } else if ( clazz . isAnnotationPresent ( XmlRootElement . class ) ) { try { final JAXBSerialiser serialiser = JAXBSerialiser . getMoxy ( clazz ) ; return generate ( serialiser ) ; } catch ( Exception e ) { // Ignore return "error generating schema for " + clazz + ": " + e . getMessage ( ) ; } } else if ( clazz . isAnnotationPresent ( XmlType . class ) || clazz . isAnnotationPresent ( XmlEnum . class ) ) { // Class generated by JAXB XSD To Java (as a result we have to emit the entire schema rather than being able to provide a specific sub-schema for the type in question because XmlRootElement is not specified) try { final JAXBSerialiser serialiser = JAXBSerialiser . getMoxy ( clazz . getPackage ( ) . getName ( ) ) ; return generate ( serialiser ) ; } catch ( Exception e ) { // Ignore return "error generating schema for XSD-To-Java package schema for class " + clazz + ": " + e . getMessage ( ) ; } } else { return clazz . toString ( ) ; } }
Retrieve a schema description for a type