Skip to content

Commit

Permalink
Retranslate Java.
Browse files Browse the repository at this point in the history
  • Loading branch information
shunter committed Mar 22, 2019
1 parent 668e665 commit 00ded2b
Showing 1 changed file with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public CesiumOutputStream(@Nonnull Writer writer) {
}

/**
* Gets whether or not the written data should be formatted for easy human readability.
When this property is {@code false} (the default), more compact Cesium is generated.
* Gets a value indicating whether or not the written data should be formatted for easy human readability.
When this property is {@code false} (the default), more compact CZML is generated.
*/
Expand All @@ -53,8 +53,8 @@ public final boolean getPrettyFormatting() {
}

/**
* Sets whether or not the written data should be formatted for easy human readability.
When this property is {@code false} (the default), more compact Cesium is generated.
* Sets a value indicating whether or not the written data should be formatted for easy human readability.
When this property is {@code false} (the default), more compact CZML is generated.
*/
Expand All @@ -74,7 +74,7 @@ public final void writeStartObject() {
TextWriterHelper.write(m_writer, '{');
m_firstInContainer = true;
m_inProperty = false;
m_indent += IndentLevel;
increaseIndent();
}

/**
Expand All @@ -85,7 +85,7 @@ public final void writeStartObject() {
*/
public final void writeEndObject() {
m_firstInContainer = false;
m_indent -= IndentLevel;
decreaseIndent();
if (getPrettyFormatting()) {
TextWriterHelper.writeLine(m_writer);
writeIndent();
Expand All @@ -105,7 +105,7 @@ public final void writeStartSequence() {
TextWriterHelper.write(m_writer, '[');
m_firstInContainer = true;
m_inProperty = false;
m_indent += IndentLevel;
increaseIndent();
}

/**
Expand All @@ -116,7 +116,7 @@ public final void writeStartSequence() {
*/
public final void writeEndSequence() {
m_firstInContainer = false;
m_indent -= IndentLevel;
decreaseIndent();
if (getPrettyFormatting()) {
TextWriterHelper.writeLine(m_writer);
writeIndent();
Expand Down Expand Up @@ -191,10 +191,7 @@ public final void writeValue(double value) {
* @param value The value to write.
*/
public final void writeValue(int value) {
startNewValue();
m_firstInContainer = false;
m_inProperty = false;
TextWriterHelper.write(m_writer, IntHelper.toString(value, CultureInfoHelper.getInvariantCulture()));
writeRawValueString(IntHelper.toString(value, CultureInfoHelper.getInvariantCulture()));
}

/**
Expand All @@ -206,10 +203,7 @@ public final void writeValue(int value) {
* @param value The value to write.
*/
public final void writeValue(long value) {
startNewValue();
m_firstInContainer = false;
m_inProperty = false;
TextWriterHelper.write(m_writer, LongHelper.toString(value, CultureInfoHelper.getInvariantCulture()));
writeRawValueString(LongHelper.toString(value, CultureInfoHelper.getInvariantCulture()));
}

/**
Expand All @@ -221,10 +215,14 @@ public final void writeValue(long value) {
* @param value The value to write.
*/
public final void writeValue(boolean value) {
writeRawValueString(value ? "true" : "false");
}

private final void writeRawValueString(String s) {
startNewValue();
m_firstInContainer = false;
m_inProperty = false;
TextWriterHelper.write(m_writer, value ? "true" : "false");
TextWriterHelper.write(m_writer, s);
}

/**
Expand Down Expand Up @@ -333,6 +331,7 @@ private final void writeEscapedString(@Nonnull String value) {
}
}

@Nonnull
private static String toCharAsUnicode(char c) {
char h1 = intToHex((c >>> 12) & '\u000f');
char h2 = intToHex((c >>> 8) & '\u000f');
Expand All @@ -356,6 +355,10 @@ private static char intToHex(int n) {
}

private final void startNewValue() {
if (m_firstInStream) {
m_firstInStream = false;
return;
}
if (!m_firstInContainer) {
TextWriterHelper.write(m_writer, ',');
}
Expand All @@ -366,13 +369,23 @@ private final void startNewValue() {
}
}

private final void increaseIndent() {
m_indent += IndentLevel;
}

private final void decreaseIndent() {
m_indent -= IndentLevel;
}

private final void writeIndent() {
for (int i = 0; i < m_indent; ++i)
for (int i = 0; i < m_indent; ++i) {
TextWriterHelper.write(m_writer, ' ');
}
}

@Nonnull
private Writer m_writer;
private boolean m_firstInStream = true;
private boolean m_firstInContainer = true;
private boolean m_inProperty;
private boolean m_nextValueOnNewLine;
Expand Down

0 comments on commit 00ded2b

Please sign in to comment.