org.norther.tammi.acorn.lang
Class XMLString

java.lang.Object
  extended by org.norther.tammi.acorn.lang.XMLString
All Implemented Interfaces:
Serializable, CharSequence

public class XMLString
extends Object
implements CharSequence, Serializable

A string representation of XML text encoding all string input except tags with specific methods.

Note that character level modifications may break the encoding.

Version:
$Id: XMLString.java,v 1.5 2009/09/28 15:08:49 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static String BR
          The XHTML line break tag.
static String NBSP
          The XHTML space reference.
 
Constructor Summary
XMLString()
          Constructs a new string.
XMLString(CharSequence seq)
          Constructs a new string for the specified char sequence.
XMLString(CharSequence seq, String delim)
          Constructs a new string for the specified char sequence with a line delimiter.
XMLString(int capacity)
          Constructs a new string of the specified capacity.
XMLString(int capacity, String delim)
          Constructs a new string of the specified capacity and line delimiter.
XMLString(String delim)
          Constructs a new string with a line delimiter.
 
Method Summary
 XMLString append(boolean b)
          Appends a boolean argument.
 XMLString append(char c)
          Appends a char argument.
 XMLString append(char[] chars)
          Appends a char array argument.
 XMLString append(char[] chars, int index, int len)
          Appends a char array argument.
 XMLString append(CharSequence s)
          Appends a char sequence argument.
 XMLString append(CharSequence s, int start, int end)
          Appends a char sequence argument.
 XMLString append(double d)
          Appends a double argument.
 XMLString append(float f)
          Appends a float argument.
 XMLString append(int i)
          Appends an int argument.
 XMLString append(long l)
          Appends a long argument.
 XMLString append(Object obj)
          Appends an object argument.
 XMLString append(String str)
          Appends a string argument.
 XMLString append(StringBuffer sb)
          Appends a string buffer argument.
 XMLString appendTag(CharSequence tag)
          Appends a tag argument without encoding.
 int capacity()
          Returns the capacity.
 char charAt(int index)
           
 XMLString delete(int start, int end)
          Deletes a sequense.
 XMLString deleteCharAt(int index)
          Deletes a character.
 void ensureCapacity(int minimumCapacity)
          Ensures a capacity.
 boolean equals(Object other)
           
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
          Gets characters.
 String getLineDelimiter()
          Gets the line delimiter to apply.
 int hashCode()
           
 int indexOf(String str)
          Returns the index of the specified substring.
 int indexOf(String str, int fromIndex)
          Returns the index of the specified substring.
 XMLString insert(int offset, boolean b)
          Inserts a boolean argument.
 XMLString insert(int offset, char c)
          Inserts a char argument.
 XMLString insert(int offset, char[] chars)
          Inserts a char array argument.
 XMLString insert(int offset, char[] chars, int index, int len)
          Inserts a char array argument.
 XMLString insert(int offset, CharSequence s)
          Inserts a char sequence argument.
 XMLString insert(int offset, CharSequence s, int start, int end)
          Inserts a char sequence argument.
 XMLString insert(int offset, double d)
          Inserts a double argument.
 XMLString insert(int offset, float f)
          Inserts a float argument.
 XMLString insert(int offset, int i)
          Inserts an int argument.
 XMLString insert(int offset, long l)
          Inserts a long argument.
 XMLString insert(int offset, Object obj)
          Inserts an object argument.
 XMLString insert(int offset, String str)
          Inserts a string argument.
 XMLString insertTag(int offset, CharSequence tag)
          Inserts a tag argument without encoding.
 int lastIndexOf(String str)
          Returns the last index of the specified substring.
 int lastIndexOf(String str, int fromIndex)
          Returns the last index of the specified substring.
 int length()
           
 XMLString replace(int start, int end, String str)
          Replaces a string argument.
 XMLString replaceTag(int start, int end, CharSequence tag)
          Replaces a tag argument without encoding.
 void setCharAt(int index, char c)
          Sets the indexed character.
 void setLength(int newLength)
          Sets the length.
 CharSequence subSequence(int start, int end)
           
 String substring(int start)
          Returns a substring.
 String substring(int start, int end)
          Returns a substring.
 String toString()
           
 void trimToSize()
          Trims this string to its size.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NBSP

public static final String NBSP
The XHTML space reference.

See Also:
Constant Field Values

BR

public static final String BR
The XHTML line break tag.

See Also:
Constant Field Values
Constructor Detail

XMLString

public XMLString()
Constructs a new string.


XMLString

public XMLString(String delim)
Constructs a new string with a line delimiter.

Parameters:
delim - the line delimiter.

XMLString

public XMLString(int capacity)
Constructs a new string of the specified capacity.

Parameters:
capacity - the initial capacity.
Throws:
NegativeArraySizeException - if capaciy < 0.

XMLString

public XMLString(int capacity,
                 String delim)
Constructs a new string of the specified capacity and line delimiter.

Parameters:
capacity - the initial capacity.
delim - the line delimiter.
Throws:
NegativeArraySizeException - if capacity < 0.

XMLString

public XMLString(CharSequence seq)
Constructs a new string for the specified char sequence.

Parameters:
seq - the sequence to copy.
Throws:
NullPointerException - if seq is null.

XMLString

public XMLString(CharSequence seq,
                 String delim)
Constructs a new string for the specified char sequence with a line delimiter.

Parameters:
seq - the sequence to copy.
delim - the line delimiter.
Throws:
NullPointerException - if seq is null.
Method Detail

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

length

public int length()
Specified by:
length in interface CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

getLineDelimiter

public String getLineDelimiter()
Gets the line delimiter to apply.

Returns:
the line delimiter or null.

append

public XMLString append(boolean b)
Appends a boolean argument.

Parameters:
b - the argument.
Returns:
the updated string.

append

public XMLString append(char c)
Appends a char argument.

Parameters:
c - the argument.
Returns:
the updated string.

append

public XMLString append(char[] chars,
                        int index,
                        int len)
Appends a char array argument.

Parameters:
chars - the argument.
index - the index.
len - the length.
Returns:
the updated string.

append

public XMLString append(char[] chars)
Appends a char array argument.

Parameters:
chars - the argument.
Returns:
the updated string.

append

public XMLString append(CharSequence s,
                        int start,
                        int end)
Appends a char sequence argument.

Parameters:
s - the argument.
start - the start.
end - the end.
Returns:
the updated string.

append

public XMLString append(CharSequence s)
Appends a char sequence argument.

Parameters:
s - the argument.
Returns:
the updated string.

append

public XMLString append(double d)
Appends a double argument.

Parameters:
d - the argument.
Returns:
the updated string.

append

public XMLString append(float f)
Appends a float argument.

Parameters:
f - the argument.
Returns:
the updated string.

append

public XMLString append(int i)
Appends an int argument.

Parameters:
i - the argument.
Returns:
the updated string.

append

public XMLString append(long l)
Appends a long argument.

Parameters:
l - the argument.
Returns:
the updated string.

append

public XMLString append(Object obj)
Appends an object argument.

Parameters:
obj - the argument.
Returns:
the updated string.

append

public XMLString append(String str)
Appends a string argument.

Parameters:
str - the argument.
Returns:
the updated string.

append

public XMLString append(StringBuffer sb)
Appends a string buffer argument.

Parameters:
sb - the argument.
Returns:
the updated string.

appendTag

public XMLString appendTag(CharSequence tag)
Appends a tag argument without encoding.

Parameters:
tag - the argument.
Returns:
the updated string.

capacity

public int capacity()
Returns the capacity.

Returns:
the capacity.

delete

public XMLString delete(int start,
                        int end)
Deletes a sequense.

Parameters:
start - the start.
end - the end.
Returns:
the updated string.

deleteCharAt

public XMLString deleteCharAt(int index)
Deletes a character.

Parameters:
index - the index.
Returns:
the updated string.

ensureCapacity

public void ensureCapacity(int minimumCapacity)
Ensures a capacity.

Parameters:
minimumCapacity - the minimum capacity.

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)
Gets characters.

Parameters:
srcBegin - the begin index.
srcEnd - the en index.
dst - the destination.
dstBegin - the destination index.

indexOf

public int indexOf(String str,
                   int fromIndex)
Returns the index of the specified substring.

Parameters:
str - the substring.
fromIndex - the start index.
Returns:
the index or -1.

indexOf

public int indexOf(String str)
Returns the index of the specified substring.

Parameters:
str - the substring.
Returns:
the index or -1.

insert

public XMLString insert(int offset,
                        boolean b)
Inserts a boolean argument.

Parameters:
offset - the offset.
b - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        char c)
Inserts a char argument.

Parameters:
offset - the offset.
c - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        char[] chars,
                        int index,
                        int len)
Inserts a char array argument.

Parameters:
offset - the offset.
chars - the argument.
index - the index.
len - the length.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        char[] chars)
Inserts a char array argument.

Parameters:
offset - the offset.
chars - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        CharSequence s,
                        int start,
                        int end)
Inserts a char sequence argument.

Parameters:
offset - the offset.
s - the argument.
start - the start.
end - the end.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        CharSequence s)
Inserts a char sequence argument.

Parameters:
offset - the offset.
s - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        double d)
Inserts a double argument.

Parameters:
offset - the offset.
d - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        float f)
Inserts a float argument.

Parameters:
offset - the offset.
f - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        int i)
Inserts an int argument.

Parameters:
offset - the offset.
i - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        long l)
Inserts a long argument.

Parameters:
offset - the offset.
l - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        Object obj)
Inserts an object argument.

Parameters:
offset - the offset.
obj - the argument.
Returns:
the updated string.

insert

public XMLString insert(int offset,
                        String str)
Inserts a string argument.

Parameters:
offset - the offset.
str - the argument.
Returns:
the updated string.

insertTag

public XMLString insertTag(int offset,
                           CharSequence tag)
Inserts a tag argument without encoding.

Parameters:
offset - the offset.
tag - the argument.
Returns:
the updated string.

lastIndexOf

public int lastIndexOf(String str,
                       int fromIndex)
Returns the last index of the specified substring.

Parameters:
str - the substring.
fromIndex - the start index.
Returns:
the index or -1.

lastIndexOf

public int lastIndexOf(String str)
Returns the last index of the specified substring.

Parameters:
str - the substring.
Returns:
the index or -1.

replace

public XMLString replace(int start,
                         int end,
                         String str)
Replaces a string argument.

Parameters:
start - the start.
end - the end.
str - the argument.
Returns:
the updated string.

replaceTag

public XMLString replaceTag(int start,
                            int end,
                            CharSequence tag)
Replaces a tag argument without encoding.

Parameters:
start - the start.
end - the end.
tag - the argument.
Returns:
the updated string.

setCharAt

public void setCharAt(int index,
                      char c)
Sets the indexed character.

Parameters:
index - the index.
c - the character.

setLength

public void setLength(int newLength)
Sets the length.

Parameters:
newLength - the length.

substring

public String substring(int start,
                        int end)
Returns a substring.

Parameters:
start - the start.
end - the end.
Returns:
the substring.

substring

public String substring(int start)
Returns a substring.

Parameters:
start - the start.
Returns:
the substring.

trimToSize

public void trimToSize()
Trims this string to its size.



Copyright © 2004 The Norther Organization. All rights reserved.