Skip to content

Commit

Permalink
GEODE-2142: spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Udo Kohlmeyer committed Feb 27, 2017
1 parent 7c8794c commit eac0bb8
Show file tree
Hide file tree
Showing 16 changed files with 5,350 additions and 5,517 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ private ResultData addAsFile(String fileName, byte[] data, int fileType, String
sectionData.put(FILE_TYPE_FIELD, fileType);
sectionData.put(FILE_MESSAGE, message);
DeflaterInflaterData deflaterInflaterData = CliUtil.compressBytes(data);
sectionData.put(FILE_DATA_FIELD, Base64.getEncoder().encodeToString(deflaterInflaterData.getData()));
sectionData.put(DATA_LENGTH_FIELD,deflaterInflaterData.getDataLength());
sectionData.put(FILE_DATA_FIELD,
Base64.getEncoder().encodeToString(deflaterInflaterData.getData()));
sectionData.put(DATA_LENGTH_FIELD, deflaterInflaterData.getDataLength());
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
Expand Down Expand Up @@ -231,7 +232,7 @@ public static void readFileDataAndDump(GfJsonArray byteDataArray, String directo
String fileDataString = (String) object.get(FILE_DATA_FIELD);
int fileDataLength = (int) object.get(DATA_LENGTH_FIELD);
byte[] byteArray = Base64.getDecoder().decode(fileDataString);
byte[] uncompressBytes = CliUtil.uncompressBytes(byteArray,fileDataLength).getData();
byte[] uncompressBytes = CliUtil.uncompressBytes(byteArray, fileDataLength).getData();

boolean isGfshVM = CliUtil.isGfshVM();
File fileToDumpData = new File(fileName);
Expand Down
176 changes: 86 additions & 90 deletions geode-json/src/main/java/org/json/JSON.java
Original file line number Diff line number Diff line change
@@ -1,116 +1,112 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package org.json;

class JSON {
/**
* Returns the input if it is a JSON-permissible value; throws otherwise.
*/
static double checkDouble(double d) throws JSONException {
if (Double.isInfinite(d) || Double.isNaN(d)) {
throw new JSONException("Forbidden numeric value: " + d);
}
return d;
/**
* Returns the input if it is a JSON-permissible value; throws otherwise.
*/
static double checkDouble(double d) throws JSONException {
if (Double.isInfinite(d) || Double.isNaN(d)) {
throw new JSONException("Forbidden numeric value: " + d);
}
return d;
}

static Boolean toBoolean(Object value) {
if (value instanceof Boolean) {
return (Boolean) value;
} else if (value instanceof String) {
String stringValue = (String) value;
if ("true".equalsIgnoreCase(stringValue)) {
return true;
} else if ("false".equalsIgnoreCase(stringValue)) {
return false;
}
}
return null;
static Boolean toBoolean(Object value) {
if (value instanceof Boolean) {
return (Boolean) value;
} else if (value instanceof String) {
String stringValue = (String) value;
if ("true".equalsIgnoreCase(stringValue)) {
return true;
} else if ("false".equalsIgnoreCase(stringValue)) {
return false;
}
}
return null;
}

static Double toDouble(Object value) {
if (value instanceof Double) {
return (Double) value;
} else if (value instanceof Number) {
return ((Number) value).doubleValue();
} else if (value instanceof String) {
try {
return Double.valueOf((String) value);
} catch (NumberFormatException ignored) {
}
}
return null;
static Double toDouble(Object value) {
if (value instanceof Double) {
return (Double) value;
} else if (value instanceof Number) {
return ((Number) value).doubleValue();
} else if (value instanceof String) {
try {
return Double.valueOf((String) value);
} catch (NumberFormatException ignored) {
}
}
return null;
}

static Integer toInteger(Object value) {
if (value instanceof Integer) {
return (Integer) value;
} else if (value instanceof Number) {
return ((Number) value).intValue();
} else if (value instanceof String) {
try {
return (int) Double.parseDouble((String) value);
} catch (NumberFormatException ignored) {
}
}
return null;
static Integer toInteger(Object value) {
if (value instanceof Integer) {
return (Integer) value;
} else if (value instanceof Number) {
return ((Number) value).intValue();
} else if (value instanceof String) {
try {
return (int) Double.parseDouble((String) value);
} catch (NumberFormatException ignored) {
}
}
return null;
}

static Long toLong(Object value) {
if (value instanceof Long) {
return (Long) value;
} else if (value instanceof Number) {
return ((Number) value).longValue();
} else if (value instanceof String) {
try {
return (long) Double.parseDouble((String) value);
} catch (NumberFormatException ignored) {
}
}
return null;
static Long toLong(Object value) {
if (value instanceof Long) {
return (Long) value;
} else if (value instanceof Number) {
return ((Number) value).longValue();
} else if (value instanceof String) {
try {
return (long) Double.parseDouble((String) value);
} catch (NumberFormatException ignored) {
}
}
return null;
}

static String toString(Object value) {
if (value instanceof String) {
return (String) value;
} else if (value != null) {
return String.valueOf(value);
}
return null;
static String toString(Object value) {
if (value instanceof String) {
return (String) value;
} else if (value != null) {
return String.valueOf(value);
}
return null;
}

public static JSONException typeMismatch(Object indexOrName, Object actual,
String requiredType) throws JSONException {
if (actual == null) {
throw new JSONException("Value at " + indexOrName + " is null.");
} else {
throw new JSONException("Value " + actual + " at " + indexOrName
+ " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
public static JSONException typeMismatch(Object indexOrName, Object actual, String requiredType)
throws JSONException {
if (actual == null) {
throw new JSONException("Value at " + indexOrName + " is null.");
} else {
throw new JSONException("Value " + actual + " at " + indexOrName + " of type "
+ actual.getClass().getName() + " cannot be converted to " + requiredType);
}
}

public static JSONException typeMismatch(Object actual, String requiredType)
throws JSONException {
if (actual == null) {
throw new JSONException("Value is null.");
} else {
throw new JSONException("Value " + actual
+ " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
public static JSONException typeMismatch(Object actual, String requiredType)
throws JSONException {
if (actual == null) {
throw new JSONException("Value is null.");
} else {
throw new JSONException("Value " + actual + " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
}
}
Loading

0 comments on commit eac0bb8

Please sign in to comment.