com.guiseframework.platform
Class AbstractTextDepictContext

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.platform.AbstractDepictContext
          extended by com.guiseframework.platform.AbstractTextDepictContext
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, DepictContext, TextDepictContext
Direct Known Subclasses:
AbstractXMLDepictContext

public abstract class AbstractTextDepictContext
extends AbstractDepictContext
implements TextDepictContext

Abstract encapsulation of text information related to the current depiction.

Author:
Garret Wilson

Field Summary
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Constructor Summary
AbstractTextDepictContext(GuiseSession session, Destination destination)
          Guise session constructor.
 
Method Summary
 void clearDepictText()
          Clears all data collected for depiction.
protected  java.lang.String encode(java.lang.String string)
          Encodes text information for writing.
 java.lang.StringBuilder getDepictStringBuilder()
          The string builder that holds the current content being collected, though not necessarily all the content collected.
 java.lang.String getDepictText()
           
 int getIndentLevel()
           
 void indent()
          Increments the indent level.
 void indent(int indentDelta)
          Changes the indent level by the given amount.
 boolean isFormatted()
           
 void setIndentLevel(int newIndentLevel)
          Sets the level of text indentation.
 void unindent()
          Decrements the indent level.
 void write(char character)
          Writes a character, encoding it as necessary.
 void write(java.lang.String text)
          Writes text, encoding it as necessary.
 void writeIndent()
          Writes an indention at the current indention level.
 void writeLiteral(java.lang.String text)
          Writes literal text with no encoding.
 
Methods inherited from class com.guiseframework.platform.AbstractDepictContext
getDepictionURI, getDepictionURI, getDestination, getPlatform, getSession, getStyles
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.guiseframework.platform.TextDepictContext
getOutputCharacterEncoding, getOutputContentType, setOutputContentType
 
Methods inherited from interface com.guiseframework.platform.DepictContext
getDepictionURI, getDepictionURI, getDepictionURI, getDestination, getPlatform, getSession, getStyles
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

AbstractTextDepictContext

public AbstractTextDepictContext(GuiseSession session,
                                 Destination destination)
                          throws java.io.IOException
Guise session constructor.

Parameters:
session - The Guise user session of which this context is a part.
destination - The destination with which this context is associated.
Throws:
java.lang.NullPointerException - if the given session and/or destination is null.
java.io.IOException - If there was an I/O error loading a needed resource.
Method Detail

getDepictStringBuilder

public java.lang.StringBuilder getDepictStringBuilder()
The string builder that holds the current content being collected, though not necessarily all the content collected. The string builder returned is appropriate for adding content, but may not be a complete representation of all the text collected.

Specified by:
getDepictStringBuilder in interface TextDepictContext
Returns:
The string builder that holds the current content being collected for depiction.

clearDepictText

public void clearDepictText()
Clears all data collected for depiction.

Specified by:
clearDepictText in interface TextDepictContext

getDepictText

public java.lang.String getDepictText()
Specified by:
getDepictText in interface TextDepictContext
Returns:
The string that holds the current content being collected for depiction.

isFormatted

public boolean isFormatted()
Specified by:
isFormatted in interface TextDepictContext
Returns:
Whether output should be formatted. This version returns true.

getIndentLevel

public int getIndentLevel()
Specified by:
getIndentLevel in interface TextDepictContext
Returns:
The zero-based level of text indentation.

setIndentLevel

public void setIndentLevel(int newIndentLevel)
Sets the level of text indentation.

Specified by:
setIndentLevel in interface TextDepictContext
Parameters:
newIndentLevel - The new zero-based level of text indention.

indent

public void indent(int indentDelta)
Changes the indent level by the given amount.

Specified by:
indent in interface TextDepictContext
Parameters:
indentDelta - The amount by which to increase or decrease the indent level.
See Also:
getIndentLevel(), setIndentLevel(int)

indent

public void indent()
Increments the indent level.

Specified by:
indent in interface TextDepictContext
See Also:
indent(int)

unindent

public void unindent()
Decrements the indent level.

Specified by:
unindent in interface TextDepictContext
See Also:
indent(int)

writeLiteral

public void writeLiteral(java.lang.String text)
                  throws java.io.IOException
Writes literal text with no encoding. All writing by the controller should use this method.

Specified by:
writeLiteral in interface TextDepictContext
Parameters:
text - The literal text to write.
Throws:
java.io.IOException - if there is an error writing the information.

write

public void write(char character)
           throws java.io.IOException
Writes a character, encoding it as necessary. This method calls writeLiteral(String).

Specified by:
write in interface TextDepictContext
Parameters:
character - The character to write.
Throws:
java.io.IOException - if there is an error writing the information.
See Also:
#encode(StringBuilder)

write

public void write(java.lang.String text)
           throws java.io.IOException
Writes text, encoding it as necessary. This method calls writeLiteral(String).

Specified by:
write in interface TextDepictContext
Parameters:
text - The text to write.
Throws:
java.io.IOException - if there is an error writing the information.
See Also:
#encode(StringBuilder)

encode

protected java.lang.String encode(java.lang.String string)
Encodes text information for writing. This method uses a string parameter so that no processing need occur if no characters need encoded. This version does no processing of the text.

Parameters:
string - The text information to encode.
Returns:
The encoded text.

writeIndent

public void writeIndent()
                 throws java.io.IOException
Writes an indention at the current indention level. If the context is not formatted, no action occurs.

Specified by:
writeIndent in interface TextDepictContext
Throws:
java.io.IOException - if there is an error writing the information.
See Also:
isFormatted(), getIndentLevel()


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.