org.thdl.tib.text
Class TibTextUtils

java.lang.Object
  |
  +--org.thdl.tib.text.TibTextUtils

public class TibTextUtils
extends Object

Provides methods for converting back and forth between Extended Wylie and TibetanMachineWeb. This class is not instantiable.

The class provides a variety of static methods for converting back and forth between Extended Wylie and TibetanMachineWeb. The Wylie can be accessed as a String, while the TibetanMachineWeb can be exported as Rich Text Format.

Author:
Edward Garrett, Tibetan and Himalayan Digital Library

Method Summary
static org.thdl.tib.text.DuffData[] convertGlyphs(List glyphs)
          Converts a list of glyphs into an array of DuffData.
static List getBindu(org.thdl.tib.text.DuffCode dc)
          Gets the bindu sequence for a given context.
static List getGlyphs(List chars, boolean areStacksOnRight, boolean definitelyTibetan, boolean definitelySanskrit)
          Figures out how to arrange a list of characters into glyphs.
static String getNext(String wylie)
          Finds the first meaningful element to occur within a string of Extended Wylie.
static org.thdl.tib.text.DuffData[] getTibetanMachineWeb(String wylie)
          Converts a string of Extended Wylie into DuffData.
static List getVowel(org.thdl.tib.text.DuffCode context_1, org.thdl.tib.text.DuffCode context_2, String vowel)
          Gets the vowel sequence for a given vowel in a given context.
static List getVowel(org.thdl.tib.text.DuffCode context, String vowel)
          Gets the vowel sequence for a given vowel in a given context.
static String getWylie(org.thdl.tib.text.DuffCode[] dcs)
          Gets the Extended Wylie for a set of glyphs.
static String withA(List glyphList)
          Scans a list of glyphs and returns an Extended Wylie string with 'a' inserted.
static String withoutA(List glyphList)
          Gets the Extended Wylie for a list of glyphs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertGlyphs

public static org.thdl.tib.text.DuffData[] convertGlyphs(List glyphs)
Converts a list of glyphs into an array of DuffData. The motivation for this is that most processes - for example using TibetanMachineWeb in HTML - only need to know what text to output, and when to change fonts. In general, they don't need to have an explicit indication for each glyph of the font for that glyph.

Parameters:
glyphs - the list of TibetanMachineWeb glyphs you want to convert
Returns:
an array of DuffData corresponding to this list of glyphs

getGlyphs

public static List getGlyphs(List chars,
                             boolean areStacksOnRight,
                             boolean definitelyTibetan,
                             boolean definitelySanskrit)
Figures out how to arrange a list of characters into glyphs. For example, if the user types 'bsgr' using the Extended Wylie keyboard, this method figures out that this should be represented as a 'b' glyph followed by a 's-g-r' glyph. If you know that the characters do not contain Sanskrit stacks, or do not contain Tibetan stacks, then you can specify this to speed the process up. Otherwise, the method will first check to see if the characters correspond to any Tibetan stacks, and if not, then it will check for Sanskrit stacks.

Parameters:
chars - the list of Tibetan characters you want to find glyphs for
areStacksOnRight - whether stacking should try to maximize from right to left (true) or from left to right (false). In the Extended Wylie keyboard, you try to stack from right to left. Thus, the character sequence r-g-r would be stacked as r followed by gr, rather than rg followed by r. In the Sambhota and TCC keyboards, the stack direction is reversed.
definitelyTibetan - should be true if the characters are known to be Tibetan and not Sanskrit
definitelySanskrit - should be true if the characters are known to be Sanskrit and not Tibetan

getNext

public static String getNext(String wylie)
Finds the first meaningful element to occur within a string of Extended Wylie. This could be a character, a vowel, punctuation, or formatting. For example, passed the string 'tshapo', this method will return 'tsh'.

Parameters:
wylie - the String of wylie you want to scan
Returns:
the next meaningful subpart of this string, or null if no meaningful subpart can be found (for example 'x' has no equivalent in Extended Wylie)

getTibetanMachineWeb

public static org.thdl.tib.text.DuffData[] getTibetanMachineWeb(String wylie)
                                                         throws InvalidWylieException
Converts a string of Extended Wylie into DuffData.

Parameters:
wylie - the Wylie you want to convert
Returns:
an array of TibetanMachineWeb data corresponding to the Wylie text
Throws:
InvalidWylieException - if the Wylie is deemed invalid, i.e. if it does not conform to the Extended Wylie standard

getBindu

public static List getBindu(org.thdl.tib.text.DuffCode dc)
Gets the bindu sequence for a given context. In the TibetanMachineWeb fonts, bindu (anusvara) is realized differently depending on which vowel it attaches to. Although the default bindu glyph is affixed to consonants and subscript vowels, for superscript vowels (i, e, o, etc), there is a single glyph which merges the bindu and that vowel together. When you pass this method a glyph context, it will return a List of glyphs which will either consist of the original glyph followed by the default bindu glyph, or a composite vowel+bindu glyph. Note that there is only one glyph in the context. This means that bindus will not affix properly if superscript vowels are allowed to directly precede subscript vowels (e.g. pou).

Parameters:
dc - the DuffCode of the glyph you want to attach a bindu to
Returns:
a List of DuffCode glyphs that include the original dc, as well as a bindu

getVowel

public static List getVowel(org.thdl.tib.text.DuffCode context,
                            String vowel)
Gets the vowel sequence for a given vowel in a given context. Given a context, this method affixes a vowel and returns the context plus the vowel. Generally, it is enough to provide just one glyph for context.

Parameters:
context - the glyph preceding the vowel you want to affix
vowel - the vowel you want to affix, in Wylie
Returns:
a List of glyphs equal to the vowel in context

getVowel

public static List getVowel(org.thdl.tib.text.DuffCode context_1,
                            org.thdl.tib.text.DuffCode context_2,
                            String vowel)
Gets the vowel sequence for a given vowel in a given context. Given a context, this method affixes a vowel and returns the context plus the vowel. Since the choice of vowel glyph depends on the consonant to which it is attached, generally it is enough to provide just the immediately preceding context. However, in some cases, double vowels are allowed - for example 'buo'. To find the correct glyph for 'o', we need 'b' in this case, not 'u'. Note also that some Extended Wylie vowels correspond to multiple glyphs in TibetanMachineWeb. For example, the vowel I consists of both an achung and a reverse gigu. All required glyphs are part of the returned List.

Parameters:
context_1 - the glyph occurring two glyphs before the vowel you want to affix
context_2 - the glyph immediately before the vowel you want to affix
vowel - the vowel you want to affix, in Wylie
Returns:
a List of glyphs equal to the vowel in context

withA

public static String withA(List glyphList)
Scans a list of glyphs and returns an Extended Wylie string with 'a' inserted. Passed a list of TibetanMachineWeb glyphs that constitute a partial syllable that is in need of an 'a' vowel, this method scans the list, figures out where to put the 'a' vowel, and then returns a string of Wylie corresponding to this sequence. This method is used heavily during TibetanMachineWeb to Extended Wylie conversion, since there is no glyph corresponding to the Extended Wylie 'a' vowel.

Parameters:
glyphList - a list of TibetanMachine glyphs, i.e. DuffCodes.
Returns:
the Wylie string corresponding to this glyph list, with 'a' inserted.

withoutA

public static String withoutA(List glyphList)
Gets the Extended Wylie for a list of glyphs. Passed a list of TibetanMachineWeb glyphs that constitute a partial or complete syllable, this method scans the list, and then returns a string of Wylie corresponding to this sequence. No 'a' vowel is inserted because it is assumed that the glyph list already contains some other vowel. If the glyph list does not already contain a vowel, then this method should not be called.

Parameters:
glyphList - a list of TibetanMachine glyphs, i.e. DuffCodes
Returns:
the Wylie string corresponding to this glyph list

getWylie

public static String getWylie(org.thdl.tib.text.DuffCode[] dcs)
Gets the Extended Wylie for a set of glyphs.

Parameters:
dcs - an array of glyphs
Returns:
the Extended Wylie corresponding to these glyphs


These API docs were created 02/02/2003 08:19 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by SourceForge_Logo