Class PolyString
- java.lang.Object
-
- com.evolveum.midpoint.prism.polystring.PolyString
-
- All Implemented Interfaces:
Matchable<PolyString>
,Recomputable
,Structured
,DebugDumpable
,ShortDumpable
,Serializable
,Comparable<Object>
public class PolyString extends Object implements Matchable<PolyString>, Recomputable, Structured, DebugDumpable, ShortDumpable, Serializable, Comparable<Object>
Polymorphic string. String that may have more than one representation at the same time. The primary representation is the original version that is composed of the full Unicode character set. The other versions may be normalized to trim it, normalize character case, normalize spaces, remove national characters or even transliterate the string. PolyString is (almost) immutable. The original value is immutable, but the other normalized values can be changed. However the only way to change them is to recompute them from the original value.- Author:
- Radovan Semancik
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ItemName
F_LANG
static String
F_LANG_LOCAL_PART
static ItemName
F_NORM
static ItemName
F_ORIG
static ItemName
F_TRANSLATION
static String
F_TRANSLATION_LOCAL_PART
-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Constructor Summary
Constructors Constructor Description PolyString(String orig)
PolyString(String orig, String norm)
PolyString(String orig, String norm, PolyStringTranslationType translation)
PolyString(String orig, String norm, PolyStringTranslationType translation, Map<String,String> lang)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkConsistence()
int
compareTo(Object other)
PolyString
copy()
String
debugDump(int indent)
boolean
endsWith(String value)
Helper function that checks whether this original string ends with the specified value.boolean
equals(Object obj)
boolean
equalsOriginalValue(Recomputable obj)
static PolyString
fromOrig(String orig)
PolyString
getAt(int index)
Map<String,String>
getLang()
String
getNorm()
static String
getNorm(PolyString s)
Returns norm value or null for the nullable input polystring.static String
getNorm(PolyStringType s)
Returns norm value or null for the nullable input polystring.String
getOrig()
static String
getOrig(PolyString s)
Returns orig value or null for the nullable input polystring.static String
getOrig(PolyStringType s)
Returns orig value or null for the nullable input polystring.PolyStringTranslationType
getTranslation()
int
hashCode()
boolean
isComputed()
boolean
isEmpty()
boolean
isNull()
boolean
isSimple()
Returns true if the PolyString form contains only simple string.int
length()
boolean
match(PolyString other)
boolean
matches(String regex)
PolyString
plus(Object other)
void
recompute(PolyStringNormalizer normalizer)
Object
resolve(ItemPath subpath)
void
setComputedOrig(String computedOrig)
Used to set computed values of orig, e.g.void
setLang(Map<String,String> lang)
Do NOT rely on this method too much.void
setTranslation(PolyStringTranslationType translation)
Do NOT rely on this method too much.void
shortDump(StringBuilder sb)
Show the content of the object intended for diagnostics.boolean
startsWith(String value)
Helper function that checks whether this original string begins with the specified value.String
substring(int from, int to)
static PolyString
toPolyString(PolyStringType value)
static PolyStringType
toPolyStringType(PolyString value)
String
toString()
PolyString
trim()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDumpLazily, debugDumpLazily
-
Methods inherited from interface com.evolveum.midpoint.util.ShortDumpable
shortDump, shortDumpLazily
-
-
-
-
Field Detail
-
F_ORIG
public static final ItemName F_ORIG
-
F_NORM
public static final ItemName F_NORM
-
F_TRANSLATION
public static final ItemName F_TRANSLATION
-
F_TRANSLATION_LOCAL_PART
public static final String F_TRANSLATION_LOCAL_PART
-
F_LANG
public static final ItemName F_LANG
-
F_LANG_LOCAL_PART
public static final String F_LANG_LOCAL_PART
-
-
Constructor Detail
-
PolyString
public PolyString(String orig)
-
PolyString
public PolyString(String orig, String norm, PolyStringTranslationType translation)
-
-
Method Detail
-
getOrig
public String getOrig()
-
setComputedOrig
public void setComputedOrig(String computedOrig)
Used to set computed values of orig, e.g. in cases of translation. Not very clean.
-
getNorm
public String getNorm()
-
getTranslation
public PolyStringTranslationType getTranslation()
-
setTranslation
@Experimental public void setTranslation(PolyStringTranslationType translation)
Do NOT rely on this method too much. It may disappear later, e.g. when we align PolyString and PolyString type and make PolyString really immutable.
-
setLang
@Experimental public void setLang(Map<String,String> lang)
Do NOT rely on this method too much. It may disappear later, e.g. when we align PolyString and PolyString type and make PolyString really immutable.
-
isEmpty
public boolean isEmpty()
-
isNull
public boolean isNull()
-
recompute
public void recompute(PolyStringNormalizer normalizer)
-
isComputed
public boolean isComputed()
-
resolve
public Object resolve(ItemPath subpath)
- Specified by:
resolve
in interfaceStructured
-
plus
public PolyString plus(Object other)
-
getAt
public PolyString getAt(int index)
-
compareTo
public int compareTo(Object other)
- Specified by:
compareTo
in interfaceComparable<Object>
-
length
public int length()
-
trim
public PolyString trim()
-
substring
public String substring(int from, int to)
-
startsWith
public boolean startsWith(String value)
Helper function that checks whether this original string begins with the specified value.- Parameters:
value
- the value- Returns:
- the string
-
endsWith
public boolean endsWith(String value)
Helper function that checks whether this original string ends with the specified value.- Parameters:
value
- the value- Returns:
- the string
-
equalsOriginalValue
public boolean equalsOriginalValue(Recomputable obj)
- Specified by:
equalsOriginalValue
in interfaceRecomputable
-
debugDump
public String debugDump(int indent)
- Specified by:
debugDump
in interfaceDebugDumpable
-
shortDump
public void shortDump(StringBuilder sb)
Description copied from interface:ShortDumpable
Show the content of the object intended for diagnostics. This method is supposed to append a compact, human-readable output in a single line. Unlike toString() method, there is no requirement to identify the actual class or type of the object. It is assumed that the class/type will be obvious from the context in which the output is used.- Specified by:
shortDump
in interfaceShortDumpable
- Parameters:
sb
- StringBuilder to which to a compact one-line content of the object intended for diagnostics by system administrator should be appended.
-
getOrig
public static String getOrig(PolyString s)
Returns orig value or null for the nullable input polystring.
-
getOrig
public static String getOrig(PolyStringType s)
Returns orig value or null for the nullable input polystring.
-
getNorm
public static String getNorm(PolyString s)
Returns norm value or null for the nullable input polystring.
-
getNorm
public static String getNorm(PolyStringType s)
Returns norm value or null for the nullable input polystring.
-
match
public boolean match(PolyString other)
- Specified by:
match
in interfaceMatchable<PolyString>
-
matches
public boolean matches(String regex)
- Specified by:
matches
in interfaceMatchable<PolyString>
-
isSimple
public boolean isSimple()
Returns true if the PolyString form contains only simple string. I.e. returns true if the polystring can be serialized in a simplified form of a single string. Returns true in case that there are language mutations, translation, etc.
-
checkConsistence
public void checkConsistence()
- Specified by:
checkConsistence
in interfaceRecomputable
-
toPolyString
public static PolyString toPolyString(PolyStringType value)
-
toPolyStringType
public static PolyStringType toPolyStringType(PolyString value)
-
fromOrig
public static PolyString fromOrig(String orig)
-
copy
public PolyString copy()
-
-