Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
清理初始化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
testacount1 committed Jul 16, 2017
1 parent 08a4802 commit dbe68eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 181 deletions.
150 changes: 0 additions & 150 deletions src/com/spreada/utils/chinese/数据整理类.java

This file was deleted.

43 changes: 12 additions & 31 deletions src/com/spreada/utils/chinese/简繁转换类.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,27 @@

public class 简繁转换类 {

// TODO: 分开: 简到繁; 繁到简
private Properties 字符表 = new Properties();
private Properties 短语表 = new Properties();

private Set<String> 多对应单字集 = new HashSet<>();

public enum 目标 {
繁体(0), 简体(1);

int 内部值;
目标(int ) {
内部值 = ;
}
繁体, 简体;
}
private static final int NUM_OF_CONVERTERS = 2;
private static final 简繁转换类[] converters = new 简繁转换类[NUM_OF_CONVERTERS];
private final static 简繁转换类 简体转换器 = new 简繁转换类();
private final static 简繁转换类 繁体转换器 = new 简繁转换类();

public static 简繁转换类 getInstance(目标 简繁) {
return getInstance(简繁.内部值);
}

/**
*
* @param converterType 0 for traditional and 1 for simplified
* @return
*/
private static 简繁转换类 getInstance(int converterType) {
if (converters[converterType] == null) {
synchronized (简繁转换类.class) {
converters[converterType] = new 简繁转换类();
if (converterType == 0) {
converters[converterType].读取字表("简到繁单字.properties", "简到繁短语.properties");
} else {
converters[converterType].读取字表("繁到简单字.properties", "繁到简短语.properties");
}
}
if (简繁.equals(目标.繁体)) {
繁体转换器.读取字表("简到繁单字.properties", "简到繁短语.properties");
return 繁体转换器;
} else {
简体转换器.读取字表("繁到简单字.properties", "繁到简短语.properties");
return 简体转换器;
}
return converters[converterType];
}

private 简繁转换类() { }

public static String 转换(String 文本, 目标 简繁) {
Expand All @@ -64,8 +45,8 @@ public enum 目标 {
读取字表(短语表, 短语字表文件名);
}

private void 读取字表(Properties 对应表, String propertyFile) {
InputStream is = getClass().getResourceAsStream(propertyFile);
private void 读取字表(Properties 对应表, String 属性文件名) {
InputStream is = getClass().getResourceAsStream(属性文件名);

if (is != null) {
BufferedReader reader = null;
Expand Down

0 comments on commit dbe68eb

Please sign in to comment.