Class pmr.sgml.SGMLNode
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.sgml.SGMLNode

java.lang.Object
   |
   +----pmr.sgml.SGMLNode

public class SGMLNode
extends Object
Every SGML ELEMENT maps onto a Node. This class is frequently subclassed and therefore contains a lot of functionality
Author:
(C) P. Murray-Rust, 1996

Variable Index

 o attribs
 o child
 o childrenHiddenManually
 o color
 o content
 o contentNode
Some SGMLNodes are just containers for others - a contentNode is one such
 o drawableSGMLNodes
DrawableSGMLNodes which refer to this node
 o gi
 o giName
 o hiddenManually
 o index
 o nattribs
 o nchild
 o nchildbuf
 o nodeType
 o parent
 o PRINT_ESIS
 o PRINT_HTML
 o processed
 o searchKey
 o title
 o tree
inheritable by subclasses NOT in pmr.sgml
 o validContent
 o visible
 o whichChild

Constructor Index

 o SGMLNode()
 o SGMLNode(SGMLNode)
'copy' constructor - NOT recursive, just copies references
 o SGMLNode(String, SGMLTree)
nt = "_PEL", "_DOCROOT", or is the GI

Method Index

 o addChild(int)
the parent may react to adding a child; usually subclassed
 o addChild(int, SGMLNode)
add a child newNode at childIndex (runs from 0 to nchild); values outside this throw exception
 o addContent(String)
 o addDrawableSGMLNode(DrawableSGMLNode)
 o addGIName(String)
 o addNode(SGMLNode)
add a pre-formed node to this; returns index
 o addSGMLAttlist(SGMLAttlist)
 o addSGMLAttribute(SGMLAttribute)
adds SGMLAttribute, or replaces old value
 o addSGMLAttribute(String, String)
adds SGMLAttribute, or replaces old value
 o addTree(SGMLNode)
add a tree to a Node (as the last child.
 o areChildrenHidden()
are node's children hidden either by GI or by user?
 o areChildrenHiddenByGI()
are the children of this node hidden by virtue of this node's GI or GI context? To be overridden if required
 o childCount()
 o childrenToHTML()
returns (maybe recursively) the HTML representation of the children
 o childrenToString()
returns (maybe recursively) the SGML representation of the children
 o createPELandAdd(int, String)
add PEL node (often from subclasses); addes the current node (this) and also creates a PEL node from content which it then also adds
 o debug()
 o deleteNodeAndSubtree()
delete a node and all its descendants
 o deleteSubtree()
delete all descendants of a node
 o detachFromTree()
delete this but not its descendants
 o display()
display.
 o display(Graphics)
display a SGMLNode to Graphics provided from some other SGMLNode (e.g.
 o displayChildren(Graphics)
display all children.
 o displayChildrenRecursively(Graphics)
the same, but recurse
 o drawIcon(Graphics, int, int)
draws an icon based on the GI - crude at present!! Overridden by subclasses.
 o error(String)
I must replace this by exceptions...
 o getAncestors()
get all ancestors excluding current Node and DOCROOT
 o getAttval(String)
CoST: get SGMLAttribute value (if non-existent attribute, return "") attname is case-insensitive
 o getChildIndex(int)
 o getChildNode(int)
 o getChildrenHiddenManually()
are the children manually hidden; "YES", "NO", ""
 o getChildrenIndexSet()
children of node as SGMLNodeIndexSet
 o getColor()
color of SGMLNode text - overridden by subclasses?
 o getContent()
retrieves the String content (only for PEL nodes) else ""
 o getDescendants()
 o getDescendants(String)
subtree traversal - includes node; if no nodes found, return empty SGMLNodeIndexSet;
 o getFirstNode(String)
searches for a given Node or Nodes a la COST
 o getGI()
retrieves the complete GI associated with this node (cf.
 o getGIName()
 o getHiddenManually()
is the node manually hidden; "YES", "NO", ""
 o getIndex()
 o getNodeType()
 o getParentIndex()
 o getParentNode()
 o getSGMLAttlist()
 o getSGMLAttributeCount()
 o getSGMLAttributes()
 o getSGMLStream()
gets the SGMLStream for the node and subtree
 o getStringContent()
since PEL nodes are such a pain, this will retrieve the contents of a single PEL child if present
 o getTitle()
makes a suitable title for the node in following priority:
 o getTree()
 o hasAttname(String)
CoST: does this node have attribute with name attname? (Case-insensitive)
 o hasAttval(String, String)
CoST: does this node have attribute with name attname (case-insensitive) and value attval (case-sensitive)?
 o hasChild()
true if node has 1 or more children
 o hasContent()
true if the node has String content (i.e.
 o hasGI(String)
CoST: does this node have GI g? (Case-insensitive)
 o highlight()
highlights node in some way (e.g.
 o importNodeAsLastChild(SGMLNode)
add the imported node as last child.
 o importNodeAsYoungerSibling(SGMLNode)
add the imported node as younger sibling.
 o isAncestorOf(SGMLNode)
is this an ancestor of n?
 o isHidden()
is node hidden either by GI or by user?
 o isHiddenByGI()
is the SGMLNode hidden by virtue of its GI or GI context? To be overrridden by subclasses if required
 o isProcessed()
has the SGMLNode been processed?
 o isValid()
processing may determine whether a SGMLNode has valid semantics or not
 o mayContain(SGMLNode)
check whether node may be added (e.g.
 o moveToBeLastChildOf(SGMLNode)
move the current node to be LastChild of parent
 o moveToBeYoungerSiblingOf(SGMLNode)
move the current node to be YoungerSibling of esib
 o nonPELChildCount()
 o outputSGML(File)
as toString(), but ouputs to file avoids memory problems???
 o prettyContent(String)
formats the string in<= 80 cols and deals with quotes ("")
 o print(int)
output node in way determined by printType.
 o process()
dummy - to be implemented by subClasses
 o sendSignal()
makeClickable - very speculative - sends signal to table of links UNDER DEVELOPMENT
 o setChildrenHiddenManually(String)
set the children manually hidden; "YES", "NO", ""
 o setContent(String)
set the content (be very careful).
 o setGrandChildrenHiddenManually()
set the grandchildren manually hidden; always YES
 o setHiddenManually(String)
set the node manually hidden; "YES", "NO", ""
 o setTitle(String)
 o taggedEventStream()
return all the PCDATA children (PEL) as a concatenated string with the tags (e.g.
 o toHTML()
returns (maybe recursively) the HTML representation of the node.
 o toString()
returns (maybe recursively) the SGML representation of the node.
 o transferSubtree(SGMLNode, int, int)
 o untaggedEventStream()
return all the PCDATA children (PEL) as a concatenated string without the tags (e.g.
 o whichChild()
which number of child in family (eldest = 0)

Variables

 o tree
  protected SGMLTree tree
inheritable by subclasses NOT in pmr.sgml
 o index
  protected int index
 o processed
  protected boolean processed
 o nchild
  protected int nchild
 o child
  protected int child[]
 o validContent
  protected boolean validContent
 o giName
  protected String giName
 o gi
  protected GI gi
 o attribs
  protected SGMLAttlist attribs
 o nattribs
  protected int nattribs
 o content
  protected String content
 o nodeType
  protected String nodeType
 o parent
  protected int parent
 o nchildbuf
  protected int nchildbuf
 o whichChild
  protected int whichChild
 o title
  protected String title
 o color
  protected Color color
 o visible
  protected boolean visible
 o hiddenManually
  protected String hiddenManually
 o childrenHiddenManually
  protected String childrenHiddenManually
 o drawableSGMLNodes
  protected Vector drawableSGMLNodes
DrawableSGMLNodes which refer to this node
 o contentNode
  protected SGMLNode contentNode
Some SGMLNodes are just containers for others - a contentNode is one such
 o PRINT_ESIS
  protected final static int PRINT_ESIS
 o PRINT_HTML
  protected final static int PRINT_HTML
 o searchKey
  protected static String searchKey[]

Constructors

 o SGMLNode
  public SGMLNode()
 o SGMLNode
  public SGMLNode(String nt,
                  SGMLTree tree)
nt = "_PEL", "_DOCROOT", or is the GI
 o SGMLNode
  public SGMLNode(SGMLNode n)
'copy' constructor - NOT recursive, just copies references

Methods

 o createPELandAdd
  public int createPELandAdd(int parentIndex,
                             String content)
add PEL node (often from subclasses); addes the current node (this) and also creates a PEL node from content which it then also adds
 o addNode
  public int addNode(SGMLNode n)
add a pre-formed node to this; returns index
 o addTree
  public int addTree(SGMLNode n)
add a tree to a Node (as the last child. This will reassign all indexes and tree references in the subtree. The node n must have no parent; Node references in the original tree are set to null; (This is a waste of space, but probably tolerable until I remove the 'index' approach.
 o transferSubtree
  public int transferSubtree(SGMLNode n,
                             int nodeIndex,
                             int level)
 o mayContain
  public boolean mayContain(SGMLNode childNode)
check whether node may be added (e.g. compatible with DTD). Default is true, but subclassed to other Nodes witn constraints
 o detachFromTree
  public void detachFromTree()
delete this but not its descendants
 o deleteNodeAndSubtree
  public void deleteNodeAndSubtree()
delete a node and all its descendants
 o deleteSubtree
  public void deleteSubtree()
delete all descendants of a node
 o addChild
  public void addChild(int atChildIndex,
                       SGMLNode newChild) throws IllegalArgumentException, DTDViolationException, DifferentSGMLTreesException
add a child newNode at childIndex (runs from 0 to nchild); values outside this throw exception
Throws: DifferentSGMLTreesException
this and newNode have different trees
Throws: IllegalArgumentException
silly value of atChildIndex
Throws: DTDViolationException
child GI not allowed in parent
 o moveToBeYoungerSiblingOf
  public void moveToBeYoungerSiblingOf(SGMLNode esib) throws TreeViolationException, DTDViolationException, DifferentSGMLTreesException
move the current node to be YoungerSibling of esib
Throws: TreeViolationException
Cannot make ancestor child of descendant
Throws: DifferentSGMLTreesException
esib and this belong to different trees
Throws: DTDViolationException
document violates DTD
 o importNodeAsYoungerSibling
  public int importNodeAsYoungerSibling(SGMLNode n) throws IllegalArgumentException, DTDViolationException
add the imported node as younger sibling. This is done through an intermediate SGMLStream, which destroys any current state of importNode, but overrides the problem of different trees
Throws: DTDViolationException
document violates DTD
 o moveToBeLastChildOf
  public void moveToBeLastChildOf(SGMLNode newParent) throws TreeViolationException, DTDViolationException, DifferentSGMLTreesException
move the current node to be LastChild of parent
Throws: TreeViolationException
Cannot make ancestor child of descendant
Throws: DifferentSGMLTreesException
parent and this belong to different trees
Throws: DTDViolationException
document violates DTD
 o importNodeAsLastChild
  public int importNodeAsLastChild(SGMLNode n) throws IllegalArgumentException, DTDViolationException
add the imported node as last child. This is done through an intermediate SGMLStream, which destroys any current state of importNode, but overrides the problem of different trees
Throws: DTDViolationException
document violates DTD
 o isAncestorOf
  public boolean isAncestorOf(SGMLNode n)
is this an ancestor of n?
 o error
  public void error(String s)
I must replace this by exceptions...
 o addDrawableSGMLNode
  public void addDrawableSGMLNode(DrawableSGMLNode d)
 o addSGMLAttlist
  public void addSGMLAttlist(SGMLAttlist attribs)
 o addSGMLAttribute
  public void addSGMLAttribute(String name,
                               String value)
adds SGMLAttribute, or replaces old value
 o addSGMLAttribute
  public void addSGMLAttribute(SGMLAttribute a)
adds SGMLAttribute, or replaces old value
 o addGIName
  public void addGIName(String giName)
 o addChild
  public void addChild(int childIndex)
the parent may react to adding a child; usually subclassed
 o addContent
  public void addContent(String content)
 o getSGMLAttributes
  public SGMLAttribute[] getSGMLAttributes()
 o getSGMLAttlist
  public SGMLAttlist getSGMLAttlist()
 o getSGMLAttributeCount
  public int getSGMLAttributeCount()
 o getTree
  public SGMLTree getTree()
 o getNodeType
  public String getNodeType()
 o getParentIndex
  public int getParentIndex()
 o getParentNode
  public SGMLNode getParentNode()
 o isValid
  public boolean isValid()
processing may determine whether a SGMLNode has valid semantics or not
 o isProcessed
  public boolean isProcessed()
has the SGMLNode been processed?
 o process
  public void process()
dummy - to be implemented by subClasses
 o isHidden
  public boolean isHidden()
is node hidden either by GI or by user?
 o isHiddenByGI
  public boolean isHiddenByGI()
is the SGMLNode hidden by virtue of its GI or GI context? To be overrridden by subclasses if required
 o areChildrenHidden
  public boolean areChildrenHidden()
are node's children hidden either by GI or by user?
 o areChildrenHiddenByGI
  public boolean areChildrenHiddenByGI()
are the children of this node hidden by virtue of this node's GI or GI context? To be overridden if required
 o setHiddenManually
  public void setHiddenManually(String s)
set the node manually hidden; "YES", "NO", ""
 o getHiddenManually
  public String getHiddenManually()
is the node manually hidden; "YES", "NO", ""
 o setChildrenHiddenManually
  public void setChildrenHiddenManually(String s)
set the children manually hidden; "YES", "NO", ""
 o getChildrenHiddenManually
  public String getChildrenHiddenManually()
are the children manually hidden; "YES", "NO", ""
 o setGrandChildrenHiddenManually
  public void setGrandChildrenHiddenManually()
set the grandchildren manually hidden; always YES
 o getChildrenIndexSet
  public SGMLNodeIndexSet getChildrenIndexSet()
children of node as SGMLNodeIndexSet
 o childCount
  public int childCount()
 o nonPELChildCount
  public int nonPELChildCount()
 o getIndex
  public int getIndex()
 o whichChild
  public int whichChild()
which number of child in family (eldest = 0)
 o getChildNode
  public SGMLNode getChildNode(int i)
 o getChildIndex
  public int getChildIndex(int i)
 o hasGI
  public boolean hasGI(String g)
CoST: does this node have GI g? (Case-insensitive)
 o hasAttname
  public boolean hasAttname(String attname)
CoST: does this node have attribute with name attname? (Case-insensitive)
 o hasAttval
  public boolean hasAttval(String attname,
                           String attval)
CoST: does this node have attribute with name attname (case-insensitive) and value attval (case-sensitive)?
 o getAttval
  public String getAttval(String attname)
CoST: get SGMLAttribute value (if non-existent attribute, return "") attname is case-insensitive
 o hasChild
  public boolean hasChild()
true if node has 1 or more children
 o getAncestors
  public SGMLNodeIndexSet getAncestors()
get all ancestors excluding current Node and DOCROOT
 o getDescendants
  public SGMLNodeIndexSet getDescendants(String strategy)
subtree traversal - includes node; if no nodes found, return empty SGMLNodeIndexSet;
Parameters:
strategy - "DEPTH" or "BREADTH"
 o getDescendants
  public SGMLNodeIndexSet getDescendants()
 o hasContent
  public boolean hasContent()
true if the node has String content (i.e. is a PEL node)
 o setContent
  public void setContent(String s)
set the content (be very careful). Only allowed for _PEL
 o getContent
  public String getContent()
retrieves the String content (only for PEL nodes) else ""
 o getStringContent
  public String getStringContent()
since PEL nodes are such a pain, this will retrieve the contents of a single PEL child if present
 o untaggedEventStream
  public String untaggedEventStream()
return all the PCDATA children (PEL) as a concatenated string without the tags (e.g. "This <B>is</B>bold" renders as "This isbold"

For the complete event stream, use the taggedEventStream

 o taggedEventStream
  public String taggedEventStream()
return all the PCDATA children (PEL) as a concatenated string with the tags (e.g. "This <B>is</B>bold" renders as "This <B>is</B>bold"

For the event stream without tags, use the untaggedEventStream

 o getGIName
  public String getGIName()
 o getFirstNode
  public SGMLNode getFirstNode(String search)
searches for a given Node or Nodes a la COST
 o getTitle
  public String getTitle()
makes a suitable title for the node in following priority:
 o setTitle
  public void setTitle(String title)
 o getColor
  public Color getColor()
color of SGMLNode text - overridden by subclasses?
 o getGI
  public GI getGI()
retrieves the complete GI associated with this node (cf. getGIName
 o display
  public void display()
display. This is coupled to GI display. many GIs map onto subclasses of SGMLNode and will have code provided. Alternatively it may be done through the GI itself...
 o drawIcon
  public int drawIcon(Graphics g,
                      int x,
                      int y)
draws an icon based on the GI - crude at present!! Overridden by subclasses. x, y are at bottom left (pixels) and remember that y goes DOWN the page when constructing your icon!
 o displayChildren
  public void displayChildren(Graphics g)
display all children. Haven't yet decided how to select which ones or lay them out. Early days. Probably translate them in y to avoid overlap
 o displayChildrenRecursively
  public void displayChildrenRecursively(Graphics g)
the same, but recurse
 o display
  public void display(Graphics g)
display a SGMLNode to Graphics provided from some other SGMLNode (e.g. a container) Almost certainly overridden.
 o print
  public void print(int printType)
output node in way determined by printType. UNDER DEVELOPMENT
 o highlight
  public void highlight()
highlights node in some way (e.g. blink) UNDER DEVELOPMENT
 o sendSignal
  public void sendSignal()
makeClickable - very speculative - sends signal to table of links UNDER DEVELOPMENT
 o debug
  public void debug()
 o getSGMLStream
  public SGMLStream getSGMLStream()
gets the SGMLStream for the node and subtree
 o toString
  public String toString()
returns (maybe recursively) the SGML representation of the node. calls childrenToString(), which might be overridden by some SGMLNode types
Overrides:
toString in class Object
 o childrenToString
  public String childrenToString()
returns (maybe recursively) the SGML representation of the children
 o toHTML
  public String toHTML()
returns (maybe recursively) the HTML representation of the node. calls childrenToHTML(), which might be overridden by some SGMLNode types
 o childrenToHTML
  public String childrenToHTML()
returns (maybe recursively) the HTML representation of the children
 o outputSGML
  public void outputSGML(File file) throws IOException
as toString(), but ouputs to file avoids memory problems???
 o prettyContent
  public static String prettyContent(String s)
formats the string in<= 80 cols and deals with quotes ("")

All Packages  Class Hierarchy  This Package  Previous  Next  Index