com.metamatrix.api.core.xmi
Class XMIHeader

java.lang.Object
  extended by com.metamatrix.api.core.xmi.XMIHeader

public final class XMIHeader
extends java.lang.Object

Class that represents the content of an XMI file's header.

The XMI processor is designed to hide as much as possible the semantics of XMI by simply constructing FeatureInfo and EntityInfo instances as an XMI stream is processed. These info classes are thus similar to SAX events of a SAX XML document parser.


Nested Class Summary
static class XMIHeader.Documentation
          Class that represents the "xmi.document" portion of the header
static class XMIHeader.Import
          Class that represents the "xmi.import" tag in the header.
static class XMIHeader.MetaMetaModel
          Class that represents the "xmi.metametamodel" tag in the header.
static class XMIHeader.MetaModel
          Class that represents the "xmi.metamodel" tag in the header.
static class XMIHeader.Model
          Class that represents the "xmi.model" tag in the header
 
Field Summary
static java.lang.String DEFAULT_INDENT
          Default indentation upon write
 
Constructor Summary
XMIHeader()
          Constructor for XMIHeader.
 
Method Summary
protected static boolean addElement(org.jdom.Element parent, java.lang.String tagName, java.lang.String text)
          Helper method.
protected static boolean addImport(org.jdom.Element parent, XMIHeader.Import importObj)
          Helper method to add an import under the parent
 void addImport(java.lang.String name, java.lang.String version, java.lang.String href)
          Add an import to this header.
 void addImport(java.lang.String name, java.lang.String version, java.lang.String href, java.lang.String content)
          Add an import to this header.
 void addMetaMetaModel(java.lang.String name, java.lang.String version, java.lang.String href)
          Add a metametamodel to this header.
 void addMetaMetaModel(java.lang.String name, java.lang.String version, java.lang.String href, java.lang.String content)
          Add a metametamodel to this header.
 void addMetaModel(java.lang.String name, java.lang.String version, java.lang.String href)
          Add a metamodel to this header.
 void addMetaModel(java.lang.String name, java.lang.String version, java.lang.String href, java.lang.String content)
          Add a metamodel to this header.
protected static boolean addModel(org.jdom.Element parent, XMIHeader.Model model)
          Helper method to add a model to the parent.
 void addModel(java.lang.String name, java.lang.String version, java.lang.String href)
          Add a model to this header.
 void addModel(java.lang.String name, java.lang.String version, java.lang.String href, java.lang.String content)
          Add a model to this header.
protected static boolean addText(org.jdom.Element tag, java.lang.String text)
          Helper method to set the content on an Element.
static void applyHeader(org.jdom.Document doc, XMIHeader xmiHeader)
          Apply the supplied XMI header to the XML (JDOM) Document.
static void applyHeader(org.jdom.Element root, XMIHeader xmiHeader, boolean newDocument)
          Apply the supplied XMI header to the specified element in an XML (JDOM) Document.
 boolean equals(java.lang.Object obj)
          Determine whether this object is equivalent to the supplied object.
 XMIHeader.Documentation getDocumentation()
          Get the Documentation object.
 java.util.Collection getImports()
          Get the imports
 java.util.Collection getMetaMetaModels()
          Get the meta-metamodels
 java.util.Collection getMetaModels()
          Get the metamodels
 java.util.Collection getModels()
          Get the models
 java.lang.String getXMIFragment()
          Get the XML fragment that represents the header, using the default indentation and new lines for each tag.
 java.lang.String getXMIFragment(java.lang.String indent, boolean newlines)
          Get the XML fragment that represents the header
 void print(java.io.PrintStream stream)
          Method to print the contents of the XMI Header object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INDENT

public static final java.lang.String DEFAULT_INDENT
Default indentation upon write

See Also:
Constant Field Values
Constructor Detail

XMIHeader

public XMIHeader()
Constructor for XMIHeader.

Method Detail

getDocumentation

public XMIHeader.Documentation getDocumentation()
Get the Documentation object.

Returns:
the documentation; never null

getModels

public java.util.Collection getModels()
Get the models

Returns:
the Collection of XMIHeader.Model instances

getMetaModels

public java.util.Collection getMetaModels()
Get the metamodels

Returns:
the Collection of XMIHeader.MetaModel instances

getMetaMetaModels

public java.util.Collection getMetaMetaModels()
Get the meta-metamodels

Returns:
the Collection of XMIHeader.MetaMetaModel instances

getImports

public java.util.Collection getImports()
Get the imports

Returns:
the Collection of XMIHeader.Import instances

addModel

public void addModel(java.lang.String name,
                     java.lang.String version,
                     java.lang.String href)
Add a model to this header.

Parameters:
name - the name of the model
version - the version of the model
href - the URI of the model

addModel

public void addModel(java.lang.String name,
                     java.lang.String version,
                     java.lang.String href,
                     java.lang.String content)
Add a model to this header.

Parameters:
name - the name of the model
version - the version of the model
href - the URI of the model
content - the value of the "xmi.model" tag

addMetaModel

public void addMetaModel(java.lang.String name,
                         java.lang.String version,
                         java.lang.String href)
Add a metamodel to this header.

Parameters:
name - the name of the metamodel
version - the version of the metamodel
href - the URI of the metamodel

addMetaModel

public void addMetaModel(java.lang.String name,
                         java.lang.String version,
                         java.lang.String href,
                         java.lang.String content)
Add a metamodel to this header.

Parameters:
name - the name of the metamodel
version - the version of the metamodel
href - the URI of the metamodel
content - the value of the "xmi.metamodel" tag

addMetaMetaModel

public void addMetaMetaModel(java.lang.String name,
                             java.lang.String version,
                             java.lang.String href)
Add a metametamodel to this header.

Parameters:
name - the name of the metametamodel
version - the version of the metametamodel
href - the URI of the metametamodel

addMetaMetaModel

public void addMetaMetaModel(java.lang.String name,
                             java.lang.String version,
                             java.lang.String href,
                             java.lang.String content)
Add a metametamodel to this header.

Parameters:
name - the name of the metametamodel
version - the version of the metametamodel
href - the URI of the metametamodel
content - the value of the "xmi.metametamodel" tag

addImport

public void addImport(java.lang.String name,
                      java.lang.String version,
                      java.lang.String href)
Add an import to this header.

Parameters:
name - the name of the imported file/model
version - the version of the imported file/model
href - the URI of the imported file/model

addImport

public void addImport(java.lang.String name,
                      java.lang.String version,
                      java.lang.String href,
                      java.lang.String content)
Add an import to this header.

Parameters:
name - the name of the imported file/model
version - the version of the imported file/model
href - the URI of the imported file/model
content - the value of the "xmi.import" tag

getXMIFragment

public java.lang.String getXMIFragment(java.lang.String indent,
                                       boolean newlines)
Get the XML fragment that represents the header

Parameters:
indent - the String value to use for indentation
newlines - true if tags should be written on separate lines, or false if the output should be condensed
Returns:
the stringified form of the XML fragment

getXMIFragment

public java.lang.String getXMIFragment()
Get the XML fragment that represents the header, using the default indentation and new lines for each tag.

Returns:
the stringified form of the XML fragment

equals

public boolean equals(java.lang.Object obj)
Determine whether this object is equivalent to the supplied object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to be compared with this
Returns:
true if the objects are equivalent, or false otherwise.

applyHeader

public static void applyHeader(org.jdom.Document doc,
                               XMIHeader xmiHeader)
Apply the supplied XMI header to the XML (JDOM) Document.

Parameters:
doc - the JDOM document that is to contain the XMI header
xmiHeader - the header information to be written to the document

applyHeader

public static void applyHeader(org.jdom.Element root,
                               XMIHeader xmiHeader,
                               boolean newDocument)
Apply the supplied XMI header to the specified element in an XML (JDOM) Document.

Parameters:
root - the element under which the header fragment is to be written; this should be the "XMI" root tag of an XMI document.
xmiHeader - the header information to be written to the document
newDocument - true if this document may be a new document, or false if an existing header (if one exists) should be replaced

addElement

protected static boolean addElement(org.jdom.Element parent,
                                    java.lang.String tagName,
                                    java.lang.String text)
Helper method. This method does nothing (and returns false) if there is no need or insufficient information to create the Element.

Parameters:
parent - the parent Element
tagName - the name of the new Element
text - the content for the new Element
Returns:
true if a new Element was created, or false otherwise

addText

protected static boolean addText(org.jdom.Element tag,
                                 java.lang.String text)
Helper method to set the content on an Element. This method does nothing (and returns false) if there is no need to set the content.

Parameters:
tag - the parent Element; may be null
text - the content for the new Element; may be null
Returns:
true if the Element's content was set, or false otherwise

addModel

protected static boolean addModel(org.jdom.Element parent,
                                  XMIHeader.Model model)
Helper method to add a model to the parent. This method determines the correct tag name given the subclass of XMIHeader.Model.

Parameters:
parent - the parent Element; may be null
model - the model to be added
Returns:
true if a model tag was created, or false otherwise.

addImport

protected static boolean addImport(org.jdom.Element parent,
                                   XMIHeader.Import importObj)
Helper method to add an import under the parent

Parameters:
parent - the parent
importObj - the import object to be added
Returns:
true if the import object was added, or false otherwise

print

public void print(java.io.PrintStream stream)
Method to print the contents of the XMI Header object.

Parameters:
stream - the stream


Copyright © 2009. All Rights Reserved.