com.bea.schema
Class SOMObject

java.lang.Object
  extended bycom.bea.schema.SOMObject
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SOMAnnotation, SOMAppInfo, SOMAttributeGroup, SOMBasic, SOMExtension, SOMFacet, SOMGroupType, SOMList, SOMSchema, SOMSimpleContent, SOMType, SOMUnion, SOMUnresolvedReference

public abstract class SOMObject
extends Object
implements Serializable

abstract base class for all SOM classes

Version:
1.0
Author:
sharpe
See Also:
SOMSchema, Serialized Form

Constructor Summary
SOMObject()
           
 
Method Summary
 void addPrefixMapping(String prefix, String uri)
          add a new prefix mapping to this object.
 String getContainmentXPath()
           
 Map getEffectivePrefixMappings()
          get a map of all the prefix->URI mappings that are in effect for this SOMObject.
 String getID_UQ()
          get the unqualified ID (no namespace).
abstract  String getID()
          Returns a printable element tag for this Schema Object
 SOMObject getParent()
          get a reference to the parent object
 String getParentName()
          get the name of the nearest named parent for this object
 SOMSchema getParentSchema()
          get a reference to the parent schema for this object
 String getPrefixForTargetNamespace()
          get an appropriate namespace prefix for the current target namespace, or null if no prefix can be found or no target namespace has been set.
 String getPrefixMapping(String prefix)
          get the namespace mapped to the given prefix, or null if no such mapping exists.
 String getTargetNamespace()
          get the value of the targetNamespace attribute for this schema, or null if none was specified.
 String getURIForPrefix(String prefix)
          get the URI mapped to a given namespace prefix within this SOMObject, or null if no URI is mapped to the given prefix.
 boolean isCircularReference(SOMReference reference)
           
 boolean isSchemaChild()
          determines if the immediate parent object is the schema element.
static String msg(String key)
          get the i18n resource msg.
static String msg(String key, Object[] arguments)
          get the i18n resource msg.
static String removeNamespaceQualifier(String value)
          remove the namespace qualifier from a string.
 String removePrefixMapping(String prefix)
          remove a new prefix mapping from this object.
static void setIndent(String indentToken)
          Allows the user to specify a token to be used for the indent when formatting output XML.
 void setParent(SOMObject parent)
           
 void setTargetNamespace(String targetNamespace)
          set the value of the targetNamespace attribute for this schema
 String toString()
          The String representation of the XML Schema Object.
 String toXML()
          The String representation of the XML Schema Object.
 String toXML(String encoding)
          The String representation of the XML Schema Object.
 void toXML(Writer rtn)
          Outputs a formatted XML representation of SOMObject.
abstract  void toXML(Writer rtn, int indent)
          Outputs a formatted XML representation of SOMObject.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SOMObject

public SOMObject()
Method Detail

addPrefixMapping

public void addPrefixMapping(String prefix,
                             String uri)
add a new prefix mapping to this object. A prefix mapping will appear as an xmlns:="" attribute on the root element for this object.


removePrefixMapping

public String removePrefixMapping(String prefix)
remove a new prefix mapping from this object. A prefix mapping appears as an xmlns:="" attribute on the root element for this object.

Returns:
The URI to which this prefix was mapped (or null if no mapping)

getPrefixMapping

public String getPrefixMapping(String prefix)
get the namespace mapped to the given prefix, or null if no such mapping exists.


getEffectivePrefixMappings

public Map getEffectivePrefixMappings()
get a map of all the prefix->URI mappings that are in effect for this SOMObject. This will always return non-null, but if no mappings are in effect, the map will be empty.


getURIForPrefix

public String getURIForPrefix(String prefix)
get the URI mapped to a given namespace prefix within this SOMObject, or null if no URI is mapped to the given prefix.


getTargetNamespace

public String getTargetNamespace()
get the value of the targetNamespace attribute for this schema, or null if none was specified.


setTargetNamespace

public void setTargetNamespace(String targetNamespace)
set the value of the targetNamespace attribute for this schema


getPrefixForTargetNamespace

public String getPrefixForTargetNamespace()
get an appropriate namespace prefix for the current target namespace, or null if no prefix can be found or no target namespace has been set.


toString

public String toString()
The String representation of the XML Schema Object. Uses java.io.StringWriter to create a serialized XML Schema.

Returns:
formatted XML

toXML

public String toXML()
The String representation of the XML Schema Object. This method calls the toXML(Writer, int) method using OutputStreamWriter with UTF-8 encoding. If an IOException occurs in the underlying Writer, the exception is discarded and an empty or partial String is returned.

Returns:
printable XML Schema.

toXML

public String toXML(String encoding)
The String representation of the XML Schema Object. This method calls the toXML(Writer, int) method using OutputStreamWriter with the specified encoding. If an IOException occurs in the underlying Writer, the exception is discarded and an empty or partial String is returned.

Returns:
printable XML Schema.

toXML

public void toXML(Writer rtn)
           throws IOException
Outputs a formatted XML representation of SOMObject. Indent is set to zero.

Parameters:
rtn - printable XML Schema
Throws:
IOException - if IOExcpetion is thrown by underlying java.io.Writer

toXML

public abstract void toXML(Writer rtn,
                           int indent)
                    throws IOException
Outputs a formatted XML representation of SOMObject.

Parameters:
rtn - printable XML Schema
indent - the indent level for formatting at which to start this schema object.
Throws:
IOException - if IOExcpetion is thrown by underlying java.io.Writer

getParentSchema

public SOMSchema getParentSchema()
get a reference to the parent schema for this object

Returns:
The parent SOMSchema for this object or null if the object doesn't have a schema parent.

getParentName

public String getParentName()
get the name of the nearest named parent for this object

Returns:
The name of the nearest named parent for this object.

getContainmentXPath

public String getContainmentXPath()

getParent

public SOMObject getParent()
get a reference to the parent object

Returns:
The parent object for this object in the tree

setParent

public void setParent(SOMObject parent)

isSchemaChild

public boolean isSchemaChild()
determines if the immediate parent object is the schema element. If the immediate parent object of this object is an instance of a SOMSchema, this method returns true, and otherwise false.

Returns:
true if getParent() is instanceof SOMSchema

getID

public abstract String getID()
Returns a printable element tag for this Schema Object

Returns:
String representation of the element tag

getID_UQ

public String getID_UQ()
get the unqualified ID (no namespace). By default, all schema elements are prefixed with the namespace xsd. With getID_UQ(), the xsd: is stripped off and the unqualified ID is returned.

Returns:
Unqualified ID

removeNamespaceQualifier

public static String removeNamespaceQualifier(String value)
remove the namespace qualifier from a string. For example, if the string "xsd:element" was passed by value, the value "element" would be returned.

Parameters:
value - qualified data
Returns:
substring of data following the colon

setIndent

public static void setIndent(String indentToken)
Allows the user to specify a token to be used for the indent when formatting output XML. The default is two spaces, " ". To set the output to be tabbed indenting, use
setIndent("\t");

Parameters:
indentToken -

isCircularReference

public boolean isCircularReference(SOMReference reference)

msg

public static String msg(String key,
                         Object[] arguments)
get the i18n resource msg. Loads the com.bea.schema.i18n.SOMLocalizer resource bundle if necessary and returns the message for the key provided.

msg uses the java.text.Message class to format messages from the ResourceBundle

Parameters:
key - property/message key
arguments - for use with the message resources "{#}"
Returns:
property value

msg

public static String msg(String key)
get the i18n resource msg. Loads the com.bea.schema.i18n.SOMLocalizer resource bundle if necessary and returns the message for the key provided.

Parameters:
key - property/message key
Returns:
property value