-//##header\r
-//#if defined(FOUNDATION10) || defined(J2SE13)\r
-//#else\r
-/*\r
- *******************************************************************************\r
- * Copyright (C) 1996-2009, International Business Machines Corporation and *\r
- * others. All Rights Reserved. *\r
- *******************************************************************************\r
- */\r
-package com.ibm.icu.dev.test.util;\r
-\r
-import java.io.DataInput;\r
-import java.io.IOException;\r
-import java.io.ObjectInput;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-//import java.util.HashMap;\r
-import java.util.LinkedHashSet;\r
-import java.util.List;\r
-//import java.util.Map;\r
-\r
-//import com.ibm.icu.impl.Utility;\r
-import com.ibm.icu.text.UTF16;\r
-\r
-/**\r
- * Simple data input compressor. Nothing fancy, but much smaller footprint for\r
- * ints and many strings.\r
- */\r
-public final class DataInputCompressor implements ObjectInput {\r
- static final boolean SHOW = false;\r
-\r
- private ObjectInput dataInput;\r
-\r
- private transient StringBuffer stringBuffer = new StringBuffer();\r
-\r
- public DataInputCompressor(ObjectInput dataInput) {\r
- this.dataInput = dataInput;\r
- }\r
-\r
- public DataInput getDataInput() {\r
- return dataInput;\r
- }\r
-\r
- public void setDataInput(ObjectInput dataInput) {\r
- this.dataInput = dataInput;\r
- }\r
-\r
- public boolean readBoolean() throws IOException {\r
- return dataInput.readBoolean();\r
- }\r
-\r
- public byte readByte() throws IOException {\r
- return dataInput.readByte();\r
- }\r
-\r
- public int readUnsignedByte() throws IOException {\r
- return dataInput.readUnsignedByte();\r
- }\r
-\r
- public double readDouble() throws IOException {\r
- return dataInput.readDouble();\r
- }\r
-\r
- public float readFloat() throws IOException {\r
- return dataInput.readFloat();\r
- }\r
-\r
- public void readFully(byte[] b) throws IOException {\r
- dataInput.readFully(b);\r
- }\r
-\r
- public void readFully(byte[] b, int off, int len) throws IOException {\r
- dataInput.readFully(b, off, len);\r
- }\r
-\r
- public int skipBytes(int n) throws IOException {\r
- return dataInput.skipBytes(n);\r
- }\r
-\r
- public String readLine() throws IOException {\r
- return dataInput.readLine();\r
- }\r
-\r
- public int available() throws IOException {\r
- return dataInput.available();\r
- }\r
- public void close() throws IOException {\r
- dataInput.close();\r
- }\r
- public int read() throws IOException {\r
- return dataInput.read();\r
- }\r
- public int read(byte[] b) throws IOException {\r
- return dataInput.read(b);\r
- }\r
- public int read(byte[] b, int off, int len) throws IOException {\r
- return dataInput.read(b, off, len);\r
- }\r
- public Object readObject() throws ClassNotFoundException, IOException {\r
- return dataInput.readObject();\r
- }\r
- public long skip(long n) throws IOException {\r
- return dataInput.skip(n);\r
- }\r
- public String toString() {\r
- return dataInput.toString();\r
- }\r
- // ==== New Routines ====\r
-\r
- public char readChar() throws IOException {\r
- return (char) readULong();\r
- }\r
-\r
- public short readShort() throws IOException {\r
- return (short) readLong();\r
- }\r
-\r
- public int readUnsignedShort() throws IOException {\r
- return (int) readULong();\r
- }\r
-\r
- public int readUShort() throws IOException {\r
- return (int) readULong();\r
- }\r
-\r
- public int readInt() throws IOException {\r
- return (int) readLong();\r
- }\r
-\r
- public int readUInt() throws IOException {\r
- return (int) readULong();\r
- }\r
-\r
- public String readChars(int len) throws IOException {\r
- stringBuffer.setLength(0);\r
- for (int i = 0; i < len; ++i) {\r
- int cp = (int) readULong();\r
- UTF16.append(stringBuffer, cp);\r
- }\r
- return stringBuffer.toString();\r
- }\r
-\r
- public String readUTF() throws IOException {\r
- int len = (int) readULong();\r
- return readChars(len);\r
- }\r
-\r
- public long readLong() throws IOException {\r
- long result = 0;\r
- int offset = 0;\r
- while (true) {\r
- long input = readByte();\r
- result |= (input & 0x7F) << offset;\r
- if ((input & 0x80) == 0)\r
- break;\r
- offset += 7;\r
- }\r
- boolean negative = (result & 1) != 0; // get sign bit from the bottom,\r
- // and invert\r
- result >>>= 1;\r
- if (negative)\r
- result = ~result;\r
- return result;\r
- }\r
-\r
- public long readULong() throws IOException {\r
- long result = 0;\r
- int offset = 0;\r
- while (true) { // read sequence of 7 bits, with top bit = 1 for\r
- // continuation\r
- int input = readByte();\r
- result |= (input & 0x7F) << offset;\r
- if ((input & 0x80) == 0)\r
- return result;\r
- offset += 7;\r
- }\r
- }\r
-\r
- /**\r
- * \r
- */\r
- public Object[] readStringSet(Collection availableValues)\r
- throws IOException {\r
- int size = readUInt();\r
- if (SHOW) System.out.println("readStringSet");\r
- Object[] valuesList = new Object[size + 1];\r
- // first item is null\r
- String lastString = "";\r
- ReadPool trailingPool = new ReadPool();\r
- for (int i = 0; i < size; ++i) {\r
- int common = readUInt();\r
- boolean inPool = (common & 1) != 0;\r
- common >>>= 1;\r
- if (SHOW) System.out.println(common);\r
- String current;\r
- if (inPool) {\r
- int poolIndex = readUInt();\r
- if (SHOW) System.out.println("\t" + poolIndex);\r
- current = (String) trailingPool.get(poolIndex);\r
- } else {\r
- current = readUTF();\r
- trailingPool.add(current);\r
- }\r
- valuesList[i + 1] = lastString = lastString.substring(0, common)\r
- + current;\r
- if (SHOW) System.out.println("\t\t" + lastString);\r
- if (availableValues != null) availableValues.add(current);\r
- }\r
- return valuesList;\r
- }\r
- \r
- public static class ReadPool {\r
- private List trailingPool = new ArrayList();\r
- public Object get(int index) {\r
- return trailingPool.get(index);\r
- }\r
- public void add(Object o) {\r
- trailingPool.add(o);\r
- }\r
- }\r
-\r
- /**\r
- * @throws IOException\r
- * @throws ClassNotFoundException\r
- * \r
- */\r
- public Object[] readCollection(LinkedHashSet availableValues) throws ClassNotFoundException, IOException {\r
- int size = readUInt();\r
- Object[] valuesList = new Object[size + 1];\r
- for (int i = 0; i < size; ++i) {\r
- valuesList[i + 1] = readObject();\r
- }\r
- return valuesList;\r
- }\r
-}\r
-//#endif\r
+//##header J2SE15
+//#if defined(FOUNDATION10) || defined(J2SE13)
+//#else
+/*
+ *******************************************************************************
+ * Copyright (C) 1996-2009, International Business Machines Corporation and *
+ * others. All Rights Reserved. *
+ *******************************************************************************
+ */
+package com.ibm.icu.dev.test.util;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.util.ArrayList;
+import java.util.Collection;
+//import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+//import java.util.Map;
+
+//import com.ibm.icu.impl.Utility;
+import com.ibm.icu.text.UTF16;
+
+/**
+ * Simple data input compressor. Nothing fancy, but much smaller footprint for
+ * ints and many strings.
+ */
+public final class DataInputCompressor implements ObjectInput {
+ static final boolean SHOW = false;
+
+ private ObjectInput dataInput;
+
+ private transient StringBuffer stringBuffer = new StringBuffer();
+
+ public DataInputCompressor(ObjectInput dataInput) {
+ this.dataInput = dataInput;
+ }
+
+ public DataInput getDataInput() {
+ return dataInput;
+ }
+
+ public void setDataInput(ObjectInput dataInput) {
+ this.dataInput = dataInput;
+ }
+
+ public boolean readBoolean() throws IOException {
+ return dataInput.readBoolean();
+ }
+
+ public byte readByte() throws IOException {
+ return dataInput.readByte();
+ }
+
+ public int readUnsignedByte() throws IOException {
+ return dataInput.readUnsignedByte();
+ }
+
+ public double readDouble() throws IOException {
+ return dataInput.readDouble();
+ }
+
+ public float readFloat() throws IOException {
+ return dataInput.readFloat();
+ }
+
+ public void readFully(byte[] b) throws IOException {
+ dataInput.readFully(b);
+ }
+
+ public void readFully(byte[] b, int off, int len) throws IOException {
+ dataInput.readFully(b, off, len);
+ }
+
+ public int skipBytes(int n) throws IOException {
+ return dataInput.skipBytes(n);
+ }
+
+ public String readLine() throws IOException {
+ return dataInput.readLine();
+ }
+
+ public int available() throws IOException {
+ return dataInput.available();
+ }
+ public void close() throws IOException {
+ dataInput.close();
+ }
+ public int read() throws IOException {
+ return dataInput.read();
+ }
+ public int read(byte[] b) throws IOException {
+ return dataInput.read(b);
+ }
+ public int read(byte[] b, int off, int len) throws IOException {
+ return dataInput.read(b, off, len);
+ }
+ public Object readObject() throws ClassNotFoundException, IOException {
+ return dataInput.readObject();
+ }
+ public long skip(long n) throws IOException {
+ return dataInput.skip(n);
+ }
+ public String toString() {
+ return dataInput.toString();
+ }
+ // ==== New Routines ====
+
+ public char readChar() throws IOException {
+ return (char) readULong();
+ }
+
+ public short readShort() throws IOException {
+ return (short) readLong();
+ }
+
+ public int readUnsignedShort() throws IOException {
+ return (int) readULong();
+ }
+
+ public int readUShort() throws IOException {
+ return (int) readULong();
+ }
+
+ public int readInt() throws IOException {
+ return (int) readLong();
+ }
+
+ public int readUInt() throws IOException {
+ return (int) readULong();
+ }
+
+ public String readChars(int len) throws IOException {
+ stringBuffer.setLength(0);
+ for (int i = 0; i < len; ++i) {
+ int cp = (int) readULong();
+ UTF16.append(stringBuffer, cp);
+ }
+ return stringBuffer.toString();
+ }
+
+ public String readUTF() throws IOException {
+ int len = (int) readULong();
+ return readChars(len);
+ }
+
+ public long readLong() throws IOException {
+ long result = 0;
+ int offset = 0;
+ while (true) {
+ long input = readByte();
+ result |= (input & 0x7F) << offset;
+ if ((input & 0x80) == 0)
+ break;
+ offset += 7;
+ }
+ boolean negative = (result & 1) != 0; // get sign bit from the bottom,
+ // and invert
+ result >>>= 1;
+ if (negative)
+ result = ~result;
+ return result;
+ }
+
+ public long readULong() throws IOException {
+ long result = 0;
+ int offset = 0;
+ while (true) { // read sequence of 7 bits, with top bit = 1 for
+ // continuation
+ int input = readByte();
+ result |= (input & 0x7F) << offset;
+ if ((input & 0x80) == 0)
+ return result;
+ offset += 7;
+ }
+ }
+
+ /**
+ *
+ */
+ public Object[] readStringSet(Collection availableValues)
+ throws IOException {
+ int size = readUInt();
+ if (SHOW) System.out.println("readStringSet");
+ Object[] valuesList = new Object[size + 1];
+ // first item is null
+ String lastString = "";
+ ReadPool trailingPool = new ReadPool();
+ for (int i = 0; i < size; ++i) {
+ int common = readUInt();
+ boolean inPool = (common & 1) != 0;
+ common >>>= 1;
+ if (SHOW) System.out.println(common);
+ String current;
+ if (inPool) {
+ int poolIndex = readUInt();
+ if (SHOW) System.out.println("\t" + poolIndex);
+ current = (String) trailingPool.get(poolIndex);
+ } else {
+ current = readUTF();
+ trailingPool.add(current);
+ }
+ valuesList[i + 1] = lastString = lastString.substring(0, common)
+ + current;
+ if (SHOW) System.out.println("\t\t" + lastString);
+ if (availableValues != null) availableValues.add(current);
+ }
+ return valuesList;
+ }
+
+ public static class ReadPool {
+ private List trailingPool = new ArrayList();
+ public Object get(int index) {
+ return trailingPool.get(index);
+ }
+ public void add(Object o) {
+ trailingPool.add(o);
+ }
+ }
+
+ /**
+ * @throws IOException
+ * @throws ClassNotFoundException
+ *
+ */
+ public Object[] readCollection(LinkedHashSet availableValues) throws ClassNotFoundException, IOException {
+ int size = readUInt();
+ Object[] valuesList = new Object[size + 1];
+ for (int i = 0; i < size; ++i) {
+ valuesList[i + 1] = readObject();
+ }
+ return valuesList;
+ }
+}
+//#endif