com.simonstl.gorille
Class Context

java.lang.Object
  |
  +--com.simonstl.gorille.Context
All Implemented Interfaces:
ContextI, NamespaceStackI

public class Context
extends java.lang.Object
implements ContextI

Created by IntelliJ IDEA. User: simon Date: Mar 8, 2003 Time: 10:46:01 AM


Field Summary
protected  StackableComponentI current
           
protected  java.lang.String encoding
           
protected  java.util.Hashtable entities
           
protected  NSContext namespaces
           
protected  java.lang.String origin
           
protected  java.lang.String standalone
           
protected  java.lang.String version
           
protected  boolean xmlDecl
           
 
Constructor Summary
Context()
           
 
Method Summary
 void addNode(StackableComponentI child)
          Adds a childless node.
 void declarePrefix(java.lang.String prefix, java.lang.String URI)
          Accepts a namespace declaration mapping a prefix to a URI.
 void endChild()
          Ends a node and adjusts context.
 StackableComponentI getCurrent()
          Returns the current node.
 java.lang.String getEncoding()
          Provides access to the encoding information from the XML declaration.
 boolean getExplicitXMLDecl()
          Identifies whether or not the document included an XML declaration.
 java.lang.String getOrigin()
          Returns a string identifying the origin of the document.
 StackableComponentI getParent()
          Returns the component which is the parent of the current node.
 java.lang.String getPrefix(java.lang.String URI)
          Returns a prefix which currently maps to a particular URI.
 java.lang.String getStandalone()
          Provides access to the standalone information from the XML declaration.
 java.lang.String getUri(java.lang.String prefix)
          Returns the URI which currently maps to a particular prefix.
 java.lang.String getVersion()
          Provides access to the version information from the XML declaration.
 boolean isSpace(char c)
          Reports whether the character c is whitespace or not.
static void main(java.lang.String[] args)
           
 void popLevel()
          Pops the element level up one to undeclare namespaces whose scope is done.
 void pushLevel()
          Pushes the element level one deeper for namespace-nesting.
 void reset()
          clear everything in the namespace stack
 java.lang.String resolveEntity(java.lang.String entName)
          Resolves an entity, hexRef, or decRef.
 void setEncoding(java.lang.String encoding)
          Sets the character encoding of XML used by the document, retrieved from the XML declaration.
 void setEntity(java.lang.String name, java.lang.String value)
          Establishes an entity name-value relationship.
 void setExplicitXMLDecl(boolean happened)
          Identifies whether the document contained an explicit XML declaration.
 void setOrigin(java.lang.String origin)
          Accepts a string identifying the origin of the document.
 void setStandalone(java.lang.String standalone)
          Sets the value of the standalone declaration, retrieved from the XML declaration.
 void setVersion(java.lang.String version)
          Sets the version of XML used by the document, retrieved from the XML declaration.
 boolean setXMLDeclaration(java.lang.String declaration)
          Takes a complete XML declaration for processing
 void startChild(StackableComponentI child)
          Adds a new node to the stack and adjusts context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

origin

protected java.lang.String origin

version

protected java.lang.String version

encoding

protected java.lang.String encoding

standalone

protected java.lang.String standalone

xmlDecl

protected boolean xmlDecl

namespaces

protected NSContext namespaces

current

protected StackableComponentI current

entities

protected java.util.Hashtable entities
Constructor Detail

Context

public Context()
Method Detail

setOrigin

public void setOrigin(java.lang.String origin)
Accepts a string identifying the origin of the document. Most likely a URI stating where it came from.

Specified by:
setOrigin in interface ContextI

getOrigin

public java.lang.String getOrigin()
Returns a string identifying the origin of the document. Most likely a URI stating where it came from.

Specified by:
getOrigin in interface ContextI

setXMLDeclaration

public boolean setXMLDeclaration(java.lang.String declaration)
Takes a complete XML declaration for processing

Specified by:
setXMLDeclaration in interface ContextI
Parameters:
declaration - the complete XML declaration, from

setVersion

public void setVersion(java.lang.String version)
Sets the version of XML used by the document, retrieved from the XML declaration. Should default to "1.0".

Specified by:
setVersion in interface ContextI
Parameters:
version -

getVersion

public java.lang.String getVersion()
Provides access to the version information from the XML declaration.

Specified by:
getVersion in interface ContextI
Returns:
the version of XML used by the document

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the character encoding of XML used by the document, retrieved from the XML declaration. Should default to "1.0".

Specified by:
setEncoding in interface ContextI
Parameters:
encoding -

getEncoding

public java.lang.String getEncoding()
Provides access to the encoding information from the XML declaration.

Specified by:
getEncoding in interface ContextI
Returns:
the character encoding specified by the document

setStandalone

public void setStandalone(java.lang.String standalone)
Sets the value of the standalone declaration, retrieved from the XML declaration. Should default to "no". "yes" is the other option.

Specified by:
setStandalone in interface ContextI
Parameters:
standalone -

getStandalone

public java.lang.String getStandalone()
Provides access to the standalone information from the XML declaration.

Specified by:
getStandalone in interface ContextI
Returns:
whether the document declares itself standalone

setExplicitXMLDecl

public void setExplicitXMLDecl(boolean happened)
Identifies whether the document contained an explicit XML declaration.

Specified by:
setExplicitXMLDecl in interface ContextI
Parameters:
happened - - true if the document had a decl, false if not

getExplicitXMLDecl

public boolean getExplicitXMLDecl()
Identifies whether or not the document included an XML declaration.

Specified by:
getExplicitXMLDecl in interface ContextI
Returns:
the version of XML used by the document

getParent

public StackableComponentI getParent()
Returns the component which is the parent of the current node.

Specified by:
getParent in interface ContextI

getCurrent

public StackableComponentI getCurrent()
Returns the current node.

Specified by:
getCurrent in interface ContextI

startChild

public void startChild(StackableComponentI child)
Adds a new node to the stack and adjusts context.

Specified by:
startChild in interface ContextI

endChild

public void endChild()
Ends a node and adjusts context.

Specified by:
endChild in interface ContextI

addNode

public void addNode(StackableComponentI child)
Adds a childless node.

Specified by:
addNode in interface ContextI

declarePrefix

public void declarePrefix(java.lang.String prefix,
                          java.lang.String URI)
Accepts a namespace declaration mapping a prefix to a URI.

Specified by:
declarePrefix in interface NamespaceStackI

getUri

public java.lang.String getUri(java.lang.String prefix)
Returns the URI which currently maps to a particular prefix.

Specified by:
getUri in interface NamespaceStackI

getPrefix

public java.lang.String getPrefix(java.lang.String URI)
Returns a prefix which currently maps to a particular URI. There can be multiple prefixes for a particular URI, and this method only promises to return one of them.

Specified by:
getPrefix in interface NamespaceStackI

pushLevel

public void pushLevel()
Description copied from interface: NamespaceStackI
Pushes the element level one deeper for namespace-nesting.

Specified by:
pushLevel in interface ContextI

popLevel

public void popLevel()
Description copied from interface: NamespaceStackI
Pops the element level up one to undeclare namespaces whose scope is done.

Specified by:
popLevel in interface ContextI

setEntity

public void setEntity(java.lang.String name,
                      java.lang.String value)
Description copied from interface: ContextI
Establishes an entity name-value relationship. The value must be provided directly and not by reference.

Specified by:
setEntity in interface ContextI
Parameters:
name - name of the entity
value - value of the entity

resolveEntity

public java.lang.String resolveEntity(java.lang.String entName)
Description copied from interface: ContextI
Resolves an entity, hexRef, or decRef.

Specified by:
resolveEntity in interface ContextI
Parameters:
entName - the name of the entity or ref, minus the & and ;
Returns:
a string containing either the entity or hex/dec processing result

isSpace

public boolean isSpace(char c)
Reports whether the character c is whitespace or not.

Specified by:
isSpace in interface ContextI
Parameters:
c - a character to test
Returns:
true if it's whitespace, false if it's not

reset

public void reset()
Description copied from interface: NamespaceStackI
clear everything in the namespace stack

Specified by:
reset in interface ContextI

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exception