Skip to content

Commit

Permalink
Renamed readable_format flag to human
Browse files Browse the repository at this point in the history
Closes #3541
  • Loading branch information
javanna committed Aug 20, 2013
1 parent cf9df5c commit b6c55c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Expand Up @@ -83,7 +83,7 @@ public static XContentBuilder builder(XContent xContent) throws IOException {

private StringBuilder cachedStringBuilder;

private boolean readableFormat = true;
private boolean humanReadable = true;

/**
* Constructs a new builder using the provided xcontent and an OutputStream. Make sure
Expand All @@ -108,13 +108,13 @@ public XContentBuilder prettyPrint() {
return this;
}

public XContentBuilder readableFormat(boolean readableFormat) {
this.readableFormat = readableFormat;
public XContentBuilder humanReadable(boolean humanReadable) {
this.humanReadable = humanReadable;
return this;
}

public boolean readableFormat() {
return this.readableFormat;
public boolean humanReadable() {
return this.humanReadable;
}

public XContentBuilder field(String name, ToXContent xContent) throws IOException {
Expand Down Expand Up @@ -837,31 +837,31 @@ public XContentBuilder rawField(String fieldName, BytesReference content) throws
}

public XContentBuilder timeValueField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, TimeValue timeValue) throws IOException {
if (readableFormat) {
if (humanReadable) {
field(readableFieldName, timeValue.toString());
}
field(rawFieldName, timeValue.millis());
return this;
}

public XContentBuilder timeValueField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, long rawTime) throws IOException {
if (readableFormat) {
if (humanReadable) {
field(readableFieldName, new TimeValue(rawTime).toString());
}
field(rawFieldName, rawTime);
return this;
}

public XContentBuilder byteSizeField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, ByteSizeValue byteSizeValue) throws IOException {
if (readableFormat) {
if (humanReadable) {
field(readableFieldName, byteSizeValue.toString());
}
field(rawFieldName, byteSizeValue.bytes());
return this;
}

public XContentBuilder byteSizeField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, long rawSize) throws IOException {
if (readableFormat) {
if (humanReadable) {
field(readableFieldName, new ByteSizeValue(rawSize).toString());
}
field(rawFieldName, rawSize);
Expand Down
Expand Up @@ -58,7 +58,7 @@ public static XContentBuilder restContentBuilder(RestRequest request, @Nullable
builder.prettyPrint();
}

builder.readableFormat(request.paramAsBoolean("readable_format", builder.readableFormat()));
builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable()));

String casing = request.param("case");
if (casing != null && "camelCase".equals(casing)) {
Expand Down

0 comments on commit b6c55c1

Please sign in to comment.