|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.g11ntoolkit.levblock.LeverageBlock
The set of information for a token that can be used to leverage existing translations.
Each entry is made up of a token, token comments, a source translation entry, and one or more target translation entries. The target entries table may be null. The token and the source translation entry may not be null.
A leverage block when seen in a file has a definite format:
tokenoptional token comments - may be more than one linesource translation entry - includes locale and stringoptional source translation entry comments - may be more than one linetarget translation entry 1 - includes locale and stringoptional target translation entry 1 comments - may be more than one linetarget translation entry n - includes locale and stringoptional target translation entry n comments - may be more than one line
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.
XLEntry,
Token| Field Summary | |
private static java.util.logging.Logger |
log
The log used for all messages from this class. |
private static java.util.ResourceBundle |
mrb
Message Resource Bundle. |
private XLEntry |
sourceEntry
The source entry for this block. |
private java.util.Hashtable |
targetEntries
The target entries for the block. |
private int |
targetEntryCount
The current number of entries in the target entries table. |
private Token |
token
The token for this block. |
private java.lang.String |
tokenComments
The token comments for this block. |
private static java.util.ResourceBundle |
vrb
Constants Resource Bundle. |
private static java.util.ResourceBundle |
xrb
Constants, messages, and variables used by the tools and classes for XML processing. |
| Constructor Summary | |
LeverageBlock()
Creates an empty instance of LeverageBlock so it is ready to receive data via the set methods. |
|
LeverageBlock(java.lang.StringBuffer someRecords)
Creates an instance of LeverageBlock from the specified string buffer. |
|
LeverageBlock(Token aToken)
Creates an instance of LeverageBlock for the specified token. |
|
LeverageBlock(Token aToken,
XLEntry aSource,
XLEntry aTarget)
Creates an instance of LeverageBlock for the specified token, source entry, and target entry. |
|
| Method Summary | |
void |
addTarget(XLEntry aTarget)
Adds a target entry to the current set of target entries for this block. |
void |
addTokenComment(java.lang.String aComment)
Adds the specified comment to the token comments for this block. |
void |
debugDump()
Prints the entire contents of this object to the console for debugging purposes. |
void |
debugDump(java.lang.String what)
Prints the contents of this object to the console for debugging purposes. |
boolean |
equals(LeverageBlock anotherBlock)
Returns true if this block is equal to the specified block. |
boolean |
equals(java.lang.Object anotherBlock)
Returns true if this block is equal to the specified object. |
int |
getCount()
Returns the count of target entry blocks. |
XLEntry |
getSource()
Returns the source entry for this block. |
java.util.Hashtable |
getTargets()
Returns the target entries for this block. |
Token |
getToken()
Returns the token for this block. |
java.lang.String |
getTokenComments()
Returns the token comments for this block. |
int |
hashCode()
Returns a hash code for this leverage block. |
boolean |
hasSource()
Returns true if the block has a source translation entry. |
boolean |
hasTargets()
Returns true if the block has a target translation entry. |
boolean |
hasToken()
Returns true if the block has a token. |
boolean |
hasTokenComments()
Returns true if the block has a token comments. |
void |
setSource(XLEntry aSource)
Sets the source entry for this block. |
void |
setTargets(java.util.Hashtable someTargets)
Sets the target entries for this block to the specified set of target entries. |
void |
setToken(Token aToken)
Sets the token for this block. |
void |
setToken(Token aToken,
java.lang.String aComment)
Sets the token and its comments for this block. |
void |
setTokenComments(java.lang.String aComment)
Sets the token comments for this block. |
java.lang.String |
toString()
Returns the contents of this block as a string. |
boolean |
validate()
Returns true if this block is well formed. |
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 |
private static java.util.logging.Logger log
private static java.util.ResourceBundle mrb
private static java.util.ResourceBundle vrb
private static java.util.ResourceBundle xrb
private Token token
private java.lang.String tokenComments
private XLEntry sourceEntry
There can be only one source entry for a block. The source entry is made up of a locale, a string, and some comments. Comments are optional.
private java.util.Hashtable targetEntries
Each target entry may be for the same locale or for different locales. The key to this table is a sequence number for the entry in the target entries. The keys in the table begin with 1. There is no theoretical upper limit on the number of entries in the table.
private int targetEntryCount
This index is used as the key for each target entry.
| Constructor Detail |
public LeverageBlock()
LeverageBlock so it is ready to receive data via the set methods.
public LeverageBlock(Token aToken)
LeverageBlock for the specified token.
It is assumed that the data will be added later via the set methods.
aToken - a Token object
public LeverageBlock(Token aToken,
XLEntry aSource,
XLEntry aTarget)
LeverageBlock for the specified token, source entry, and target entry.
The source or target entries may be null.
aToken - a Token objectaSource - a XLEntry object specifying the source translation entryaTarget - a XLEntry object specifying the target translation entry
public LeverageBlock(java.lang.StringBuffer someRecords)
throws LeverageBlockError
LeverageBlock from the specified string buffer.
Parse the buffer to find the token information, the source translation entry, and the target translation entries.
someRecords - a StringBuffer object specifying the records for this object
LeverageBlockError - when there is an error in processing the records| Method Detail |
public void setToken(Token aToken)
If the token already exists it will be replaced. If the token or its comments already exist they will be replaced. If the token is replaced, it is assumed that it does not conflict with and information in any of the targets which may exist. No checking is done in this method.
aToken - a Token specifying the Token valuegetToken()
public void setToken(Token aToken,
java.lang.String aComment)
If the token or its comments already exist they will be replaced. If the token is replaced, it is assumed that it does not conflict with and information in any of the targets which may exist. No checking is done in this method.
aToken - a Token object specifying the tokenaComment - a String specifying the commentgetToken()public void setTokenComments(java.lang.String aComment)
If the token comments already exist they will be replaced.
If the string begins with the comment delimiter, the delimiter is removed before making the string the comment.
aComment - a String specifying the token comments valuegetTokenComments()public void addTokenComment(java.lang.String aComment)
A single blank will added to the comments before the new comment is added.
If the string begins with the comment delimiter, the delimiter is removed before adding the string to the comments.
aComment - a String specifying the commentpublic void setSource(XLEntry aSource)
If the source entry already exists it will be replaced. If the source entry is replaced, it is assumed that it does not conflict with any target entries which may exist and that it is the correct string for the token which may exist. No checking is done in this method.
aSource - an XLEntry object specifying the source valuegetSource()public void setTargets(java.util.Hashtable someTargets)
The specified hashtable is assumed to contain the correct target entries for this instance of LeverageBlock. This means that the sequence number keys and the XLEntries have the proper information in them. No checking is done in this method.
someTargets - a Hashtable object specifying the targetsgetTargets()public void addTarget(XLEntry aTarget)
It is assumed that the specified XLEntry contains the correct locale and string information for the current instance of LeverageBlock. No checking is done. in this method.
aTarget - a XLEntry object specifying the target entrypublic Token getToken()
setToken(com.g11ntoolkit.token.Token)public java.lang.String getTokenComments()
setTokenComments(java.lang.String)public XLEntry getSource()
setSource(com.g11ntoolkit.levblock.XLEntry)public java.util.Hashtable getTargets()
setTargets(java.util.Hashtable)public int getCount()
public boolean hasToken()
public boolean hasTokenComments()
public boolean hasSource()
public boolean hasTargets()
public int hashCode()
The hash code for a leverage block is the sum of the hash code for its token, the hash code for its source translation entry, and the sum of the hash codes for all of its target entries.
hashCode in class java.lang.ObjectToken.hashCode(),
XLEntry.hashCode()public boolean equals(LeverageBlock anotherBlock)
This method uses the equals methods of the various objects contained in this block to perform its comparisons.
anotherBlock - a LeverageBlock object
public boolean equals(java.lang.Object anotherBlock)
equals in class java.lang.ObjectanotherBlock - an Object that purports to be a leverage block
equals(com.g11ntoolkit.levblock.LeverageBlock)public boolean validate()
Well formed means that the block has a valid token and a well formed source entry. It is not required to have any comments nor is it required to have any targets. If there are any target entries then they each must be well formed. This method is needed because the block can be made up in bits and pieces so we need to be able to determine if the block is complete.
public java.lang.String toString()
toString in class java.lang.Object
public void writeXML(java.io.Writer out)
throws java.io.IOException
out - a Writer to use for the output
java.io.IOException - for any errors detected by the specified Writerpublic void debugDump()
public void debugDump(java.lang.String what)
Takes a parameter to control what it dumps. The parameter can be ALL, TOKEN, SOURCE, or TARGET to get the various parts of the block or all of it. The parameter must be in uppercase.
what - a String indicating what information is to be dumped
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||