PAJES 2.3.9

org.pajes.html
Class Container

java.lang.Object
  extended byorg.pajes.html.Tag
      extended byorg.pajes.html.TraversableElement
          extended byorg.pajes.html.Container
All Implemented Interfaces:
java.lang.Cloneable, HTML, java.io.Serializable, Traversable
Direct Known Subclasses:
Applet, Body, Center, Div, Form, FormattedText, Head, IFrame, Label, ListContainer, NoBreak, NoFrames, NoScript, OptionGroup, Paje, Paragraph, Script, Span, StyleSheet, TableContainer

public class Container
extends TraversableElement

The base class for all HTML objects that contain other HTML objects. Also used by utility sub-classes that may or may not end up in a specified container.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.pajes.html.Tag
ON_CLICK_ATTRIBUTE, TAG_CLOSE, TAG_LEFT, TAG_RIGHT
 
Constructor Summary
Container()
          Creates an empty Container.
Container(java.lang.String name)
          Creates an empty Container.
 
Method Summary
 Container add(HTML htmlObject)
          Adds an HTML object to the current container
 Container add(java.lang.String htmlCodeOrString)
          Adds a string or piece of HTML code to the current container.
 Container add(java.lang.String htmlCodeOrString, boolean suppressNewLine)
          Adds a string or piece of HTML code to the current container
 Container add(java.lang.String htmlCodeOrString, boolean suppressNewLine, boolean encode)
          Adds a string or piece of HTML code to the current container
 void addContent(java.lang.String content)
          Adds the specified String to this container.
 Container clear()
          Empties the container.
 java.lang.Object clone()
          Allows a tag to be cloned.
 Container delete(int position)
          Deletes the HTML object at a specified position in the container.
 Container delete(java.lang.Object htmlObject)
          Deletes the specified HTML object from the container.
 void destroy()
          Loops through the container and retrieves each object contained within it and then invokes that objects destroy method.
 HTML get(int position)
          Gets the HTML object from the specified position in the container.
 HTML getContent()
          Returns the content in this container.
 java.lang.String getContents()
          Returns the contents of this container as a String, without any enclosing container specific tags.
 int getPosition(HTML htmlObject)
          Returns the position of the specified HTML object in the container.
 Container insert(HTML htmlObject, int position)
          Inserts an HTML object at a specified position in the container.
 Container replace(Container container)
          Deletes all the objects in this container, and replaces them with the cloned objects from another container.
 Traversable set(HTML htmlObject, int position)
          Sets an HTML object at a specified position in the container.
 void setContent(HTML html)
          Clears the contents of this container, and then adds the specified HTML as the only content.
 void setContent(java.lang.String content)
          Clears the contents of this container, and then adds the specified String as the only content.
 int size()
          Returns the number of HTML objects contained within this object.
protected  void writeContent(Browser browser)
          Loops through the container and gets each object contained within it and invokes that objects write method.
 
Methods inherited from class org.pajes.html.TraversableElement
dump, dump, getAll, getFieldByName, getFirstFieldByName, getFirstTagByAttribute, getFirstTagByClass, getFirstTagByID, getFirstTagByName, getTagByAttribute, getTagByClass, getTagByID, getTagByName, setWritable
 
Methods inherited from class org.pajes.html.Tag
addAttribute, addAttributes, addAttributes, clearAttribute, clearAttributes, getAttribute, getAttributes, getAttributeSet, getContainer, getDocument, getId, getOnClickHandler, getOnDBLClickHandler, getOnKeyDownHandler, getOnKeyPressHandler, getOnKeyUpHandler, getOnMouseDownHandler, getOnMouseOutHandler, getOnMouseOverHandler, getOnMouseUpHandler, getStyle, getStyleSheetClass, getTagName, getTitle, getWritePermission, init, initAttributes, isWritable, isWritable, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setContainer, setId, setOnClickHandler, setOnDBLClickHandler, setOnKeyDownHandler, setOnKeyPressHandler, setOnKeyUpHandler, setOnMouseDownHandler, setOnMouseOutHandler, setOnMouseOverHandler, setOnMouseUpHandler, setStyle, setStyleSheetClass, setTagName, setTitle, setWritable, setWriteAttributes, setWriteEndTag, setWritelnAfter, setWritelnAfterContent, setWritelnBefore, setWritelnBeforeContent, setWritePermission, toString, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Container

public Container(java.lang.String name)
Creates an empty Container.

Parameters:
name - the tag name.

Container

public Container()
Creates an empty Container.

Method Detail

setContent

public void setContent(HTML html)
Clears the contents of this container, and then adds the specified HTML as the only content.

Overrides:
setContent in class Tag
Parameters:
html - the content of this Container.
See Also:
clear(), add(HTML), getContent()

setContent

public void setContent(java.lang.String content)
Clears the contents of this container, and then adds the specified String as the only content.

Specified by:
setContent in interface HTML
Overrides:
setContent in class Tag
Parameters:
content - the content of this Container.
See Also:
clear(), add(java.lang.String), getContent()

getContent

public HTML getContent()
Returns the content in this container.

Overrides:
getContent in class Tag
Returns:
the contents of this container.
See Also:
setContent(HTML), setContent(String)

getContents

public java.lang.String getContents()
Returns the contents of this container as a String, without any enclosing container specific tags.

Returns:
the contents of this container as a String.

getPosition

public int getPosition(HTML htmlObject)
Returns the position of the specified HTML object in the container. If the specified object occurs mulitple times in the container, only the position of the first instance will be returned.

Parameters:
htmlObject - - the Object to locate
Returns:
the position of the object, or -1 if it is not found.

add

public Container add(HTML htmlObject)
Adds an HTML object to the current container

Parameters:
htmlObject - - the Object to add (eg. doc.add(new htmlBody);)
Returns:
the modified Container object;
Throws:
TagException - if an attempt is made to add an invalid object to the container.

add

public Container add(java.lang.String htmlCodeOrString)
Adds a string or piece of HTML code to the current container.

Parameters:
htmlCodeOrString -
Returns:
the modified Container object.

add

public Container add(java.lang.String htmlCodeOrString,
                     boolean suppressNewLine)
Adds a string or piece of HTML code to the current container

Parameters:
htmlCodeOrString -
suppressNewLine - suppresses a new line after the text.
Returns:
the modified Container object.

add

public Container add(java.lang.String htmlCodeOrString,
                     boolean suppressNewLine,
                     boolean encode)
Adds a string or piece of HTML code to the current container

Parameters:
htmlCodeOrString -
suppressNewLine - suppresses a new line after the text.
encode - true if any special HTML characters in the text are to be converted to their equivalent HTML named character entity, or false if no changes are to be made to the text.
Returns:
the modified Container object.

addContent

public void addContent(java.lang.String content)
Adds the specified String to this container.

Specified by:
addContent in interface HTML
Overrides:
addContent in class Tag
Parameters:
content - the additonal content for this Container.
See Also:
add(java.lang.String), setContent(java.lang.String)

clear

public Container clear()
Empties the container.

Returns:
The modified Container instance.

clone

public java.lang.Object clone()
Allows a tag to be cloned. Over-rides the clone() method in Tag to do a deep clone: all the objects contained in this object will be cloned individually.

Specified by:
clone in interface HTML
Overrides:
clone in class Tag
Returns:
a clone of this Container.

delete

public Container delete(int position)
Deletes the HTML object at a specified position in the container.

Parameters:
position - the position in the container of the object to be deleted.
Returns:
the modified Container object.

delete

public Container delete(java.lang.Object htmlObject)
Deletes the specified HTML object from the container.

Parameters:
htmlObject - the object to be deleted.
Returns:
the modified Container object.

destroy

public void destroy()
Loops through the container and retrieves each object contained within it and then invokes that objects destroy method. It then clears all internal variables.

Sub-classes MUST call super.destroy(); if over-riding this method!

Specified by:
destroy in interface HTML
Overrides:
destroy in class Tag

get

public HTML get(int position)
Gets the HTML object from the specified position in the container.

Parameters:
position - the position to get the html object
Returns:
the object at the specified location

insert

public Container insert(HTML htmlObject,
                        int position)
Inserts an HTML object at a specified position in the container.

Parameters:
htmlObject - - the Object to add (eg. doc.add(new htmlBody);)
position - - the position to place the html object
Returns:
the modified Container object.

replace

public Container replace(Container container)
Deletes all the objects in this container, and replaces them with the cloned objects from another container.

Parameters:
container - the Container from which objects are to be copied.
Returns:
the modified Container object.

set

public Traversable set(HTML htmlObject,
                       int position)
Sets an HTML object at a specified position in the container.

Parameters:
htmlObject - the Object to add.
position - the position at which to place the html object.
Returns:
the modified Traversable object.

size

public int size()
Returns the number of HTML objects contained within this object.

Returns:
the number of HTML objects contained within this object.

writeContent

protected void writeContent(Browser browser)
                     throws java.io.IOException
Loops through the container and gets each object contained within it and invokes that objects write method.

Overrides:
writeContent in class Tag
Parameters:
browser - the browser to which the results are to be output.
Throws:
java.io.IOException - if an I/O error occurs writing to the browser.
See Also:
Tag.setWriteEndTag(boolean)

PAJES 2.3.9

Copyright © 2002-2003 Viridian Pty Limited. All Rights Reserved.