com.jstatcom.util
Class CIString

java.lang.Object
  extended by com.jstatcom.util.CIString
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<CIString>

public final class CIString
extends java.lang.Object
implements java.lang.Comparable<CIString>, java.io.Serializable

A case insensitive nonempty string. It stores the original upper/lowercase representation of a string but uses only the uppercase representation for comparisons. This is useful to keep the original string representation for rendering, for example for portfolio names, but make only case insensitive lookups. Furthermore, all strings all trimmed.

This class is immutable.

Author:
Markus Kraetzig
See Also:
Serialized Form

Constructor Summary
CIString(java.lang.String s)
          Creates a portfolio string from a regular string.
 
Method Summary
 int compareTo(CIString s)
           
 boolean equals(java.lang.Object o)
          Overwrite equals to compare only uppercase representation.
 int hashCode()
          Overwritten because equals was overwritten.
 java.lang.String toString()
          Gets the original string.
 java.lang.String toUpperCase()
          Gets the uppercase string.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CIString

public CIString(java.lang.String s)
Creates a portfolio string from a regular string.

Parameters:
s - regular string
Throws:
java.lang.IllegalArgumentException - if null argument or if s is empty after trimming
Method Detail

toString

public java.lang.String toString()
Gets the original string.

Overrides:
toString in class java.lang.Object
Returns:
upper/lowercase string

toUpperCase

public java.lang.String toUpperCase()
Gets the uppercase string.

Returns:
uppercase string representation

equals

public boolean equals(java.lang.Object o)
Overwrite equals to compare only uppercase representation.

Overrides:
equals in class java.lang.Object
Returns:
true if o is PFString with same uppercase representation, false otherwise

hashCode

public int hashCode()
Overwritten because equals was overwritten.

Overrides:
hashCode in class java.lang.Object
Returns:
hashcode of uppercase representation

compareTo

public int compareTo(CIString s)
Specified by:
compareTo in interface java.lang.Comparable<CIString>