org.apache.ecs
Class GenericElement

java.lang.Object
  |
  +--org.apache.ecs.GenericElement
All Implemented Interfaces:
Element, ElementRegistry, java.io.Serializable
Direct Known Subclasses:
ElementAttributes

public abstract class GenericElement
extends java.lang.Object
implements Element, java.io.Serializable

This class implements the ElementFactory.

Version:
$Id: GenericElement.java,v 1.21 2003/04/27 09:45:34 rdonkin Exp $
Author:
Stephan Nagy, Jon S. Stevens
See Also:
Serialized Form

Field Summary
private  java.lang.String __text
           
private static Filter _defaultFilter
          Create default filter to use in all GenericElements Can be overridden by setFilter method.
private  char begin_end_modifier
          What the end modifier should be
private  boolean begin_end_modifier_defined
          What the modifier should be...optimization variable
private  char begin_start_modifier
          What the start modifier should be
private  boolean begin_start_modifier_defined
          What the modifier should be...optimization variable
private  int case_type
          Default value to set case type
private  java.lang.String codeset
          What codeset are we going to use the default is 8859_1
private  java.util.Hashtable element
          Where to get the element definition from
private  java.lang.String element_type
          Location to store element_type at.
private  boolean end_element
          Does this element need a closing tag?
private  char end_end_modifier
          What the end modifier should be
private  boolean end_end_modifier_defined
          What the modifier should be...optimization variable
private  boolean end_modifier_defined
          What the modifier should be...optimization variable
private  char end_start_modifier
          What the start modifier should be
private  boolean end_start_modifier_defined
          What the modifier should be...optimization variable
private  char end_tag
           
private  Filter filter
          Filter to use to escape input
private  boolean filter_state
          Should we filter the value of <>VALUE</>
private  int position
          position of tag relative to start and end.
private  boolean pretty_print
          Should we print html in a more readable format?
private  boolean start_modifier_defined
          What the modifier should be...optimization variable
private  char start_tag
           
protected  int tabLevel
          Our current tab level.
private static java.lang.String VERSION
          Version number for codebase
 
Fields inherited from interface org.apache.ecs.Element
CENTER, LEFT, LOWERCASE, MIXEDCASE, RIGHT, UPPERCASE
 
Constructor Summary
GenericElement()
          Base class for defining all elements.
 
Method Summary
protected  java.lang.String alterCase(java.lang.String value)
          Alter the case of this element so that it is rendered according to whatever the value of case_type is.
 java.lang.String createEndTag()
           
 java.lang.String createStartTag()
           
 char getBeginEndModifier()
          What is the element modifier for this tag.
protected  boolean getBeginEndModifierDefined()
          Modifier optimization
 char getBeginStartModifier()
          What is the element modifier for this tag.
protected  boolean getBeginStartModifierDefined()
          Modifier optimization
 int getCase()
          Find out what case the element is supposed to be rendered in.
 java.lang.String getCodeSet()
          Find out what the current codeset is.
protected  java.util.Hashtable getElementHashEntry()
          Get the Hashtable representation of an element.
 java.lang.String getElementType()
          Find out what type of element this is.
 char getEndEndModifier()
          What is the element modifier for this tag.
protected  boolean getEndEndModifierDefined()
          Modifier optimization
 char getEndStartModifier()
          What is the element modifier for this tag.
protected  boolean getEndStartModifierDefined()
          Modifier optimization
 char getEndTagChar()
          Get the end tag character.
 Filter getFilter()
          Get the filter that is currently in use.
 boolean getFilterState()
          get the filter state of the element.
 boolean getNeedClosingTag()
          Determine if this element needs to be closed.
 boolean getNeedLineBreak()
          Determine if this element needs a line break, if pretty printing.
 boolean getPrettyPrint()
          Do we want to do pretty printing?
 char getStartTagChar()
          Get the start tag character.
 int getTabLevel()
          Get the tab level for pretty printing.
 int getTagPosition()
          Get the position the tag is to be rendered at.
 java.lang.String getTagText()
           
 java.lang.String getVersion()
          What version of htmlGen is this?
 void output(java.io.OutputStream out)
          Add the element to the designated OutputStream.
 void output(java.io.PrintWriter out)
          Add element to the designated PrintWriter.
 void output(java.io.Writer out)
          Writer version of this method.
protected  void putTabs(int tabCount, java.io.OutputStream out)
           
protected  void putTabs(int tabCount, java.io.PrintWriter out)
           
 Element removeBeginEndModifier()
          Remove the element modifier for this tag.
 Element removeBeginStartModifier()
          Remove the element modifier for this tag.
 Element removeEndEndModifier()
          Remove the element modifier for this tag.
 Element removeEndStartModifier()
          Remove the element modifier for this tag.
 Element setBeginEndModifier(char modifier)
          Set the element modifier the default is no modifier.
private  void setBeginEndModifierDefined(boolean val)
          Modifier optimization
 Element setBeginModifier(char modifier)
          Set the element modifier the default is no modifier.
 Element setBeginModifier(char start_modifier, char end_modifier)
          Set the element modifier the default is no modifier.
 Element setBeginStartModifier(char modifier)
          Set the element modifier the default is no modifier.
private  void setBeginStartModifierDefined(boolean val)
          Modifier optimization
 void setCase(int case_type)
          Determine what case the html element should be rendered.
 void setCodeSet(java.lang.String codeset)
          Determine what codeset should be used.
 void setElementType(java.lang.String element_type)
          Determine what type of element this is A,BR,EM,ACRONYM
 Element setEndEndModifier(char modifier)
          Set the element modifier the default is no modifier.
private  void setEndEndModifierDefined(boolean val)
          Modifier optimization
 Element setEndModifier(char modifier)
          Set the element modifier the default is no modifier.
 Element setEndModifier(char start_modifier, char end_modifier)
          Set the element modifier the default is no modifier.
 Element setEndStartModifier(char modifier)
          Set the element modifier the default is no modifier.
private  void setEndStartModifierDefined(boolean val)
          Modifier optimization
 void setEndTagChar(char end_tag)
          Set the end tag character.
 void setFilter(Filter filter)
          Override the default filter with a user supplied filter.
 Element setFilterState(boolean filter_state)
          set the filter state of the element.
 void setNeedClosingTag(boolean close)
          Does this element need a closing tag.
 Element setPrettyPrint(boolean pretty_print)
          Do we want to pretty print?
 void setStartTagChar(char start_tag)
          Set the start tag character.
 void setTabLevel(int tabLevel)
          Set the tab level for pretty printing
 void setTagPosition(int position)
          Set the position of the tag to be rendered at in relation to start_element_char
 Element setTagText(java.lang.String text)
           
 java.lang.String toString()
          Override toString() method to print something meaningful
 java.lang.String toString(java.lang.String codeset)
          Override toString(encode) method to print something meaningful
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface org.apache.ecs.ElementRegistry
addElementToRegistry, addElementToRegistry, registryHasElement, registryHasElement, removeElementFromRegistry, removeElementFromRegistry
 

Field Detail

_defaultFilter

private static Filter _defaultFilter
Create default filter to use in all GenericElements Can be overridden by setFilter method. Of course using getFilter then modifying will have some interesting side effects, like changing the global defaults.

filter

private Filter filter
Filter to use to escape input

position

private int position
position of tag relative to start and end.

filter_state

private boolean filter_state
Should we filter the value of <>VALUE</>

pretty_print

private boolean pretty_print
Should we print html in a more readable format?

VERSION

private static final java.lang.String VERSION
Version number for codebase

case_type

private int case_type
Default value to set case type

element

private java.util.Hashtable element
Where to get the element definition from

end_element

private boolean end_element
Does this element need a closing tag?

codeset

private java.lang.String codeset
What codeset are we going to use the default is 8859_1

begin_start_modifier

private char begin_start_modifier
What the start modifier should be

end_start_modifier

private char end_start_modifier
What the start modifier should be

begin_end_modifier

private char begin_end_modifier
What the end modifier should be

end_end_modifier

private char end_end_modifier
What the end modifier should be

start_modifier_defined

private boolean start_modifier_defined
What the modifier should be...optimization variable

begin_start_modifier_defined

private boolean begin_start_modifier_defined
What the modifier should be...optimization variable

end_start_modifier_defined

private boolean end_start_modifier_defined
What the modifier should be...optimization variable

begin_end_modifier_defined

private boolean begin_end_modifier_defined
What the modifier should be...optimization variable

end_end_modifier_defined

private boolean end_end_modifier_defined
What the modifier should be...optimization variable

end_modifier_defined

private boolean end_modifier_defined
What the modifier should be...optimization variable

tabLevel

protected int tabLevel
Our current tab level.

start_tag

private char start_tag

end_tag

private char end_tag

__text

private java.lang.String __text

element_type

private java.lang.String element_type
Location to store element_type at.
Constructor Detail

GenericElement

public GenericElement()
Base class for defining all elements.
Method Detail

getPrettyPrint

public boolean getPrettyPrint()
Do we want to do pretty printing?
Specified by:
getPrettyPrint in interface Element

setPrettyPrint

public Element setPrettyPrint(boolean pretty_print)
Do we want to pretty print?
Specified by:
setPrettyPrint in interface Element
Parameters:
pretty_print - turn pretty printing on or off.

getElementHashEntry

protected java.util.Hashtable getElementHashEntry()
Get the Hashtable representation of an element.

setFilterState

public Element setFilterState(boolean filter_state)
set the filter state of the element.
Specified by:
setFilterState in interface Element
Parameters:
filter_state - (true|false) do we want to use a filter? default true;

getFilterState

public boolean getFilterState()
get the filter state of the element.
Specified by:
getFilterState in interface Element

getFilter

public Filter getFilter()
Get the filter that is currently in use.

setFilter

public void setFilter(Filter filter)
Override the default filter with a user supplied filter.

getVersion

public java.lang.String getVersion()
What version of htmlGen is this?
Specified by:
getVersion in interface Element

setCase

public void setCase(int case_type)
Determine what case the html element should be rendered. Default is MIXEDCASE
Specified by:
setCase in interface Element

getCase

public int getCase()
Find out what case the element is supposed to be rendered in.
Specified by:
getCase in interface Element

setElementType

public void setElementType(java.lang.String element_type)
Determine what type of element this is A,BR,EM,ACRONYM
Specified by:
setElementType in interface Element

getElementType

public java.lang.String getElementType()
Find out what type of element this is.
Specified by:
getElementType in interface Element

setCodeSet

public void setCodeSet(java.lang.String codeset)
Determine what codeset should be used.

getCodeSet

public java.lang.String getCodeSet()
Find out what the current codeset is.

setNeedClosingTag

public void setNeedClosingTag(boolean close)
Does this element need a closing tag. Default is true
Specified by:
setNeedClosingTag in interface Element

getNeedClosingTag

public boolean getNeedClosingTag()
Determine if this element needs to be closed.
Specified by:
getNeedClosingTag in interface Element

getNeedLineBreak

public boolean getNeedLineBreak()
Determine if this element needs a line break, if pretty printing.
Specified by:
getNeedLineBreak in interface Element

setTagPosition

public void setTagPosition(int position)
Set the position of the tag to be rendered at in relation to start_element_char
Specified by:
setTagPosition in interface Element

getTagPosition

public int getTagPosition()
Get the position the tag is to be rendered at.
Specified by:
getTagPosition in interface Element

alterCase

protected java.lang.String alterCase(java.lang.String value)
Alter the case of this element so that it is rendered according to whatever the value of case_type is. Default is MIXEDCASE

setBeginModifier

public Element setBeginModifier(char modifier)
Set the element modifier the default is no modifier.
Parameters:
modifier - the modifier for the element a ? would result
in <? ?>

setBeginStartModifier

public Element setBeginStartModifier(char modifier)
Set the element modifier the default is no modifier.
Specified by:
setBeginStartModifier in interface Element
Parameters:
modifier - the modifier for the element a ? would result
in <? >

setBeginEndModifier

public Element setBeginEndModifier(char modifier)
Set the element modifier the default is no modifier.
Specified by:
setBeginEndModifier in interface Element
Parameters:
modifier - the modifier for the element a ? would result
in < ?>

setBeginModifier

public Element setBeginModifier(char start_modifier,
                                char end_modifier)
Set the element modifier the default is no modifier.
Parameters:
modifier - the modifier for the element a ? would result
in <? ?>

getBeginStartModifier

public char getBeginStartModifier()
What is the element modifier for this tag.
Specified by:
getBeginStartModifier in interface Element

getBeginEndModifier

public char getBeginEndModifier()
What is the element modifier for this tag.
Specified by:
getBeginEndModifier in interface Element

removeBeginStartModifier

public Element removeBeginStartModifier()
Remove the element modifier for this tag.

removeBeginEndModifier

public Element removeBeginEndModifier()
Remove the element modifier for this tag.

setBeginStartModifierDefined

private void setBeginStartModifierDefined(boolean val)
Modifier optimization

setBeginEndModifierDefined

private void setBeginEndModifierDefined(boolean val)
Modifier optimization

getEndStartModifierDefined

protected boolean getEndStartModifierDefined()
Modifier optimization

getEndEndModifierDefined

protected boolean getEndEndModifierDefined()
Modifier optimization

setEndModifier

public Element setEndModifier(char modifier)
Set the element modifier the default is no modifier.
Parameters:
modifier - the modifier for the element a ? would result
in <? ?>

setEndStartModifier

public Element setEndStartModifier(char modifier)
Set the element modifier the default is no modifier.
Specified by:
setEndStartModifier in interface Element
Parameters:
modifier - the modifier for the element a ? would result
in <? >

setEndEndModifier

public Element setEndEndModifier(char modifier)
Set the element modifier the default is no modifier.
Specified by:
setEndEndModifier in interface Element
Parameters:
modifier - the modifier for the element a ? would result
in < ?>

setEndModifier

public Element setEndModifier(char start_modifier,
                              char end_modifier)
Set the element modifier the default is no modifier.
Parameters:
modifier - the modifier for the element a ? would result
in <? ?>

getEndStartModifier

public char getEndStartModifier()
What is the element modifier for this tag.
Specified by:
getEndStartModifier in interface Element

getEndEndModifier

public char getEndEndModifier()
What is the element modifier for this tag.
Specified by:
getEndEndModifier in interface Element

removeEndStartModifier

public Element removeEndStartModifier()
Remove the element modifier for this tag.

removeEndEndModifier

public Element removeEndEndModifier()
Remove the element modifier for this tag.

setEndStartModifierDefined

private void setEndStartModifierDefined(boolean val)
Modifier optimization

setEndEndModifierDefined

private void setEndEndModifierDefined(boolean val)
Modifier optimization

getBeginStartModifierDefined

protected boolean getBeginStartModifierDefined()
Modifier optimization

getBeginEndModifierDefined

protected boolean getBeginEndModifierDefined()
Modifier optimization

setStartTagChar

public void setStartTagChar(char start_tag)
Set the start tag character.
Specified by:
setStartTagChar in interface Element

getStartTagChar

public char getStartTagChar()
Get the start tag character.
Specified by:
getStartTagChar in interface Element

setEndTagChar

public void setEndTagChar(char end_tag)
Set the end tag character.
Specified by:
setEndTagChar in interface Element

getEndTagChar

public char getEndTagChar()
Get the end tag character.
Specified by:
getEndTagChar in interface Element

getTagText

public java.lang.String getTagText()

setTagText

public Element setTagText(java.lang.String text)

createStartTag

public java.lang.String createStartTag()

createEndTag

public java.lang.String createEndTag()

toString

public final java.lang.String toString()
Override toString() method to print something meaningful
Overrides:
toString in class java.lang.Object

toString

public final java.lang.String toString(java.lang.String codeset)
Override toString(encode) method to print something meaningful

output

public void output(java.io.OutputStream out)
Add the element to the designated OutputStream.
Specified by:
output in interface Element

output

public void output(java.io.PrintWriter out)
Add element to the designated PrintWriter.
Specified by:
output in interface Element

output

public void output(java.io.Writer out)
Writer version of this method.

setTabLevel

public void setTabLevel(int tabLevel)
Set the tab level for pretty printing
Specified by:
setTabLevel in interface Element

getTabLevel

public int getTabLevel()
Description copied from interface: Element
Get the tab level for pretty printing.
Specified by:
getTabLevel in interface Element

putTabs

protected void putTabs(int tabCount,
                       java.io.OutputStream out)
                throws java.io.IOException

putTabs

protected void putTabs(int tabCount,
                       java.io.PrintWriter out)


Copyright © 1999-2003 Apache Software Foundation. All Rights Reserved.