Package com.simplicite.util.tools
Class StringIntern
- java.lang.Object
-
- com.simplicite.util.tools.StringIntern
-
- All Implemented Interfaces:
java.io.Serializable
public final class StringIntern extends java.lang.Object implements java.io.Serializable
Internal String : factorize String to optimize heap usage. Can be removed thru a clear cache
Reserved to common repository and core object's definitions, not for user's dynamic data- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringIntern
EMPTY
Empty string "" as a StringInternstatic java.lang.String
NO
No "N" indexed valuestatic StringIntern
NULL
Null as a StringInternstatic java.lang.String
YES
Yes "Y" indexed valuestatic StringIntern
ZERO
Zero string "0&qot; as a StringIntern
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clear()
Clear internal Stringsint
compareTo(java.lang.Object a)
Same as String.compareToboolean
equals(java.lang.Object a)
Check if value equals argumentstatic StringIntern
get(java.lang.String value)
Get the internalized Stringjava.lang.String
getValue()
Get the value, same as toStringstatic java.lang.String
getValue(StringIntern intern)
Get the value of a string singletonstatic java.lang.String
getValue(java.lang.String value)
Return the String singleton from any stringint
hashCode()
Get hash codeint
indexOf(char c)
Same as String.indexOfint
indexOf(java.lang.String s)
Same as String.indexOfint
length()
Same as String.lengthvoid
setValue(java.lang.String value)
Set the valueboolean
startsWith(java.lang.String prefix)
Same as String.startsWithjava.lang.String
toString()
Get value, same as getValue
-
-
-
Field Detail
-
NULL
public static final StringIntern NULL
Null as a StringIntern
-
EMPTY
public static final StringIntern EMPTY
Empty string "" as a StringIntern
-
ZERO
public static final StringIntern ZERO
Zero string "0&qot; as a StringIntern
-
YES
public static final java.lang.String YES
Yes "Y" indexed value
-
NO
public static final java.lang.String NO
No "N" indexed value
-
-
Method Detail
-
getValue
public java.lang.String getValue()
Get the value, same as toString- Returns:
- Value
-
toString
public java.lang.String toString()
Get value, same as getValue- Overrides:
toString
in classjava.lang.Object
- Returns:
- Value
-
setValue
public void setValue(java.lang.String value)
Set the value- Parameters:
value
- Value
-
equals
public boolean equals(java.lang.Object a)
Check if value equals argument- Overrides:
equals
in classjava.lang.Object
- Parameters:
a
- Argument- Returns:
- True if equals
-
hashCode
public int hashCode()
Get hash code- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- Hash code
-
compareTo
public int compareTo(java.lang.Object a)
Same as String.compareTo- Returns:
- 0 if equals, lt; 0 if inferior, > 0 if superior
-
startsWith
public boolean startsWith(java.lang.String prefix)
Same as String.startsWith- Parameters:
prefix
- Prefix- Returns:
- True if starts with
-
indexOf
public int indexOf(java.lang.String s)
Same as String.indexOf- Parameters:
s
- String- Returns:
- Indef of string or -1
-
indexOf
public int indexOf(char c)
Same as String.indexOf- Parameters:
c
- Chararcter- Returns:
- Index of character or -1
-
length
public int length()
Same as String.length- Returns:
- length
-
get
public static StringIntern get(java.lang.String value)
Get the internalized String- Parameters:
value
- Value to index- Returns:
- StringIntern singleton equals to value
-
clear
public static void clear()
Clear internal Strings
-
getValue
public static java.lang.String getValue(java.lang.String value)
Return the String singleton from any string- Parameters:
value
- Value to index- Returns:
- String singleton equals to value
-
getValue
public static java.lang.String getValue(StringIntern intern)
Get the value of a string singleton- Parameters:
intern
- Internalized string- Returns:
- Value
-
-