net.rim.device.api.util
Class AbstractStringWrapper

java.lang.Object
  extended by net.rim.device.api.util.AbstractStringWrapper
All Implemented Interfaces:
AbstractString

public abstract class AbstractStringWrapper
extends Object
implements AbstractString

Wraps string data to provide consistent basis for the string utility methods defined in AbstractString.

This class can wrap a String, a StringBuffer, or a character array. To be thrifty with runtime storage you can instantiate one wrapper, and re-use it on different string data.


Constructor Summary
protected AbstractStringWrapper()
          Creates new AbstractStringWrapper instance.
 
Method Summary
static AbstractStringWrapper createInstance(Object string)
          Retrieves an abstract string wrapper for provided string data.
 int hashCode()
          Retrieves hash code for this wrapper's enclosed string data.
abstract  void reset(Object string)
          Wraps new string with this wrapper.
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.rim.device.api.util.AbstractString
charAt, getChars, indexOf, length
 



Constructor Detail

AbstractStringWrapper

protected AbstractStringWrapper()
Creates new AbstractStringWrapper instance.



Method Detail

createInstance

public static AbstractStringWrapper createInstance(Object string)
                                            throws IllegalArgumentException
Retrieves an abstract string wrapper for provided string data.

Invoke this method to wrap string data of some kind and gain access to the various utility methods defined in this class and in AbstractString.

Parameters:
string - String data to wrap; may be a String, a StringBuffer, or a character array.
Returns:
Abstract string wrapper around provided string data.
Throws:
IllegalArgumentException - If string parameter is not of expected type.

reset

public abstract void reset(Object string)
                    throws IllegalArgumentException
Wraps new string with this wrapper.

Use this method to avoid creating a new wrapper instance.

Parameters:
string - New string to wrap; may be a String, a StringBuffer, or a character array.
Throws:
IllegalArgumentException - If string parameter is not of expected type.

hashCode

public int hashCode()
Retrieves hash code for this wrapper's enclosed string data.

Invoking this method is equivalent to invoking (this.toString()).hashCode().

Overrides:
hashCode in class Object
Returns:
Hash code for the underlying string data enclosed by this wrapper.
See Also:
Object.equals(java.lang.Object), Hashtable





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal