com.jstatcom.util
Class CIString
- java.lang.Object
-
- 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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description CIString(java.lang.String s)Creates a portfolio string from a regular string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intcompareTo(CIString s)booleanequals(java.lang.Object o)Overwrite equals to compare only uppercase representation.inthashCode()Overwritten becauseequalswas overwritten.java.lang.StringtoString()Gets the original string.java.lang.StringtoUpperCase()Gets the uppercase string.
-
-
-
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- ifnullargument or ifsis empty after trimming
-
-
Method Detail
-
toString
public java.lang.String toString()
Gets the original string.- Overrides:
toStringin classjava.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:
equalsin classjava.lang.Object- Returns:
trueif o isPFStringwith same uppercase representation,falseotherwise
-
hashCode
public int hashCode()
Overwritten becauseequalswas overwritten.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashcode of uppercase representation
-
-
DMelt 3.0 © DataMelt by jWork.ORG