|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.griphyn.vdl.Chimera
org.griphyn.vdl.classes.VDL
org.griphyn.vdl.classes.Definitions
public class Definitions
This class implements the container to carry any number of
Transformation and Derivation instances.
In addition, it captures some attributes from the root element of
the XML document.
Definition,
Transformation,
Derivation,
Serialized Form| Field Summary | |
|---|---|
private ArrayList |
m_definitionList
children are either Transformations or Derivations,
both of which are Derivations. |
private int[][] |
m_state
updating old Use.linkage with new Use.linkage. |
private String |
m_vdlns
Capture the global namespace given to all child elements that do not set their own namespace definition. |
private String |
m_version
Capture the version of the XML document. |
static String |
SCHEMA_LOCATION
The "not-so-official" location URL of the VDLx schema definition. |
static String |
SCHEMA_NAMESPACE
The "official" namespace URI of the VDLx schema. |
| Constructor Summary | |
|---|---|
Definitions()
ctor. |
|
Definitions(String vdlns)
ctor: Create a new container, using the given namespace. |
|
Definitions(String vdlns,
String version)
ctor: Create a new container, using a namespace and version. |
|
| Method Summary | |
|---|---|
void |
addDefinition(Definition d)
Accessor: Appends a Definition to the container. |
void |
addDefinition(int index,
Definition d)
Accessor: Inserts a Definition at a particular place. |
private void |
checkLinkage(Map use,
Use u,
Transformation tr)
Checks the linkage of a transformation between a declared, previously used and currently used variable of the same name. |
Enumeration |
enumerateDefinition()
Deprecated. Use the new Collection based interfaces |
Definition[] |
getDefinition()
Deprecated. Use the new Collection based interfaces |
Definition |
getDefinition(int index)
Accessor: Obtains a Definition at a particular place
in this container. |
int |
getDefinitionCount()
Accessor: Counts the number of Transformation and
Derivation definitions. |
List |
getDefinitionList()
Accessor: Obtains all Definitions available. |
List |
getDefinitionOfAKind(int type)
Obtains a vector of all definition instances that share the same instance type. |
String |
getVdlns()
Accessor: Obtains the document namespace. |
String |
getVersion()
Accessor: Obtains the document version number. |
Iterator |
iterateDefinition()
Accessor: Provides an iterator for the list of Transformation
and Derivation references. |
ListIterator |
listIterateDefinition()
Accessor: Provides an iterator for the list of Transformation
and Derivation references. |
ListIterator |
listIterateDefinition(int start)
Accessor: Provides an iterator for the list of Transformation
and Derivation references. |
int |
positionOfDefinition(Definition d)
Accessor: Search the database for the existence of a Definition with the same primary keys and type as the parameter. |
void |
removeAllDefinition()
Accessor: Removes all definitions we know about. |
boolean |
removeDefinition(Definition d)
Accessor: Removes a definition named by its reference. |
Definition |
removeDefinition(int index)
Accessor: Removes a definition. |
protected void |
sanitizeDefinition(Definition d)
Clean-up definition and perform abstract type checks before submitting them into the document. |
void |
setDefinition(Collection definitions)
Accessor: Replace all Definitions with a new list. |
void |
setDefinition(Definition[] definitionArray)
Deprecated. Use the new Collection based interfaces |
Definition |
setDefinition(int index,
Definition d)
Accessor: Sets the component at the specified index of this vector to be the specified object. |
void |
setVdlns(String vdlns)
Accessor: Sets the document default namespace. |
void |
setVersion(String version)
Accessor: Replaces the version number of the document. |
void |
toString(Writer stream)
Dumps the content of the given element into a string. |
void |
toXML(Writer stream,
String indent,
String namespace)
Dump the state of the current element as XML output. |
void |
writeXMLHeader(Writer stream,
String indent,
String namespace)
Writes the header of the XML output. |
| Methods inherited from class org.griphyn.vdl.Chimera |
|---|
escape, quote, toString, toXML, toXML, writeAttribute |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String SCHEMA_NAMESPACE
public static final String SCHEMA_LOCATION
private String m_vdlns
private String m_version
private ArrayList m_definitionList
Transformations or Derivations,
both of which are Derivations.
private int[][] m_state
| -1 | NONE| IN | OUT | IO
----+-----+-----+-----+-----+----
-1 | (-) | (-) | (-) | (-) | (-)
NONE| NONE| (-) | # | # | #
IN| IN | # | (-) | IO | (-)
OUT| OUT | # | IO | (-) | (-)
IO| IO | # | IO | IO | (-)
----+-----+-----+-----+-----+----
The table uses -1 for no action to do, and -2 for an illegal state.
| Constructor Detail |
|---|
public Definitions()
Definition
objects.
public Definitions(String vdlns)
Definition instance.
vdlns - is the namespace to use for elements w/o namespace.
public Definitions(String vdlns,
String version)
vdlns - is the namespace to propagate to children w/o namespace.version - is a version of the XML document used to transport
the data.| Method Detail |
|---|
private void checkLinkage(Map use,
Use u,
Transformation tr)
use - is a table of previously used variables and their linkageu - is the variable at the "cursor position".tr - is the transformation to be checked.
protected void sanitizeDefinition(Definition d)
throws IllegalArgumentException,
IncompatibleLinkageException,
UndeclaredVariableException,
IllegalTransformationException
IllegalArgumentException - will be thrown if the
Definition is neither a Derivation nor a
Transformation. This should not happen.
UndeclaredVariableException - will be thrown, if
a Transformation uses a bound variable via Use,
but fails to declare the formal argument with Declare.
IncompatibleLinkageException - will be thrown, if
the declared linkage of a formal argument is incompatible with the
usage of such a bound variable within a Transformation.
IllegalTransformationException - will be thrown, if
the Transformation has simultaneously Call
and Argument items. This exception is bound to vanish
with the next major re-design.Transformation,
Derivation,
Use,
Declare
public void addDefinition(Definition d)
throws IndexOutOfBoundsException
Definition to the container. The
namespace and version information will be, in case they are
missing, updated from the definitions namespace and version
respectively.
d - is the Transformation or Derivation
to append to the internal container.
IndexOutOfBoundsException - if the definition does not fit into
the container.
public void addDefinition(int index,
Definition d)
throws IndexOutOfBoundsException
Definition at a particular place. The
namespace and version information will be, in case they are
missing, updated from the definitions namespace and version
respectively.Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.
index - is the position to insert a Definitiond - is the Transformation or Derivation
to append to the internal container.
IndexOutOfBoundsException - if the definition does not fit into
the container.public int positionOfDefinition(Definition d)
d - is the Definition to search for
public Enumeration enumerateDefinition()
Transformation
and Derivation.
Definitions.Enumerationpublic List getDefinitionOfAKind(int type)
Transformation or Derivation
objects. The vector may have zero size, if no such instances exist.
public Definition getDefinition(int index)
throws IndexOutOfBoundsException
Definition at a particular place
in this container.
index - is the place to look up the element.
Definition at the specified place.
IndexOutOfBoundsException - if the referenced position does
not exist.Definitionpublic Definition[] getDefinition()
Definitions available.
This array is a copy to avoid write-through modifications.
Transformation
or Derivation at each position.public int getDefinitionCount()
Transformation and
Derivation definitions.
public List getDefinitionList()
Definitions available.
This list is read-only.
Transformation
or Derivation at each position.public String getVdlns()
setVdlns(java.lang.String)public String getVersion()
public Iterator iterateDefinition()
Transformation
and Derivation references.
Definitions.ListIteratorpublic ListIterator listIterateDefinition()
Transformation
and Derivation references.
Definitions.ListIteratorpublic ListIterator listIterateDefinition(int start)
Transformation
and Derivation references.
start - is the starting point of the iteration.
Definitions.ListIteratorpublic void removeAllDefinition()
Definitionpublic Definition removeDefinition(int index)
index - is the position to remove the argument fragment from.
ArrayIndexOutOfBoundsException - if the index was invalid.Definitionpublic boolean removeDefinition(Definition d)
d - is a definition instance that originated from this list.
Definition
public Definition setDefinition(int index,
Definition d)
throws IndexOutOfBoundsException
index - is the postion at which to replace a Definition.d - is either a Transformation or
Derivation to use for replacement.
IndexOutOfBoundsException - if the index was invalid.public void setDefinition(Definition[] definitionArray)
Definitions with a new list.
definitionArray - is an array of possibly mixed
Transformation and Derivation elements.public void setDefinition(Collection definitions)
Definitions with a new list.
definitions - is an collection of possibly mixed
Transformation and Derivation elements.public void setVdlns(String vdlns)
vdlns - is the new namespace to use. Note that the change will
not be propagated to contained elememts.getVdlns()public void setVersion(String version)
version - is the new version number.getVersion()
public void toString(Writer stream)
throws IOException
toString in class Chimerastream - is a stream opened and ready for writing. This can also
be a string stream for efficient output.
IOException - if something fishy happens to the stream.
public void writeXMLHeader(Writer stream,
String indent,
String namespace)
throws IOException
stream - is a stream opened and ready for writing. This can also
be a string stream for efficient output.indent - is a String of spaces used for pretty
printing. The initial amount of spaces should be an empty string.
The parameter is used internally for the recursive traversal.namespace - is the XML schema namespace prefix. If neither
empty nor null, each element will be prefixed with this prefix,
and the root element will map the XML namespace.
IOException - if something fishy happens to the stream.
public void toXML(Writer stream,
String indent,
String namespace)
throws IOException
toXML in class Chimerastream - is a stream opened and ready for writing. This can also
be a string stream for efficient output.indent - is a String of spaces used for pretty
printing. The initial amount of spaces should be an empty string.
The parameter is used internally for the recursive traversal.namespace - is the XML schema namespace prefix. If neither
empty nor null, each element will be prefixed with this prefix,
and the root element will map the XML namespace.
IOException - if something fishy happens to the stream.BufferedWriter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||