Class ChangeTrackingIndirectMultilingualString

java.lang.Object
cz.cvut.kbss.jopa.model.MultilingualString
cz.cvut.kbss.jopa.proxy.change.ChangeTrackingIndirectMultilingualString
All Implemented Interfaces:
IndirectWrapper, Serializable

public class ChangeTrackingIndirectMultilingualString extends MultilingualString implements IndirectWrapper
Wraps a MultilingualString so that calls to modifying operations are intercepted and reported to the persistence context (if necessary).
See Also:
  • Constructor Details

    • ChangeTrackingIndirectMultilingualString

      public ChangeTrackingIndirectMultilingualString(Object owner, Field f, UnitOfWork uow, MultilingualString referencedString)
      Create new indirect multilingual string backed by the specified referenced MultilingualString.
      Parameters:
      owner - Owner of the string
      f - The field holding this string
      uow - Persistence context the owner belongs to
      referencedString - The string to reference
      Throws:
      NullPointerException - If the referencedString is null
  • Method Details

    • set

      public MultilingualString set(String language, String value)
      Description copied from class: MultilingualString
      Sets value in the specified language.

      This overrides any previous value in the specified language, if it existed.

      Overrides:
      set in class MultilingualString
      Parameters:
      language - Language to use with the specified value. Passing null has the same effect as MultilingualString.set(String)
      value - String value in the specified language
      Returns:
      This instance
      See Also:
    • set

      public MultilingualString set(String value)
      Description copied from class: MultilingualString
      Sets value without language.

      That is, the specified value will be stored as a simple literal (type xsd:string).

      Overrides:
      set in class MultilingualString
      Parameters:
      value - Value to set
      Returns:
      This instance
      See Also:
    • get

      public String get(String language)
      Description copied from class: MultilingualString
      Gets value for the specified language.

      If no language is specified, either the simple literal value is returned (if present), or any other existing value is returned. However, note that, in case of missing simple literal, repeated calls may return values in different languages. If there are no translations, null is returned.

      Overrides:
      get in class MultilingualString
      Parameters:
      language - Requested language (language tag). Can be null
      Returns:
      Value of this string for the specified language (or null if not available)
    • get

      public String get()
      Description copied from class: MultilingualString
      Gets the value of a simple literal represented by this instance.

      If this instances does not represent a simple literal, any other existing value is returned. However, note that in that case repeated calls may return values in different languages.

      If this object is empty (i.e., neither simple literal nor any translations are available), null is returned.

      Overrides:
      get in class MultilingualString
      Returns:
      Value of simple literal represented by this string
    • contains

      public boolean contains(String language)
      Description copied from class: MultilingualString
      Checks whether this string contains value in the specified language.

      If no language is specified (argument is null), this method will return true if there is value without language tag (simple literal) or in any other language.

      Overrides:
      contains in class MultilingualString
      Parameters:
      language - Requested language (language tag)
      Returns:
      true if this string exists in the specified language
    • containsSimple

      public boolean containsSimple()
      Description copied from class: MultilingualString
      Checks whether this string contains a simple literal value.

      That is, whether this instance contains a value without a language tag.

      Overrides:
      containsSimple in class MultilingualString
      Returns:
      true if and only if this string exists as a simple literal
    • isEmpty

      public boolean isEmpty()
      Description copied from class: MultilingualString
      Checks whether this instance does not contain any language representations (including a simple literal).
      Overrides:
      isEmpty in class MultilingualString
      Returns:
      true if no translations exist in this instance
    • remove

      public void remove(String language)
      Description copied from class: MultilingualString
      Removes translation in the specified language.

      Passing in null will remove the simple literal contained in this instance.

      Overrides:
      remove in class MultilingualString
      Parameters:
      language - Language for which translation should be removed
    • getLanguages

      public Set<String> getLanguages()
      Description copied from class: MultilingualString
      Gets the set of languages for which translations exist in the instance.

      Note that the result may contain null, indicating a simple literal.

      Overrides:
      getLanguages in class MultilingualString
      Returns:
      Set of languages available in this multilingual string
    • getValue

      public Map<String,String> getValue()
      Description copied from class: MultilingualString
      Gets the translations contained in this instance as a map of language-value pairs.

      Convenience method for accessing all values at once. Note that this method returns the actual value used by this instance, so any changes to it will be reflected in the instance's behavior. It is not a general purpose method, rather a way to access and manipulate the underlying data structure more efficiently when necessary.

      Overrides:
      getValue in class MultilingualString
      Returns:
      Map of language to translation values
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class MultilingualString
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class MultilingualString
    • toString

      public String toString()
      Overrides:
      toString in class MultilingualString
    • unwrap

      public MultilingualString unwrap()
      Description copied from interface: IndirectWrapper
      Retrieves the wrapped object.
      Specified by:
      unwrap in interface IndirectWrapper
      Returns:
      The wrapped object