org.thdl.tib.text
Class TibetanKeyboard

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

public class TibetanKeyboard
extends Object

An alternate (non-Extended Wylie) keyboard input method. A keyboard URL is passed to its constructor. This URL must follow a particular format, and include particular subparts. For example, the keyboard URL must specify values for various input parameters, as well as correspondences for the Wylie characters this keyboard allows the user to input. For an example, see the file 'sambhota_keyboard.ini' found in the same directory as this class.

It is normative practice for a null keyboard to be interpreted as the default Wylie keyboard. A non-null keyboard defines a transformation of the default Wylie keyboard, setting new values for each Wylie value, as well as (re-)defining various parameters.

Author:
Edward Garrett, Tibetan and Himalayan Digital Library

Nested Class Summary
 class TibetanKeyboard.InvalidKeyboardException
          A generic Exception to indicate an invalid keyboard.
 
Constructor Summary
TibetanKeyboard(URL url)
          Opens the URL specified by the parameter, and tries to construct a keyboard from it.
 
Method Summary
 char getDisambiguatingKey()
          Gets the disambiguating key for this keyboard.
 char getStackingKey()
          Gets the stacking key.
 String getWylieForChar(String s)
          Gets the Extended Wylie corresponding to this character.
 String getWylieForPunc(String s)
          Gets the Extended Wylie corresponding to this punctuation.
 String getWylieForVowel(String s)
          Gets the Extended Wylie corresponding to this vowel.
 boolean hasAVowel()
          Does the keyboard have a key for the invisible 'a' vowel?
 boolean hasDisambiguatingKey()
          Does this keyboard have a disambiguating key?
 boolean hasInputPrefix(String s)
          This addresses bug 624133, "Input freezes after impossible character".
 boolean hasSanskritStackingKey()
          Does this keyboard require a stacking key for Sanskrit stacks?
 boolean hasTibetanStackingKey()
          Does this keyboard require a stacking key for Tibetan stacks?
 boolean isAChenRequiredBeforeVowel()
          Must achen be typed first if you want achen plus a vowel?
 boolean isAChungConsonant()
          Is achung treated as an ordinary consonant?
 boolean isChar(String s)
          Decides whether or not a string is a character (as opposed to a vowel or punctuation) in this keyboard.
 boolean isPunc(String s)
          Decides whether or not a string is a punctuation mark in this keyboard?
 boolean isStackingMedial()
          Is stacking medial?
 boolean isVowel(String s)
          Decides whether or not the string is a vowel in this keyboard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TibetanKeyboard

public TibetanKeyboard(URL url)
                throws TibetanKeyboard.InvalidKeyboardException
Opens the URL specified by the parameter, and tries to construct a keyboard from it. If the file is missing, or is invalid, an InvalidKeyboardException is thrown.

Parameters:
url - the URL of the keyboard
Throws:
TibetanKeyboard.InvalidKeyboardException - a valid keyboard cannot be constructed from this URL
Method Detail

hasDisambiguatingKey

public boolean hasDisambiguatingKey()
Does this keyboard have a disambiguating key?

Returns:
true if this keyboard has a disambiguating key, e.g. the period in Wylie 'g.y' vs. Wylie 'gy', false otherwise

getDisambiguatingKey

public char getDisambiguatingKey()
Gets the disambiguating key for this keyboard.

Returns:
the disambiguating key, assuming this keyboard has one

hasSanskritStackingKey

public boolean hasSanskritStackingKey()
Does this keyboard require a stacking key for Sanskrit stacks?

Returns:
true if this keyboard requires a stacking key for Sanskrit stacks

hasTibetanStackingKey

public boolean hasTibetanStackingKey()
Does this keyboard require a stacking key for Tibetan stacks?

Returns:
true if this keyboard requires a stacking key for Tibetan stacks

isStackingMedial

public boolean isStackingMedial()
Is stacking medial?

Returns:
true if this keyboard has stacking, and if that stacking is medial rather than pre/post. In other words, if you want a stack consisting of the (Wylie) characters 's', 'g', and 'r', and if the stack key is '+', then if you get the stack by typing 's+g+r', then this method returns true. If you get it by typing '+sgr' or '+sgr+', then the method returns false.

getStackingKey

public char getStackingKey()
Gets the stacking key.

Returns:
the stacking key, if there is one

isAChenRequiredBeforeVowel

public boolean isAChenRequiredBeforeVowel()
Must achen be typed first if you want achen plus a vowel?

Returns:
true if it is necessary in this keyboard to type achen plus a vowel to get achen plus a vowel, or if you can (as in Wylie), simply type the vowel, and then automatically get achen plus the vowel, assuming there is no preceding consonant.

isAChungConsonant

public boolean isAChungConsonant()
Is achung treated as an ordinary consonant?

Returns:
true if achung is counted as a consonant, and thus treated as stackable like any other consonant; false if achung is treated as a vowel, as in Wylie.

hasAVowel

public boolean hasAVowel()
Does the keyboard have a key for the invisible 'a' vowel?

Returns:
true if this keyboard has a keystroke sequence for the invisible Wylie vowel 'a', false if there is no way to type this invisible vowel.

isChar

public boolean isChar(String s)
Decides whether or not a string is a character (as opposed to a vowel or punctuation) in this keyboard.

Parameters:
s - the possible character
Returns:
true if the parameter is a character in this keyboard. This method checks to see if the passed string has been mapped to a Wylie character - if not, then it returns false.

getWylieForChar

public String getWylieForChar(String s)
Gets the Extended Wylie corresponding to this character.

Returns:
the Wylie value corresponding to this parameter, assuming it is in fact a character in this keyboard; if not, returns null.

isPunc

public boolean isPunc(String s)
Decides whether or not a string is a punctuation mark in this keyboard?

Parameters:
s - the possible punctuation
Returns:
true if the parameter is punctuation in this keyboard. This method checks to see if the passed string has been mapped to Wylie punctuation - if not, then it returns false.

getWylieForPunc

public String getWylieForPunc(String s)
Gets the Extended Wylie corresponding to this punctuation.

Parameters:
s - the possible punctuation
Returns:
the Wylie value corresponding to this parameter, assuming it is in fact punctuation in this keyboard; if not, returns null.

isVowel

public boolean isVowel(String s)
Decides whether or not the string is a vowel in this keyboard.

Parameters:
s - the possible vowel
Returns:
true if the parameter is a vowel in this keyboard. This method checks to see if the passed string has been mapped to a Wylie vowel - if not, then it returns false.

getWylieForVowel

public String getWylieForVowel(String s)
Gets the Extended Wylie corresponding to this vowel.

Returns:
the Wylie value corresponding to this parameter, assuming it is in fact a vowel in this keyboard; if not, returns null.

hasInputPrefix

public boolean hasInputPrefix(String s)
This addresses bug 624133, "Input freezes after impossible character". Returns true iff s is a proper prefix of some legal input for this keyboard. In the extended Wylie keyboard, hasInputPrefix("S") is true because "Sh" is legal input. hasInputPrefix("Sh") is false because though "Sh" is legal input, ("Sh" + y) is not valid input for any non-empty String y.



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