Java Globus API: Class ConverterFromMdsml

org.globus.mdsml
Class ConverterFromMdsml

java.lang.Object
  |
  +--org.globus.mdsml.ConverterFromMdsml
Direct Known Subclasses:
Mdsml2DsmlConverter

public abstract class ConverterFromMdsml
extends java.lang.Object

This is the abstract base class for classes in the org.globus.mdsml package which take an MDSML document as a string and convert it into a different format.

To use converters based off of this abstract base class, you may have two choices: 1) if the converter is in the org.globus.mdsml package, you can use the Converter class--a command-line tool for performing the desired conversions or 2) use the converters as stand-alone classes.

1) To use the Converter class, please consult it's own documentation.

2) Using the individual converters is fairly straight forward. The user creates a new instance of the desired converter by passing a string representing an MDSML document to the constructor. Certain options may be set to customize the conversion. Then, a call to the getConvertedString() method returns the converted document as a string object. For example:

String mdsmlDocument = ...
Mdsml2DsmlConverter mdsmlConverter = new Mdsml2DsmlConverter( mdsmlDocument );
mdsmlConverter.setSeperator( "--" );
String dsmlDocument = mdsmlConverter.getConvertedString();

That's basically all there is to it.


To create a new converter module that extends ConverterFromMdsml, various methods are redefined as needed to produce strings representing parts of the converted document. The methods are called when the getConvertedString() method is called by the user of the class. Though ConverterFromMdsml is an abstract class, all of these methods produce default strings which are null so that if a specific method does not apply to the converted format, no text will be produced for that part. The following are descriptions of the various methods which may be redefined when appropriate:

First, the documentHeader() method is called to produce any possible header text such as document type information for the converted document.

The objectclassString() method is then called for each objectclass in the MDSML document. This method produces the converted document's equivalent of an individual objectclass.

Next, the entryString() method is called on each entry for similar purposes as the objectclassString() method.

Finally, the documentFooter() method is called to produce any text that may appear at the end of the converted document including additional sections which may not be addressed by the above methods. DSML, for example lists it's attribute definitions seperatly from the objectclasses that contain them. The documentFooter() method can be used to produce this additional information.

Author:
Peter Lane
See Also:
Converter

Field Summary
protected  boolean flagDescText
          flags
 
Constructor Summary
ConverterFromMdsml(java.lang.String mdsmlString)
          Creates a new MDSML converter and initializes it with an mdsml document string
 
Method Summary
protected  java.lang.String documentFooter()
          Constructs the document footer and returns the result
protected  java.lang.String documentHeader()
          Constructs the document header and returns the result
protected  java.lang.String entryString()
          Constructs the converted entry body from the entry data pointed to by the given DOM element
protected  void ERROR(java.lang.String message)
           
protected  org.w3c.dom.NodeList getAllObjectclassAttributes()
          Gets a list of DOM nodes representing every attribute found in all of the objectclasses
 java.lang.String getConvertedString()
          Performs the conversion from the MDSML ( XML ) file to the desired format and returns the result
protected  java.lang.String getEntryAttributeName(org.w3c.dom.Element entryAttribute)
          Gets the name of the specified entry attribute
protected  java.lang.String getEntryAttributeValue(org.w3c.dom.Element entryAttribute)
          Gets the value of the specified entry attribute
protected  org.w3c.dom.NodeList getEntryAttrributes()
          Gets a list of entry attributes for the current entry
protected  java.lang.String getEntryDN()
          Gets the distinguished name (DN) of the current entry
protected  java.lang.String[] getEntryObjectclassNames()
          Gets a list of objectclass names associated with the current entry
protected  java.lang.String getObjectclassAttributeDescription(org.w3c.dom.Element objectclassAttribute)
          Gets the description of the specified objectclass attribute
protected  java.lang.String getObjectclassAttributeName(org.w3c.dom.Element objectclassAttribute)
          Gets the name of the specified objectclass attribute
protected  java.lang.String getObjectclassAttributeOccurrence(org.w3c.dom.Element objectclassAttribute)
          Gets the the occurrence type of the specified objectclass attribute
protected  java.lang.String getObjectclassAttributeOID(org.w3c.dom.Element objectclassAttribute)
          Gets the oid of the specified objectclass attribute
protected  org.w3c.dom.NodeList getObjectclassAttributes()
          Gets a list of DOM nodes representing the attributes of the current objectclass
protected  java.lang.String getObjectclassAttributeType(org.w3c.dom.Element objectclassAttribute)
          Gets the type of the specified objectclass attribute
protected  java.lang.String getObjectclassDescription()
          Gets the description of the current objectclass
protected  java.lang.String getObjectclassName()
          Gets the name of the current objectclass
protected  java.lang.String getObjectclassOID()
          Gets the oid of the current objectclass
protected  java.lang.String getObjectclassSuperior()
          Gets the superior objectclass of the current objectclass
protected  java.lang.String getObjectclassType()
          Gets the type of the current objectclass
 java.lang.String getOIDDatabase()
          Gets the name of the file used as an OID "database"
protected  java.lang.String getOutputFileName()
          Gets the name of the file to use to output the converted document to seperatly from the string returned from the getConvertedString() method.
 java.lang.String getSeperator()
          Gets the name-namespace seperator.
protected  boolean isObjectclassAttributeRequired(org.w3c.dom.Element objectclassAttribute)
          Checks whether the specified objectclass attribute is required or not
 boolean isUsingNamespaces()
          Gets the flag that indicates whether namespaces should be included with the names of document elements
protected  java.lang.String nodeTypeToString(short nodeType)
          Converts DOM node type integers to a string description
protected  java.lang.String objectclassString()
          Constructs the converted objectclass body from the objectclass data pointed to by the given DOM element
protected  void printChildren(org.w3c.dom.Element parent)
           
 void setOIDDatabase(java.lang.String oidDatabase)
          Sets the name of the file used as an OID "database"
protected  void setOutputFileName(java.lang.String outputFileName)
          Sets the name of the file to use to output the converted document to seperatly from the string returned from the getConvertedString() method.
 void setSeperator(java.lang.String seperator)
          Sets the name-namespace seperator.
 void setUsingNamespaces(boolean usingNamespaces)
          Sets the flag that indicates whether namespaces should be included with the names of document elements
protected  void WARNING(java.lang.String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flagDescText

protected boolean flagDescText
flags
Constructor Detail

ConverterFromMdsml

public ConverterFromMdsml(java.lang.String mdsmlString)
Creates a new MDSML converter and initializes it with an mdsml document string
Parameters:
mdsmlString - the mdsml document to be converted as a string
Method Detail

getConvertedString

public java.lang.String getConvertedString()
Performs the conversion from the MDSML ( XML ) file to the desired format and returns the result
Returns:
the converted document string

documentHeader

protected java.lang.String documentHeader()
Constructs the document header and returns the result
Returns:
the constructed document header

objectclassString

protected java.lang.String objectclassString()
Constructs the converted objectclass body from the objectclass data pointed to by the given DOM element
Parameters:
objectclassNode - the root-level node of a objectclasses DOM sub-tree
Returns:
the converted objectclass body

entryString

protected java.lang.String entryString()
Constructs the converted entry body from the entry data pointed to by the given DOM element
Parameters:
objectclassNode - the root-level node of a objectclasses DOM sub-tree
Returns:
the converted objectclass body

documentFooter

protected java.lang.String documentFooter()
Constructs the document footer and returns the result
Returns:
the constructed document footer

getObjectclassName

protected java.lang.String getObjectclassName()
Gets the name of the current objectclass
Returns:
String the current objectclass name

getObjectclassType

protected java.lang.String getObjectclassType()
Gets the type of the current objectclass
Returns:
String "structural", "abstract", or "auxiliary"

getObjectclassOID

protected java.lang.String getObjectclassOID()
Gets the oid of the current objectclass
Returns:
String objectclass OID

getObjectclassDescription

protected java.lang.String getObjectclassDescription()
Gets the description of the current objectclass
Returns:
String objectclass description

getObjectclassSuperior

protected java.lang.String getObjectclassSuperior()
Gets the superior objectclass of the current objectclass
Returns:
String objectclass superior

getObjectclassAttributes

protected org.w3c.dom.NodeList getObjectclassAttributes()
Gets a list of DOM nodes representing the attributes of the current objectclass
Returns:
NodeList the attribute nodes of the objectclass

getAllObjectclassAttributes

protected org.w3c.dom.NodeList getAllObjectclassAttributes()
Gets a list of DOM nodes representing every attribute found in all of the objectclasses
Returns:
NodeList the attribute nodes of all the objectclasses

getObjectclassAttributeName

protected java.lang.String getObjectclassAttributeName(org.w3c.dom.Element objectclassAttribute)
Gets the name of the specified objectclass attribute
Parameters:
objectclassAttribute - the objectclass attribute to operate on
Returns:
String objectclass attribute name

getObjectclassAttributeType

protected java.lang.String getObjectclassAttributeType(org.w3c.dom.Element objectclassAttribute)
Gets the type of the specified objectclass attribute
Parameters:
objectclassAttribute - the objectclass attribute to operate on
Returns:
String "cis", "ces", "bin", "int", "dn", "cisfloat", "cisdate", cisboolean", "tel", or "url"

isObjectclassAttributeRequired

protected boolean isObjectclassAttributeRequired(org.w3c.dom.Element objectclassAttribute)
Checks whether the specified objectclass attribute is required or not
Parameters:
objectclassAttribute - the objectclass attribute to operate on
Returns:
boolean "true" if required (MUST HAVE), "false" if not (MAY HAVE)

getObjectclassAttributeOccurrence

protected java.lang.String getObjectclassAttributeOccurrence(org.w3c.dom.Element objectclassAttribute)
Gets the the occurrence type of the specified objectclass attribute
Parameters:
objectclassAttribute - the objectclass attribute to operate on
Returns:
String "single" or "multiple"

getObjectclassAttributeOID

protected java.lang.String getObjectclassAttributeOID(org.w3c.dom.Element objectclassAttribute)
Gets the oid of the specified objectclass attribute
Parameters:
objectclassAttribute - the objectclass attribute to operate on
Returns:
String objectclass attribute oid

getObjectclassAttributeDescription

protected java.lang.String getObjectclassAttributeDescription(org.w3c.dom.Element objectclassAttribute)
Gets the description of the specified objectclass attribute
Parameters:
objectclassAttribute - the objectclass attribute to operate on
Returns:
String objectclass attribute description

getEntryDN

protected java.lang.String getEntryDN()
Gets the distinguished name (DN) of the current entry
Parameters:
entry - the entry to operate on
Returns:
String entry dn (example: hn=croxley.mcs.anl.gov,o=Globus,...)

getEntryObjectclassNames

protected java.lang.String[] getEntryObjectclassNames()
Gets a list of objectclass names associated with the current entry
Returns:
String[] entry's associated objectclass names

getEntryAttrributes

protected org.w3c.dom.NodeList getEntryAttrributes()
Gets a list of entry attributes for the current entry
Returns:
NodeList attributes associated with the current entry

getEntryAttributeName

protected java.lang.String getEntryAttributeName(org.w3c.dom.Element entryAttribute)
Gets the name of the specified entry attribute
Parameters:
entryAttribute - the entry attribute to operate on
Returns:
String entry attribute name

getEntryAttributeValue

protected java.lang.String getEntryAttributeValue(org.w3c.dom.Element entryAttribute)
Gets the value of the specified entry attribute
Parameters:
entryAttribute - the entry attribute to operate on
Returns:
String entry attribute value

setOIDDatabase

public void setOIDDatabase(java.lang.String oidDatabase)
Sets the name of the file used as an OID "database"
Parameters:
oidDatabase - the OID database filename

getOIDDatabase

public java.lang.String getOIDDatabase()
Gets the name of the file used as an OID "database"
Returns:
String the OID database filename

setUsingNamespaces

public void setUsingNamespaces(boolean usingNamespaces)
Sets the flag that indicates whether namespaces should be included with the names of document elements
Parameters:
usingNamespaces - "true" if namespaces are desired, "false" if not

isUsingNamespaces

public boolean isUsingNamespaces()
Gets the flag that indicates whether namespaces should be included with the names of document elements
Returns:
boolean "true" if namespaces are desired, "false" if not

setSeperator

public void setSeperator(java.lang.String seperator)
Sets the name-namespace seperator. This is ignored if namespaces are not desired.
Parameters:
seperator - the name-namespace seperator

getSeperator

public java.lang.String getSeperator()
Gets the name-namespace seperator. This is ignored if namespaces are not desired.
Returns:
String "the name-namespace seperator

setOutputFileName

protected void setOutputFileName(java.lang.String outputFileName)
Sets the name of the file to use to output the converted document to seperatly from the string returned from the getConvertedString() method.

This is in reality just a simple string and can be used in the subclass conversion module classes in any manor. One example of this is to use this property to specify a base name for a set of output files for a complex document format.
Parameters:
outputFileName - the name of the output file

getOutputFileName

protected java.lang.String getOutputFileName()
Gets the name of the file to use to output the converted document to seperatly from the string returned from the getConvertedString() method.

This is in reality just a simple string and can be used in the subclass conversion module classes in any manor. One example of this is to use this property to specify a base name for a set of output files for a complex document format.
Returns:
String the name of the output file

nodeTypeToString

protected java.lang.String nodeTypeToString(short nodeType)
Converts DOM node type integers to a string description
Parameters:
nodeType - a valid DOM node type
Returns:
the string representation of the node type

WARNING

protected void WARNING(java.lang.String message)

ERROR

protected void ERROR(java.lang.String message)

printChildren

protected void printChildren(org.w3c.dom.Element parent)