eu.etaxonomy.cdm.model.description
Class TextData

java.lang.Object
  extended by eu.etaxonomy.cdm.model.common.CdmBase
      extended by eu.etaxonomy.cdm.model.common.VersionableEntity
          extended by eu.etaxonomy.cdm.model.common.AnnotatableEntity
              extended by eu.etaxonomy.cdm.model.description.DescriptionElementBase
                  extended by eu.etaxonomy.cdm.model.description.TextData
All Implemented Interfaces:
IAnnotatableEntity, ICdmBase, IMultiLanguageTextHolder, ISourceable<DescriptionElementSource>, IVersionableEntity, IModifiable, Serializable, Cloneable

@Indexed(index="eu.etaxonomy.cdm.model.description.DescriptionElementBase")
public class TextData
extends DescriptionElementBase
implements IMultiLanguageTextHolder, Cloneable

This class represents information pieces expressed in one or several natural languages (for the feature "medical use" for instance). A format used for structuring the text may also be stated.

This class corresponds partially to NaturalLanguageDescriptionType according to the SDD schema.

Version:
1.0
Author:
m.doering
See Also:
Serialized Form

Field Summary
 
Fields inherited from class eu.etaxonomy.cdm.model.common.AnnotatableEntity
annotations, markers
 
Fields inherited from class eu.etaxonomy.cdm.model.common.CdmBase
uuid
 
Constructor Summary
TextData()
          Class constructor: creates a new empty text data instance.
TextData(Feature feature)
          Class constructor: creates a new text data instance with the feature to be described.
 
Method Summary
 Object clone()
          Clones this text data.
 boolean containsKey(Language language)
           
 boolean containsValue(LanguageString languageString)
           
 int countLanguages()
          Returns the number of languages in which the content of this text data has been formulated.
 TextFormat getFormat()
          Returns the format used for structuring the text representing the content of this text data.
 LanguageString getLanguageText(Language language)
          Returns the multilanguage text with the content of this text data for a specific language.
 Map<Language,LanguageString> getMultilanguageText()
          Returns a copy of the multilanguage text with the content of this text data.
 LanguageString getPreferredLanguageString(List<Language> languages)
          Returns the LanguageString in the preferred language.
 String getText(Language language)
          Returns the text string in the given language with the content of this text data.
static TextData NewInstance()
          Creates a new empty text data instance.
static TextData NewInstance(Feature feature)
          Creates a new text data instance with the feature to be described.
static TextData NewInstance(String text, Language language, TextFormat format)
          Creates a new text data instance with a given text in a given particular language and with the given text format for structuring it.
 LanguageString putText(LanguageString languageString)
          Adds a translated text in a particular language to the multi-language text representing the content of this text data.
 LanguageString putText(Language language, String text)
          Creates a language string based on the given text string and the given language, returns it and adds it to the multilanguage text representing the content of this text data.
 LanguageString putText(String text, Language language)
          Deprecated. should follow the put semantic of maps, this method will be removed in v4.0 Use the putText method instead
 LanguageString removeText(Language language)
          Removes from the multilanguage representing the content of this text data the one language string with the given language.
 void setFormat(TextFormat format)
           
 int size()
          Returns the number of languages available for this text data.
 
Methods inherited from class eu.etaxonomy.cdm.model.description.DescriptionElementBase
addMedia, addModifier, addModifyingText, addModifyingText, addSource, addSource, addSource, clone, getFeature, getInDescription, getMedia, getModifiers, getModifiers, getModifyingText, getSources, makeModifierMap, putModifyingText, putModifyingText, removeMedia, removeModifier, removeModifyingText, removeSource, setFeature, setInDescription
 
Methods inherited from class eu.etaxonomy.cdm.model.common.AnnotatableEntity
addAnnotation, addMarker, getAnnotations, getMarkers, hasMarker, hasMarker, removeAnnotation, removeMarker
 
Methods inherited from class eu.etaxonomy.cdm.model.common.VersionableEntity
equals, getUpdated, getUpdatedBy, setUpdated, setUpdatedBy
 
Methods inherited from class eu.etaxonomy.cdm.model.common.CdmBase
addPropertyChangeListener, addPropertyChangeListener, clone, deproxy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCreated, getCreatedBy, getId, getUuid, hashCode, hasListeners, invokeSetMethod, invokeSetMethodWithNull, isInstanceOf, removePropertyChangeListener, removePropertyChangeListener, setCreated, setCreatedBy, setId, setUuid, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.IVersionableEntity
getUpdated, getUpdatedBy, setUpdated, setUpdatedBy
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.ICdmBase
getCreated, getCreatedBy, getId, getUuid, setCreated, setCreatedBy, setId, setUuid
 

Constructor Detail

TextData

public TextData()
Class constructor: creates a new empty text data instance.

See Also:
TextData(Feature)

TextData

public TextData(Feature feature)
Class constructor: creates a new text data instance with the feature to be described.

Parameters:
feature - the feature the text data refer to
See Also:
TextData()
Method Detail

NewInstance

public static TextData NewInstance()
Creates a new empty text data instance.

See Also:
NewInstance(Feature), NewInstance(String, Language, TextFormat)

NewInstance

public static TextData NewInstance(Feature feature)
Creates a new text data instance with the feature to be described.

Parameters:
feature - the feature the text data refer to
See Also:
NewInstance(), NewInstance(String, Language, TextFormat)

NewInstance

public static TextData NewInstance(String text,
                                   Language language,
                                   TextFormat format)
Creates a new text data instance with a given text in a given particular language and with the given text format for structuring it.

Parameters:
text - the text string with the content of the description
language - the language in which the text string is formulated
format - the text format used to structure the text string
See Also:
NewInstance(), NewInstance(Feature)

getMultilanguageText

public Map<Language,LanguageString> getMultilanguageText()
Returns a copy of the multilanguage text with the content of this text data. The different language strings (texts) contained in the multilanguage text should all have the same meaning.

See Also:
getText(Language)

getLanguageText

public LanguageString getLanguageText(Language language)
Returns the multilanguage text with the content of this text data for a specific language.

Parameters:
language - the language in which the text string looked for is formulated
Returns:

getText

public String getText(Language language)
Returns the text string in the given language with the content of this text data.

Parameters:
language - the language in which the text string looked for is formulated
See Also:
#getMultilanguageText(Language)

getPreferredLanguageString

public LanguageString getPreferredLanguageString(List<Language> languages)
Returns the LanguageString in the preferred language. Preferred languages are specified by the parameter languages, which receives a list of Language instances in the order of preference. If no representation in any preferred languages is found the method falls back to return the Representation in Language.DEFAULT() and if neccesary further falls back to return the first element found if any. TODO think about this fall-back strategy & see also TermBase.getPreferredRepresentation(List)

Parameters:
languages -
Returns:

putText

@Deprecated
public LanguageString putText(String text,
                                         Language language)
Deprecated. should follow the put semantic of maps, this method will be removed in v4.0 Use the putText method instead

Creates a language string based on the given text string and the given language, returns it and adds it to the multilanguage text representing the content of this text data.

Parameters:
text - the string representing the content of the text data in a particular language
language - the language in which the text string is formulated
Returns:
the previous language string associated with the given Language, or null if there was no mapping for the given Language
See Also:
getMultilanguageText(), putText(LanguageString)

putText

public LanguageString putText(Language language,
                              String text)
Creates a language string based on the given text string and the given language, returns it and adds it to the multilanguage text representing the content of this text data.

Parameters:
language - the language in which the text string is formulated
text - the string representing the content of the text data in a particular language
Returns:
the previous language string associated with the given Language, or null if there was no mapping for the given Language
See Also:
getMultilanguageText(), putText(LanguageString)

putText

public LanguageString putText(LanguageString languageString)
Adds a translated text in a particular language to the multi-language text representing the content of this text data. The given language string will be returned.

Parameters:
languageString - the language string representing the content of the text data in a particular language
Returns:
the previous language string associated with key, or null if there was no mapping for key
See Also:
getMultilanguageText(), putText(String, Language), HashMap.put(Object, Object)

removeText

public LanguageString removeText(Language language)
Removes from the multilanguage representing the content of this text data the one language string with the given language. Returns the removed language string.

Parameters:
language - the language in which the language string to be removed has been formulated
Returns:
the language string associated with the given language or null if there was no mapping for the given Language
See Also:
getMultilanguageText()

countLanguages

public int countLanguages()
Returns the number of languages in which the content of this text data has been formulated.

See Also:
getMultilanguageText()

getFormat

public TextFormat getFormat()
Returns the format used for structuring the text representing the content of this text data.

See Also:
getMultilanguageText()

setFormat

public void setFormat(TextFormat format)
See Also:
getFormat()

containsKey

public boolean containsKey(Language language)
Parameters:
language -
Returns:
See Also:
java.util.Map#containsKey(Object)}

containsValue

public boolean containsValue(LanguageString languageString)
Parameters:
languageString -
Returns:
See Also:
java.util.Map#containsValue(Object)}

size

public int size()
Returns the number of languages available for this text data.

Returns:
See Also:
java.util.Map#size()}

clone

public Object clone()
Clones this text data. This is a shortcut that enables to create a new instance that differs only slightly from this text data by modifying only some of the attributes.

Overrides:
clone in class DescriptionElementBase
See Also:
DescriptionElementBase.clone(), Object.clone()


Copyright © 2007-2012 EDIT. All Rights Reserved.