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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ItemNamestatic final Stringstatic final ItemNamestatic final ItemNamestatic final ItemNamestatic final StringFields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING -
Constructor Summary
ConstructorsConstructorDescriptionPolyString(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
Modifier and TypeMethodDescriptionvoidintcopy()debugDump(int indent) booleanHelper function that checks whether this original string ends with the specified value.booleanbooleanstatic PolyStringReturns poly-string for the provided `orig` value with `norm` recomputed with default normalizer.getAt(int index) getLang()getNorm()static StringReturns norm value or null for the nullable input polystring.static StringReturns norm value or null for the nullable input polystring.getOrig()static StringReturns orig value or null for the nullable input polystring.static StringReturns orig value or null for the nullable input polystring.inthashCode()booleanbooleanisEmpty()booleanisNull()booleanisSimple()Returns true if the PolyString form contains only simple string.intlength()booleanmatch(PolyString other) booleanRecomputes normalized value with default normalizer and returns modified `this`.voidrecompute(PolyStringNormalizer normalizer) voidsetComputedOrig(String computedOrig) Used to set computed values of orig, e.g.voidDo NOT rely on this method too much.voidsetTranslation(PolyStringTranslationType translation) Do NOT rely on this method too much.voidShow the content of the object intended for diagnostics.booleanstartsWith(String value) Helper function that checks whether this original string begins with the specified value.substring(int from, int to) static PolyStringtoPolyString(PolyStringType value) static PolyStringTypetoPolyStringType(PolyString value) toString()trim()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDumpLazily, debugDumpLazilyMethods inherited from interface com.evolveum.midpoint.util.ShortDumpable
shortDump, shortDumpLazily
-
Field Details
-
F_ORIG
-
F_NORM
-
F_TRANSLATION
-
F_TRANSLATION_LOCAL_PART
-
F_LANG
-
F_LANG_LOCAL_PART
-
-
Constructor Details
-
PolyString
-
PolyString
-
PolyString
-
PolyString
-
-
Method Details
-
getOrig
-
setComputedOrig
Used to set computed values of orig, e.g. in cases of translation. Not very clean. -
getNorm
-
getTranslation
-
getLang
-
setTranslation
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
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
-
recompute
Recomputes normalized value with default normalizer and returns modified `this`. -
isComputed
public boolean isComputed() -
resolve
- Specified by:
resolvein interfaceStructured
-
plus
-
getAt
-
compareTo
- Specified by:
compareToin interfaceComparable<Object>
-
length
public int length() -
trim
-
substring
-
startsWith
Helper function that checks whether this original string begins with the specified value.- Parameters:
value- the value- Returns:
- the string
-
endsWith
Helper function that checks whether this original string ends with the specified value.- Parameters:
value- the value- Returns:
- the string
-
hashCode
public int hashCode() -
equals
-
equalsOriginalValue
- Specified by:
equalsOriginalValuein interfaceRecomputable
-
toString
-
debugDump
- Specified by:
debugDumpin interfaceDebugDumpable
-
shortDump
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
Returns orig value or null for the nullable input polystring. -
getOrig
Returns orig value or null for the nullable input polystring. -
getNorm
Returns norm value or null for the nullable input polystring. -
getNorm
Returns norm value or null for the nullable input polystring. -
match
- Specified by:
matchin interfaceMatchable<PolyString>
-
matches
- 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
-
toPolyStringType
-
fromOrig
Returns poly-string for the provided `orig` value with `norm` recomputed with default normalizer. If, for whatever reason, poly-string with only `orig` is needed, use the constructor with `orig` parameter. TODO: Recompute added in 4.7, check usages, remove useless recomputes outside and eventually remove this TODO. -
copy
-