Skip to content

Commit

Permalink
stleary#863 improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Simulant87 committed Feb 23, 2024
1 parent 7c7a98d commit 0ff635c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/main/java/org/json/StringBuilderWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@
class StringBuilderWriter extends Writer {
private final StringBuilder builder;

/**
* Create a new string builder writer using the default initial string-builder buffer size.
*/
StringBuilderWriter() {
builder = new StringBuilder();
lock = builder;
}

StringBuilderWriter(int initialSize) {
if (initialSize < 0) {
throw new IllegalArgumentException("Negative buffer size");
}
builder = new StringBuilder(initialSize);
lock = builder;
}

@Override
public void write(int c) {
builder.append((char) c);
}

@Override
public void write(char cbuf[], int offset, int length) {
public void write(char[] cbuf, int offset, int length) {
if ((offset < 0) || (offset > cbuf.length) || (length < 0) ||
((offset + length) > cbuf.length) || ((offset + length) < 0)) {
throw new IndexOutOfBoundsException();
Expand Down Expand Up @@ -57,7 +52,9 @@ public StringBuilderWriter append(CharSequence csq) {

@Override
public StringBuilderWriter append(CharSequence csq, int start, int end) {
if (csq == null) csq = "null";
if (csq == null) {
csq = "null";
}
return append(csq.subSequence(start, end));
}

Expand Down

0 comments on commit 0ff635c

Please sign in to comment.