net.sf.joost.instruction
Class GroupBase

java.lang.Object
  extended by net.sf.joost.instruction.AbstractInstruction
      extended by net.sf.joost.instruction.NodeBase
          extended by net.sf.joost.instruction.GroupBase
All Implemented Interfaces:
Cloneable, Constants
Direct Known Subclasses:
GroupFactory.Instance, TransformFactory.Instance

public abstract class GroupBase
extends NodeBase

Base class for stx:group (class GroupFactory.Instance) and stx:transform (class TransformFactory.Instance) elements. The stx:transform root element is also a group.

Version:
$Revision: 2.17 $ $Date: 2008/10/04 17:13:14 $
Author:
Oliver Becker

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.joost.instruction.NodeBase
NodeBase.End
 
Field Summary
protected  Vector children
          Vector of the children
private  Vector containedGlobalTemplates
          Vector of all contained global templates in this group Used only temporarily during compiling the transformation sheet.
protected  GroupBase[] containedGroups
          Contained groups in this group
private  Vector containedGroupTemplates
          Vector of all contained group templates in this group.
private  Hashtable containedPublicProcedures
          Table of all contained public and global procedures in this group Used only temporarily during compiling the transformation sheet.
private  Vector containedPublicTemplates
          Vector of all contained public templates in this group.
(package private)  Hashtable globalProcedures
          Table of all global procedures in the transformation sheet, stems from the parent group
 String groupName
          Expanded name of this group
(package private)  Hashtable groupProcedures
          Table of the group procedures visible for this group
 TemplateFactory.Instance[] groupTemplates
          The templates from containedGroupTemplates as array
private  VariableBase[] groupVariables
          Group variables
 Hashtable namedGroups
          Table of named groups: key = group name, value = group object.
 GroupBase parentGroup
          parent group
 byte passThrough
          The rule how to process unmatched events (from stx:options' pass-through)
 boolean recognizeCdata
          Should CDATA section be recognized (from stx:options' recognize-cdata)?
 boolean stripSpace
          Should white-space only text nodes be stripped (from stx:options' strip-space)?
 Hashtable visibleProcedures
          Visible procedures: procedures from this group and public templates from subgroups
 TemplateFactory.Instance[] visibleTemplates
          Visible templates: templates from this group and public templates from subgroups
 
Fields inherited from class net.sf.joost.instruction.NodeBase
lastChild, localFieldStack, nodeEnd, parent, preserveSpace, publicId, qName, scopedVariables, systemId
 
Fields inherited from class net.sf.joost.instruction.AbstractInstruction
colNo, lineNo, next
 
Fields inherited from interface net.sf.joost.Constants
DEBUG, DEFAULT_ENCODING, FEAT_NS, FEAT_NSPREFIX, FEATURE_URI_PREFIX, FUNC_NS, JOOST_EXT_NS, PR_ATTRIBUTES, PR_BUFFER, PR_CHILDREN, PR_CONTINUE, PR_ERROR, PR_SELF, PR_SIBLINGS, STX_NS
 
Constructor Summary
protected GroupBase(String qName, NodeBase parent, ParseContext context, byte passThrough, boolean stripSpace, boolean recognizeCdata)
           
 
Method Summary
protected  void addGroupProcedures(Hashtable pTable)
          Add the procedures from pTable to the group procedures of this group and all sub-groups.
protected  void addGroupTemplates(Vector tVec)
          Add the templates from tVec to the group templates of this group and all sub-groups.
 boolean compile(int pass, ParseContext context)
          Determines the visible templates for this group in pass 0 and the array of group templates in pass 1.
 void enterRecursionLevel(Context context)
          Enters a recursion level by creating a new set of group variable instances.
 void exitRecursionLevel(Context context)
          Exits a recursion level by removing the current group variable instances.
 Vector getGlobalTemplates()
          Returns the globally visible templates in this group (and all sub-groups).
 TemplateFactory.Instance[] getVisibleTemplates()
          returns the value of visibleTemplates
 void initGroupVariables(Context context)
          Initializes recursively the group variables of this group and all contained sub-groups (breadth first).
 void insert(NodeBase node)
          Insert a new node as a child of this element
protected  void onDeepCopy(AbstractInstruction copy, HashMap copies)
          Callback that will be called when a clone of this instance has been created.
 short process(Context c)
          Save local variables if needed.
 boolean processable()
           
 
Methods inherited from class net.sf.joost.instruction.NodeBase
declareVariable, getNode, getNodeEnd, mayDropEnd, processEnd, setEndLocation, toString
 
Methods inherited from class net.sf.joost.instruction.AbstractInstruction
deepCopy, deepHashtableCopy, deepTemplateArrayCopy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

passThrough

public byte passThrough
The rule how to process unmatched events (from stx:options' pass-through)


stripSpace

public boolean stripSpace
Should white-space only text nodes be stripped (from stx:options' strip-space)?


recognizeCdata

public boolean recognizeCdata
Should CDATA section be recognized (from stx:options' recognize-cdata)?


containedPublicTemplates

private Vector containedPublicTemplates
Vector of all contained public templates in this group. Used only temporarily during compiling the transformation sheet.


containedGroupTemplates

private Vector containedGroupTemplates
Vector of all contained group templates in this group. Used only temporarily during compiling the transformation sheet.


containedGlobalTemplates

private Vector containedGlobalTemplates
Vector of all contained global templates in this group Used only temporarily during compiling the transformation sheet.


visibleTemplates

public TemplateFactory.Instance[] visibleTemplates
Visible templates: templates from this group and public templates from subgroups


groupTemplates

public TemplateFactory.Instance[] groupTemplates
The templates from containedGroupTemplates as array


containedPublicProcedures

private Hashtable containedPublicProcedures
Table of all contained public and global procedures in this group Used only temporarily during compiling the transformation sheet.


groupProcedures

Hashtable groupProcedures
Table of the group procedures visible for this group


globalProcedures

Hashtable globalProcedures
Table of all global procedures in the transformation sheet, stems from the parent group


visibleProcedures

public Hashtable visibleProcedures
Visible procedures: procedures from this group and public templates from subgroups


containedGroups

protected GroupBase[] containedGroups
Contained groups in this group


namedGroups

public Hashtable namedGroups
Table of named groups: key = group name, value = group object. All groups will have a reference to the same singleton Hashtable.


parentGroup

public GroupBase parentGroup
parent group


groupVariables

private VariableBase[] groupVariables
Group variables


groupName

public String groupName
Expanded name of this group


children

protected Vector children
Vector of the children

Constructor Detail

GroupBase

protected GroupBase(String qName,
                    NodeBase parent,
                    ParseContext context,
                    byte passThrough,
                    boolean stripSpace,
                    boolean recognizeCdata)
Method Detail

insert

public void insert(NodeBase node)
            throws SAXParseException
Description copied from class: NodeBase
Insert a new node as a child of this element

Overrides:
insert in class NodeBase
Parameters:
node - the node to be inserted
Throws:
SAXParseException

compile

public boolean compile(int pass,
                       ParseContext context)
                throws SAXException
Determines the visible templates for this group in pass 0 and the array of group templates in pass 1.

Overrides:
compile in class NodeBase
Parameters:
pass - the number of invocations already performed on this node
context - the parse context
Returns:
true if another invocation in the next pass is necessary, false if the compiling is complete. This instance returns false.
Throws:
SAXException - if conflicts were encountered

initGroupVariables

public void initGroupVariables(Context context)
                        throws SAXException
Initializes recursively the group variables of this group and all contained sub-groups (breadth first).

Throws:
SAXException

enterRecursionLevel

public void enterRecursionLevel(Context context)
                         throws SAXException
Enters a recursion level by creating a new set of group variable instances.

Throws:
SAXException

exitRecursionLevel

public void exitRecursionLevel(Context context)
Exits a recursion level by removing the current group variable instances.


addGroupTemplates

protected void addGroupTemplates(Vector tVec)
Add the templates from tVec to the group templates of this group and all sub-groups.

Parameters:
tVec - a Vector containing the templates

addGroupProcedures

protected void addGroupProcedures(Hashtable pTable)
                           throws SAXParseException
Add the procedures from pTable to the group procedures of this group and all sub-groups.

Parameters:
pTable - a Hashtable containing the procedures
Throws:
SAXParseException - if one of the procedures is already defined

getGlobalTemplates

public Vector getGlobalTemplates()
Returns the globally visible templates in this group (and all sub-groups). This method is called from compile(int, net.sf.joost.stx.ParseContext) in the parent group, which adds in turn the returned vector to its vector of the global templates. The field containedGlobalTemplates will be set to null afterwards to allow garbage collection.


processable

public boolean processable()
Overrides:
processable in class NodeBase
Returns:
true if NodeBase.process(net.sf.joost.stx.Context) can be invoked on this node, and false otherwise

process

public short process(Context c)
              throws SAXException
Description copied from class: NodeBase
Save local variables if needed.

Overrides:
process in class NodeBase
Parameters:
c - the current context
Returns:
Constants.PR_CONTINUE
Throws:
SAXException - if an error occurs (in a derived class)

getVisibleTemplates

public TemplateFactory.Instance[] getVisibleTemplates()
returns the value of visibleTemplates


onDeepCopy

protected void onDeepCopy(AbstractInstruction copy,
                          HashMap copies)
Description copied from class: AbstractInstruction
Callback that will be called when a clone of this instance has been created. To be overridden in subclasses.

Overrides:
onDeepCopy in class NodeBase
Parameters:
copy - the created clones
copies - the map of already copied objects