www.element4solution.com

e4s.translate
Class E4Label

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.html.E4HtmlObject
          extended by e4s.html.E4HtmlElementGeneral
              extended by e4s.translate.E4Label
All Implemented Interfaces:
E4HtmlElement_Intf, E4Label_Intf
Direct Known Subclasses:
E4LabelApp, E4LabelSys

public abstract class E4Label
extends E4HtmlElementGeneral
implements E4HtmlElement_Intf, E4Label_Intf

Basic translation object.

Since:
JDK 1.4
See Also:
E4LabelApp, E4LabelSys, Language

Field Summary
protected  java.lang.String m_destination
           
protected  java.lang.String[] m_params
           
protected  java.lang.String m_source
           
static int TRANS_TYPE_APP
          Application type, to be used within the application development.
static int TRANS_TYPE_DATA
          Application type, to be used within the application development.
static int TRANS_TYPE_NONE
          Used for translation types, which do not have translation capabilities, such as E4LabelNone.
static int TRANS_TYPE_SYS
          Core system translation types, to be used only within the e4s development, not intended to be used for application development.
 
Fields inherited from class e4s.html.E4HtmlElementGeneral
m_elements, m_needed_scripts
 
Fields inherited from class e4s.html.E4HtmlObject
m_parent_e4sID
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4Label(E4String s)
           
E4Label(E4String s, java.lang.String[] params)
           
E4Label(E4String s, java.lang.String param1, java.lang.String param2, java.lang.String param3)
           
E4Label(java.lang.String s)
           
E4Label(java.lang.String s, java.lang.String param1)
           
E4Label(java.lang.String s, java.lang.String[] params)
           
E4Label(java.lang.String s, java.lang.String param1, java.lang.String param2)
           
E4Label(java.lang.String s, java.lang.String param1, java.lang.String param2, java.lang.String param3)
           
E4Label(java.lang.String s, java.lang.String param1, java.lang.String param2, java.lang.String param3, java.lang.String param4)
           
 
Method Summary
static java.lang.String _getSVNVersionString()
          Get version info string from subversion.
abstract  java.lang.Object clone()
           
 void collectTranslationsForEditing(E4TranslationsVec translations, E4ServletImplementation_Intf servlet)
          Build a list (Vector) with translation texts used so far during display of this page.
 int compareTo(Language dest_lang, E4Label_Intf val2)
          Compare the translated results with those of another label.
 java.lang.String getDest(Language user_lang)
          Get the destination string for targeting the current running user language.
 java.lang.String getDest(Language user_lang, boolean brakets_if_not_translated)
          Get the destination string for targeting the current running user language, but set the result in brackets [] if not available if required.
 boolean getForceEncode()
           
 java.lang.String getSource()
          Get the source string, this is equivalent the String that is used during construction of the object and is used in the program code.
abstract  int getType()
          Get the type of the translation.
static java.lang.String replaceTranslations(java.lang.String str, java.lang.String[] params)
          Replacement of '#' characters to elements provided in the array.
protected  boolean requiresTranslation()
          Check, if String is some spacial character sequence, e.g. empty strings or E4Object.NBSP, which requires no translation at all.
 void setDest(Language user_lang, java.lang.String dest, E4User user)
           
 void setForceEncode()
          Force to explicit call E4Util._encodeHtml(String) before rendering the translated text.
abstract  boolean shallHaveTranslation()
          Check, if this object shall have an translation.
abstract  boolean showUntranslatedInBrackets()
          Retrieve the current state for the display behavior for non-translated items.
abstract  void showUntranslatedInBrackets(boolean mode)
          Change the current display behavior for non-translated items.
 void toHtml(E4StringBufferHtml buf, E4ServletImplementation_Intf servlet)
          Create the HTML output for this element.
 java.lang.String toString()
          Debug capabilities only - do not use except debugging and tracing.
 
Methods inherited from class e4s.html.E4HtmlElementGeneral
addScript, addScript, addScript, addStyleForEditing, addTranslationForEditing, buildStyleAttribute, buildStyleClassReference, collectScripts, collectStylesForEditing, collectStylesForEditing, collectStylesForEditing, collectTranslationsForEditing, createScript, createScript, debugToString, findElement, findElement, findElement, findElement, getElements, getElementsVec, getField, getId, getLastElement, getStringContent, getStyle, getSTYLE, getStyle, hasScripts, hasSTYLE, isContentClass, isE4InputField_Intf, openTag, removeAll, removeElementById, removeElements, removeElements, removeStyle, setId, setReadOnly, setStyle, setStyle, setSTYLE, setValue, Style, Style, toHtml_hidden, validate
 
Methods inherited from class e4s.html.E4HtmlObject
E4ID, E4ID, set_e4sID
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, finalize, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_source

protected java.lang.String m_source

m_destination

protected java.lang.String m_destination

m_params

protected java.lang.String[] m_params

TRANS_TYPE_NONE

public static final int TRANS_TYPE_NONE
Used for translation types, which do not have translation capabilities, such as E4LabelNone.

See Also:
E4LabelNone, E4Label_Intf.getType(), TRANS_TYPE_SYS, TRANS_TYPE_APP, Constant Field Values

TRANS_TYPE_SYS

public static final int TRANS_TYPE_SYS
Core system translation types, to be used only within the e4s development, not intended to be used for application development.

See Also:
E4LabelSys, E4Label_Intf.getType(), TRANS_TYPE_NONE, TRANS_TYPE_APP, TRANS_TYPE_DATA, Constant Field Values

TRANS_TYPE_APP

public static final int TRANS_TYPE_APP
Application type, to be used within the application development.

See Also:
E4LabelApp, E4Label_Intf.getType(), TRANS_TYPE_NONE, TRANS_TYPE_SYS, TRANS_TYPE_DATA, Constant Field Values

TRANS_TYPE_DATA

public static final int TRANS_TYPE_DATA
Application type, to be used within the application development.

See Also:
E4LabelData, E4Label_Intf.getType(), TRANS_TYPE_NONE, TRANS_TYPE_SYS, TRANS_TYPE_APP, Constant Field Values
Constructor Detail

E4Label

public E4Label(java.lang.String s)

E4Label

public E4Label(java.lang.String s,
               java.lang.String param1)

E4Label

public E4Label(java.lang.String s,
               java.lang.String param1,
               java.lang.String param2)

E4Label

public E4Label(java.lang.String s,
               java.lang.String param1,
               java.lang.String param2,
               java.lang.String param3)

E4Label

public E4Label(java.lang.String s,
               java.lang.String param1,
               java.lang.String param2,
               java.lang.String param3,
               java.lang.String param4)

E4Label

public E4Label(java.lang.String s,
               java.lang.String[] params)

E4Label

public E4Label(E4String s,
               java.lang.String param1,
               java.lang.String param2,
               java.lang.String param3)

E4Label

public E4Label(E4String s)

E4Label

public E4Label(E4String s,
               java.lang.String[] params)
Method Detail

setDest

public void setDest(Language user_lang,
                    java.lang.String dest,
                    E4User user)

getDest

public java.lang.String getDest(Language user_lang)
Description copied from interface: E4Label_Intf
Get the destination string for targeting the current running user language. The language of this string is always E4ServletImplementation.getLanguage(). E4Label: It will not be ensured, that each String has a valida translation so far. It is intended to use the module E4ModuleTranslationsEditing for translation of the source String (E4Label_Intf.getSource(). If no translation is available, usually the source string will be returned within brackets [ ] to indicate the user that a translation is missing. E4String: This interface is also implemented for compatibility reasons in E4String but it is not intended that a E4String holds any translation information, so this classes would always return the same String as defined as source.

Specified by:
getDest in interface E4Label_Intf
See Also:
E4Label_Intf.getSource(), #getDest(boolean)

getDest

public java.lang.String getDest(Language user_lang,
                                boolean brakets_if_not_translated)
Description copied from interface: E4Label_Intf
Get the destination string for targeting the current running user language, but set the result in brackets [] if not available if required. The language of this string is always E4ServletImplementation.getLanguage(). E4Label: It will not be ensured, that each String has a valida translation so far. It is intended to use the module E4ModuleTranslationsEditing for translation of the source String (E4Label_Intf.getSource(). If no translation is available, usually the source string will be returned within brackets [ ] to indicate the user that a translation is missing. E4String: This interface is also implemented for compatibility reasons in E4String but it is not intended that a E4String holds any translation information, so this classes would always return the same String as defined as source.

Specified by:
getDest in interface E4Label_Intf
brakets_if_not_translated - a value of true sets the result value in brackets [] to indicate, that no translation is available and to avoid having null or blank values, a value of false treats the result as it is
Returns:
the result translation, depending on the parmeter setting
See Also:
E4Label_Intf.getSource(), E4Label_Intf.getDest(e4s.application.Language)

requiresTranslation

protected boolean requiresTranslation()
Check, if String is some spacial character sequence, e.g. empty strings or E4Object.NBSP, which requires no translation at all.

Returns:
false if the source String (getSource() is null, is empty, has a length of 1 or equals E4Object.NBSP

getSource

public java.lang.String getSource()
Get the source string, this is equivalent the String that is used during construction of the object and is used in the program code.

Specified by:
getSource in interface E4Label_Intf
Returns:
the source String
See Also:
getDest(e4s.application.Language), #getDest(boolean)

toString

public java.lang.String toString()
Debug capabilities only - do not use except debugging and tracing.

Overrides:
toString in class E4Object

toHtml

public void toHtml(E4StringBufferHtml buf,
                   E4ServletImplementation_Intf servlet)
            throws java.lang.Exception
Description copied from interface: E4HtmlElement_Intf
Create the HTML output for this element. Also run throught all child elements, and call their E4HtmlElement_Intf.toHtml(e4s.util.E4StringBufferHtml, e4s.servlet.E4ServletImplementation_Intf) function to generate output of those objects which becomes appended. Normally, there is no need to call this function anyway, and this also might result in side effects of too-early relasing of objects in some cases. This function is called by E4ServletImplementation_Intf.write(e4s.html.E4HtmlElement) on the top level HTML element (common this is a HTML or BODY element) and branches down to all child elements.

Specified by:
toHtml in interface E4HtmlElement_Intf
Overrides:
toHtml in class E4HtmlElementGeneral
servlet - the servlet environment currently running in
Throws:
java.lang.Exception

collectTranslationsForEditing

public void collectTranslationsForEditing(E4TranslationsVec translations,
                                          E4ServletImplementation_Intf servlet)
Description copied from class: E4HtmlElementGeneral
Build a list (Vector) with translation texts used so far during display of this page. Run throught all subclasses elements and collect their texts as well. Note, that a text will only be added one time. The Vector contains elements of class E4Label.

Specified by:
collectTranslationsForEditing in interface E4HtmlElement_Intf
Overrides:
collectTranslationsForEditing in class E4HtmlElementGeneral
Parameters:
translations - the Vector where the styles will be collected, may not be null
servlet - the current servlet instance
See Also:
E4Label_Intf

getType

public abstract int getType()
Get the type of the translation. Generally, This will be one of TRANS_TYPE_SYS, TRANS_TYPE_APP or TRANS_TYPE_NONE (but not for this case).

Specified by:
getType in interface E4Label_Intf
Returns:
the value of TRANS_TYPE_APP or TRANS_TYPE_SYS
See Also:
TRANS_TYPE_SYS, TRANS_TYPE_APP, TRANS_TYPE_NONE

shallHaveTranslation

public abstract boolean shallHaveTranslation()
Description copied from interface: E4Label_Intf
Check, if this object shall have an translation. For example, there are objects not intended to have an translation in general such as E4LabelNone

Specified by:
shallHaveTranslation in interface E4Label_Intf
Returns:
true if a translations is required in principal

compareTo

public int compareTo(Language dest_lang,
                     E4Label_Intf val2)
Compare the translated results with those of another label.

Specified by:
compareTo in interface E4Label_Intf
Returns:
the value 0 if the argument label is equal to this label; a value less than 0 if this label is lexicographically less than the label argument; and a value greater than 0 if this label is lexicographically greater than the label argument.

replaceTranslations

public static java.lang.String replaceTranslations(java.lang.String str,
                                                   java.lang.String[] params)
Replacement of '#' characters to elements provided in the array. Example:
replaceTranslations("My name is # and i am # years old",new String[] {"Robert","66"})
 would return a value of "My name is Robert and i am 66 years old"

Parameters:
str - the basic String where replacements shall take place
params - an array of possible parameters to be replaced, one by one, in the order and position of the '#' character withn the String
Returns:
null if the argument str is null, the argument string if the params array is null or has a length of 0, the argument string if if does not at least contain one '#' character, the replacemts within the argument string.

showUntranslatedInBrackets

public abstract boolean showUntranslatedInBrackets()
Retrieve the current state for the display behavior for non-translated items. By default, if a translation is not found then the text will be displayed in original text and language instead of the translated text. To give the user a feedback about this missing translation, the non-translated text in original language in this case will be displayed included in [ ] brackets.

Returns:
true = show un-translated text in brackets (default), false = no brackets
See Also:
showUntranslatedInBrackets(boolean)

showUntranslatedInBrackets

public abstract void showUntranslatedInBrackets(boolean mode)
Change the current display behavior for non-translated items. By default, if a translation is not found then the text will be displayed in original text and language instead of the translated text. To give the user a feedback about this missing translation, the non-translated text in original language in this case will be displayed included in [ ] brackets.

Parameters:
mode - true = show un-translated text in brackets (default), false = no brackets
See Also:
showUntranslatedInBrackets()

setForceEncode

public void setForceEncode()
Description copied from interface: E4Label_Intf
Force to explicit call E4Util._encodeHtml(String) before rendering the translated text.

Specified by:
setForceEncode in interface E4Label_Intf

getForceEncode

public boolean getForceEncode()

clone

public abstract java.lang.Object clone()
Specified by:
clone in interface E4Label_Intf
Overrides:
clone in class java.lang.Object

_getSVNVersionString

public static java.lang.String _getSVNVersionString()
Get version info string from subversion.

Returns:
the version info string.
See Also:
E4Util.getRevisionCodeFromSVN(Class)

www.element4solution.com