|
|
@ -67,12 +67,24 @@ public final class serverCodings {
|
|
|
|
return s;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String encodeOctal(byte[] in) {
|
|
|
|
|
|
|
|
if (in == null) return "";
|
|
|
|
|
|
|
|
StringBuffer result = new StringBuffer(in.length * 8 / 3);
|
|
|
|
|
|
|
|
for (int i = 0; i < in.length; i++) {
|
|
|
|
|
|
|
|
if ((0Xff & (int) in[i]) < 8) result.append('0');
|
|
|
|
|
|
|
|
result.append(Integer.toOctalString(0Xff & (int) in[i]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new String(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String encodeHex(byte[] in) {
|
|
|
|
public static String encodeHex(byte[] in) {
|
|
|
|
if (in == null) return "";
|
|
|
|
if (in == null) return "";
|
|
|
|
String result = "";
|
|
|
|
StringBuffer result = new StringBuffer(in.length * 2);
|
|
|
|
for (int i = 0; i < in.length; i++)
|
|
|
|
for (int i = 0; i < in.length; i++) {
|
|
|
|
result = result + (((0Xff & (int) in[i]) < 16) ? "0" : "") + Integer.toHexString(0Xff & (int) in[i]);
|
|
|
|
if ((0Xff & (int) in[i]) < 16) result.append('0');
|
|
|
|
return result;
|
|
|
|
result.append(Integer.toHexString(0Xff & (int) in[i]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new String(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static byte[] decodeHex(String hex) {
|
|
|
|
public static byte[] decodeHex(String hex) {
|
|
|
@ -181,7 +193,7 @@ public final class serverCodings {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String map2string(Map m, String separator, boolean braces) {
|
|
|
|
public static String map2string(Map m, String separator, boolean braces) {
|
|
|
|
final StringBuffer buf = new StringBuffer(512);
|
|
|
|
final StringBuffer buf = new StringBuffer(20 * m.size());
|
|
|
|
if (braces) { buf.append("{"); }
|
|
|
|
if (braces) { buf.append("{"); }
|
|
|
|
final Iterator i = m.entrySet().iterator();
|
|
|
|
final Iterator i = m.entrySet().iterator();
|
|
|
|
while (i.hasNext()) {
|
|
|
|
while (i.hasNext()) {
|
|
|
@ -192,7 +204,7 @@ public final class serverCodings {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (buf.length() > 1) { buf.setLength(buf.length() - 1); } // remove last separator
|
|
|
|
if (buf.length() > 1) { buf.setLength(buf.length() - 1); } // remove last separator
|
|
|
|
if (braces) { buf.append("}"); }
|
|
|
|
if (braces) { buf.append("}"); }
|
|
|
|
return buf.toString();
|
|
|
|
return new String(buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Set string2set(String string, String separator) {
|
|
|
|
public static Set string2set(String string, String separator) {
|
|
|
@ -220,7 +232,7 @@ public final class serverCodings {
|
|
|
|
if (hasNext) buf.append(separator);
|
|
|
|
if (hasNext) buf.append(separator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (braces) buf.append("}");
|
|
|
|
if (braces) buf.append("}");
|
|
|
|
return buf.toString();
|
|
|
|
return new String(buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] s) {
|
|
|
|
public static void main(String[] s) {
|
|
|
|