asjava.uniclientlibs
Class UniString

java.lang.Object
  extended byasjava.uniclientlibs.UniString
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
UniDynArray

public class UniString
extends java.lang.Object
implements java.io.Serializable

UniString is the primary class used for handling UniObjects Java string operations. It is an extension of the general String and StringBuffer classes, with numerous UniVerse specific additions. Unlike those classes, however, operations performed on the object, such as insert, change the internal data element and do not return a new object.

Since:
UNICLIENTLIBS 1.0
Version:
Version 1.0
Author:
David T. Meeks
See Also:
Serialized Form

Field Summary
protected  int count
           
protected  asjava.unirpc.UniRPCPacket inPacket
           
protected  asjava.unirpc.UniRPCPacket outPacket
           
protected  UniConnection uniConnection
           
protected  int uniReturnCode
           
protected  int uniStatus
           
protected  char[] value
           
 
Constructor Summary
UniString()
          Constructs a UniString with no characters in it and an initial capacity of 16 characters.
UniString(int length)
          Constructs a UniString with no characters in it and an initial capacity specified by the length argument.
UniString(java.lang.Object aString)
          Constructs a UniString with the value set to the supplied argument
UniString(java.lang.String aString)
          Constructs a UniString with the value set to the supplied argument
UniString(UniConnection aNewSession)
          Constructs a UniString with no characters in it and an initial capacity of 16 characters, binds it to the given UniConnection object which will cause it to perform certain operations on the server
UniString(UniConnection aNewSession, java.lang.Object aString)
          Constructs a UniString with no characters in it and an initial capacity of 16 characters.
UniString(UniString aString)
          Constructs a UniString (copy constructor)
 
Method Summary
 boolean alpha()
          Determines whether a given session contains only alphabetic characters
 boolean alpha(UniConnection aConnection)
          Determines whether a given session contains only alphabetic characters.
 void append(boolean b)
          Appends the string representation of the boolean argument to the string buffer.
 void append(char c)
          Appends the string representation of the char argument to this string buffer.
 void append(char[] str)
          Appends the string representation of the char array argument to this string buffer.
 void append(char[] str, int offset, int len)
          Appends the string representation of a subarray of the char array argument to this string buffer.
 void append(double d)
          Appends the string representation of the double argument to this string buffer.
 void append(float f)
          Appends the string representation of the float argument to this string buffer.
 void append(int i)
          Appends the string representation of the int argument to this string buffer.
 void append(long l)
          Appends the string representation of the long argument to this string buffer.
 void append(java.lang.Object aString)
          Appends the string representation of the Object argument to this string buffer.
 void append(java.lang.String aString)
          Appends the string representation of the Object argument to this string buffer.
 void change(java.lang.Object aSubString, java.lang.Object aReplacementString)
          Changes the current string by replacing a given substring expression with the replacement substring specified
 void change(java.lang.Object aSubString, java.lang.Object aReplacementString, int aOccurance)
          Changes the current string by replacing a given substring expression with the replacement substring specified
 void change(java.lang.Object aSubString, java.lang.Object aReplacementString, int aOccurance, int aStart)
          Changes the current string by replacing a given substring expression with the replacement substring specified
 char charAt(int index)
          Returns the character at a specific index in this string buffer.
 int compareTo(java.lang.Object aCompareString)
          Returns the lexicographical comparison of this string against the string passed in as an argument.
 void convert(java.lang.Object aReplaceChars, java.lang.Object aReplaceWithChars)
          Converts a set of characters with a new set
 void convert(UniConnection aConnection, java.lang.Object aReplaceChars, java.lang.Object aReplaceWithChars)
          Converts a set of characters with a new set
 int count()
          Count the number of @FM marks existing in the string
 int count(java.lang.Object aSubString)
          Count the number of occurances of the given substring
 int dcount()
          Count the number of occurances of the @FM mark character, adding one to it
 int dcount(java.lang.Object aSubString)
          Count the number of occurances of the given substring, adding one to it
 boolean equals(java.lang.Object anObject)
          Determine whether this UniString is equivalent to another Object.
 boolean equalsIgnoreCase(java.lang.Object anObject)
          Determine whether this UniString is equivalent to another Object, when case is ignored.
 byte[] getBytes()
          return the current string as a byte[] array
 byte[] getBytes(java.lang.String enc)
           
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
          Characters are copied from this string buffer into the destination character array dst.
protected  java.lang.String getInternalMarkCharacter(int aTokenVal)
          Returns the requested mark character.
 java.lang.String getMarkCharacter(int aTokenVal)
          Returns the requested mark character.
 UniString iconv(UniConnection aConnection, java.lang.Object aConvCode)
          Performs a conversion of the current string into an internal representation, which depends on the given conversion code
 void insert(int offset, boolean b)
          Inserts the string representation of the boolean argument into this string buffer.
 void insert(int offset, char c)
          Inserts the string representation of the char argument into this string buffer.
 void insert(int offset, char[] str)
          Inserts the string representation of the char array argument into this string buffer.
 void insert(int offset, double d)
          Inserts the string representation of the double argument into this string buffer.
 void insert(int offset, float f)
          Inserts the string representation of the float argument into this string buffer.
 void insert(int offset, int i)
          Inserts the string representation of the second int argument into this string buffer.
 void insert(int offset, long l)
          Inserts the string representation of the long argument into this string buffer.
 void insert(int offset, java.lang.Object obj)
          Inserts the string into this string buffer.
 UniString left(int aNumChars)
          Returns the leftmost aNumChars characters of the string.
 int length()
          Returns the length (character count) of this string buffer.
 UniString oconv(UniConnection aConnection, java.lang.Object aConvCode)
          Performs a conversion of the current string into an external representation, which depends on the given conversion code
 void quote()
          Quotes the given string with the "'" character (single quote)
 void quote(java.lang.Object aChar)
          Quotes the given string with the given quote character
 UniString right(int aNumChars)
          Returns the rightmost aNumChars characters of the string.
 void setCharAt(int index, char ch)
          The character at the specified index of this string buffer is set to ch.
 void setValue(java.lang.Object newValue)
          Sets the current values of the string buffer and it's size
 void setValue(java.lang.String newValue)
          Sets the current values of the string buffer and it's size
 int status()
          Returns the current status of the last operation
 UniString substring(int aBeginIndex)
          return a substring of the current UniString, starting at the given index
 UniString substring(int aBeginPoint, int aEndPoint)
          return a substring of the current UniString, starting at the given index and ending at the given endpoint
 char[] toCharArray()
          return the current string as a char[] array
 UniString toLowerCase()
          change the given string to all lower case characters
 java.lang.String toString()
          Converts to a string representing the data in this string buffer.
 UniString toUpperCase()
          change the given string to all upper case characters
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected char[] value

count

protected int count

uniStatus

protected int uniStatus

uniReturnCode

protected int uniReturnCode

uniConnection

protected UniConnection uniConnection

inPacket

protected asjava.unirpc.UniRPCPacket inPacket

outPacket

protected asjava.unirpc.UniRPCPacket outPacket
Constructor Detail

UniString

public UniString()
Constructs a UniString with no characters in it and an initial capacity of 16 characters.

Since:
UNICLIENTLIBS 1.0

UniString

public UniString(int length)
Constructs a UniString with no characters in it and an initial capacity specified by the length argument.

Parameters:
length - the initial capacity.
Since:
UNICLIENTLIBS 1.0

UniString

public UniString(java.lang.String aString)
Constructs a UniString with the value set to the supplied argument

Parameters:
aString - initial string to set the object to
Since:
UNICLIENTLIBS 1.0

UniString

public UniString(UniString aString)
Constructs a UniString (copy constructor)

Parameters:
aString - initial string to set the object to
Since:
UNICLIENTLIBS 1.0

UniString

public UniString(java.lang.Object aString)
Constructs a UniString with the value set to the supplied argument

Parameters:
aString - initial string to set the object to
Since:
UNICLIENTLIBS 1.0

UniString

public UniString(UniConnection aNewSession)
Constructs a UniString with no characters in it and an initial capacity of 16 characters, binds it to the given UniConnection object which will cause it to perform certain operations on the server

Parameters:
aNewSession - UniConnection object to bind the string to
Since:
UNICLIENTLIBS 1.0

UniString

public UniString(UniConnection aNewSession,
                 java.lang.Object aString)
Constructs a UniString with no characters in it and an initial capacity of 16 characters.

Parameters:
aNewSession - UniConnection object to bind the string to
aString - initial string to set the object to.
Since:
UNICLIENTLIBS 1.0
Method Detail

alpha

public boolean alpha()
              throws UniStringException
Determines whether a given session contains only alphabetic characters

Returns:
boolean to indicate whether string is all alphabetic or not
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

alpha

public boolean alpha(UniConnection aConnection)
              throws UniStringException
Determines whether a given session contains only alphabetic characters. This version uses the defined UniConnection reference to perform the operation on the defined connection. This is primarily done for NLS purposes.

Parameters:
aConnection - UniConnection object representing the server we should contact to ensure this string is alphabetic
Returns:
boolean to indicate whether string is all alphabetic or not
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

append

public void append(java.lang.String aString)
Appends the string representation of the Object argument to this string buffer.

Parameters:
aString - string to append
Since:
UNICLIENTLIBS 1.0

append

public void append(java.lang.Object aString)
Appends the string representation of the Object argument to this string buffer.

Parameters:
aString - string to append
Since:
UNICLIENTLIBS 1.0

append

public void append(char[] str)
Appends the string representation of the char array argument to this string buffer.

Parameters:
str - the characters to be appended.
Since:
UNICLIENTLIBS 1.0

append

public void append(char[] str,
                   int offset,
                   int len)
Appends the string representation of a subarray of the char array argument to this string buffer.

Parameters:
str - the characters to be appended.
offset - the index of the first character to append.
len - the number of characters to append.
Since:
UNICLIENTLIBS 1.0

append

public void append(boolean b)
Appends the string representation of the boolean argument to the string buffer.

Parameters:
b - a boolean.
Since:
UNICLIENTLIBS 1.0

append

public void append(char c)
Appends the string representation of the char argument to this string buffer.

Parameters:
c - a char.
Since:
UNICLIENTLIBS 1.0

append

public void append(int i)
Appends the string representation of the int argument to this string buffer.

Parameters:
i - an int.
Since:
UNICLIENTLIBS 1.0

append

public void append(long l)
Appends the string representation of the long argument to this string buffer.

Parameters:
l - a long.
Since:
UNICLIENTLIBS 1.0

append

public void append(float f)
Appends the string representation of the float argument to this string buffer.

Parameters:
f - a float.
Since:
UNICLIENTLIBS 1.0

append

public void append(double d)
Appends the string representation of the double argument to this string buffer.

Parameters:
d - a double.
Since:
UNICLIENTLIBS 1.0

change

public void change(java.lang.Object aSubString,
                   java.lang.Object aReplacementString)
Changes the current string by replacing a given substring expression with the replacement substring specified

Parameters:
aSubString - String representing the substring to be replaced
aReplacementString - String representing what the aSubString should be replaced with
Since:
UNICLIENTLIBS 1.0

change

public void change(java.lang.Object aSubString,
                   java.lang.Object aReplacementString,
                   int aOccurance)
Changes the current string by replacing a given substring expression with the replacement substring specified

Parameters:
aSubString - String representing the substring to be replaced
aReplacementString - String representing what the aSubString should be replaced with
aOccurance - integer representing the number of occurance to change. A number less than 1 refers to replacing all occurrances of the substring
Since:
UNICLIENTLIBS 1.0

change

public void change(java.lang.Object aSubString,
                   java.lang.Object aReplacementString,
                   int aOccurance,
                   int aStart)
Changes the current string by replacing a given substring expression with the replacement substring specified

Parameters:
aSubString - String representing the substring to be replaced
aReplacementString - String representing what the aSubString should be replaced with
aOccurance - integer representing the number of occurance to change. A number less than 1 refers to replacing all occurrances of the substring
aStart - integer referring to the first occurance to start replacing. A number less than 1 refers to starting from the beginning
Since:
UNICLIENTLIBS 1.0

charAt

public char charAt(int index)
            throws UniStringException
Returns the character at a specific index in this string buffer.

Parameters:
index - the index of the desired character.
Returns:
the character at the specified index of this string buffer.
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

compareTo

public int compareTo(java.lang.Object aCompareString)
Returns the lexicographical comparison of this string against the string passed in as an argument. Will return a 0 if the strings are lexicographically equivalent, a value less than 0 if this string is less than the argument string, or a value greater than 0 if this string is lexicographically greater.

Parameters:
aCompareString - Object to compare against
Returns:
integer representing the lexicographical comparison. 0 denotes equivalence, < 0 denotes this string is less than the argument string, and > 0 denotes that it compares greater than the argument string.
Since:
UNICLIENTLIBS 1.0

convert

public void convert(UniConnection aConnection,
                    java.lang.Object aReplaceChars,
                    java.lang.Object aReplaceWithChars)
             throws UniStringException
Converts a set of characters with a new set

Parameters:
aConnection - UniConnection object used to establish which server to perform operation
aReplaceChars - String of characters to be replaced
aReplaceWithChars - characters to replace the others with.
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

convert

public void convert(java.lang.Object aReplaceChars,
                    java.lang.Object aReplaceWithChars)
             throws UniStringException
Converts a set of characters with a new set

Parameters:
aReplaceChars - String of characters to be replaced
aReplaceWithChars - characters to replace the others with.
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

count

public int count()
Count the number of @FM marks existing in the string

Returns:
integer representing the number of occurances
Since:
UNICLIENTLIBS 1.0

count

public int count(java.lang.Object aSubString)
Count the number of occurances of the given substring

Parameters:
aSubString - String representing the substring to check for
Returns:
integer representing the number of occurances
Since:
UNICLIENTLIBS 1.0

dcount

public int dcount()
Count the number of occurances of the @FM mark character, adding one to it

Returns:
integer representing the number of occurances
Since:
UNICLIENTLIBS 1.0

dcount

public int dcount(java.lang.Object aSubString)
Count the number of occurances of the given substring, adding one to it

Parameters:
aSubString - String representing the substring to check for
Returns:
integer representing the number of occurances
Since:
UNICLIENTLIBS 1.0

equals

public boolean equals(java.lang.Object anObject)
Determine whether this UniString is equivalent to another Object. Will return true only if the two objects represent the same sequence of characters.

Parameters:
anObject - Object to compare against
Returns:
boolean representing true if the sequence of characters represented by both is equivalent
Since:
UNICLIENTLIBS 1.0

equalsIgnoreCase

public boolean equalsIgnoreCase(java.lang.Object anObject)
Determine whether this UniString is equivalent to another Object, when case is ignored. Will return true only if the two objects represent the same sequence of characters.

Parameters:
anObject - Object to compare against
Returns:
boolean representing true if the sequence of characters represented by both is equivalent
Since:
UNICLIENTLIBS 1.0

getBytes

public byte[] getBytes()
return the current string as a byte[] array

Returns:
byte[] representing the current string
Since:
UNICLIENTLIBS 1.0

getBytes

public byte[] getBytes(java.lang.String enc)
                throws java.lang.Exception
Throws:
java.lang.Exception

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)
              throws UniStringException
Characters are copied from this string buffer into the destination character array dst. The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1. The total number of characters to be copied is srcEnd-srcBegin. The characters are copied into the subarray of dst starting at index dstBegin and ending at index:

     dstbegin + (srcEnd-srcBegin) - 1
 

Parameters:
srcBegin - start copying at this offset in the string buffer.
srcEnd - stop copying at this offset in the string buffer.
dst - the array to copy the data into.
dstBegin - offset into dst.
Throws:
UniStringException - if there is an invalid index into the buffer.
Since:
UNICLIENTLIBS 1.0

getMarkCharacter

public java.lang.String getMarkCharacter(int aTokenVal)
                                  throws UniStringException
Returns the requested mark character. Valid input values are:

Returns:
String representing the requested mark value
Throws:
UniStringException - is thrown if the input value is invalid
Since:
UNICLIENTLIBS 1.0

getInternalMarkCharacter

protected java.lang.String getInternalMarkCharacter(int aTokenVal)
Returns the requested mark character. Valid input values are:

Returns:
String representing the requested mark value
Throws:
UniStringException - is thrown if the input value is invalid
Since:
UNICLIENTLIBS 1.0

iconv

public UniString iconv(UniConnection aConnection,
                       java.lang.Object aConvCode)
                throws UniStringException
Performs a conversion of the current string into an internal representation, which depends on the given conversion code

Parameters:
aConnection - UniConnection object representing which server to use to perform the conversion
aConvCode - String representing the conversion that is to take place
Returns:
UniString new string object representing the new value
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   java.lang.Object obj)
Inserts the string into this string buffer.

The characters of the String argument are inserted, in order, into this string buffer at the indicated offset. The length of this string buffer is increased by the length of the argument.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Parameters:
offset - the offset.
obj - a Object.
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   char[] str)
Inserts the string representation of the char array argument into this string buffer.

The characters of the array argument are inserted into the contents of this string buffer at the position indicated by offset. The length of this string buffer increases by the length of the argument.

Parameters:
offset - the offset.
str - a character array.
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   boolean b)
Inserts the string representation of the boolean argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Parameters:
offset - the offset.
b - a boolean.
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   char c)
Inserts the string representation of the char argument into this string buffer.

The second argument is inserted into the contents of this string buffer at the position indicated by offset. The length of this string buffer increases by one.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Parameters:
offset - the offset.
c - a char.
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   int i)
Inserts the string representation of the second int argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Parameters:
offset - the offset.
i - an int.
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   long l)
Inserts the string representation of the long argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Parameters:
offset - the offset.
l - a long.
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   float f)
Inserts the string representation of the float argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Parameters:
offset - the offset.
f - a float.
Since:
UNICLIENTLIBS 1.0

insert

public void insert(int offset,
                   double d)
Inserts the string representation of the double argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf, and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Parameters:
offset - the offset.
d - a double.
Since:
UNICLIENTLIBS 1.0

left

public UniString left(int aNumChars)
Returns the leftmost aNumChars characters of the string.

Parameters:
aNumChars - integer representing the leftmost N characters of the string
Returns:
the requested number of characters from the left handside of the string
Since:
UNICLIENTLIBS 1.0

length

public int length()
Returns the length (character count) of this string buffer.

Returns:
the number of characters in this string buffer.
Since:
UNICLIENTLIBS 1.0

oconv

public UniString oconv(UniConnection aConnection,
                       java.lang.Object aConvCode)
                throws UniStringException
Performs a conversion of the current string into an external representation, which depends on the given conversion code

Parameters:
aConnection - UniConnection object representing which server to use to perform the conversion
aConvCode - String representing the conversion that is to take place
Returns:
UniString new string object representing the new value
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

quote

public void quote()
Quotes the given string with the "'" character (single quote)

Since:
UNICLIENTLIBS 1.0

quote

public void quote(java.lang.Object aChar)
Quotes the given string with the given quote character

Parameters:
aChar - character to quote string with
Since:
UNICLIENTLIBS 1.0

right

public UniString right(int aNumChars)
Returns the rightmost aNumChars characters of the string.

Parameters:
aNumChars - integer representing the rightmost N characters of the string
Returns:
the requested number of characters from the rightmost handside of the string
Since:
UNICLIENTLIBS 1.0

setCharAt

public void setCharAt(int index,
                      char ch)
               throws UniStringException
The character at the specified index of this string buffer is set to ch.

The offset argument must be greater than or equal to 0, and less than the length of this string buffer.

Parameters:
index - the index of the character to modify.
ch - the new character.
Throws:
UniStringException - if the index is invalid.
Since:
UNICLIENTLIBS 1.0

setValue

public void setValue(java.lang.String newValue)
Sets the current values of the string buffer and it's size

Returns:
current status value
Since:
UNICLIENTLIBS 1.0

setValue

public void setValue(java.lang.Object newValue)
Sets the current values of the string buffer and it's size

Returns:
current status value
Since:
UNICLIENTLIBS 1.0

status

public int status()
Returns the current status of the last operation

Returns:
current status value
Since:
UNICLIENTLIBS 1.0

substring

public UniString substring(int aBeginIndex)
                    throws UniStringException
return a substring of the current UniString, starting at the given index

Parameters:
aBeginIndex - beginning index to take the substring from
Returns:
UniString representing the substring requested
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

substring

public UniString substring(int aBeginPoint,
                           int aEndPoint)
                    throws UniStringException
return a substring of the current UniString, starting at the given index and ending at the given endpoint

Parameters:
aBeginPoint - beginning index to take the substring from
aEndPoint - where to end the substring operation
Returns:
UniString representing the substring requested
Throws:
UniStringException - is thrown if an error occurs
Since:
UNICLIENTLIBS 1.0

toCharArray

public char[] toCharArray()
return the current string as a char[] array

Returns:
char[] representing the current string
Since:
UNICLIENTLIBS 1.0

toLowerCase

public UniString toLowerCase()
change the given string to all lower case characters

Returns:
UniString representing the current string in all lower case
Since:
UNICLIENTLIBS 1.0

toUpperCase

public UniString toUpperCase()
change the given string to all upper case characters

Returns:
UniString representing the current string in all upper case
Since:
UNICLIENTLIBS 1.0

toString

public java.lang.String toString()
Converts to a string representing the data in this string buffer. A new String object is allocated and initialized to contain the character sequence currently represented by this string buffer. This String is then returned. Subsequent changes to the string buffer do not affect the contents of the String.

Returns:
a string representation of the string buffer.
Since:
UNICLIENTLIBS 1.0