diff options
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/JSONUtils.java')
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/JSONUtils.java | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/JSONUtils.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/JSONUtils.java index d156c587a..6081684f0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/JSONUtils.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/JSONUtils.java @@ -1,46 +1,46 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.core.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * JSON utilities helper implementations.
- */
-public final class JSONUtils {
-
- /**
- * Decodes a string object from the given byte array.
- * <p>
- * Used if services sends plain strings instead of encoding them through JSON.
- *
- * @param data The byte array or <code>null</code>.
- * @return The decoded string or <code>null</code>.
- */
- public static String decodeStringFromByteArray(byte[] data) {
- String args = null;
- if (data != null) {
- StringBuilder builder = new StringBuilder();
- InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(data));
- try {
- int c = reader.read();
- while (c != -1) {
- builder.append(c != 0 ? Character.valueOf((char)c).charValue() : ' ');
- c = reader.read();
- }
- } catch (IOException ex) { /* ignored on purpose */ }
-
- if (builder.length() > 0) args = builder.toString().trim();
- }
- return args;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.core.util; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; + +/** + * JSON utilities helper implementations. + */ +public final class JSONUtils { + + /** + * Decodes a string object from the given byte array. + * <p> + * Used if services sends plain strings instead of encoding them through JSON. + * + * @param data The byte array or <code>null</code>. + * @return The decoded string or <code>null</code>. + */ + public static String decodeStringFromByteArray(byte[] data) { + String args = null; + if (data != null) { + StringBuilder builder = new StringBuilder(); + InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(data)); + try { + int c = reader.read(); + while (c != -1) { + builder.append(c != 0 ? Character.valueOf((char)c).charValue() : ' '); + c = reader.read(); + } + } catch (IOException ex) { /* ignored on purpose */ } + + if (builder.length() > 0) args = builder.toString().trim(); + } + return args; + } +} |