• R/O
  • SSH
  • HTTPS

jsonic: コミット


コミットメタ情報

リビジョン1840 (tree)
日時2014-09-13 11:02:42
作者hizuno

ログメッセージ

(メッセージはありません)

変更サマリ

差分

--- trunk/jsonic-1.3/src/net/arnx/jsonic/io/StringBuilderOutputSource.java (revision 1839)
+++ trunk/jsonic-1.3/src/net/arnx/jsonic/io/StringBuilderOutputSource.java (revision 1840)
@@ -1,12 +1,12 @@
1-/*
1+/*
22 * Copyright 2014 Hidekatsu Izuno
3- *
3+ *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
7- *
7+ *
88 * http://www.apache.org/licenses/LICENSE-2.0
9- *
9+ *
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,38 +17,38 @@
1717
1818 public class StringBuilderOutputSource implements OutputSource {
1919 private final StringBuilder sb;
20-
21- public StringBuilderOutputSource() {
22- this.sb = new StringBuilder(1000);
20+
21+ public StringBuilderOutputSource(int size) {
22+ this.sb = new StringBuilder(size);
2323 }
24-
24+
2525 public StringBuilderOutputSource(StringBuilder sb) {
2626 this.sb = sb;
2727 }
28-
28+
2929 @Override
3030 public void append(String text) {
3131 sb.append(text);
3232 }
33-
33+
3434 @Override
3535 public void append(String text, int start, int end) {
3636 sb.append(text, start, end);
3737 }
38-
38+
3939 @Override
4040 public void append(char c) {
4141 sb.append(c);
4242 }
43-
43+
4444 @Override
4545 public void flush() {
4646 }
47-
47+
4848 public void clear() {
4949 sb.setLength(0);
5050 }
51-
51+
5252 @Override
5353 public String toString() {
5454 return sb.toString();
--- trunk/jsonic-1.3/src/net/arnx/jsonic/io/StringBufferOutputSource.java (revision 1839)
+++ trunk/jsonic-1.3/src/net/arnx/jsonic/io/StringBufferOutputSource.java (revision 1840)
@@ -1,12 +1,12 @@
1-/*
1+/*
22 * Copyright 2014 Hidekatsu Izuno
3- *
3+ *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
7- *
7+ *
88 * http://www.apache.org/licenses/LICENSE-2.0
9- *
9+ *
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,38 +17,38 @@
1717
1818 public class StringBufferOutputSource implements OutputSource {
1919 private final StringBuffer sb;
20-
21- public StringBufferOutputSource() {
22- this.sb = new StringBuffer(1000);
20+
21+ public StringBufferOutputSource(int size) {
22+ this.sb = new StringBuffer(size);
2323 }
24-
24+
2525 public StringBufferOutputSource(StringBuffer sb) {
2626 this.sb = sb;
2727 }
28-
28+
2929 @Override
3030 public void append(String text) {
3131 sb.append(text);
3232 }
33-
33+
3434 @Override
3535 public void append(String text, int start, int end) {
3636 sb.append(text, start, end);
3737 }
38-
38+
3939 @Override
4040 public void append(char c) {
4141 sb.append(c);
4242 }
43-
43+
4444 @Override
4545 public void flush() {
4646 }
47-
47+
4848 public void clear() {
4949 sb.setLength(0);
5050 }
51-
51+
5252 @Override
5353 public String toString() {
5454 return sb.toString();
--- trunk/jsonic-1.3/src/net/arnx/jsonic/Converter.java (revision 1839)
+++ trunk/jsonic-1.3/src/net/arnx/jsonic/Converter.java (revision 1840)
@@ -161,7 +161,7 @@
161161 Context context2 = context.copy();
162162 context2.skipHint = context.getHint();
163163 value = context2.preformatInternal(value);
164- StringBuilderOutputSource out = new StringBuilderOutputSource(new StringBuilder(200));
164+ StringBuilderOutputSource out = new StringBuilderOutputSource(200);
165165 try {
166166 context2.formatInternal(value, out);
167167 } catch (IOException e) {
--- trunk/jsonic-1.3/src/net/arnx/jsonic/JSON.java (revision 1839)
+++ trunk/jsonic-1.3/src/net/arnx/jsonic/JSON.java (revision 1840)
@@ -942,7 +942,9 @@
942942 len = 1000;
943943 }
944944
945- text = format(source, new StringBuilder(len)).toString();
945+ OutputSource out = new StringBuilderOutputSource(len);
946+ format(source, out);
947+ text = out.toString();
946948 } catch (IOException e) {
947949 // no handle;
948950 }
@@ -980,6 +982,11 @@
980982 out = new AppendableOutputSource(ap);
981983 }
982984
985+ format(source, out);
986+ return ap;
987+ }
988+
989+ private void format(Object source, OutputSource out) throws IOException {
983990 Context context = new Context();
984991
985992 if (context.isPrettyPrint()) {
@@ -991,7 +998,6 @@
991998 context.formatInternal(source, out);
992999 context.exit();
9931000 out.flush();
994- return ap;
9951001 }
9961002
9971003 public JSONWriter getWriter(OutputStream out) throws IOException {
旧リポジトリブラウザで表示