<rule ref="rulesets/java/design.xml">
<exclude name="UnnecessaryLocalBeforeReturn" />
+ <exclude name="FieldDeclarationsShouldBeAtStartOfClass" />
</rule>
<rule ref="rulesets/java/empty.xml" />
<rule ref="rulesets/java/naming.xml">
<exclude name="ShortVariable" />
+ <exclude name="LongVariable" />
</rule>
<rule ref="rulesets/java/optimizations.xml">
*/
protected boolean findProbe(Pattern pattern){
switchPattern(pattern);
- if( getMatcher().find() ) return true;
- return false;
+ boolean result = getMatcher().find();
+ return result;
}
/**
*/
protected boolean lookingAtProbe(Pattern pattern){
switchPattern(pattern);
- if( getMatcher().lookingAt() ) return true;
- return false;
+ boolean result = getMatcher().lookingAt();
+ return result;
}
/**
*/
protected boolean matchesProbe(Pattern pattern){
switchPattern(pattern);
- if( getMatcher().matches() ) return true;
- return false;
+ boolean result = getMatcher().matches();
+ return result;
}
/**
* @return ヒットしていたらtrue
*/
protected boolean isGroupMatched(int group){
- if(matchStart(group) >= 0) return true;
- return false;
+ boolean result = matchStart(group) >= 0;
+ return result;
}
/**
for( ; regionStart < regionEnd; regionStart++){
char letter = rawContent.charAt(regionStart);
+ boolean spaceCh;
switch(letter){
case '\u0020':
case '\t':
case '\n':
case '\r':
- hasSpace = true;
- continue;
+ spaceCh = true;
+ break;
default:
+ spaceCh = false;
break;
}
- break;
+ if(spaceCh){
+ hasSpace = true;
+ }else{
+ break;
+ }
}
if(hasSpace){
int limit = offset + length;
for(int bpos = offset; bpos < limit; bpos++){
byte bval = errorArray[bpos];
- if( ! this.hasByte1st){
- if(ShiftJis.isShiftJIS1stByte(bval)){
- this.byte1st = bval;
- this.hasByte1st = true;
- }else{
- getContent().addDecodeError(bval);
- }
- }else{
+
+ if(this.hasByte1st){
if(ShiftJis.isShiftJIS2ndByte(bval)){ // 文字集合エラー
getContent().addDecodeError(this.byte1st, bval);
this.hasByte1st = false;
getContent().addDecodeError(bval);
this.hasByte1st = false;
}
+ }else{
+ if(ShiftJis.isShiftJIS1stByte(bval)){
+ this.byte1st = bval;
+ this.hasByte1st = true;
+ }else{
+ getContent().addDecodeError(bval);
+ }
}
+
}
return;
@SuppressWarnings("serial")
public class DecodeException extends Exception{
+ private static final char CH_SP = '\u0020';
+
+
private final int bytePos;
private final int charPos;
*/
@Override
public String getMessage(){
- StringBuilder result = new StringBuilder();
+ StringBuilder result = new StringBuilder(20);
String message = super.getMessage();
if(message != null && message.length() > 0){
- result.append(message).append(' ');
+ result.append(message).append(CH_SP);
}
result.append("bytePos=").append(this.bytePos);
- result.append(' ');
+ result.append(CH_SP);
result.append("charPos=").append(this.charPos);
return result.toString();
* @param regex 置換元パターン正規表現
* @param altTxt 置換文字列。
*/
- private RegexRep(String regex, String altTxt){
+ RegexRep(String regex, String altTxt){
this.regex = regex;
this.altTxt = altTxt;
return;
* @return シフトJISの1バイト目でありうるならtrue
*/
public static boolean isShiftJIS1stByte(byte bval){
- if( (byte) 0x81 <= bval && bval <= (byte) 0x9f
- || (byte) 0xe0 <= bval && bval <= (byte) 0xfc){
- return true;
- }
- return false;
+ boolean result =
+ (byte) 0x81 <= bval && bval <= (byte) 0x9f
+ || (byte) 0xe0 <= bval && bval <= (byte) 0xfc;
+ return result;
}
/**
* @return シフトJISの2バイト目でありうるならtrue
*/
public static boolean isShiftJIS2ndByte(byte bval){
- if( (byte) 0x40 <= bval && bval <= (byte) 0x7e
- || (byte) 0x80 <= bval && bval <= (byte) 0xfc){
- return true;
- }
- return false;
+ boolean result =
+ (byte) 0x40 <= bval && bval <= (byte) 0x7e
+ || (byte) 0x80 <= bval && bval <= (byte) 0xfc;
+ return result;
}
/**
* @return シフトJISならtrue
*/
public static boolean isShiftJIS(byte b1st, byte b2nd){
- if( ShiftJis.isShiftJIS1stByte(b1st)
- && ShiftJis.isShiftJIS2ndByte(b2nd)){
- return true;
- }
- return false;
+ boolean result =
+ ShiftJis.isShiftJIS1stByte(b1st)
+ && ShiftJis.isShiftJIS2ndByte(b2nd);
+ return result;
}
}
/**
* Test of SjisDecoder & ContentBuilder.
+ * @throws java.io.IOException
+ * @throws jp.sourceforge.jindolf.parser.DecodeException
*/
@Test
public void testDecoding() throws IOException, DecodeException{
/**
* Test of unmappable character.
+ * @throws java.io.IOException
+ * @throws jp.sourceforge.jindolf.parser.DecodeException
*/
@Test
public void testUnmap() throws IOException, DecodeException{
/**
* Test of malformed character.
+ * @throws java.io.IOException
+ * @throws jp.sourceforge.jindolf.parser.DecodeException
*/
@Test
public void testMalform() throws IOException, DecodeException{
/**
* Test of Bounds buffering.
+ * @throws java.io.IOException
+ * @throws jp.sourceforge.jindolf.parser.DecodeException
*/
@Test
public void testBounds() throws IOException, DecodeException{