org.exolab.castor.xml
Class Introspector
java.lang.Object
org.exolab.castor.xml.Introspector
public final class Introspector
extends java.lang.Object
A Helper class for the Marshaller and Unmarshaller,
basically the common code base between the two. This
class handles the introspection to dynamically create
descriptors.
$Revision: 1.3 $ $Date: 2003/04/23 06:42:51 $
WRAP_COLLECTIONS_PROPERTY
public static final String WRAP_COLLECTIONS_PROPERTY
The property name for enabling collection wrapping.
The property controls whether or not collections
(arrays, vectors, etc) should be wrapped in a container element.
For example:
<foos>
<foo>foo1</foo>
<foo>foo2</foo>
</foos>
instead of the default:
<foos>foo1<foos>
<foos>foo2</foos>
Use this property with a value of true or false in the
castor.properties file
org.exolab.castor.xml.introspector.wrapCollections=true
-or-
org.exolab.castor.xml.introspector.wrapCollections=false
This property is false by default.
Introspector
public Introspector()
generateClassDescriptor
public XMLClassDescriptor generateClassDescriptor(Class c)
throws MarshalException
Creates an XMLClassDescriptor for the given class by using Reflection.
c
- the Class to create the XMLClassDescriptor for
- the new XMLClassDescriptor created for the given class
MarshalException
- when an error occurs during the creation
of the ClassDescriptor.
generateClassDescriptor
public XMLClassDescriptor generateClassDescriptor(Class c,
PrintWriter errorWriter)
throws MarshalException
Creates an XMLClassDescriptor for the given class by using Reflection.
c
- the Class to create the XMLClassDescriptor forerrorWriter
- a PrintWriter to print error information to
- the new XMLClassDescriptor created for the given class
MarshalException
- when an error occurs during the creation
of the ClassDescriptor.
getPrimitiveNodeType
public NodeType getPrimitiveNodeType()
Returns the NodeType for java primitives
- the NodeType for java primitives
introspected
public static boolean introspected(XMLClassDescriptor descriptor)
Returns true if the given XMLClassDescriptor was created via
introspection
isCollection
public static boolean isCollection(Class clazz)
Returns true if the given Class is an instance of a
collection class.
marshallable
public static boolean marshallable(Class type)
Returns true if the given Class can be marshalled.
type
- the Class to check marshallability for.
- true if the given Class can be marshalled.
setNaming
public void setNaming(XMLNaming naming)
Sets the Naming conventions to be used by the Introspector
naming
- the implementation of Naming to use. A
value of null, will reset the XMLNaming to the
default specified in the castor.properties file.
setPrimitiveNodeType
public void setPrimitiveNodeType(NodeType nodeType)
Sets the NodeType for primitives. If the
NodeType is NodeType.Element, all primitives will
be treated as Elements, otherwise all primitives
will be treated as Attributes.
nodeType
- the NodeType to use for primitive values.
setWrapCollections
public void setWrapCollections(boolean wrapCollections)
Sets whether or not collections (arrays, vectors, etc)
should be wrapped in a container element. For example:
<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.
toJavaName
public static String toJavaName(String name,
boolean upperFirst)
Converts the given xml name to a Java name.
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.
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com