Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Adjust for checkstyle warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
  • Loading branch information
miurahr committed Oct 9, 2021
1 parent d4dab41 commit d97de7e
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
public class EBDictionary {

static final Logger LOG = LoggerFactory.getLogger(EBDictionary.class.getName());
static final Set<String> ignoreBookList = new HashSet<>();
static final Set<String> IGNORE_BOOK_LIST = new HashSet<>();
private final List<SubBook> subBooks;

static {
ignoreBookList.add("「広辞苑」紹介");
ignoreBookList.add("EPWING電子カタログ");
ignoreBookList.add("EPWING 紹介");
ignoreBookList.add("書籍選択");
IGNORE_BOOK_LIST.add("「広辞苑」紹介");
IGNORE_BOOK_LIST.add("EPWING電子カタログ");
IGNORE_BOOK_LIST.add("EPWING 紹介");
IGNORE_BOOK_LIST.add("書籍選択");
}

public EBDictionary(final File catalogFile) throws Exception {
Expand Down Expand Up @@ -61,7 +61,7 @@ public SubBook getSubBook(final int index) {
public Set<IDictionary> getEBDictionarySubBooks() {
Set<IDictionary> result = new HashSet<>();
for (int i = 0, subBooksSize = subBooks.size(); i < subBooksSize; i++) {
if (!ignoreBookList.contains(subBooks.get(i).getTitle())) {
if (!IGNORE_BOOK_LIST.contains(subBooks.get(i).getTitle())) {
result.add(new EBDictionarySubbook(this, i));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public PdicDictionary(final File file) throws IOException {
if (len == headerSize) {
header = new PdicHeader();
if (header.load(headerbuff) != 0) {
// Unicode辞書 かつ ver6以上のみ許容
if ((header.version & 0xFF00) < 0x0600 || header.os != 0x20) {
// Unicode辞書 かつ ver5以上のみ許容
if ((header.version & 0xFF00) < 0x0500 || header.os != 0x20) {
LOG.warn("Unsupported dictionary version" + srcFile.getName());
throw new RuntimeException();
}
Expand Down
68 changes: 34 additions & 34 deletions src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,57 +46,57 @@ final class PdicHeader {
}

/**
* @param header_block ヘッダーデータ部分
* @param headerBlock ヘッダーデータ部分
* @return 辞書バージョン
*/
public int load(final ByteBuffer header_block) throws RuntimeException {
public int load(final ByteBuffer headerBlock) throws RuntimeException {
int ret = 0;
// Charset sjisset = Charset.forName("X-SJIS");

byte[] headernamebuff = new byte[L_HEADERNAME];
byte[] dictitlebuff = new byte[L_DICTITLE];

header_block.flip();
header_block.order(ByteOrder.LITTLE_ENDIAN);
header_block.get(headernamebuff);
headerBlock.flip();
headerBlock.order(ByteOrder.LITTLE_ENDIAN);
headerBlock.get(headernamebuff);
// headername = sjisset.decode(ByteBuffer.wrap(headernamebuff)).toString();
header_block.get(dictitlebuff);
headerBlock.get(dictitlebuff);
// dictitle = sjisset.decode(ByteBuffer.wrap(dictitlebuff)).toString();
version = header_block.getShort();
version = headerBlock.getShort();
if ((version & 0xFF00) == 0x0500 || (version & 0xFF00) == 0x0600) {
header_block.getShort(); // lword
header_block.getShort(); // ljapa
headerBlock.getShort(); // lword
headerBlock.getShort(); // ljapa

block_size = header_block.getShort();
index_block = header_block.getShort();
header_size = header_block.getShort();
header_block.getShort(); // index_size
header_block.getShort(); // empty_block
header_block.getShort(); // nindex
header_block.getShort(); // nblock
block_size = headerBlock.getShort();
index_block = headerBlock.getShort();
header_size = headerBlock.getShort();
headerBlock.getShort(); // index_size
headerBlock.getShort(); // empty_block
headerBlock.getShort(); // nindex
headerBlock.getShort(); // nblock

header_block.getInt(); // nword
headerBlock.getInt(); // nword

header_block.get(); // dicorder
header_block.get(); // dictype
attrlen = header_block.get();
os = header_block.get();
headerBlock.get(); // dicorder
headerBlock.get(); // dictype
attrlen = headerBlock.get();
os = headerBlock.get();

header_block.getInt(); // ole_number
headerBlock.getInt(); // ole_number

// lid_dummy
header_block.getShort();
header_block.getShort();
header_block.getShort();
header_block.getShort();
header_block.getShort();

index_blkbit = (header_block.get() != 0);
header_block.get(); // dummy0
extheader = header_block.getInt();
header_block.getInt(); //empty_block2
nindex2 = header_block.getInt();
header_block.getInt(); // nblock2
headerBlock.getShort();
headerBlock.getShort();
headerBlock.getShort();
headerBlock.getShort();
headerBlock.getShort();

index_blkbit = (headerBlock.get() != 0);
headerBlock.get(); // dummy0
extheader = headerBlock.getInt();
headerBlock.getInt(); //empty_block2
nindex2 = headerBlock.getInt();
headerBlock.getInt(); // nblock2

// 固定部分チェック
if (attrlen == 1) {
Expand Down
60 changes: 30 additions & 30 deletions src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public int searchIndexBlock(final String word) {
int min = 0;
int max = m_nindex - 1;

ByteBuffer __word = mEncodeCache.get(word);
if (__word == null) {
__word = encodetoByteBuffer(mMainCharset, word);
mEncodeCache.put(word, __word);
ByteBuffer buffer = mEncodeCache.get(word);
if (buffer == null) {
buffer = encodetoByteBuffer(mMainCharset, word);
mEncodeCache.put(word, buffer);
}
int limit = __word.limit();
byte[] _word = new byte[limit];
System.arraycopy(__word.array(), 0, _word, 0, limit);
int _wordlen = _word.length;
int limit = buffer.limit();
byte[] bytes = new byte[limit];
System.arraycopy(buffer.array(), 0, bytes, 0, limit);
int wordlen = bytes.length;

int[] indexPtr = mIndexPtr;
int blockbits = m_blockbits;
Expand All @@ -111,7 +111,7 @@ public int searchIndexBlock(final String word) {
}
final int look = (int) (((long) min + max) / 2);
final int len = indexPtr[look + 1] - indexPtr[look] - blockbits;
final int comp = pdicInfoCache.compare(_word, 0, _wordlen, indexPtr[look], len);
final int comp = pdicInfoCache.compare(bytes, 0, wordlen, indexPtr[look], len);
if (comp < 0) {
max = look;
} else if (comp > 0) {
Expand Down Expand Up @@ -246,12 +246,12 @@ public String getDicName() {
}

// 単語を検索する
public boolean searchWord(final String _word) {
public boolean searchWord(final String word) {
// 検索結果クリア
int cnt = 0;
mSearchResult.clear();

int ret = searchIndexBlock(_word);
int ret = searchIndexBlock(word);

boolean match = false;

Expand All @@ -264,7 +264,7 @@ public boolean searchWord(final String _word) {
byte[] pblk = readBlockData(block);
if (pblk != null) {
mAnalyze.setBuffer(pblk);
mAnalyze.setSearch(_word);
mAnalyze.setSearch(word);
searchret = mAnalyze.searchWord();
// 未発見でEOBの時のみもう一回、回る
if (!searchret && mAnalyze.mEob) {
Expand All @@ -283,7 +283,7 @@ public boolean searchWord(final String _word) {
break;
}
// 完全一致するかチェック
if (res.mIndex.compareTo(_word) == 0) {
if (res.mIndex.compareTo(word) == 0) {
match = true;
}
mSearchResult.add(res);
Expand All @@ -296,8 +296,8 @@ public boolean searchWord(final String _word) {
}

// 前方一致する単語の有無を返す
boolean searchPrefix(final String _word) {
int ret = searchIndexBlock(_word);
boolean searchPrefix(final String word) {
int ret = searchIndexBlock(word);

for (int blk = 0; blk < 2; blk++) {
// 最終ブロックは超えない
Expand All @@ -311,7 +311,7 @@ boolean searchPrefix(final String _word) {

if (pblk != null) {
mAnalyze.setBuffer(pblk);
mAnalyze.setSearch(_word);
mAnalyze.setSearch(word);

if (mAnalyze.searchWord()) {
return true;
Expand Down Expand Up @@ -417,7 +417,7 @@ final class AnalyzeBlock {
private int mCompLen = 0;
private boolean mEob = false;

public AnalyzeBlock() {
AnalyzeBlock() {
}

public void setBuffer(final byte[] buff) {
Expand All @@ -431,10 +431,10 @@ public void setBuffer(final byte[] buff) {
}

public void setSearch(final String word) {
ByteBuffer __word = encodetoByteBuffer(mMainCharset, word);
mEncodeCache.put(word, __word);
mWord = new byte[__word.limit()];
System.arraycopy(__word.array(), 0, mWord, 0, __word.limit());
ByteBuffer buffer = encodetoByteBuffer(mMainCharset, word);
mEncodeCache.put(word, buffer);
mWord = new byte[buffer.limit()];
System.arraycopy(buffer.array(), 0, mWord, 0, buffer.limit());
}

public boolean isEob() {
Expand All @@ -445,11 +445,11 @@ public boolean isEob() {
* ブロックデータの中から指定語を探す.
*/
public boolean searchWord() {
final byte[] _word = mWord;
final byte[] bytes = mWord;
final byte[] buff = mBuff;
final boolean longfield = mLongfield;
final byte[] compbuff = mCompbuff;
final int wordlen = _word.length;
final int wordlen = bytes.length;

mFoundPtr = -1;

Expand Down Expand Up @@ -506,11 +506,11 @@ public boolean searchWord() {
boolean equal = true;
for (int i = 0; i < wordlen; i++) {

if (compbuff[i] != _word[i]) {
if (compbuff[i] != bytes[i]) {
equal = false;
int cc = compbuff[i];
cc &= 0xFF;
int cw = _word[i];
int cw = bytes[i];
cw &= 0xFF;
// 超えてたら打ち切る
if (cc > cw) {
Expand Down Expand Up @@ -613,7 +613,7 @@ PdicElement getRecord() {

// 次の項目が検索語に前方一致するかチェックする
public boolean hasMoreResult(final boolean incrementptr) {
byte[] _word;
byte[] word;
final byte[] buff = mBuff;
final boolean longfield = mLongfield;
final byte[] compbuff = mCompbuff;
Expand All @@ -622,9 +622,9 @@ public boolean hasMoreResult(final boolean incrementptr) {
if (mFoundPtr == -1) {
return false;
}
_word = mWord;
word = mWord;

int wordlen = _word.length;
int wordlen = word.length;

// 訳語データ読込
int ptr = mNextPtr;
Expand Down Expand Up @@ -675,11 +675,11 @@ public boolean hasMoreResult(final boolean incrementptr) {
// 前方一致で比較
boolean equal = true;
for (int i = 0; i < wordlen; i++) {
if (compbuff[i] != _word[i]) {
if (compbuff[i] != word[i]) {
equal = false;
int cc = compbuff[i];
cc &= 0xFF;
int cw = _word[i];
int cw = word[i];
cw &= 0xFF;
// 超えてたら打ち切る
if (cc > cw) {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/io/github/eb4j/ebview/gui/DictionaryPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.text.BadLocationException;
Expand All @@ -25,7 +22,6 @@
import java.awt.event.FocusListener;
import java.awt.font.TextAttribute;
import java.awt.geom.Rectangle2D;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
Expand Down
Loading

0 comments on commit d97de7e

Please sign in to comment.