Sun Message Library for SWIFT API

com.stc.swift.runtime
Class SwiftOtdChild

java.lang.Object
  extended by com.stc.swift.runtime.SwiftOtdChild
All Implemented Interfaces:
com.stc.otd.runtime.OtdNode

public class SwiftOtdChild
extends java.lang.Object
implements com.stc.otd.runtime.OtdNode

SwiftOtdNode implementation.

Version:

Constructor Summary
SwiftOtdChild(SwiftOtdRep parent, java.lang.Class clazz)
          Creates new SwiftOtdChild
 
Method Summary
 java.lang.Object add()
          Adds repitition to end of list.
 java.lang.Object add(int rep)
          Adds/sets the given repitition.
 java.lang.Object append(byte[] data)
          Append the given data to end of existing data.
 java.lang.Object append(int rep, byte[] data)
          Append the given data to end of existing data.
 java.lang.Object append(int rep, int child, byte[] data)
          Append the given data to end of existing data.
 byte[] build(com.stc.otd.runtime.OtdOutputStream out)
          Build (marshals, serializes, renders) the internal data tree into an output stream.
 java.lang.String[] check()
          Validates the contents of the data tree.
 int choice()
          For a choice node, returns the index of the valid child.
 boolean consumedDelim()
           
 void consumedDelim(boolean consumedDelim)
           
 boolean containsData()
           
 void containsData(boolean constainsData)
           
 java.lang.Object copy(int start, byte[] data)
          Copy the given data at specified point, overwrites existing data.
 java.lang.Object copy(int rep, int start, byte[] data)
          Copy the given data at specified point, overwrites existing data.
 java.lang.Object copy(int rep, int child, int start, byte[] data)
          Copy the given data at specified point, overwrites existing data.
 int count()
          Returns the number of repitition instances contained in this child.
 int count(int rep)
          Returns the number of children instances contained in given repitition.
 boolean dataInRepititions()
           
 void dataInRepititions(boolean dataInRepititions)
           
 boolean dataP()
           
 java.lang.Object delete(int start, int unto)
          Delete data from start til upto, shifting left remaining data.
 java.lang.Object delete(int rep, int start, int unto)
          Delete data from start til upto, shifting left remaining data.
 java.lang.Object delete(int rep, int child, int start, int unto)
          Delete data from start til upto, shifting left remaining data.
 java.lang.Object get(int rep)
          Retrieves the given repitition.
 java.lang.Object get(int rep, int child)
          Retrieves the given child repitition(default to 0).
 java.lang.String getPath()
          Builds a printable representation to this object.
 java.lang.String getPath(SwiftOtdRep rep)
          Builds a printable representation to this object.
 boolean has(int rep)
          Tests whether the specified repetitiion is present.
 boolean has(int rep, int child)
          Tests whether given child of the specified repetitiion is present.
 java.lang.Object insert(int start, byte[] data)
          Inserts the given data at specified point, shifts existing data right.
 java.lang.Object insert(int rep, int start, byte[] data)
          Inserts the given data at specified point, shifts existing data right.
 java.lang.Object insert(int rep, int child, int start, byte[] data)
          Inserts the given data at specified point, shifts existing data right.
 boolean isRequired()
           
 int length()
          Retrieves the length of the data for this object.
 java.util.Map mapOfReps()
           
 void marshal(com.stc.otd.runtime.OtdOutputStream out)
          Marshals (serializes, renders) the internal data tree into an output stream.
 com.stc.otd.runtime.OtdMeta meta()
          Gets the run-time metadata for the root of the OTD's grammar.
 SwiftOtdRep parent()
           
 java.lang.Object parse(com.stc.otd.runtime.OtdInputStream in)
          Parse (unmarshals, deserializes, parses) the given input into an internal data tree.
 int print()
           
 void printClear(int bitMask)
           
 void printSet(int bitMask)
           
 void remove(int rep)
          Removes the given repitition.
 void remove(int rep, int child)
          Removes the given child repitition(default to 0).
 void resetRepititions()
           
 void saveLastMatchPath(SwiftOtdRep rep)
           
 void set(int rep, int child, java.lang.Object value)
          Stores the given child instance.
 void set(int rep, java.util.Map children)
          Assigns the children to the specified repitition.
 void set(int rep, java.lang.Object value)
          Stores the given child instance.
 void set(java.util.Map reps)
          Assigns the repititions as given in the map.
 void set(java.lang.Object data)
          Assigns the data that represents this repitition as byte[].
 int size()
          Returns the current number of repititions for this child.
 int size(int rep)
          Returns the number of children possible for given repitition.
 java.io.PrintStream trace()
           
 void trace(java.io.PrintStream trace)
           
 void unmarshal(byte[] bytes)
          Unmarshals (deserializes, parses) the given input into an internal data tree.
 void updateParentInfo()
           
 java.lang.String value()
          Retrieves the data that represents the repititions of child.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwiftOtdChild

public SwiftOtdChild(SwiftOtdRep parent,
                     java.lang.Class clazz)
Creates new SwiftOtdChild

Method Detail

trace

public void trace(java.io.PrintStream trace)

trace

public java.io.PrintStream trace()

print

public int print()

printSet

public void printSet(int bitMask)

printClear

public void printClear(int bitMask)

saveLastMatchPath

public void saveLastMatchPath(SwiftOtdRep rep)

containsData

public boolean containsData()

containsData

public void containsData(boolean constainsData)

dataP

public boolean dataP()

consumedDelim

public void consumedDelim(boolean consumedDelim)

consumedDelim

public boolean consumedDelim()

dataInRepititions

public void dataInRepititions(boolean dataInRepititions)

dataInRepititions

public boolean dataInRepititions()

updateParentInfo

public void updateParentInfo()

resetRepititions

public void resetRepititions()

parent

public SwiftOtdRep parent()

mapOfReps

public java.util.Map mapOfReps()

has

public boolean has(int rep)
            throws java.lang.IndexOutOfBoundsException
Tests whether the specified repetitiion is present.

Specified by:
has in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - repitition of this child, from 0
Returns:
boolean result of presence check
Throws:
java.lang.IndexOutOfBoundsException - for invalid rep

has

public boolean has(int rep,
                   int child)
            throws java.lang.IndexOutOfBoundsException
Tests whether given child of the specified repetitiion is present.

Specified by:
has in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
child - instance in repetition, from 0
Returns:
boolean result of presence check
Throws:
java.lang.IndexOutOfBoundsException - for invalid index or child

size

public int size()
Returns the current number of repititions for this child.

Parameters:
NONE -
Returns:
number of repititions for node.

size

public int size(int rep)
Returns the number of children possible for given repitition.

Specified by:
size in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
Returns:
count of possible children for specified repitition.

count

public int count()
Returns the number of repitition instances contained in this child.

Parameters:
NONE -
Returns:
count of repititions in this node.

choice

public int choice()
For a choice node, returns the index of the valid child. A choice node has a number of children, only one of which can occur below any given parent instance. If there is no current valid child, it returns -1.

Specified by:
choice in interface com.stc.otd.runtime.OtdNode
Parameters:
NONE -
Returns:
the child index, or -1

count

public int count(int rep)
Returns the number of children instances contained in given repitition.

Specified by:
count in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
Returns:
count of children instances for specified repitition.

check

public java.lang.String[] check()
Validates the contents of the data tree. This calls the code generated from the check overlay. Some check overlay code may be invoked automatically during unmarshal(). NOTE: WE WANT some more deep structure in the error messages, to tie in with the node-IDs to the GUIs can refer to them

Returns:
null if okay, else a list of error strings

value

public java.lang.String value()
Retrieves the data that represents the repititions of child.

Parameters:
NONE. -
Returns:
an String. The repeting data.

length

public int length()
Retrieves the length of the data for this object.

Parameters:
NONE. -
Returns:
the length of data for object.

get

public java.lang.Object get(int rep)
                     throws java.lang.IndexOutOfBoundsException
Retrieves the given repitition. If child is a leaf node expect to return a primitive Java type value that is boxed. e.g. Integer for int.

Specified by:
get in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
Returns:
an Object. The boxed value of the child or SwiftOtdRep.
Throws:
java.lang.IndexOutOfBoundsException - for invalid child

get

public java.lang.Object get(int rep,
                            int child)
                     throws java.lang.IndexOutOfBoundsException
Retrieves the given child repitition(default to 0). If child is a leaf node expect to return a primitive Java type value that is boxed. e.g. Integer for int.

Specified by:
get in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
child - instance in repetition, from 0
Returns:
an Object. The boxed value of the child or SwiftOtdRep.
Throws:
java.lang.IndexOutOfBoundsException - for invalid index or child

remove

public void remove(int rep)
            throws java.lang.IndexOutOfBoundsException
Removes the given repitition.

Specified by:
remove in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
Throws:
java.lang.IndexOutOfBoundsException - for invalid rep

remove

public void remove(int rep,
                   int child)
            throws java.lang.IndexOutOfBoundsException
Removes the given child repitition(default to 0).

Specified by:
remove in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
child - instance in repetition, from 0
Throws:
java.lang.IndexOutOfBoundsException - for invalid index or child

set

public void set(java.util.Map reps)
Assigns the repititions as given in the map. May contain holes.

Parameters:
map - containing the repititions to be assigned.

set

public void set(int rep,
                java.util.Map children)
Assigns the children to the specified repitition. May contain holes.

Parameters:
rep - containing the children to be assigned.

set

public void set(java.lang.Object data)
Assigns the data that represents this repitition as byte[].

Parameters:
data - byte[] that represents the repititions value.
Throws:
java.lang.IllegalArgumentException - for a type or value error

set

public void set(int rep,
                java.lang.Object value)
         throws java.lang.IndexOutOfBoundsException,
                java.lang.IllegalArgumentException
Stores the given child instance. Primitive Java type values are passed boxed, e.g. Integer for int.

Specified by:
set in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
value - the new child value
Throws:
java.lang.IndexOutOfBoundsException - for invalid child
java.lang.IllegalArgumentException - for a type or value error

set

public void set(int rep,
                int child,
                java.lang.Object value)
         throws java.lang.IndexOutOfBoundsException,
                java.lang.IllegalArgumentException
Stores the given child instance. Primitive Java type values are passed boxed, e.g. Integer for int.

Specified by:
set in interface com.stc.otd.runtime.OtdNode
Parameters:
rep - index of this child, from 0
child - instance in repetition, from 0
value - the new child value
Throws:
java.lang.IndexOutOfBoundsException - for invalid index or child
java.lang.IllegalArgumentException - for a type or value error

add

public java.lang.Object add()
Adds repitition to end of list.

Parameters:
NONE -
Throws:
java.lang.IndexOutOfBoundsException - for invalid child or rep

add

public java.lang.Object add(int rep)
Adds/sets the given repitition.

Parameters:
rep - index of this child, from 0
Throws:
java.lang.IndexOutOfBoundsException - for invalid child or rep

getPath

public java.lang.String getPath()
Builds a printable representation to this object.

Returns:
Path represented as String.

getPath

public java.lang.String getPath(SwiftOtdRep rep)
Builds a printable representation to this object.

Parameters:
rep - the repitition of this child.
Returns:
Path represented as String.

insert

public java.lang.Object insert(int start,
                               byte[] data)
Inserts the given data at specified point, shifts existing data right.

Parameters:
start - byte of the insertion, from 0.
data - to be inserted.
Returns:
the result of inserting the data

insert

public java.lang.Object insert(int rep,
                               int start,
                               byte[] data)
Inserts the given data at specified point, shifts existing data right.

Parameters:
rep - index of this child, from 0
start - byte of the insertion, from 0.
data - to be inserted.
Returns:
the result of inserting the data

insert

public java.lang.Object insert(int rep,
                               int child,
                               int start,
                               byte[] data)
Inserts the given data at specified point, shifts existing data right.

Parameters:
rep - index of this child, from 0
child - instance in repetition, from 0
start - byte of the insertion, from 0.
data - to be inserted.
Returns:
the result of inserting the data

copy

public java.lang.Object copy(int start,
                             byte[] data)
Copy the given data at specified point, overwrites existing data.

Parameters:
start - byte of the copying, from 0.
data - to be copied.
Returns:
the result of copying the data

copy

public java.lang.Object copy(int rep,
                             int start,
                             byte[] data)
Copy the given data at specified point, overwrites existing data.

Parameters:
rep - index of this child, from 0
start - byte of the copying, from 0.
data - to be copied.
Returns:
the result of copying the data

copy

public java.lang.Object copy(int rep,
                             int child,
                             int start,
                             byte[] data)
Copy the given data at specified point, overwrites existing data.

Parameters:
rep - index of this child, from 0
child - instance in repetition, from 0
start - byte of the copying, from 0.
data - to be copied.
Returns:
the result of copying the data

append

public java.lang.Object append(byte[] data)
Append the given data to end of existing data.

Parameters:
data - to be appended.
Returns:
the result of appending the data

append

public java.lang.Object append(int rep,
                               byte[] data)
Append the given data to end of existing data.

Parameters:
rep - index of this child, from 0
data - to be appended.
Returns:
the result of appending the data

append

public java.lang.Object append(int rep,
                               int child,
                               byte[] data)
Append the given data to end of existing data.

Parameters:
rep - index of this child, from 0.
child - instance in repetition, from 0.
data - to be appended.
Returns:
the result of appending the data

delete

public java.lang.Object delete(int start,
                               int unto)
Delete data from start til upto, shifting left remaining data.

Parameters:
start - byte of the deleting, from 0.
upto - byte of the deleting, from 0.
Returns:
the result of deleting the data

delete

public java.lang.Object delete(int rep,
                               int start,
                               int unto)
Delete data from start til upto, shifting left remaining data.

Parameters:
rep - index of this child, from 0
start - byte of the deleting, from 0.
upto - byte of the deleting, from 0.
Returns:
the result of deleting the data

delete

public java.lang.Object delete(int rep,
                               int child,
                               int start,
                               int unto)
Delete data from start til upto, shifting left remaining data.

Parameters:
rep - index of this child, from 0
child - instance in repetition, from 0
start - byte of the deleting, from 0.
upto - byte of the deleting, from 0.
Returns:
the result of deleting the data

meta

public com.stc.otd.runtime.OtdMeta meta()
Gets the run-time metadata for the root of the OTD's grammar. Note that this is really a static method by nature, because the grammar for the OTD is not tied to any particular instance of it, but Java interfaces do not allow static methods in interface definitions, and this gives us more freedom of implementation.

Specified by:
meta in interface com.stc.otd.runtime.OtdNode
Returns:
DOCUMENT ME!

marshal

public void marshal(com.stc.otd.runtime.OtdOutputStream out)
             throws com.stc.otd.runtime.MarshalException,
                    java.io.IOException
Marshals (serializes, renders) the internal data tree into an output stream.

Parameters:
out - the stream to place the output to.
Throws:
java.io.IOException - ioexception
com.stc.otd.runtime.MarshalException - for an inconsistent internal tree

build

public byte[] build(com.stc.otd.runtime.OtdOutputStream out)
             throws com.stc.otd.runtime.MarshalException,
                    java.io.IOException
Build (marshals, serializes, renders) the internal data tree into an output stream.

Parameters:
out - the stream to place the output to.
Returns:
if (delimiter not used) delimiter else byte[0].
Throws:
java.io.IOException - ioexception
com.stc.otd.runtime.MarshalException - for an inconsistent internal tree

unmarshal

public void unmarshal(byte[] bytes)
               throws com.stc.otd.runtime.UnmarshalException,
                      java.io.IOException
Unmarshals (deserializes, parses) the given input into an internal data tree.

Parameters:
bytes - the byte[] containing data for parsing.
Throws:
java.io.IOException - ioexception
com.stc.otd.runtime.UnmarshalException - for a lexical or other mismatch

parse

public java.lang.Object parse(com.stc.otd.runtime.OtdInputStream in)
                       throws com.stc.otd.runtime.UnmarshalException,
                              java.io.IOException
Parse (unmarshals, deserializes, parses) the given input into an internal data tree.

Parameters:
in - the input, as a byte stream
Throws:
java.io.IOException - ioexception
com.stc.otd.runtime.UnmarshalException - for a lexical or other mismatch

isRequired

public boolean isRequired()

Sun Message Library for SWIFT API

Copyright © 2008 Sun Microsystems, Inc. All rights reserved.