< prev index next >
src/java.base/share/classes/sun/text/normalizer/ICUBinary.java
Print this page
rev 54996 : 8221431: Support for Unicode 12.1
Reviewed-by:
*** 1,7 ****
/*
! * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 117,130 ****
if (capacity < 128) {
capacity = 128;
} else if (capacity < 0x4000) {
capacity *= 2; // Grow faster until we reach 16kB.
}
! // TODO Java 6 replace new byte[] and arraycopy(): bytes = Arrays.copyOf(bytes, capacity);
! byte[] newBytes = new byte[capacity];
! System.arraycopy(bytes, 0, newBytes, 0, length);
! bytes = newBytes;
bytes[length++] = (byte) nextByte;
}
}
return ByteBuffer.wrap(bytes, 0, length);
}
--- 117,127 ----
if (capacity < 128) {
capacity = 128;
} else if (capacity < 0x4000) {
capacity *= 2; // Grow faster until we reach 16kB.
}
! bytes = Arrays.copyOf(bytes, capacity);
bytes[length++] = (byte) nextByte;
}
}
return ByteBuffer.wrap(bytes, 0, length);
}
*** 262,271 ****
--- 259,298 ----
if (skipLength > 0) {
bytes.position(bytes.position() + skipLength);
}
}
+ public static byte[] getBytes(ByteBuffer bytes, int length, int additionalSkipLength) {
+ byte[] dest = new byte[length];
+ bytes.get(dest);
+ if (additionalSkipLength > 0) {
+ skipBytes(bytes, additionalSkipLength);
+ }
+ return dest;
+ }
+
+ public static String getString(ByteBuffer bytes, int length, int additionalSkipLength) {
+ CharSequence cs = bytes.asCharBuffer();
+ String s = cs.subSequence(0, length).toString();
+ skipBytes(bytes, length * 2 + additionalSkipLength);
+ return s;
+ }
+
+ public static char[] getChars(ByteBuffer bytes, int length, int additionalSkipLength) {
+ char[] dest = new char[length];
+ bytes.asCharBuffer().get(dest);
+ skipBytes(bytes, length * 2 + additionalSkipLength);
+ return dest;
+ }
+
+ public static int[] getInts(ByteBuffer bytes, int length, int additionalSkipLength) {
+ int[] dest = new int[length];
+ bytes.asIntBuffer().get(dest);
+ skipBytes(bytes, length * 4 + additionalSkipLength);
+ return dest;
+ }
+
/**
* Returns a VersionInfo for the bytes in the compact version integer.
*/
public static VersionInfo getVersionInfoFromCompactInt(int version) {
return VersionInfo.getInstance(
< prev index next >