|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.flexive.shared.value.FxValue<T,TDerived>
public abstract class FxValue<T,TDerived extends FxValue<T,TDerived>>
Abstract base class of all value objects. Common base classed is used for multilingual properties, etc.
To check if a value is empty a flag is used for each language resp. the single value. Use the setEmpty() method to explicity set a value to be empty
| Field Summary | |
|---|---|
static boolean |
DEFAULT_MULTILANGUAGE
|
protected long |
defaultLanguage
|
protected java.util.Map<java.lang.Long,java.lang.Boolean> |
emptyTranslations
|
protected boolean |
multiLanguage
|
protected T |
singleValue
Data if multiLanguage is disabled |
protected java.util.Map<java.lang.Long,T> |
translations
Data if multiLanguage is enabled |
| Constructor Summary | |
|---|---|
protected |
FxValue(boolean multiLanguage,
long defaultLanguage,
java.util.Map<java.lang.Long,T> translations)
Constructor |
protected |
FxValue(boolean multiLanguage,
long defaultLanguage,
T value)
Constructor |
protected |
FxValue(boolean multiLanguage,
java.util.Map<java.lang.Long,T> translations)
Constructor |
protected |
FxValue(boolean multiLanguage,
T value)
Constructor |
protected |
FxValue(FxValue<T,TDerived> clone)
Constructor |
protected |
FxValue(long defaultLanguage,
boolean multiLanguage)
Initialize an empty FxValue (used for initalization for XML import, etc.) |
protected |
FxValue(long defaultLanguage,
java.util.Map<java.lang.Long,T> translations)
Constructor |
protected |
FxValue(long defaultLanguage,
T value)
Constructor |
protected |
FxValue(java.util.Map<java.lang.Long,T[]> translations,
int pos)
Constructor - create value from an array of translations |
protected |
FxValue(java.util.Map<java.lang.Long,T> translations)
Constructor |
protected |
FxValue(T value)
Constructor |
| Method Summary | |
|---|---|
void |
clearDefaultLanguage()
Reset the default language to the system language |
int |
compareTo(FxValue o)
A generic comparable implementation based on the value's string representation. |
abstract TDerived |
copy()
Creates a copy of the given object (useful if the actual type is unknown). |
boolean |
equals(java.lang.Object other)
|
abstract T |
fromString(java.lang.String value)
Evaluates the given string value to an object of type T. |
T |
getBestTranslation()
Get the translation that best fits the current users language. |
T |
getBestTranslation(FxLanguage language)
Get the translation that best fits the requested language. |
T |
getBestTranslation(long lang)
Get the translation that best fits the requested language. |
T |
getBestTranslation(UserTicket ticket)
Get the translation that best fits the requested users language. |
long |
getDefaultLanguage()
Get the default language of this value |
T |
getDefaultTranslation()
Get a representation of this value in the default translation |
abstract T |
getEmptyValue()
Returns an empty value object for this FxValue type. |
T |
getErrorValue()
Returns the value that caused isValid() to return false. |
boolean |
getIsEmpty()
Like empty(), for JSF EL, since empty cannot be used. |
int |
getMaxInputLength()
Returns the maximum input length an input field should have for this value (or -1 for unlimited length). |
long |
getSelectedLanguage()
Get the language selected in user interfaces |
java.lang.String |
getSqlValue()
Format this FxValue for inclusion in a SQL statement. |
java.lang.String |
getStringValue(T value)
Converts the given instance of T to a string that can be parsed again by fromString(String). |
long[] |
getTranslatedLanguages()
Get all languages for which translations exist |
T |
getTranslation(FxLanguage lang)
Get a String representation of this value in the requested language or an empty String if the translation does not exist |
T |
getTranslation(long lang)
Get the translation for a requested language |
abstract java.lang.Class<T> |
getValueClass()
Return the class instance of the value type. |
java.lang.String |
getXPath()
Get the XPath for this value - the XPath is optional and can be an empty String if not explicitly assigned! |
java.lang.String |
getXPathName()
Returns the name of the value from the xpath. |
boolean |
hasDefaultLanguage()
Is a default value set for this FxValue? |
int |
hashCode()
|
protected boolean |
isAcceptsEmptyDefaultTranslations()
|
boolean |
isDefaultLanguage(long language)
Check if the passed language is the default language |
boolean |
isEmpty()
Is this value empty? |
boolean |
isImmutableValueType()
Return true if T is immutable (e.g. |
boolean |
isMultiLanguage()
Is this value available for multiple languages? |
boolean |
isReadOnly()
Is this value editable by the user? This always returns true except it is a FxNoAccess value or flagged as readOnly |
boolean |
isTranslationEmpty(FxLanguage lang)
Check if the translation for the given language is empty |
boolean |
isTranslationEmpty(long lang)
Check if the translation for the given language is empty |
boolean |
isValid()
Returns true if this value is valid for the actual type (e.g. |
void |
removeLanguage(long language)
Remove the translation for the given language |
void |
setDefaultLanguage(long defaultLanguage)
Set the default language. |
void |
setDefaultLanguage(long defaultLanguage,
boolean force)
Set the default language. |
FxValue |
setDefaultTranslation(T translation)
Set the translation in the default language. |
TDerived |
setEmpty()
Mark this FxValue as empty |
void |
setEmpty(long language)
Mark the entry for the given language as empty |
void |
setMaxInputLength(int maxInputLength)
Set the maximum input length for this value (-1 for unlimited length). |
void |
setReadOnly()
One-time operation to flag this FxValue as read only. |
FxValue |
setSelectedLanguage(long selectedLanguage)
Set the user selected language |
TDerived |
setTranslation(FxLanguage lang,
T translation)
Set the translation for a language or override the single language value if this value is not flagged as multi language enabled |
TDerived |
setTranslation(long language,
T value)
Set the translation for a language or override the single language value if this value is not flagged as multi language enabled. |
void |
setValue(T value)
For multilanguage values, set the default translation. |
TDerived |
setXPath(java.lang.String XPath)
Set the XPath (unless readonly) |
java.lang.String |
toString()
|
boolean |
translationExists(long languageId)
Does a translation exist for the given language? |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final boolean DEFAULT_MULTILANGUAGE
protected boolean multiLanguage
protected long defaultLanguage
protected java.util.Map<java.lang.Long,T> translations
multiLanguage is enabled
protected java.util.Map<java.lang.Long,java.lang.Boolean> emptyTranslations
protected T singleValue
multiLanguage is disabled
| Constructor Detail |
|---|
protected FxValue(boolean multiLanguage,
long defaultLanguage,
java.util.Map<java.lang.Long,T> translations)
multiLanguage - multilanguage value?defaultLanguage - the default languagetranslations - HashMap containing language->translation mapping
protected FxValue(long defaultLanguage,
boolean multiLanguage)
defaultLanguage - default languagemultiLanguage - multilanguage value?
protected FxValue(long defaultLanguage,
java.util.Map<java.lang.Long,T> translations)
defaultLanguage - the default languagetranslations - HashMap containing language->translation mapping
protected FxValue(boolean multiLanguage,
java.util.Map<java.lang.Long,T> translations)
multiLanguage - multilanguage value?translations - HashMap containing language->translation mappingprotected FxValue(java.util.Map<java.lang.Long,T> translations)
translations - HashMap containing language->translation mapping
protected FxValue(java.util.Map<java.lang.Long,T[]> translations,
int pos)
translations - HashMap containing language->translation mappingpos - position (index) in the array to use
protected FxValue(boolean multiLanguage,
long defaultLanguage,
T value)
multiLanguage - multilanguage value?defaultLanguage - the default languagevalue - single initializing value
protected FxValue(long defaultLanguage,
T value)
defaultLanguage - the default languagevalue - single initializing value
protected FxValue(boolean multiLanguage,
T value)
multiLanguage - multilanguage value?value - single initializing valueprotected FxValue(T value)
value - single initializing valueprotected FxValue(FxValue<T,TDerived> clone)
clone - original FxValue to be cloned| Method Detail |
|---|
public java.lang.String getXPath()
public java.lang.String getXPathName()
public TDerived setXPath(java.lang.String XPath)
XPath - the XPath to set, will be ignored if readonly
public void setReadOnly()
public TDerived setEmpty()
public void setEmpty(long language)
language - the language to flag as emptypublic abstract java.lang.Class<T> getValueClass()
public abstract T fromString(java.lang.String value)
value - string value to be evaluated
public java.lang.String getStringValue(T value)
fromString(String).
value - the value to be converted
fromString(String).public abstract TDerived copy()
public boolean isImmutableValueType()
public boolean isReadOnly()
FxNoAccesspublic boolean isValid()
public T getErrorValue()
throws java.lang.IllegalStateException
isValid() to return false. If isValid() is true,
a RuntimeException is thrown.
isValid() to fail
java.lang.IllegalStateException - if the instance is valid and the error value is undefinedpublic T getDefaultTranslation()
public T getTranslation(long lang)
lang - requested language
public T getTranslation(FxLanguage lang)
lang - requested language id
public T getBestTranslation(long lang)
lang - requested best-fit language
public T getBestTranslation(FxLanguage language)
language - requested best-fit language
public T getBestTranslation(UserTicket ticket)
ticket - UserTicket to obtain the users language
public T getBestTranslation()
public long[] getTranslatedLanguages()
public boolean translationExists(long languageId)
languageId - language to query
public boolean getIsEmpty()
public boolean isEmpty()
public boolean isTranslationEmpty(FxLanguage lang)
lang - language to check
public boolean isTranslationEmpty(long lang)
lang - language to check
public long getSelectedLanguage()
public FxValue setSelectedLanguage(long selectedLanguage)
throws FxNoAccessException
selectedLanguage - selected language ID
FxNoAccessException - if the selected Language is not contained
public final TDerived setTranslation(long language,
T value)
language - language to set the translation forvalue - translation
public TDerived setTranslation(FxLanguage lang,
T translation)
lang - language to set the translation fortranslation - translation
public void setValue(T value)
value - the value to be storedpublic FxValue setDefaultTranslation(T translation)
translation - the default translation
public long getDefaultLanguage()
public int getMaxInputLength()
public void setMaxInputLength(int maxInputLength)
maxInputLength - the maximum input length for this value (-1 for unlimited length).public void setDefaultLanguage(long defaultLanguage)
defaultLanguage - requested default language
public void setDefaultLanguage(long defaultLanguage,
boolean force)
defaultLanguage - requested default languageforce - if true, the default language will also be updated if no translation exists (for UI input)public void clearDefaultLanguage()
public boolean hasDefaultLanguage()
public boolean isDefaultLanguage(long language)
language - the language to check
public void removeLanguage(long language)
language - the language to remove the translation forpublic boolean isMultiLanguage()
protected boolean isAcceptsEmptyDefaultTranslations()
public java.lang.String getSqlValue()
public abstract T getEmptyValue()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(FxValue o)
compareTo in interface java.lang.Comparable<FxValue>o - the other object
Comparable.compareTo(T).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||