com.baseprogramming.lang
Class Translation

java.lang.Object
  extended by com.baseprogramming.lang.Translation

public class Translation
extends java.lang.Object

(c)wordreference.com translation. It Contains a Note, an original term and up to ten translation entries for that term (as of 10/14/2011, (c)wordreference.com provides up to four)

The following is an example of 2 translations in the PrincipalTranslations Category

 "PrincipalTranslations" : {
        "0" :{
                "OriginalTerm" : { "term" : "translation", "POS" : "n", "sense" : "document produced", "usage" : ""}, 
                "FirstTranslation" : {"term" : "traduzione", "POS" : "nf", "sense" : "documento prodotto"}, "Note" : ""},
        "1" :{
                "OriginalTerm" : { "term" : "translation", "POS" : "n", "sense" : "act of translating", "usage" : ""}, 
                "FirstTranslation" : {"term" : "traduzione", "POS" : "nf", "sense" : "azione di tradurre"}, "Note" : ""}},
 

When parsed, this block would result in a list (java.util.List) of two Translation Elements. Each Translation element would have the original term (a DictionaryTerm), and one translation Entry (also a DictionaryTerm).


Constructor Summary
Translation()
          Default constructor
 
Method Summary
 void addTranslation(java.lang.String label, DictionaryTerm term)
          Add a translation entry for this term
static Translation createInstance(com.google.gson.JsonObject json, int index)
          Create a translation instance for this JSON objecct
 int getCount()
          Get count of translation Entries
 DictionaryTerm getEntry(java.lang.String name)
          Get a translation entry (term) by name (e.g.
 java.util.Set<java.lang.String> getEntryNames()
          Get all Translation Entry names
 DictionaryTerm getFirstTranslation()
          Get the first translation
 DictionaryTerm getFourthTranslation()
          Get the fourth translation
 int getIndex()
          Get Index
 java.lang.String getNote()
          Get translation note
 DictionaryTerm getOriginalTerm()
          get original term
 DictionaryTerm getSecondTranslation()
          Get the second translation
 DictionaryTerm getThirdTranslation()
          Get the third translation
 void setIndex(int index)
          Set index
 void setNote(java.lang.String note)
          Set Translation note
 void setOriginalTerm(DictionaryTerm term)
          Set the oridinal term
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Translation

public Translation()
Default constructor

Method Detail

getCount

public int getCount()
Get count of translation Entries

Returns:
int

getEntryNames

public java.util.Set<java.lang.String> getEntryNames()
Get all Translation Entry names

Returns:

setNote

public void setNote(java.lang.String note)
Set Translation note

Parameters:
note -

getNote

public java.lang.String getNote()
Get translation note

Returns:
Note

getIndex

public int getIndex()
Get Index

Returns:
index

setIndex

public void setIndex(int index)
Set index

Parameters:
index -

getOriginalTerm

public DictionaryTerm getOriginalTerm()
get original term

Returns:

setOriginalTerm

public void setOriginalTerm(DictionaryTerm term)
Set the oridinal term

Parameters:
term -

getEntry

public DictionaryTerm getEntry(java.lang.String name)
                        throws java.lang.IllegalArgumentException
Get a translation entry (term) by name (e.g. FirstTranslation, SecondTranslation, etc)

Parameters:
name -
Returns:
Throws:
java.lang.IllegalArgumentException

getFirstTranslation

public DictionaryTerm getFirstTranslation()
Get the first translation

Returns:
translation

getSecondTranslation

public DictionaryTerm getSecondTranslation()
Get the second translation

Returns:
translation

getThirdTranslation

public DictionaryTerm getThirdTranslation()
Get the third translation

Returns:
translation

getFourthTranslation

public DictionaryTerm getFourthTranslation()
Get the fourth translation

Returns:
translation

addTranslation

public void addTranslation(java.lang.String label,
                           DictionaryTerm term)
Add a translation entry for this term

Parameters:
label -
term -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createInstance

public static Translation createInstance(com.google.gson.JsonObject json,
                                         int index)
                                  throws java.io.IOException
Create a translation instance for this JSON objecct

Parameters:
json -
Returns:
Throws:
java.io.IOException