NASString class
The NASString class shadows the java.lang.String class.
Strings are constant. However, NASStrings are not. Their value can be changed, and they provide a simple method to change which part of a String to operate on. In this way, you can section off parts of a String without the overhead of creating a new String. In addition, NASString conforms to the method signatures provided for the String class.
Although anyone developing a NAS application can use NASString, this class is typically used in components generated by Netscape Application Builder.
Package
com.netscape.server.servlet.extension
Constructors
The following constructors are available:
Methods
NASString and String are almost identical. Every instance method on java.lang.String has a corresponding, functionally identical method on NASString. Every instance method on String that takes a String as a parameter is overloaded in NASString to take a String or a NASString.
The following additional methods are in NASString but not in String.
equals( )
Compares this NASString to the specified parameter.
Syntax 1
public boolean equals(
Object anObject)
Syntax 2
public boolean equals(
String val)
Syntax 3
public boolean equals(
NASString string)
Usage
The equals( ) method compares this NASString to the specified parameter, either an Object, a String, or an NASString.
This method returns true if the parameter is not null and if it meets the following conditions:
The equals( ) method allows the compiler to bind to this method when the class of the object is known. This binding allows for removal of the code to check the class of the incoming object.
Return Value
Returns true if the previous conditions are met; otherwise, returns false.
makeSubstring( )
Modifies this NASString to point to a substring of shadow.
Syntax
public void makeSubstring(
int beginIndex)
Syntax
public void makeSubstring(
int beginIndex,
int endIndex)
beginIndex.
The beginning index. If the NASString is already pointing at a substring, then this index can be negative, indicating that the beginning of the substring will occur earlier. If beginIndex is out of range, this method throws StringIndexOutOfBoundsException.
endIndex.
The ending index, excluding itself.
Usage
Use makeSubstring( ) to modify this NASString to point at a substring of shadow. The substring begins at the specified index, which is the offset from the current substring being shadowed by the NASString.
If no endIndex is specified, the substring extends to the end of the currently shadowed substring. If endIndex is specified, the substring extends to the character located at endIndex - 1 of the newly shadowed substring.
setValue( )
Resets the value of this NASString to shadow the specified String.
Syntax
public void setValue(
String val)
val.
The String to shadow.
Usage
Use setValue( ) to reset the value of this NASString to shadow the specified String.
|