com.abra.j2xb.beans.xmlModel
Class MoXmlBindingModel

java.lang.Object
  extended by com.abra.j2xb.beans.xmlModel.MoXmlBindingModel

public class MoXmlBindingModel
extends java.lang.Object

Defines the XML binding model (persistency environment). The binding model includes the mapped classes, the XML Schemas and special types (MOPropertyEditor).

Since:
JDK1.5
Version:
1.0, Dec 10, 2007
Author:
Yoav Abrahami
See Also:
MOPropertyEditorRegistry, MOPropertyEditor

Constructor Summary
MoXmlBindingModel()
           
 
Method Summary
 MOPersistentBeanDescriptor addBean(java.lang.Class clazz)
          Adds a bean to the binding model.
 MoXmlSchema defineSchema(java.lang.String beanXmlNamespace, java.lang.String schemaPrefix)
           
 void generateSchemas(java.io.File dir)
          writes the XML Schemas of the binding model to a directory.
 void generateSchemas(MoXmlSchemaLocationGenerator schemaLocationGenerator)
          writes the XML Schemas of the binding model to a directory.
 MOPersistentBeanDescriptor getBeanDescriptor(java.lang.Class clazz)
          getter for MOPersistentBeanDescriptor
 MOPropertyEditorRegistry getPropertyEditorRegistry()
           
 MoXmlSchema getSchema(java.lang.Class<?> aClass)
           
 MoXmlSchema getSchema(MOPropertyDescriptor propertyDescriptor)
           
 java.util.Collection<MoXmlSchema> getXmlSchemas()
           
 boolean hasBean(java.lang.Class clazz)
          tests if the model has the clazz parameter
 void inspectClassForPropertyEditorRegistryAnnotations(java.lang.Class clazz)
          inspects a class for MORegisterPropertyEditor or MORegisterPropertyEditors annotations and registers the property editors defined using those annotations.
 void inspectClassForSeeAlsoAnnotations(java.lang.Class clazz)
          inspects a class for MOSeeAlso annotation and adds the references classes to the model.
 boolean isMapExceptionTrace()
           
 void setMapExceptionTrace(boolean mapExceptionTrace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoXmlBindingModel

public MoXmlBindingModel()
Method Detail

addBean

public MOPersistentBeanDescriptor addBean(java.lang.Class clazz)
                                   throws MOBeansException
Adds a bean to the binding model. Each bean that is to be read or written to XML must be added to the binding model. When adding a class which has Bean members, the bean members will be picked from the class definition and added to the model automatically. However, subclasses will not be added automatically and should be added manually.

Parameters:
clazz - the bean to add
Returns:
MOPersistentBeanDescriptor of the added bean
Throws:
MOBeansException - thrown if the bean cannot be mapped to XML because of misuse of the J2XB annotations.

hasBean

public boolean hasBean(java.lang.Class clazz)
tests if the model has the clazz parameter

Parameters:
clazz - - a J2XB mapped class
Returns:
true if the class was added to the model

getBeanDescriptor

public MOPersistentBeanDescriptor getBeanDescriptor(java.lang.Class clazz)
getter for MOPersistentBeanDescriptor

Parameters:
clazz - - a J2XB mapped class
Returns:
MOPersistentBeanDescriptor of the added bean or null if the class is not mapped

generateSchemas

public void generateSchemas(java.io.File dir)
                     throws MoXmlSchemaGenerationException
writes the XML Schemas of the binding model to a directory. Multiple files will be written to this directory (one file per XML Schema) using default filenames.

Parameters:
dir - the output directory
Throws:
MoXmlSchemaGenerationException - thrown in case of error to generate the schemas

generateSchemas

public void generateSchemas(MoXmlSchemaLocationGenerator schemaLocationGenerator)
                     throws MoXmlSchemaGenerationException
writes the XML Schemas of the binding model to a directory. Multiple files will be written to this directory (one file per XML Schema) where the filenames are determined by the filename generator.

Parameters:
schemaLocationGenerator - - filename generator for the schemas
Throws:
MoXmlSchemaGenerationException - thrown in case of error to generate the schemas

getXmlSchemas

public java.util.Collection<MoXmlSchema> getXmlSchemas()
Returns:
a collection of the Xml Schemas

getSchema

public MoXmlSchema getSchema(java.lang.Class<?> aClass)
Parameters:
aClass - a mapped bean class
Returns:
the Xml Schemas by mapped bean class

getSchema

public MoXmlSchema getSchema(MOPropertyDescriptor propertyDescriptor)
Parameters:
propertyDescriptor - a property descriptor of a mapped bean
Returns:
the Xml Schemas by property descriptor

getPropertyEditorRegistry

public MOPropertyEditorRegistry getPropertyEditorRegistry()
Returns:
the property editor registry

defineSchema

public MoXmlSchema defineSchema(java.lang.String beanXmlNamespace,
                                java.lang.String schemaPrefix)

isMapExceptionTrace

public boolean isMapExceptionTrace()

setMapExceptionTrace

public void setMapExceptionTrace(boolean mapExceptionTrace)

inspectClassForPropertyEditorRegistryAnnotations

public void inspectClassForPropertyEditorRegistryAnnotations(java.lang.Class clazz)
                                                      throws MOBeansException
inspects a class for MORegisterPropertyEditor or MORegisterPropertyEditors annotations and registers the property editors defined using those annotations.

Parameters:
clazz - - class to inspect
Throws:
MOBeansException - - on inspection error

inspectClassForSeeAlsoAnnotations

public void inspectClassForSeeAlsoAnnotations(java.lang.Class clazz)
                                       throws MOBeansException
inspects a class for MOSeeAlso annotation and adds the references classes to the model.

Parameters:
clazz - - class to inspect
Throws:
MOBeansException - - on inspection error


Copyright © 2008. All Rights Reserved.