Class PolyString

java.lang.Object
com.evolveum.midpoint.prism.polystring.PolyString
All Implemented Interfaces:
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 Details

    • 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 Details

  • Method Details

    • 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()
    • getLang

      public Map<String,String> getLang()
    • 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)
    • recompute

      public PolyString recompute()
      Recomputes normalized value with default normalizer and returns modified `this`.
    • isComputed

      public boolean isComputed()
    • resolve

      public Object resolve(ItemPath subpath)
      Specified by:
      resolve in interface Structured
    • plus

      public PolyString plus(Object other)
    • getAt

      public PolyString getAt(int index)
    • compareTo

      public int compareTo(Object other)
      Specified by:
      compareTo in interface Comparable<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
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equalsOriginalValue

      public boolean equalsOriginalValue(Recomputable obj)
      Specified by:
      equalsOriginalValue in interface Recomputable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • debugDump

      public String debugDump(int indent)
      Specified by:
      debugDump in interface DebugDumpable
    • 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 interface ShortDumpable
      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 interface Matchable<PolyString>
    • matches

      public boolean matches(String regex)
      Specified by:
      matches in interface Matchable<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 interface Recomputable
    • toPolyString

      public static PolyString toPolyString(PolyStringType value)
    • toPolyStringType

      public static PolyStringType toPolyStringType(PolyString value)
    • fromOrig

      public static PolyString fromOrig(String orig)
      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

      public PolyString copy()