This commit is contained in:
wentch
2016-01-06 11:42:49 +08:00
parent 8c22c3b05e
commit e94b5706ea
2 changed files with 17 additions and 17 deletions

View File

@@ -60,7 +60,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return 有效字符或空白字符 * @return 有效字符或空白字符
*/ */
@Override @Override
protected char nextChar() { protected final char nextChar() {
if (currentChar != 0) { if (currentChar != 0) {
char ch = currentChar; char ch = currentChar;
this.currentChar = 0; this.currentChar = 0;
@@ -86,7 +86,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return 有效字符 * @return 有效字符
*/ */
@Override @Override
protected char nextGoodChar() { protected final char nextGoodChar() {
char c = nextChar(); char c = nextChar();
if (c > ' ' || c == 0) return c; // 0 表示buffer结尾了 if (c > ' ' || c == 0) return c; // 0 表示buffer结尾了
for (;;) { for (;;) {
@@ -101,7 +101,7 @@ public class JsonByteBufferReader extends JsonReader {
* @param ch 回退的字符 * @param ch 回退的字符
*/ */
@Override @Override
protected void backChar(char ch) { protected final void backChar(char ch) {
this.currentChar = ch; this.currentChar = ch;
} }
@@ -111,7 +111,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return SIGN_NOLENGTH 或 SIGN_NULL * @return SIGN_NOLENGTH 或 SIGN_NULL
*/ */
@Override @Override
public int readObjectB() { public final int readObjectB() {
char ch = nextGoodChar(); char ch = nextGoodChar();
if (ch == '{') return SIGN_NOLENGTH; if (ch == '{') return SIGN_NOLENGTH;
if (ch == 'n' && nextChar() == 'u' && nextChar() == 'l' && nextChar() == 'l') return SIGN_NULL; if (ch == 'n' && nextChar() == 'u' && nextChar() == 'l' && nextChar() == 'l') return SIGN_NULL;
@@ -125,7 +125,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return SIGN_NOLENGTH 或 SIGN_NULL * @return SIGN_NOLENGTH 或 SIGN_NULL
*/ */
@Override @Override
public int readArrayB() { public final int readArrayB() {
char ch = nextGoodChar(); char ch = nextGoodChar();
if (ch == '[' || ch == '{') return SIGN_NOLENGTH; if (ch == '[' || ch == '{') return SIGN_NOLENGTH;
if (ch == 'n' && nextChar() == 'u' && nextChar() == 'l' && nextChar() == 'l') return SIGN_NULL; if (ch == 'n' && nextChar() == 'u' && nextChar() == 'l' && nextChar() == 'l') return SIGN_NULL;
@@ -137,7 +137,7 @@ public class JsonByteBufferReader extends JsonReader {
* 判断下一个非空白字符是否: * 判断下一个非空白字符是否:
*/ */
@Override @Override
public void skipBlank() { public final void skipBlank() {
char ch = nextGoodChar(); char ch = nextGoodChar();
if (ch == ':') return; if (ch == ':') return;
throw new ConvertException("expected a ':' but '" + ch + "'(position = " + position + ")"); throw new ConvertException("expected a ':' but '" + ch + "'(position = " + position + ")");
@@ -149,7 +149,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return 是否存在 * @return 是否存在
*/ */
@Override @Override
public boolean hasNext() { public final boolean hasNext() {
char ch = nextGoodChar(); char ch = nextGoodChar();
if (ch == ',') return true; if (ch == ',') return true;
if (ch == '}' || ch == ']') return false; if (ch == '}' || ch == ']') return false;
@@ -163,7 +163,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return String值 * @return String值
*/ */
@Override @Override
public String readSmallString() { public final String readSmallString() {
char ch = nextGoodChar(); char ch = nextGoodChar();
if (ch == 0) return null; if (ch == 0) return null;
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
@@ -259,7 +259,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return int值 * @return int值
*/ */
@Override @Override
public int readInt() { public final int readInt() {
char firstchar = nextGoodChar(); char firstchar = nextGoodChar();
if (firstchar == '"' || firstchar == '\'') { if (firstchar == '"' || firstchar == '\'') {
firstchar = nextChar(); firstchar = nextChar();
@@ -293,7 +293,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return long值 * @return long值
*/ */
@Override @Override
public long readLong() { public final long readLong() {
char firstchar = nextGoodChar(); char firstchar = nextGoodChar();
if (firstchar == '"' || firstchar == '\'') { if (firstchar == '"' || firstchar == '\'') {
firstchar = nextChar(); firstchar = nextChar();
@@ -327,7 +327,7 @@ public class JsonByteBufferReader extends JsonReader {
* @return String值 * @return String值
*/ */
@Override @Override
public String readString() { public final String readString() {
return readSmallString(); return readSmallString();
} }

View File

@@ -107,7 +107,7 @@ public final class JsonByteBufferWriter extends JsonWriter {
} }
@Override @Override
public void writeTo(final char[] chs, final int start, final int len) { public final void writeTo(final char[] chs, final int start, final int len) {
writeTo(-1, false, chs, start, len); writeTo(-1, false, chs, start, len);
} }
@@ -194,7 +194,7 @@ public final class JsonByteBufferWriter extends JsonWriter {
return this.buffers[++this.index]; return this.buffers[++this.index];
} }
private static int encodeUTF8Length(final char[] text, final int start, final int len) { protected static int encodeUTF8Length(final char[] text, final int start, final int len) {
char c; char c;
int size = 0; int size = 0;
final char[] chars = text; final char[] chars = text;
@@ -206,7 +206,7 @@ public final class JsonByteBufferWriter extends JsonWriter {
return size; return size;
} }
private static int encodeEscapeUTF8Length(final char[] text, final int start, final int len) { protected static int encodeEscapeUTF8Length(final char[] text, final int start, final int len) {
char c; char c;
int size = 0; int size = 0;
final char[] chars = text; final char[] chars = text;
@@ -239,7 +239,7 @@ public final class JsonByteBufferWriter extends JsonWriter {
* @param value String值 * @param value String值
*/ */
@Override @Override
public void writeTo(final boolean quote, final String value) { public final void writeTo(final boolean quote, final String value) {
char[] chs = Utility.charArray(value); char[] chs = Utility.charArray(value);
writeTo(-1, quote, chs, 0, chs.length); writeTo(-1, quote, chs, 0, chs.length);
} }
@@ -331,14 +331,14 @@ public final class JsonByteBufferWriter extends JsonWriter {
} }
@Override @Override
public void writeField(boolean comma, Attribute attribute) { public final void writeField(boolean comma, Attribute attribute) {
if (comma) writeTo(','); if (comma) writeTo(',');
writeTo(true, attribute.field()); writeTo(true, attribute.field());
writeTo(':'); writeTo(':');
} }
@Override @Override
public void writeSmallString(String value) { public final void writeSmallString(String value) {
writeTo(false, value); writeTo(false, value);
} }