Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes

org.exolab.castor.xml.Introspector Class Reference

List of all members.

Classes

class  IdentityConvertor
class  MethodSet

Public Member Functions

 Introspector ()
synchronized void addFieldHandlerFactory (FieldHandlerFactory factory)
NodeType getPrimitiveNodeType ()
XMLClassDescriptor generateClassDescriptor (Class c) throws MarshalException
XMLClassDescriptor generateClassDescriptor (Class c, PrintWriter errorWriter) throws MarshalException
synchronized boolean removeFieldHandlerFactory (FieldHandlerFactory factory)
void setWrapCollections (boolean wrapCollections)
void setNaming (XMLNaming naming)
void setPrimitiveNodeType (NodeType nodeType)
void setSaveMapKeys (boolean saveMapKeys)

Static Public Member Functions

static boolean introspected (XMLClassDescriptor descriptor)
static boolean marshallable (Class type)
static String toJavaName (String name, boolean upperFirst)
static boolean isCollection (Class clazz)
static boolean isMapCollection (Class clazz)

Static Public Attributes

static final String WRAP_COLLECTIONS_PROPERTY = "org.exolab.castor.xml.introspector.wrapCollections"

Detailed Description

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.

Author:
Keith Visco
Version:
Revision:
1.16
Date:
2004/10/01 13:25:13

Constructor & Destructor Documentation

org.exolab.castor.xml.Introspector.Introspector (  ) 

Creates a new instance of the Introspector


Member Function Documentation

synchronized void org.exolab.castor.xml.Introspector.addFieldHandlerFactory ( FieldHandlerFactory  factory  ) 

Registers the given "generalized" FieldHandlerFactory with this Introspector.

Parameters:
factory the FieldHandlerFactory to add to this introspector
Exceptions:
IllegalArgumentException if the given factory is null
XMLClassDescriptor org.exolab.castor.xml.Introspector.generateClassDescriptor ( Class  c,
PrintWriter  errorWriter 
) throws MarshalException

Creates an XMLClassDescriptor for the given class by using Reflection.

Parameters:
c the Class to create the XMLClassDescriptor for
errorWriter a PrintWriter to print error information to
Returns:
the new XMLClassDescriptor created for the given class
Exceptions:
MarshalException when an error occurs during the creation of the ClassDescriptor.

References org.exolab.castor.util.List.add(), org.exolab.castor.xml.Introspector.MethodSet.add, org.exolab.castor.xml.util.XMLClassDescriptorImpl.addFieldDescriptor(), org.exolab.castor.xml.Introspector.MethodSet.create, org.exolab.castor.mapping.FieldHandlerFactory.createFieldHandler(), org.exolab.castor.xml.Introspector.MethodSet.fieldName, org.exolab.castor.xml.Introspector.generateClassDescriptor(), org.exolab.castor.util.List.get(), org.exolab.castor.xml.Introspector.MethodSet.get, org.exolab.castor.xml.util.XMLFieldDescriptorImpl.getFieldType(), org.exolab.castor.mapping.GeneralizedFieldHandler.getFieldType(), org.exolab.castor.xml.util.XMLFieldDescriptorImpl.getHandler(), org.exolab.castor.xml.Introspector.isCollection(), org.exolab.castor.xml.Introspector.isMapCollection(), org.exolab.castor.xml.Introspector.MethodSet.set, org.exolab.castor.xml.util.XMLFieldDescriptorImpl.setClassDescriptor(), org.exolab.castor.xml.util.XMLClassDescriptorImpl.setExtends(), org.exolab.castor.mapping.GeneralizedFieldHandler.setFieldHandler(), org.exolab.castor.xml.util.XMLFieldDescriptorImpl.setHandler(), org.exolab.castor.xml.util.XMLFieldDescriptorImpl.setImmutable(), org.exolab.castor.xml.util.XMLFieldDescriptorImpl.setMatches(), org.exolab.castor.xml.util.XMLFieldDescriptorImpl.setMultivalued(), org.exolab.castor.xml.util.XMLFieldDescriptorImpl.setNodeType(), org.exolab.castor.xml.handlers.DateFieldHandler.setUseSQLDate(), org.exolab.castor.xml.util.XMLFieldDescriptorImpl.setXMLName(), org.exolab.castor.util.List.size(), and org.exolab.castor.xml.XMLNaming.toXMLName().

XMLClassDescriptor org.exolab.castor.xml.Introspector.generateClassDescriptor ( Class  c  )  throws MarshalException

Creates an XMLClassDescriptor for the given class by using Reflection.

Parameters:
c the Class to create the XMLClassDescriptor for
Returns:
the new XMLClassDescriptor created for the given class
Exceptions:
MarshalException when an error occurs during the creation of the ClassDescriptor.

Referenced by org.exolab.castor.tools.MappingTool.addClass(), org.exolab.castor.xml.XMLMappingLoader.createDescriptor(), org.exolab.castor.xml.Introspector.generateClassDescriptor(), and org.exolab.castor.xml.util.ClassDescriptorResolverImpl.resolve().

NodeType org.exolab.castor.xml.Introspector.getPrimitiveNodeType (  ) 

Returns the NodeType for java primitives

Returns:
the NodeType for java primitives
static boolean org.exolab.castor.xml.Introspector.introspected ( XMLClassDescriptor  descriptor  )  [static]

Returns true if the given XMLClassDescriptor was created via introspection

Referenced by org.exolab.castor.tools.MappingTool.addClass().

static boolean org.exolab.castor.xml.Introspector.isCollection ( Class  clazz  )  [static]

Returns true if the given Class is an instance of a collection class.

See also:
loadCollections

Referenced by org.exolab.castor.xml.Introspector.generateClassDescriptor().

static boolean org.exolab.castor.xml.Introspector.isMapCollection ( Class  clazz  )  [static]

Returns true if the given Class is an instance of a collection class.

See also:
loadCollections

Referenced by org.exolab.castor.xml.Introspector.generateClassDescriptor().

static boolean org.exolab.castor.xml.Introspector.marshallable ( Class  type  )  [static]

Returns true if the given Class can be marshalled.

Parameters:
type the Class to check marshallability for.
Returns:
true if the given Class can be marshalled.
synchronized boolean org.exolab.castor.xml.Introspector.removeFieldHandlerFactory ( FieldHandlerFactory  factory  ) 

Removes the given FieldHandlerFactory from this Introspector

Parameters:
factory the FieldHandlerFactory to remove
Returns:
true if the given FieldHandlerFactory was removed, or false otherwise.
Exceptions:
IllegalArgumentException if the given factory is null
void org.exolab.castor.xml.Introspector.setNaming ( XMLNaming  naming  ) 

Sets the Naming conventions to be used by the Introspector

Parameters:
naming the implementation of Naming to use. A value of null, will reset the XMLNaming to the default specified in the castor.properties file.
void org.exolab.castor.xml.Introspector.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.

Parameters:
nodeType the NodeType to use for primitive values.

References org.exolab.castor.xml.NodeType.Attribute, and org.exolab.castor.xml.NodeType.Element.

void org.exolab.castor.xml.Introspector.setSaveMapKeys ( boolean  saveMapKeys  ) 

Sets whether or not keys from Hastable / Map instances should be saved in the XML.

Note: This is true by default since Castor 0.9.5.3

Parameters:
saveMapKeys a boolean that when true indicates keys from Hashtable or Map instances should be saved. Otherwise only the value object is saved.
void org.exolab.castor.xml.Introspector.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>
 
Parameters:
wrapCollections a boolean that when true indicates collections should be wrapped in a container element.
static String org.exolab.castor.xml.Introspector.toJavaName ( String  name,
boolean  upperFirst 
) [static]

Converts the given xml name to a Java name.

Parameters:
name the name to convert to a Java Name
upperFirst a flag to indicate whether or not the the first character should be converted to uppercase.

Member Data Documentation

final String org.exolab.castor.xml.Introspector.WRAP_COLLECTIONS_PROPERTY = "org.exolab.castor.xml.introspector.wrapCollections" [static]

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties