public final class Introspector extends Object
Constructor and Description |
---|
Introspector()
Creates a new instance of the Introspector.
|
Introspector(ClassLoader classLoader)
Creates a new instance of the Introspector.
|
Modifier and Type | Method and Description |
---|---|
void |
addFieldHandlerFactory(FieldHandlerFactory factory)
Registers the given "generalized" FieldHandlerFactory with this
Introspector.
|
XMLClassDescriptor |
generateClassDescriptor(Class c)
Creates an XMLClassDescriptor for the given class by using Reflection.
|
XMLClassDescriptor |
generateClassDescriptor(Class c,
PrintWriter errorWriter)
Creates an XMLClassDescriptor for the given class by using Reflection.
|
NodeType |
getPrimitiveNodeType()
Returns the NodeType for java primitives
|
static boolean |
introspected(XMLClassDescriptor descriptor)
Returns true if the given XMLClassDescriptor was created via
introspection
|
static boolean |
isCollection(Class clazz)
Returns true if the given Class is an instance of a
collection class.
|
static boolean |
isMapCollection(Class clazz)
Returns true if the given Class is an instance of a
collection class.
|
static boolean |
marshallable(Class type)
Returns true if the given Class can be marshalled.
|
boolean |
removeFieldHandlerFactory(FieldHandlerFactory factory)
Removes the given FieldHandlerFactory from this Introspector
|
void |
setInternalContext(InternalContext internalContext) |
void |
setNaming(XMLNaming naming)
Sets the Naming conventions to be used by the Introspector
|
void |
setPrimitiveNodeType(NodeType nodeType)
Sets the NodeType for primitives.
|
void |
setSaveMapKeys(boolean saveMapKeys)
Sets whether or not keys from Hastable / Map instances
should be saved in the XML.
|
void |
setWrapCollections(boolean wrapCollections)
Sets whether or not collections (arrays, vectors, etc)
should be wrapped in a container element.
|
static String |
toJavaName(String name,
boolean upperFirst)
Converts the given xml name to a Java name.
|
public Introspector()
public Introspector(ClassLoader classLoader)
classLoader
- public void setInternalContext(InternalContext internalContext)
public void addFieldHandlerFactory(FieldHandlerFactory factory)
factory
- the FieldHandlerFactory to add to this
introspectorIllegalArgumentException
- if the given factory is nullpublic NodeType getPrimitiveNodeType()
public XMLClassDescriptor generateClassDescriptor(Class c) throws MarshalException
c
- the Class to create the XMLClassDescriptor forMarshalException
- when an error occurs during the creation
of the ClassDescriptor.public XMLClassDescriptor generateClassDescriptor(Class c, PrintWriter errorWriter) throws MarshalException
c
- the Class to create the XMLClassDescriptor forerrorWriter
- a PrintWriter to print error information toMarshalException
- when an error occurs during the creation
of the ClassDescriptor.public boolean removeFieldHandlerFactory(FieldHandlerFactory factory)
factory
- the FieldHandlerFactory to removeIllegalArgumentException
- if the given factory is nullpublic void setWrapCollections(boolean wrapCollections)
<foos> <foo>foo1</foo> <foo>foo2</foo> </foos> instead of the default: <foos>foo1<foos> <foos>foo2</foos>
wrapCollections
- a boolean that when true indicates
collections should be wrapped in a container element.public static boolean introspected(XMLClassDescriptor descriptor)
public static boolean marshallable(Class type)
type
- the Class to check marshallability for.public void setNaming(XMLNaming naming)
naming
- the implementation of Naming to use. A
value of null, will reset the XMLNaming to the
default specified in the castor.properties file.public void setPrimitiveNodeType(NodeType nodeType)
nodeType
- the NodeType to use for primitive values.public void setSaveMapKeys(boolean saveMapKeys)
Note: This is true by default since Castor 0.9.5.3
saveMapKeys
- a boolean that when true indicates keys
from Hashtable or Map instances should be saved. Otherwise
only the value object is saved.public static String toJavaName(String name, boolean upperFirst)
name
- the name to convert to a Java NameupperFirst
- a flag to indicate whether or not the
the first character should be converted to uppercase.public static boolean isCollection(Class clazz)
public static boolean isMapCollection(Class clazz)
Copyright © 2014. All rights reserved.