net.sourceforge.pinyin4j
Class ChineseToPinyinResource

java.lang.Object
  extended by net.sourceforge.pinyin4j.ChineseToPinyinResource

 class ChineseToPinyinResource
extends java.lang.Object

Manage all external resources required in PinyinHelper class.

Author:
Li Min (xmlerlimin@gmail.com)

Nested Class Summary
private static class ChineseToPinyinResource.ChineseToPinyinResourceHolder
          Singleton implementation helper.
(package private)  class ChineseToPinyinResource.Field
          A class encloses common string constants used in Properties files
 
Field Summary
private  java.util.Properties unicodeToHanyuPinyinTable
          A hash table contains pairs
 
Constructor Summary
private ChineseToPinyinResource()
          Private constructor as part of the singleton pattern.
 
Method Summary
private  java.lang.String getHanyuPinyinRecordFromChar(char ch)
           
(package private)  java.lang.String[] getHanyuPinyinStringArray(char ch)
          Get the unformatted Hanyu Pinyin representations of the given Chinese character in array format.
(package private) static ChineseToPinyinResource getInstance()
          Singleton factory method.
private  java.util.Properties getUnicodeToHanyuPinyinTable()
           
private  void initializeResource()
          Initialize a hash-table contains pairs
private  boolean isValidRecord(java.lang.String record)
           
private  void setUnicodeToHanyuPinyinTable(java.util.Properties unicodeToHanyuPinyinTable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unicodeToHanyuPinyinTable

private java.util.Properties unicodeToHanyuPinyinTable
A hash table contains pairs

Constructor Detail

ChineseToPinyinResource

private ChineseToPinyinResource()
Private constructor as part of the singleton pattern.

Method Detail

setUnicodeToHanyuPinyinTable

private void setUnicodeToHanyuPinyinTable(java.util.Properties unicodeToHanyuPinyinTable)
Parameters:
unicodeToHanyuPinyinTable - The unicodeToHanyuPinyinTable to set.

getUnicodeToHanyuPinyinTable

private java.util.Properties getUnicodeToHanyuPinyinTable()
Returns:
Returns the unicodeToHanyuPinyinTable.

initializeResource

private void initializeResource()
Initialize a hash-table contains pairs


getHanyuPinyinStringArray

java.lang.String[] getHanyuPinyinStringArray(char ch)
Get the unformatted Hanyu Pinyin representations of the given Chinese character in array format.

Parameters:
ch - given Chinese character in Unicode
Returns:
The Hanyu Pinyin strings of the given Chinese character in array format; return null if there is no corresponding Pinyin string.

isValidRecord

private boolean isValidRecord(java.lang.String record)
Parameters:
record - given record string of Hanyu Pinyin
Returns:
return true if record is not null and record is not "none0" and record is not mal-formatted, else return false

getHanyuPinyinRecordFromChar

private java.lang.String getHanyuPinyinRecordFromChar(char ch)
Parameters:
ch - given Chinese character in Unicode
Returns:
corresponding Hanyu Pinyin Record in Properties file; null if no record found

getInstance

static ChineseToPinyinResource getInstance()
Singleton factory method.

Returns:
the one and only MySingleton.