com.g11ntoolkit.levblock
Class TokContext

java.lang.Object
  |
  +--com.g11ntoolkit.levblock.TokContext

public class TokContext
extends java.lang.Object

The set of information that makes up the context of a string that has been tokenized for translation.

The context is made up of 2 parts each of which has 2 parts in the following structure:

  1. where the item is used
    1. the file name: the name of the file that contains the tokenized string
    2. the element identifier: the element within the file, could be a key, or a line number, or anything else that will identify where the item is located within the file
  2. how the item is used
    1. the linguistic use: could be something like noun, verb, ...
    2. the technical use: could be something like button title, text string, window title, ...

Version:
2005/06/20
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.


Field Summary
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.
private  java.lang.String useL
          The linguistic part of the use attribute.
private  java.lang.String useT
          The technical part of the use attribute.
protected static java.util.ResourceBundle vrb
          Variables Resource Bundle.
private  java.lang.String whereEI
          The element identifier part of the where attribute.
private  java.lang.String whereFN
          The file name part of the where attribute.
private static java.util.ResourceBundle xrb
          Constants, messages, and variables used by the tools and classes for XML processing.
 
Constructor Summary
TokContext()
          Constructs an empty instance so it is ready to receive data via the set methods.
TokContext(java.lang.String cs)
          Constructs an instance from a string.
TokContext(java.lang.String fn, java.lang.String ei, java.lang.String ul, java.lang.String ut)
          Constructs an instance using the specified information.
 
Method Summary
 void debugDump()
          Dumps the contents of the object to the console.
 boolean equals(java.lang.Object anotherContext)
          Returns true if this context is equal to the specified object.
 boolean equals(TokContext anotherContext)
          Returns true if this context is equal to the specified context.
 java.lang.String getElement()
          Returns the element identifier part of the where attribute.
 java.lang.String getFileName()
          Returns the file name part of the where attribute.
 java.lang.String getLinguisticUse()
          Returns the linguistic use part of the use attribute.
 java.lang.String getTechnicalUse()
          Returns the technical use part of the use attribute.
 int hashCode()
          Returns a hash code for this entry.
 boolean isEmpty()
          Returns true if all of the parts of the context are null, false, if any one part is not null.
private  java.lang.String[] parsePattern(java.lang.String pattern)
          Parses the context pattern and returns a string array with its parts.
 void setElement(java.lang.String anElementId)
          Sets the element identifier part of the where attribute.
 void setFileName(java.lang.String aFileName)
          Sets the file name part of the where attribute.
 void setLinguisticUse(java.lang.String aUse)
          Sets the linguistic use part of the use attribute.
 void setTechnicalUse(java.lang.String aUse)
          Sets the technical use part of the use attribute.
 void setUse(java.lang.String aLinguisticUse, java.lang.String aTechnicalUse)
          Sets the use attribute.
 void setWhere(java.lang.String aFileName, java.lang.String anElementId)
          Sets the where attribute.
 java.lang.String toString()
          Returns the a displayable string for this context.
 java.lang.String[] toStringArray()
          Returns a string array of the elements of this context.
 void writeXML(java.io.Writer out)
          Writes the contents of the object to the specified Writer in 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.


vrb

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


xrb

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


whereFN

private java.lang.String whereFN
The file name part of the where attribute.


whereEI

private java.lang.String whereEI
The element identifier part of the where attribute.


useL

private java.lang.String useL
The linguistic part of the use attribute.


useT

private java.lang.String useT
The technical part of the use attribute.

Constructor Detail

TokContext

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


TokContext

public TokContext(java.lang.String fn,
                  java.lang.String ei,
                  java.lang.String ul,
                  java.lang.String ut)
Constructs an instance using the specified information.

Parameters:
fn - a String specifying the file name
ei - a String specifying the key id
ul - a String specifying the linguistic use
ut - a String specifying the technical use

TokContext

public TokContext(java.lang.String cs)
           throws MalformedContextPattern,
                  InvalidContextString
Constructs an instance from a string.

The string must conform to the context.display message in the messages.properties file.

Parameters:
cs - a String specifying the context in a string form
Throws:
MalformedContextPattern - if the specified string is not a well formed context
InvalidContextString - if the specified string is an invalid context
Method Detail

parsePattern

private java.lang.String[] parsePattern(java.lang.String pattern)
Parses the context pattern and returns a string array with its parts.

Parameters:
pattern - a String specifying the context in a string form
Returns:
a String Array representing the elements of the context

setWhere

public void setWhere(java.lang.String aFileName,
                     java.lang.String anElementId)
Sets the where attribute.

Parameters:
aFileName - a String specifying a file name
anElementId - a String specifying a key id

setFileName

public void setFileName(java.lang.String aFileName)
Sets the file name part of the where attribute.

Parameters:
aFileName - a String specifying the file name value
See Also:
getFileName()

getFileName

public java.lang.String getFileName()
Returns the file name part of the where attribute.

Returns:
a String representing the file name value
See Also:
setFileName(java.lang.String)

setElement

public void setElement(java.lang.String anElementId)
Sets the element identifier part of the where attribute.

Parameters:
anElementId - a String specifying the element value
See Also:
getElement()

getElement

public java.lang.String getElement()
Returns the element identifier part of the where attribute.

Returns:
a String representing the element value
See Also:
setElement(java.lang.String)

setUse

public void setUse(java.lang.String aLinguisticUse,
                   java.lang.String aTechnicalUse)
Sets the use attribute.

Parameters:
aLinguisticUse - a String specifying the linguistic use value
aTechnicalUse - a String specifying the technical use value

setLinguisticUse

public void setLinguisticUse(java.lang.String aUse)
Sets the linguistic use part of the use attribute.

Parameters:
aUse - a String specifying the linguistic use value
See Also:
getLinguisticUse()

getLinguisticUse

public java.lang.String getLinguisticUse()
Returns the linguistic use part of the use attribute.

Returns:
a String representing the linguistic use value
See Also:
setLinguisticUse(java.lang.String)

setTechnicalUse

public void setTechnicalUse(java.lang.String aUse)
Sets the technical use part of the use attribute.

Parameters:
aUse - a String specifying the technical use value
See Also:
getTechnicalUse()

getTechnicalUse

public java.lang.String getTechnicalUse()
Returns the technical use part of the use attribute.

Returns:
a String representing the technical use value
See Also:
setTechnicalUse(java.lang.String)

isEmpty

public boolean isEmpty()
Returns true if all of the parts of the context are null, false, if any one part is not null.

Returns:
true if this object is empty

toString

public java.lang.String toString()
Returns the a displayable string for this context.

Overrides:
toString in class java.lang.Object
Returns:
a String representing the context

toStringArray

public java.lang.String[] toStringArray()
Returns a string array of the elements of this context.

The elements are returned in the following positions of the array:

Returns:
a String Array containing the parts of the context

equals

public boolean equals(TokContext anotherContext)
Returns true if this context is equal to the specified context.

All parts of the context must be equal to qualify for equality.

Parameters:
anotherContext - a TokContext object
Returns:
true if the specified TokContext object is equal to this object

equals

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

The specified object must be TokContext object and all parts of the context must be equal to qualify for equality.

Overrides:
equals in class java.lang.Object
Parameters:
anotherContext - an Object specifying the object to compare this instance to
Returns:
true if the specified object is a TokContext object and 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 representing the hash code for this object

writeXML

public void writeXML(java.io.Writer out)
              throws java.io.IOException
Writes the contents of the object to the specified Writer in XML form.

Parameters:
out - a Writer for the desired output
Throws:
java.io.IOException - if the Writer detects any errors

debugDump

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