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 ItemNameF_LANGstatic StringF_LANG_LOCAL_PARTstatic ItemNameF_NORMstatic ItemNameF_ORIGstatic ItemNameF_TRANSLATIONstatic StringF_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 voidcheckConsistence()intcompareTo(Object other)StringdebugDump(int indent)booleanendsWith(String value)Helper function that checks whether this original string ends with the specified value.booleanequals(Object obj)booleanequalsOriginalValue(Recomputable obj)static PolyStringfromOrig(String orig)PolyStringgetAt(int index)Map<String,String>getLang()StringgetNorm()StringgetOrig()static StringgetOrig(PolyString s)static StringgetOrig(PolyStringType s)PolyStringTranslationTypegetTranslation()inthashCode()booleanisComputed()booleanisEmpty()booleanisNull()booleanisSimple()Returns true if the PolyString form contains only simple string.intlength()booleanmatch(PolyString other)booleanmatches(String regex)PolyStringplus(Object other)voidrecompute(PolyStringNormalizer normalizer)Objectresolve(ItemPath subpath)voidsetComputedOrig(String computedOrig)Used to set computed values of orig, e.g.voidsetLang(Map<String,String> lang)Do NOT rely on this method too much.voidsetTranslation(PolyStringTranslationType translation)Do NOT rely on this method too much.voidshortDump(StringBuilder sb)Show the content of the object intended for diagnostics.booleanstartsWith(String value)Helper function that checks whether this original string begins with the specified value.Stringsubstring(int from, int to)static PolyStringtoPolyString(PolyStringType value)static PolyStringTypetoPolyStringType(PolyString value)StringtoString()PolyStringtrim()-
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:
resolvein interfaceStructured
-
plus
public PolyString plus(Object other)
-
getAt
public PolyString getAt(int index)
-
compareTo
public int compareTo(Object other)
- Specified by:
compareToin 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:
equalsOriginalValuein interfaceRecomputable
-
debugDump
public String debugDump(int indent)
- Specified by:
debugDumpin interfaceDebugDumpable
-
shortDump
public void shortDump(StringBuilder sb)
Description copied from interface:ShortDumpableShow 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:
shortDumpin 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)
-
getOrig
public static String getOrig(PolyStringType s)
-
match
public boolean match(PolyString other)
- Specified by:
matchin interfaceMatchable<PolyString>
-
matches
public boolean matches(String regex)
- Specified by:
matchesin 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:
checkConsistencein interfaceRecomputable
-
toPolyString
public static PolyString toPolyString(PolyStringType value)
-
toPolyStringType
public static PolyStringType toPolyStringType(PolyString value)
-
fromOrig
public static PolyString fromOrig(String orig)
-
-