Package Torello.Languages
Class HTMLWordTables
- java.lang.Object
-
- Torello.Languages.HTMLWordTables
-
public class HTMLWordTables extends java.lang.Object
HTMLWordTables for Mandarin Chinese Translations.
This class generates the HTML CSS z-index-based tables that are used by java-script. Java-script utilizes the z-index axis to generate popup windows which contain Mandarin Chinese, English, and even Spanish Translations. Specifically, the tables generally contain:- 繁体字 (Traditional-Chinese, Hong Kong, Taiwan, Southern China - Optional)
- 简体中文 (Standard-Chinese Simplified Characters
- 拼音罗马 (Romanization)
- English
- Español
Hi-Lited Source-Code:- View Here: Torello/Languages/HTMLWordTables.java
- Open New Browser-Tab: Torello/Languages/HTMLWordTables.java
File Size: 6,064 Bytes Line Count: 150 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctional
Annotation may also be called 'The Spaghetti Report'.Static-Functional
classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@Stateless
Annotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 2 Method(s), 2 declared static
- 0 Field(s)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method static String
getHTMLVocabTable(String tableClass, String tableID, boolean setNoDisplay, Vector<String> simpWords, Vector<String> pronWords, Vector<String> tradWords, Vector<String> englWords, Vector<String> espaWords)
static String
toHTML(String simpSentence, String englSentence, String espaSentence, String tableClass, String tableID, String onClickListener)
-
-
-
Method Detail
-
toHTML
public static java.lang.String toHTML(java.lang.String simpSentence, java.lang.String englSentence, java.lang.String espaSentence, java.lang.String tableClass, java.lang.String tableID, java.lang.String onClickListener)
Builds a simple, short HTML version of the Chinese-Simplified / English / Spanish sentence DIV- Parameters:
simpSentence
- This may be a single word, a complete phrase, sentence, or even a paragraph of simplified Mandarin Chinese scraped from a web-site like Gov.CN. If this parameter is null, an exception will be thrown.englSentence
- This is intended to be the English-Translated version of the Simplified-Chinese sentence. If this parameter is null, the output HTML-table will have one less / fewer row included.espaSentence
- This is supposed to be the Spanish-translated version of the Simplified-Chinese sentence. If this parameter is null, the output HTML-table will have one less / fewer row included.tableClass
- If this table needs a CSS-Class selector, pass it here.tableID
- If this table requires a CSS-ID selector, pass it here.onClickListener
- This is a string of the form "callbackFuntion(params);" It is inserted into the <TABLE on_click="INSERTED-STRING-HERE"> tag- Returns:
- An Table-HTML string. Note: The Vocabulary tables *ARE NOT* included. This only includes the English, Spanish & Chinese sentences.
- Throws:
java.lang.NullPointerException
- If simpSentence is null.- Code:
- Exact Method Body:
if (simpSentence == null) throw new NullPointerException ("simpSentence MAY NOT be NULL, engl and espa can be."); String tableIncludeStr = ""; tableIncludeStr += (tableClass != null) ? (" CLASS=\"" + tableClass + "\"") : ""; tableIncludeStr += (tableID != null) ? (" ID=\"" + tableID + "\"") : ""; tableIncludeStr += (onClickListener != null) ? (" onclick=\"" + onClickListener + "\"") : ""; return "<TABLE " + tableIncludeStr + "><TBODY>\n" + ((simpSentence != null) ? ("<TR CLASS=\"ZHROW\" ><TD>" + simpSentence + "</TD></TR>\n") : "") + ((englSentence != null) ? ("<TR CLASS=\"ENROW\" ><TD>" + englSentence + "</TD></TR>\n") : "") + ((espaSentence != null) ? ("<TR CLASS=\"ESROW\" ><TD>" + espaSentence + "</TD></TR>\n") : "") + "</TBODY></TABLE>\n";
-
getHTMLVocabTable
public static java.lang.String getHTMLVocabTable (java.lang.String tableClass, java.lang.String tableID, boolean setNoDisplay, java.util.Vector<java.lang.String> simpWords, java.util.Vector<java.lang.String> pronWords, java.util.Vector<java.lang.String> tradWords, java.util.Vector<java.lang.String> englWords, java.util.Vector<java.lang.String> espaWords)
The purpose of this method is to generate the "Pop Up" vocabulary table as HTML- Parameters:
tableClass
- This contains the HTML-tag "class" String. It is included in the HTML <TABLE CLASS="INSERT-TEXT-HERE> StringtableID
- This contains the HTML-tag "id" String. It is included in the HTML <TABLE ID="INSERT-TEXT-HERE"> StringsetNoDisplay
- When this variable isTRUE
, a CSS tag is added to the opening <TABLE> tag, indicating:STYLE="display: none;"
- which ensures that this vocabulary table remains hidden.simpWords
- A Vector of simplified chinese character-words. This parameter may not be null.pronWords
- A Parallel Vector of the pronunciation of this input Simplified Mandarin words. Can be left out / null.tradWords
- Parallel Vector. Traditional-Chinese Characters. May be null.englWords
- Parallel Vector. English Words. Can be null.espaWords
- Parallel Vector. Chinese in Spanish. Also may be null.- Returns:
- returns the Vocabulary Table as an HTML String of <TABLE>Vocab-Rows</TABLE>
- Throws:
java.lang.NullPointerException
- If simpWords is null.- Code:
- Exact Method Body:
if (simpWords== null) throw new NullPointerException ("simpWords MAY NOT be NULL, engl and espa can be."); StringBuilder sb = new StringBuilder(); // Build the <TABLE> tag. It may require a CSS "CLASS=...", possibly a "ID=...", // or a CSS-styled "display: none;" sb.append("<TABLE"); if (tableClass != null) sb.append(" CLASS=\"" + tableClass + "\""); if (tableID != null) sb.append(" ID=\"" + tableID + "\""); if (setNoDisplay) sb.append(" STYLE=\"display: none;\""); sb.append(">\n<TBODY>\n"); int len = simpWords.size(); for (int i = 0; i < len; i++) { sb.append( "<TR>\n" + ((simpWords != null) ? ("<TD>" + simpWords.elementAt(i) + "</TD>\n") : "") + ((pronWords != null) ? ("<TD>" + pronWords.elementAt(i) + "</TD>\n") : "") + ((tradWords != null) ? ("<TD>" + tradWords.elementAt(i) + "</TD>\n") : "") + ((englWords != null) ? ("<TD>" + englWords.elementAt(i) + "</TD>\n") : "") + ((espaWords != null) ? ("<TD>" + espaWords.elementAt(i) + "</TD>\n") : "") + "</TR>\n" ); } sb.append("</TBODY>\n</TABLE>\n"); return sb.toString();
-
-