org.xeril.xml
Class ClassToDtd

java.lang.Object
  |
  +--org.xeril.xml.ClassToDtd

public class ClassToDtd
extends java.lang.Object

This class is used to produce a DTD from a class


Field Summary
static java.lang.String NULL_TAG
          The constant for null objects
 
Constructor Summary
ClassToDtd(java.io.PrintWriter out)
          Constructor.
 
Method Summary
static void classToDtd(java.lang.Class clazz, java.io.PrintWriter out)
          Displays the Dtd corresponding to the class.
protected  void displayArray(java.lang.Class clazz, java.lang.String tag_name, XmlMapper mapper)
          Displays an array.
protected  void displayClass(java.lang.Class clazz)
          Displays the Dtd for the class.
 void displayDtd(java.lang.Class clazz)
          Displays the Dtd for the class.
protected  void displayField(java.lang.Class clazz, java.lang.String tag_name, XmlMapDescriptor map_desc)
          Displays a field.
protected  void displayValue(java.lang.Class clazz, java.lang.String tag_name, XmlMapper mapper)
          Displays a value.
 java.lang.String getTagNameFromClass(java.lang.Class clazz)
          Gets the tag name from the class.
protected  XmlMapDescriptor getXmlMapDescriptor(java.lang.String field_name, XmlInfo info)
          Tries to extract the map descriptor the field_name and info object.
static void main(java.lang.String[] args)
          Main method...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_TAG

public static final java.lang.String NULL_TAG
The constant for null objects

Constructor Detail

ClassToDtd

public ClassToDtd(java.io.PrintWriter out)
Constructor. You provide the print writer where dtd will be written

Parameters:
out - the writer to write the dtd result
Method Detail

classToDtd

public static void classToDtd(java.lang.Class clazz,
                              java.io.PrintWriter out)
Displays the Dtd corresponding to the class. It will try to find an XmlInfo class from which we can extract more information to bypass the default behavior.

Parameters:
clazz - the class for which to generate the Dtd
out - the print writer for writing the result

displayDtd

public void displayDtd(java.lang.Class clazz)
Displays the Dtd for the class. It will try to find an XmlInfo class from which we can extract more information to bypass the default behavior.

Parameters:
clazz - the class for which to generate the Dtd

displayClass

protected void displayClass(java.lang.Class clazz)
Displays the Dtd for the class. It will try to find an XmlInfo class from which we can extract more information to bypass the default behavior.

Parameters:
clazz - the class for which to generate the Dtd

displayField

protected void displayField(java.lang.Class clazz,
                            java.lang.String tag_name,
                            XmlMapDescriptor map_desc)
Displays a field. You must also provide the info value (which can be null) to be able to (eventually) extract some information from it.

Parameters:
clazz - the class of the field
tag_name - the name of the tag of the field
map_desc - the map descriptor

displayArray

protected void displayArray(java.lang.Class clazz,
                            java.lang.String tag_name,
                            XmlMapper mapper)
Displays an array. You must also provide the info value (which can be null) to be able to (eventually) extract some information from it.

Parameters:
clazz - the class of the field
tag_name - the name of the tag of the field
mapper - the mapper

displayValue

protected void displayValue(java.lang.Class clazz,
                            java.lang.String tag_name,
                            XmlMapper mapper)
Displays a value. You must also provide the info value (which can be null) to be able to (eventually) extract some information from it.

Parameters:
clazz - the class of the field
tag_name - the name of the tag of the field
mapper - the mapper

getTagNameFromClass

public java.lang.String getTagNameFromClass(java.lang.Class clazz)
Gets the tag name from the class. Look for an info class and returns the tag name accordingly.

Parameters:
clazz - the class to get the tag name
Returns:
the tag name

getXmlMapDescriptor

protected XmlMapDescriptor getXmlMapDescriptor(java.lang.String field_name,
                                               XmlInfo info)
Tries to extract the map descriptor the field_name and info object. If no information is found in the info object then null is returned.

Parameters:
field_name - the name of the field we are looking for its map desc
info - the info object that may hold the tag name
Returns:
the map descriptor

main

public static void main(java.lang.String[] args)
                 throws java.lang.ClassNotFoundException
Main method... just a test one