com.g11ntoolkit.levblock
Class XLEntry

java.lang.Object
  |
  +--com.g11ntoolkit.levblock.XLEntry
Direct Known Subclasses:
JSXLEntry

public class XLEntry
extends java.lang.Object

The set of information that makes up one translation entry for a particular leverage entry block.

Each entry is made up of the locale, the string, the context, and optional comments. An XLEntry can be either a source entry or a target entry.

The locales are made up of a code for the language and a code for the country. Refer to the Locale Guide in the G11NToolKit documentation for more information on locales.

The context for the string is a TokContext object.

Version:
2005/06/30
Author:
Bill Rich, Wilandra Consulting LLC
Copyright © 2001-2005, Wilandra Consulting LLC. All rights reserved.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See License Agreement.

See Also:
TokContext

Field Summary
protected  java.lang.String datatype
          The datatype for this entry block.
private static java.util.logging.Logger log
          The log used for all messages from this class.
protected static java.util.ResourceBundle mrb
          Message Resource Bundle.
protected  java.lang.String theComments
          The comments for this entry block.
protected  TokContext theContext
          The context for this entry block.
protected  java.util.Locale theLocale
          The locale for this entry block.
protected  java.lang.String theString
          The string for this entry block.
protected static java.util.ResourceBundle vrb
          Variables Resource Bundle.
protected static java.util.ResourceBundle xliffrb
          Resource Bundle for XLIFF File information.
protected static java.util.ResourceBundle xrb
          Constants, messages, and variables used by the tools and classes for XML processing.
 
Constructor Summary
XLEntry()
          Constructs an empty instance so it is ready to receive data via the set methods.
XLEntry(java.util.Locale aLocale, java.lang.String aString)
          Constructs an instance for the specified locale and string.
XLEntry(java.util.Locale aLocale, java.lang.String aString, java.lang.String aComment)
          Constructs an instance for the specified locale, string, and comments.
 
Method Summary
 void addComment(java.lang.String aComment)
          Adds the specified comment to the current comments.
 void addString(java.lang.String aString)
          Adds the specified string to the current string.
 void clean()
          Cleans the string for this entry.
 void debugDump()
          Dumps the contents of the object to StdOut.
 boolean equals(java.lang.Object anotherEntry)
          Returns true if this entry is equal to the specified object.
 boolean equals(XLEntry anotherEntry)
          Returns true if this entry is equal to the specified entry.
 java.lang.String getComments()
          Returns the comments for this entry.
 TokContext getContext()
          Returns the context for this entry.
 java.lang.String getContextDisplay()
          Returns the context for this entry in a displayable comment form.
 java.lang.String getDatatype()
          Returns the data type of the source file.
 java.util.Locale getLocale()
          Returns the locale for this entry.
 java.lang.String getString()
          Returns the string for this entry.
 boolean hasComments()
          Returns true if there are comments for this entry.
 boolean hasContext()
          Returns true if there is a context set for this entry.
 int hashCode()
          Returns a hash code for this entry.
 void setComments(java.lang.String aComment)
          Sets the comments for this entry.
 void setContext(TokContext aContext)
          Sets the context for this entry.
 void setDatatype(java.lang.String dt)
          Sets the data type of the source file.
 void setString(java.util.Locale aLocale, java.lang.String aString)
          Sets the locale and string for this entry.
 java.lang.String toString()
          Returns a displayable string of the contents of this entry.
 boolean validate()
          Returns true if this entry has a locale and a string.
 void writeFlatXML(java.io.Writer out)
          Writes the string to the specified output writer in a flat XML form.
 void writeXML(java.io.Writer out)
          Writes the string out to the specified output writer in its XML form.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log
The log used for all messages from this class.


mrb

protected static java.util.ResourceBundle mrb
Message Resource Bundle.


xliffrb

protected static java.util.ResourceBundle xliffrb
Resource Bundle for XLIFF File information.


vrb

protected static java.util.ResourceBundle vrb
Variables Resource Bundle.


xrb

protected static java.util.ResourceBundle xrb
Constants, messages, and variables used by the tools and classes for XML processing.


theLocale

protected java.util.Locale theLocale
The locale for this entry block.


theString

protected java.lang.String theString
The string for this entry block.


theComments

protected java.lang.String theComments
The comments for this entry block.


theContext

protected TokContext theContext
The context for this entry block.


datatype

protected java.lang.String datatype
The datatype for this entry block.

This is needed for the XLIFF file format. The value must be one of the values specified in the xliff.datatype section of the xliffres.java file.

See Also:
xliffres
Constructor Detail

XLEntry

public XLEntry()
Constructs an empty instance so it is ready to receive data via the set methods.


XLEntry

public XLEntry(java.util.Locale aLocale,
               java.lang.String aString)
Constructs an instance for the specified locale and string.

Parameters:
aLocale - a Locale object
aString - a String specifying the string for this entry

XLEntry

public XLEntry(java.util.Locale aLocale,
               java.lang.String aString,
               java.lang.String aComment)
Constructs an instance for the specified locale, string, and comments.

Parameters:
aLocale - a Locale object
aString - a String specifying the string for this entry
aComment - a String specifying a comment for this entry
Method Detail

setString

public void setString(java.util.Locale aLocale,
                      java.lang.String aString)
Sets the locale and string for this entry.

If the locale or string are already specified they will be replaced.

Parameters:
aLocale - a Locale object
aString - a String specifying the string for this entry
See Also:
getString()

addString

public void addString(java.lang.String aString)
Adds the specified string to the current string.

The specified string is added to the end of the current string. No extra blank or new line characters are added to the string.

Parameters:
aString - a String specifying an additional string for this entry

setComments

public void setComments(java.lang.String aComment)
Sets the comments for this entry.

Tries to make the comment a context. If it is an invalid context string then the string is treated as a comment.

If the comments are already specified they will be replaced.

If the string begins with the comment delimiter, the delimiter is removed before making the string the comment.

Parameters:
aComment - a String specifying the comments value
See Also:
getComments()

addComment

public void addComment(java.lang.String aComment)
Adds the specified comment to the current comments.

Tries to make the comment a context. If it is an invalid context string then the string is treated as a comment.

A single blank will be added to the comments before the specified comment is added.

If the string begins with the comment delimiter, the delimiter is removed before adding the string to the comments.

Parameters:
aComment - a String specifying the comments value

setContext

public void setContext(TokContext aContext)
Sets the context for this entry.

Parameters:
aContext - a TokContext object specifying the context value
See Also:
getContext()

getContext

public TokContext getContext()
Returns the context for this entry.

Returns:
a TokContext object representing the context value or null if no context is set
See Also:
setContext(com.g11ntoolkit.levblock.TokContext)

getContextDisplay

public java.lang.String getContextDisplay()
Returns the context for this entry in a displayable comment form.

Returns:
a String representing the context display value or null if not context is set

getLocale

public java.util.Locale getLocale()
Returns the locale for this entry.

Returns:
a Locale object containing the Locale value or null if no locale is set

getString

public java.lang.String getString()
Returns the string for this entry.

Returns:
a String containing the String value or null if no string is set
See Also:
setString(java.util.Locale, java.lang.String)

getComments

public java.lang.String getComments()
Returns the comments for this entry.

Returns:
a String representing the comments value or null if no comments are set
See Also:
setComments(java.lang.String)

hasContext

public boolean hasContext()
Returns true if there is a context set for this entry.

Returns:
a boolean true if there is a context value other than null

hasComments

public boolean hasComments()
Returns true if there are comments for this entry.

Returns:
a boolean true if there is a comment value other than null

setDatatype

public void setDatatype(java.lang.String dt)
Sets the data type of the source file.

Parameters:
dt - a String specifying the data type of the source file
See Also:
getDatatype(), datatype

getDatatype

public java.lang.String getDatatype()
Returns the data type of the source file.

Returns:
a String representing the data type of the source file
See Also:
setDatatype(java.lang.String), datatype

clean

public void clean()
Cleans the string for this entry.

Cleaning the string entails the reduction of all whitespace, which is outside any quoted string, to a single blank.


toString

public java.lang.String toString()
Returns a displayable string of the contents of this entry.

Overrides:
toString in class java.lang.Object
Returns:
a String that contains the contents of this object in a string form

writeXML

public void writeXML(java.io.Writer out)
              throws java.io.IOException
Writes the string out to the specified output writer in its XML form.

Parameters:
out - a Writer for the output
Throws:
java.io.IOException - when any errors are detected in writing to the output file

writeFlatXML

public void writeFlatXML(java.io.Writer out)
                  throws java.io.IOException
Writes the string to the specified output writer in a flat XML form.

The flat XML form just makes the Context element attributes of the String element.

This is done to accomodate the use of the StrFile in SDLX.

Parameters:
out - a Writer for the output
Throws:
java.io.IOException - when any errors are detected in writing to the output file

equals

public boolean equals(XLEntry anotherEntry)
Returns true if this entry is equal to the specified entry.

All parts of the entry except the comments must be equal to qualify for equality.

Parameters:
anotherEntry - a XLEntry object
Returns:
a boolean true if this XLEntry is equal to anotherEntry

equals

public boolean equals(java.lang.Object anotherEntry)
Returns true if this entry is equal to the specified object.

All parts of the entry except the comments must be equal to qualify for equality.

Overrides:
equals in class java.lang.Object
Parameters:
anotherEntry - an Object purporting to be an XLEntry
Returns:
a boolean true if the specified Object is an XLEntry and is equal to this object

hashCode

public int hashCode()
Returns a hash code for this entry.

The hash code for an XL entry is defined as the sum of the hash code for the locale and the hash code for the string.

Overrides:
hashCode in class java.lang.Object
Returns:
an int that contains the hash code for this object

validate

public boolean validate()
Returns true if this entry has a locale and a string.

Since the entry can be built up a piece at a time there needs to be some way to say that the entry is well formed at any point. Well formed means that the entry has a locale and a string. It is not required to have any comments.

Returns:
a boolean true if this XLEntry is valid

debugDump

public void debugDump()
Dumps the contents of the object to StdOut.