PAJES 2.3.9

org.pajes.util
Class QuotedString

java.lang.Object
  extended byorg.pajes.util.QuotedString

public class QuotedString
extends java.lang.Object

Utility class for returning an appropriately constructed and escaped quoted string.


Field Summary
static char DOUBLE_QUOTE
          The double quote character (")
static char SINGLE_QUOTE
          The single quote character (')
 
Constructor Summary
QuotedString()
          Creates an empty quoted string.
QuotedString(java.lang.String unquotedString)
          Creates a string surrounded with appropriate quote characters.
QuotedString(java.lang.String unquotedString, boolean doubleQuotes)
          Creates a string surrounded by the specifed quotes.
QuotedString(java.lang.String unquotedString, boolean doubleQuotes, boolean replaceQuotes)
          Creates a string surrounded by the specifed quotes.
 
Method Summary
 QuotedString setAutoQuotes()
          Specifies that the string will be surrounded with appropriate quote characters.
 QuotedString setDoubleQuotes()
          Specifies that the string must be enclosed in double quotes.
 QuotedString setEncodeCharacterEntities(boolean encode)
          Determines whether any special HTML characters in the text are to be converted to their equivalent HTML named character entity.
 QuotedString setEscapeCharacter(char escapeCharacter)
          Sets the escape character to prefix a quote contained within the quoted string.
 QuotedString setReplaceQuotes(boolean replace)
          Determines whether any quotes within the string are to be replaced with the alternate quoting character.
 QuotedString setSingleQuotes()
          Specifies that the string must be enclosed in single quotes.
 QuotedString setString(java.lang.String unquotedString)
          Specifies the unquoted string to be placed in quotes.
 java.lang.String toString()
          Over-rides the toString() method from Object to return the unquoted string appropriately quoted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DOUBLE_QUOTE

public static final char DOUBLE_QUOTE
The double quote character (")

See Also:
Constant Field Values

SINGLE_QUOTE

public static final char SINGLE_QUOTE
The single quote character (')

See Also:
Constant Field Values
Constructor Detail

QuotedString

public QuotedString()
Creates an empty quoted string.


QuotedString

public QuotedString(java.lang.String unquotedString)
Creates a string surrounded with appropriate quote characters. Any quotes within the string will be determine the enclosing quote character. If the string contains single quote (') characters, it will be surrounded with double quote (") characters, and vice-versa.

If the string contains both single and double quote characters, the string will be enclosed in single quotes ('), and any single quotes in the string will be prefixed by the escape character.

Parameters:
unquotedString - the string that is to be enclosed in quotes.

QuotedString

public QuotedString(java.lang.String unquotedString,
                    boolean doubleQuotes)
Creates a string surrounded by the specifed quotes. Any quotes within the string will be prefixed by the escape character.

Parameters:
unquotedString - the string that is to be enclosed in quotes.
doubleQuotes - true if the string is to be enclosed in double quote characters ("), or false if single quotes (') are to be used.

QuotedString

public QuotedString(java.lang.String unquotedString,
                    boolean doubleQuotes,
                    boolean replaceQuotes)
Creates a string surrounded by the specifed quotes. Any quotes within the string are replaced with the alternate quoting character.

Parameters:
unquotedString - the string that is to be enclosed in quotes.
doubleQuotes - true if the string is the be enclosed in double quote characters ("), or false if single quotes (') are to be used.
replaceQuotes - true means that any quotes within the string will be replaced by the alternate quote character before enclosing the value in quotes.
Method Detail

setAutoQuotes

public QuotedString setAutoQuotes()
Specifies that the string will be surrounded with appropriate quote characters. Any quotes within the string will be determine the enclosing quote character. If the string contains single quote (') characters, it will be surrounded with double quote (") characters, and vice-versa.

Returns:
the modified QuotedString object.

setDoubleQuotes

public QuotedString setDoubleQuotes()
Specifies that the string must be enclosed in double quotes.

Returns:
the modified QuotedString object.

setEncodeCharacterEntities

public QuotedString setEncodeCharacterEntities(boolean encode)
Determines whether any special HTML characters in the text are to be converted to their equivalent HTML named character entity. The default setting is false for historical compatability.

Parameters:
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 QuotedString object.
See Also:
Text.encodeCharacterEntities(java.lang.String)

setEscapeCharacter

public QuotedString setEscapeCharacter(char escapeCharacter)
Sets the escape character to prefix a quote contained within the quoted string. The default escape character is a slash (\).

Parameters:
escapeCharacter - the character to use to escape any quotes found within the qouted string.
Returns:
the modified QuotedString object.

setReplaceQuotes

public QuotedString setReplaceQuotes(boolean replace)
Determines whether any quotes within the string are to be replaced with the alternate quoting character.

Parameters:
replace - true means that any quotes within the string will be replaced by the alternate quote character before enclosing the value in quotes.
Returns:
the modified QuotedString object.

setSingleQuotes

public QuotedString setSingleQuotes()
Specifies that the string must be enclosed in single quotes.

Returns:
the modified QuotedString object.

setString

public QuotedString setString(java.lang.String unquotedString)
Specifies the unquoted string to be placed in quotes.

Parameters:
unquotedString - the string that is to be enclosed in quotes.
Returns:
the modified QuotedString object.

toString

public java.lang.String toString()
Over-rides the toString() method from Object to return the unquoted string appropriately quoted.

Returns:
the quoted string.

PAJES 2.3.9

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