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
-
attribs
-
-
child
-
-
childrenHiddenManually
-
-
color
-
-
content
-
-
contentNode
- Some SGMLNodes are just containers for others - a contentNode
is one such
-
drawableSGMLNodes
- DrawableSGMLNodes which refer to this node
-
gi
-
-
giName
-
-
hiddenManually
-
-
index
-
-
nattribs
-
-
nchild
-
-
nchildbuf
-
-
nodeType
-
-
parent
-
-
PRINT_ESIS
-
-
PRINT_HTML
-
-
processed
-
-
searchKey
-
-
title
-
-
tree
- inheritable by subclasses NOT in pmr.sgml
-
validContent
-
-
visible
-
-
whichChild
-
-
SGMLNode()
-
-
SGMLNode(SGMLNode)
- 'copy' constructor - NOT recursive, just copies references
-
SGMLNode(String, SGMLTree)
- nt = "_PEL", "_DOCROOT", or is the GI
-
addChild(int)
- the parent may react to adding a child; usually subclassed
-
addChild(int, SGMLNode)
- add a child newNode at childIndex (runs from 0 to nchild); values outside
this throw exception
-
addContent(String)
-
-
addDrawableSGMLNode(DrawableSGMLNode)
-
-
addGIName(String)
-
-
addNode(SGMLNode)
- add a pre-formed node to this; returns index
-
addSGMLAttlist(SGMLAttlist)
-
-
addSGMLAttribute(SGMLAttribute)
- adds SGMLAttribute, or replaces old value
-
addSGMLAttribute(String, String)
- adds SGMLAttribute, or replaces old value
-
addTree(SGMLNode)
- add a tree to a Node (as the last child.
-
areChildrenHidden()
- are node's children hidden either by GI or by user?
-
areChildrenHiddenByGI()
- are the children of this node hidden by virtue of this node's GI or
GI context? To be overridden if required
-
childCount()
-
-
childrenToHTML()
- returns (maybe recursively) the HTML representation of the children
-
childrenToString()
- returns (maybe recursively) the SGML representation of the children
-
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
-
debug()
-
-
deleteNodeAndSubtree()
- delete a node and all its descendants
-
deleteSubtree()
- delete all descendants of a node
-
detachFromTree()
- delete this but not its descendants
-
display()
- display.
-
display(Graphics)
- display a SGMLNode to Graphics provided from some other SGMLNode (e.g.
-
displayChildren(Graphics)
- display all children.
-
displayChildrenRecursively(Graphics)
- the same, but recurse
-
drawIcon(Graphics, int, int)
- draws an icon based on the GI - crude at present!! Overridden by
subclasses.
-
error(String)
- I must replace this by exceptions...
-
getAncestors()
- get all ancestors excluding current Node and DOCROOT
-
getAttval(String)
- CoST: get SGMLAttribute value (if non-existent attribute, return "")
attname is case-insensitive
-
getChildIndex(int)
-
-
getChildNode(int)
-
-
getChildrenHiddenManually()
- are the children manually hidden; "YES", "NO", ""
-
getChildrenIndexSet()
- children of node as SGMLNodeIndexSet
-
getColor()
- color of SGMLNode text - overridden by subclasses?
-
getContent()
- retrieves the String content (only for PEL nodes) else ""
-
getDescendants()
-
-
getDescendants(String)
- subtree traversal - includes node; if no nodes found, return
empty SGMLNodeIndexSet;
-
getFirstNode(String)
- searches for a given Node or Nodes a la COST
-
getGI()
- retrieves the complete GI associated with this node
(cf.
-
getGIName()
-
-
getHiddenManually()
- is the node manually hidden; "YES", "NO", ""
-
getIndex()
-
-
getNodeType()
-
-
getParentIndex()
-
-
getParentNode()
-
-
getSGMLAttlist()
-
-
getSGMLAttributeCount()
-
-
getSGMLAttributes()
-
-
getSGMLStream()
- gets the SGMLStream for the node and subtree
-
getStringContent()
- since PEL nodes are such a pain, this will retrieve the contents of
a single PEL child if present
-
getTitle()
- makes a suitable title for the node in following priority:
- content SGMLNode (any SGMLNode contained by this node and so defined by user
- TITLE attribute
- NAME attribute
- GI
-
getTree()
-
-
hasAttname(String)
- CoST: does this node have attribute with name attname? (Case-insensitive)
-
hasAttval(String, String)
- CoST: does this node have attribute with name attname
(case-insensitive) and value attval (case-sensitive)?
-
hasChild()
- true if node has 1 or more children
-
hasContent()
- true if the node has String content (i.e.
-
hasGI(String)
- CoST: does this node have GI g? (Case-insensitive)
-
highlight()
- highlights node in some way (e.g.
-
importNodeAsLastChild(SGMLNode)
- add the imported node as last child.
-
importNodeAsYoungerSibling(SGMLNode)
- add the imported node as younger sibling.
-
isAncestorOf(SGMLNode)
- is this an ancestor of n?
-
isHidden()
- is node hidden either by GI or by user?
-
isHiddenByGI()
- is the SGMLNode hidden by virtue of its GI or GI context? To be overrridden
by subclasses if required
-
isProcessed()
- has the SGMLNode been processed?
-
isValid()
- processing may determine whether a SGMLNode has valid semantics or not
-
mayContain(SGMLNode)
- check whether node may be added (e.g.
-
moveToBeLastChildOf(SGMLNode)
- move the current node to be LastChild of parent
-
moveToBeYoungerSiblingOf(SGMLNode)
- move the current node to be YoungerSibling of esib
-
nonPELChildCount()
-
-
outputSGML(File)
- as toString(), but ouputs to file
avoids memory problems???
-
prettyContent(String)
- formats the string in<= 80 cols and deals with quotes ("")
-
print(int)
- output node in way determined by printType.
-
process()
- dummy - to be implemented by subClasses
-
sendSignal()
- makeClickable - very speculative - sends signal to table of links
UNDER DEVELOPMENT
-
setChildrenHiddenManually(String)
- set the children manually hidden; "YES", "NO", ""
-
setContent(String)
- set the content (be very careful).
-
setGrandChildrenHiddenManually()
- set the grandchildren manually hidden; always YES
-
setHiddenManually(String)
- set the node manually hidden; "YES", "NO", ""
-
setTitle(String)
-
-
taggedEventStream()
- return all the PCDATA children (PEL) as a concatenated string with
the tags (e.g.
-
toHTML()
- returns (maybe recursively) the HTML representation of the node.
-
toString()
- returns (maybe recursively) the SGML representation of the node.
-
transferSubtree(SGMLNode, int, int)
-
-
untaggedEventStream()
- return all the PCDATA children (PEL) as a concatenated string without
the tags (e.g.
-
whichChild()
- which number of child in family (eldest = 0)
tree
protected SGMLTree tree
- inheritable by subclasses NOT in pmr.sgml
index
protected int index
processed
protected boolean processed
nchild
protected int nchild
child
protected int child[]
validContent
protected boolean validContent
giName
protected String giName
gi
protected GI gi
attribs
protected SGMLAttlist attribs
nattribs
protected int nattribs
content
protected String content
nodeType
protected String nodeType
parent
protected int parent
nchildbuf
protected int nchildbuf
whichChild
protected int whichChild
title
protected String title
color
protected Color color
visible
protected boolean visible
hiddenManually
protected String hiddenManually
childrenHiddenManually
protected String childrenHiddenManually
drawableSGMLNodes
protected Vector drawableSGMLNodes
- DrawableSGMLNodes which refer to this node
contentNode
protected SGMLNode contentNode
- Some SGMLNodes are just containers for others - a contentNode
is one such
PRINT_ESIS
protected final static int PRINT_ESIS
PRINT_HTML
protected final static int PRINT_HTML
searchKey
protected static String searchKey[]
SGMLNode
public SGMLNode()
SGMLNode
public SGMLNode(String nt,
SGMLTree tree)
- nt = "_PEL", "_DOCROOT", or is the GI
SGMLNode
public SGMLNode(SGMLNode n)
- 'copy' constructor - NOT recursive, just copies references
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
addNode
public int addNode(SGMLNode n)
- add a pre-formed node to this; returns index
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.
transferSubtree
public int transferSubtree(SGMLNode n,
int nodeIndex,
int level)
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
detachFromTree
public void detachFromTree()
- delete this but not its descendants
deleteNodeAndSubtree
public void deleteNodeAndSubtree()
- delete a node and all its descendants
deleteSubtree
public void deleteSubtree()
- delete all descendants of a node
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
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
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
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
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
isAncestorOf
public boolean isAncestorOf(SGMLNode n)
- is this an ancestor of n?
error
public void error(String s)
- I must replace this by exceptions...
addDrawableSGMLNode
public void addDrawableSGMLNode(DrawableSGMLNode d)
addSGMLAttlist
public void addSGMLAttlist(SGMLAttlist attribs)
addSGMLAttribute
public void addSGMLAttribute(String name,
String value)
- adds SGMLAttribute, or replaces old value
addSGMLAttribute
public void addSGMLAttribute(SGMLAttribute a)
- adds SGMLAttribute, or replaces old value
addGIName
public void addGIName(String giName)
addChild
public void addChild(int childIndex)
- the parent may react to adding a child; usually subclassed
addContent
public void addContent(String content)
getSGMLAttributes
public SGMLAttribute[] getSGMLAttributes()
getSGMLAttlist
public SGMLAttlist getSGMLAttlist()
getSGMLAttributeCount
public int getSGMLAttributeCount()
getTree
public SGMLTree getTree()
getNodeType
public String getNodeType()
getParentIndex
public int getParentIndex()
getParentNode
public SGMLNode getParentNode()
isValid
public boolean isValid()
- processing may determine whether a SGMLNode has valid semantics or not
isProcessed
public boolean isProcessed()
- has the SGMLNode been processed?
process
public void process()
- dummy - to be implemented by subClasses
isHidden
public boolean isHidden()
- is node hidden either by GI or by user?
isHiddenByGI
public boolean isHiddenByGI()
- is the SGMLNode hidden by virtue of its GI or GI context? To be overrridden
by subclasses if required
areChildrenHidden
public boolean areChildrenHidden()
- are node's children hidden either by GI or by user?
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
setHiddenManually
public void setHiddenManually(String s)
- set the node manually hidden; "YES", "NO", ""
getHiddenManually
public String getHiddenManually()
- is the node manually hidden; "YES", "NO", ""
setChildrenHiddenManually
public void setChildrenHiddenManually(String s)
- set the children manually hidden; "YES", "NO", ""
getChildrenHiddenManually
public String getChildrenHiddenManually()
- are the children manually hidden; "YES", "NO", ""
setGrandChildrenHiddenManually
public void setGrandChildrenHiddenManually()
- set the grandchildren manually hidden; always YES
getChildrenIndexSet
public SGMLNodeIndexSet getChildrenIndexSet()
- children of node as SGMLNodeIndexSet
childCount
public int childCount()
nonPELChildCount
public int nonPELChildCount()
getIndex
public int getIndex()
whichChild
public int whichChild()
- which number of child in family (eldest = 0)
getChildNode
public SGMLNode getChildNode(int i)
getChildIndex
public int getChildIndex(int i)
hasGI
public boolean hasGI(String g)
- CoST: does this node have GI g? (Case-insensitive)
hasAttname
public boolean hasAttname(String attname)
- CoST: does this node have attribute with name attname? (Case-insensitive)
hasAttval
public boolean hasAttval(String attname,
String attval)
- CoST: does this node have attribute with name attname
(case-insensitive) and value attval (case-sensitive)?
getAttval
public String getAttval(String attname)
- CoST: get SGMLAttribute value (if non-existent attribute, return "")
attname is case-insensitive
hasChild
public boolean hasChild()
- true if node has 1 or more children
getAncestors
public SGMLNodeIndexSet getAncestors()
- get all ancestors excluding current Node and DOCROOT
getDescendants
public SGMLNodeIndexSet getDescendants(String strategy)
- subtree traversal - includes node; if no nodes found, return
empty SGMLNodeIndexSet;
- Parameters:
- strategy - "DEPTH" or "BREADTH"
getDescendants
public SGMLNodeIndexSet getDescendants()
hasContent
public boolean hasContent()
- true if the node has String content (i.e. is a PEL node)
setContent
public void setContent(String s)
- set the content (be very careful). Only allowed for _PEL
getContent
public String getContent()
- retrieves the String content (only for PEL nodes) else ""
getStringContent
public String getStringContent()
- since PEL nodes are such a pain, this will retrieve the contents of
a single PEL child if present
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
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
getGIName
public String getGIName()
getFirstNode
public SGMLNode getFirstNode(String search)
- searches for a given Node or Nodes a la COST
getTitle
public String getTitle()
- makes a suitable title for the node in following priority:
- content SGMLNode (any SGMLNode contained by this node and so defined by user
- TITLE attribute
- NAME attribute
- GI
setTitle
public void setTitle(String title)
getColor
public Color getColor()
- color of SGMLNode text - overridden by subclasses?
getGI
public GI getGI()
- retrieves the complete GI associated with this node
(cf. getGIName
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...
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!
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
displayChildrenRecursively
public void displayChildrenRecursively(Graphics g)
- the same, but recurse
display
public void display(Graphics g)
- display a SGMLNode to Graphics provided from some other SGMLNode (e.g. a container)
Almost certainly overridden.
print
public void print(int printType)
- output node in way determined by printType. UNDER DEVELOPMENT
highlight
public void highlight()
- highlights node in some way (e.g. blink) UNDER DEVELOPMENT
sendSignal
public void sendSignal()
- makeClickable - very speculative - sends signal to table of links
UNDER DEVELOPMENT
debug
public void debug()
getSGMLStream
public SGMLStream getSGMLStream()
- gets the SGMLStream for the node and subtree
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
childrenToString
public String childrenToString()
- returns (maybe recursively) the SGML representation of the children
toHTML
public String toHTML()
- returns (maybe recursively) the HTML representation of the node.
calls childrenToHTML(), which might be overridden by some SGMLNode types
childrenToHTML
public String childrenToHTML()
- returns (maybe recursively) the HTML representation of the children
outputSGML
public void outputSGML(File file) throws IOException
- as toString(), but ouputs to file
avoids memory problems???
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