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
Modifier and TypeFieldDescriptionstatic final ItemName
static final String
static final ItemName
static final ItemName
static final ItemName
static final String
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
Constructor Summary
ConstructorDescriptionPolyString
(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 TypeMethodDescriptionvoid
int
copy()
copyApplyingNormalization
(@NotNull Normalizer<String> normalizer) debugDump
(int indent) boolean
Helper function that checks whether this original string ends with the specified value.boolean
boolean
static PolyString
Returns poly-string for the provided `orig` value with `norm` recomputed with default normalizer.getAt
(int index) getLang()
getNorm()
static String
Returns norm value or null for the nullable input polystring.static String
Returns norm value or null for the nullable input polystring.getOrig()
static String
Returns orig value or null for the nullable input polystring.static String
Returns orig value or null for the nullable input polystring.static String
TODO reconsider this method; it is quite a hack.boolean
Returns `true` if there is a custom (non-standard) normalization, like for resource shadow attributes.int
hashCode()
boolean
boolean
isEmpty()
boolean
isNull()
boolean
isSimple()
Returns `true` if the `PolyString` form contains only simple string.int
length()
boolean
match
(PolyString other) boolean
Recomputes normalized value with default normalizer and returns modified `this`.void
recompute
(PolyStringNormalizer normalizer) void
setComputedOrig
(String computedOrig) Used to set computed values of orig, e.g. in cases of translation.void
Do NOT rely on this method too much.void
setTranslation
(PolyStringTranslationType translation) Do NOT rely on this method too much.void
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.substring
(int from, int to) static PolyString
toPolyString
(PolyStringType value) static PolyStringType
toPolyStringType
(PolyString value) toString()
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 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:
resolve
in interfaceStructured
-
plus
-
getAt
-
compareTo
- Specified by:
compareTo
in 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:
equalsOriginalValue
in interfaceRecomputable
-
toString
-
debugDump
- Specified by:
debugDump
in interfaceDebugDumpable
-
shortDump
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
TODO reconsider this method; it is quite a hack. -
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:
match
in interfaceMatchable<PolyString>
-
matches
- 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 `false` in case that there are language mutations, translation, etc. -
hasCustomNormalization
public boolean hasCustomNormalization()Returns `true` if there is a custom (non-standard) normalization, like for resource shadow attributes. Note that missing `norm` is considered to be the standard case that will be re-computed later. -
checkConsistence
public void checkConsistence()- Specified by:
checkConsistence
in 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
-
copyApplyingNormalization
public PolyString copyApplyingNormalization(@NotNull @NotNull Normalizer<String> normalizer) throws SchemaException - Throws:
SchemaException
-