id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33,200 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java | UCharacterUtility.compareNullTermByteSubString | static int compareNullTermByteSubString(String str, byte[] array,
int strindex, int aindex)
{
byte b = 1;
int length = str.length();
while (b != 0)
{
b = array[aindex];
aindex ++;
if (b == 0) {
break;
}
// if we have reached the end of the string and yet the array has not
// reached the end of their substring yet, abort
if (strindex == length
|| (str.charAt(strindex) != (char)(b & 0xFF))) {
return -1;
}
strindex ++;
}
return strindex;
} | java | static int compareNullTermByteSubString(String str, byte[] array,
int strindex, int aindex)
{
byte b = 1;
int length = str.length();
while (b != 0)
{
b = array[aindex];
aindex ++;
if (b == 0) {
break;
}
// if we have reached the end of the string and yet the array has not
// reached the end of their substring yet, abort
if (strindex == length
|| (str.charAt(strindex) != (char)(b & 0xFF))) {
return -1;
}
strindex ++;
}
return strindex;
} | [
"static",
"int",
"compareNullTermByteSubString",
"(",
"String",
"str",
",",
"byte",
"[",
"]",
"array",
",",
"int",
"strindex",
",",
"int",
"aindex",
")",
"{",
"byte",
"b",
"=",
"1",
";",
"int",
"length",
"=",
"str",
".",
"length",
"(",
")",
";",
"whi... | Compares a null terminated substring from an array of bytes.
Substring is a set of non-zero bytes starting from argument start to the
next zero byte. if the first byte is a zero, the next byte will be taken as
the first byte.
@param str string to compare
@param array byte array
@param strindex index within str to start comparing
@param aindex array index to start in byte count
@return the end position of the substring within str if matches otherwise
a -1 | [
"Compares",
"a",
"null",
"terminated",
"substring",
"from",
"an",
"array",
"of",
"bytes",
".",
"Substring",
"is",
"a",
"set",
"of",
"non",
"-",
"zero",
"bytes",
"starting",
"from",
"argument",
"start",
"to",
"the",
"next",
"zero",
"byte",
".",
"if",
"the... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java#L90-L112 |
33,201 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java | UCharacterUtility.skipNullTermByteSubString | static int skipNullTermByteSubString(byte[] array, int index,
int skipcount)
{
byte b;
for (int i = 0; i < skipcount; i ++)
{
b = 1;
while (b != 0)
{
b = array[index];
index ++;
}
}
return index;
} | java | static int skipNullTermByteSubString(byte[] array, int index,
int skipcount)
{
byte b;
for (int i = 0; i < skipcount; i ++)
{
b = 1;
while (b != 0)
{
b = array[index];
index ++;
}
}
return index;
} | [
"static",
"int",
"skipNullTermByteSubString",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"index",
",",
"int",
"skipcount",
")",
"{",
"byte",
"b",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"skipcount",
";",
"i",
"++",
")",
"{",
"b",
"... | Skip null terminated substrings from an array of bytes.
Substring is a set of non-zero bytes starting from argument start to the
next zero byte. If the first byte is a zero, the next byte will be taken as
the first byte.
@param array byte array
@param index to start substrings in byte count
@param skipcount number of null terminated substrings to skip
@return the end position of the substrings within the character array | [
"Skip",
"null",
"terminated",
"substrings",
"from",
"an",
"array",
"of",
"bytes",
".",
"Substring",
"is",
"a",
"set",
"of",
"non",
"-",
"zero",
"bytes",
"starting",
"from",
"argument",
"start",
"to",
"the",
"next",
"zero",
"byte",
".",
"If",
"the",
"firs... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java#L124-L138 |
33,202 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java | UCharacterUtility.skipByteSubString | static int skipByteSubString(byte[] array, int index, int length,
byte skipend)
{
int result;
byte b;
for (result = 0; result < length; result ++)
{
b = array[index + result];
if (b == skipend)
{
result ++;
break;
}
}
return result;
} | java | static int skipByteSubString(byte[] array, int index, int length,
byte skipend)
{
int result;
byte b;
for (result = 0; result < length; result ++)
{
b = array[index + result];
if (b == skipend)
{
result ++;
break;
}
}
return result;
} | [
"static",
"int",
"skipByteSubString",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"index",
",",
"int",
"length",
",",
"byte",
"skipend",
")",
"{",
"int",
"result",
";",
"byte",
"b",
";",
"for",
"(",
"result",
"=",
"0",
";",
"result",
"<",
"length",
... | skip substrings from an array of characters, where each character is a set
of 2 bytes. substring is a set of non-zero bytes starting from argument
start to the byte of the argument value. skips up to a max number of
characters
@param array byte array to parse
@param index to start substrings in byte count
@param length the max number of bytes to skip
@param skipend value of byte to skip to
@return the number of bytes skipped | [
"skip",
"substrings",
"from",
"an",
"array",
"of",
"characters",
"where",
"each",
"character",
"is",
"a",
"set",
"of",
"2",
"bytes",
".",
"substring",
"is",
"a",
"set",
"of",
"non",
"-",
"zero",
"bytes",
"starting",
"from",
"argument",
"start",
"to",
"th... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java#L151-L168 |
33,203 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/SequenceInputStream.java | SequenceInputStream.nextStream | final void nextStream() throws IOException {
if (in != null) {
in.close();
}
if (e.hasMoreElements()) {
in = (InputStream) e.nextElement();
if (in == null)
throw new NullPointerException();
}
else in = null;
} | java | final void nextStream() throws IOException {
if (in != null) {
in.close();
}
if (e.hasMoreElements()) {
in = (InputStream) e.nextElement();
if (in == null)
throw new NullPointerException();
}
else in = null;
} | [
"final",
"void",
"nextStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"e",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"in",
"=",
"(",
"InputStream",
")"... | Continues reading in the next stream if an EOF is reached. | [
"Continues",
"reading",
"in",
"the",
"next",
"stream",
"if",
"an",
"EOF",
"is",
"reached",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/SequenceInputStream.java#L104-L116 |
33,204 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/URLImpl.java | URLImpl.getURLStreamHandler | public Object getURLStreamHandler(String protocol) {
URLStreamHandler handler = (URLStreamHandler) handlers.get(protocol);
if (handler == null) {
boolean checkedWithFactory = false;
// Use the factory (if any)
if (factory != null) {
handler = factory.createURLStreamHandler(protocol);
checkedWithFactory = true;
}
// Try java protocol handler
if (handler == null) {
final String packagePrefixList = System.getProperty(PROTOCOL_PATH_PROP, "");
StringTokenizer packagePrefixIter = new StringTokenizer(packagePrefixList, "|");
while (handler == null && packagePrefixIter.hasMoreTokens()) {
String packagePrefix = packagePrefixIter.nextToken().trim();
try {
String clsName = packagePrefix + "." + protocol + ".Handler";
Class<?> cls = null;
try {
ClassLoader cl = ClassLoader.getSystemClassLoader();
cls = Class.forName(clsName, true, cl);
} catch (ClassNotFoundException e) {
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
if (contextLoader != null) {
cls = Class.forName(clsName, true, contextLoader);
}
}
if (cls != null) {
handler = (URLStreamHandler) cls.newInstance();
}
} catch (ReflectiveOperationException ignored) {
// Shouldn't happen, but code below handles the error.
}
}
}
// Fallback to built-in stream handler.
// Makes okhttp the default http/https handler
if (handler == null) {
try {
if (protocol.equals("file")) {
// https://github.com/google/j2objc/issues/912
handler = new sun.net.www.protocol.file.Handler();
} else if (protocol.equals("jar")) {
throw new UnsupportedOperationException("Jar streams are not supported.");
} else if (protocol.equals("http")) {
handler = new IosHttpHandler();
} else if (protocol.equals("https")) {
try {
String name = "com.google.j2objc.net.IosHttpsHandler";
handler = (URLStreamHandler) Class.forName(name).newInstance();
} catch (Exception e) {
throw new LibraryNotLinkedError("Https support", "jre_ssl",
"JavaxNetSslHttpsURLConnection");
}
}
} catch (Exception e) {
throw new AssertionError(e);
}
}
synchronized (streamHandlerLock) {
URLStreamHandler handler2 = null;
// Check again with hashtable just in case another
// thread created a handler since we last checked
handler2 = (URLStreamHandler) handlers.get(protocol);
if (handler2 != null) {
return handler2;
}
// Check with factory if another thread set a
// factory since our last check
if (!checkedWithFactory && factory != null) {
handler2 = factory.createURLStreamHandler(protocol);
}
if (handler2 != null) {
// The handler from the factory must be given more
// importance. Discard the default handler that
// this thread created.
handler = handler2;
}
// Insert this handler into the hashtable
if (handler != null) {
handlers.put(protocol, handler);
}
}
}
return handler;
} | java | public Object getURLStreamHandler(String protocol) {
URLStreamHandler handler = (URLStreamHandler) handlers.get(protocol);
if (handler == null) {
boolean checkedWithFactory = false;
// Use the factory (if any)
if (factory != null) {
handler = factory.createURLStreamHandler(protocol);
checkedWithFactory = true;
}
// Try java protocol handler
if (handler == null) {
final String packagePrefixList = System.getProperty(PROTOCOL_PATH_PROP, "");
StringTokenizer packagePrefixIter = new StringTokenizer(packagePrefixList, "|");
while (handler == null && packagePrefixIter.hasMoreTokens()) {
String packagePrefix = packagePrefixIter.nextToken().trim();
try {
String clsName = packagePrefix + "." + protocol + ".Handler";
Class<?> cls = null;
try {
ClassLoader cl = ClassLoader.getSystemClassLoader();
cls = Class.forName(clsName, true, cl);
} catch (ClassNotFoundException e) {
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
if (contextLoader != null) {
cls = Class.forName(clsName, true, contextLoader);
}
}
if (cls != null) {
handler = (URLStreamHandler) cls.newInstance();
}
} catch (ReflectiveOperationException ignored) {
// Shouldn't happen, but code below handles the error.
}
}
}
// Fallback to built-in stream handler.
// Makes okhttp the default http/https handler
if (handler == null) {
try {
if (protocol.equals("file")) {
// https://github.com/google/j2objc/issues/912
handler = new sun.net.www.protocol.file.Handler();
} else if (protocol.equals("jar")) {
throw new UnsupportedOperationException("Jar streams are not supported.");
} else if (protocol.equals("http")) {
handler = new IosHttpHandler();
} else if (protocol.equals("https")) {
try {
String name = "com.google.j2objc.net.IosHttpsHandler";
handler = (URLStreamHandler) Class.forName(name).newInstance();
} catch (Exception e) {
throw new LibraryNotLinkedError("Https support", "jre_ssl",
"JavaxNetSslHttpsURLConnection");
}
}
} catch (Exception e) {
throw new AssertionError(e);
}
}
synchronized (streamHandlerLock) {
URLStreamHandler handler2 = null;
// Check again with hashtable just in case another
// thread created a handler since we last checked
handler2 = (URLStreamHandler) handlers.get(protocol);
if (handler2 != null) {
return handler2;
}
// Check with factory if another thread set a
// factory since our last check
if (!checkedWithFactory && factory != null) {
handler2 = factory.createURLStreamHandler(protocol);
}
if (handler2 != null) {
// The handler from the factory must be given more
// importance. Discard the default handler that
// this thread created.
handler = handler2;
}
// Insert this handler into the hashtable
if (handler != null) {
handlers.put(protocol, handler);
}
}
}
return handler;
} | [
"public",
"Object",
"getURLStreamHandler",
"(",
"String",
"protocol",
")",
"{",
"URLStreamHandler",
"handler",
"=",
"(",
"URLStreamHandler",
")",
"handlers",
".",
"get",
"(",
"protocol",
")",
";",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"boolean",
"che... | Returns the Stream Handler.
@param protocol
the protocol to use | [
"Returns",
"the",
"Stream",
"Handler",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/URLImpl.java#L218-L317 |
33,205 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/translate/CastResolver.java | CastResolver.returnValueNeedsIntCast | private boolean returnValueNeedsIntCast(Expression arg) {
ExecutableElement methodElement = TreeUtil.getExecutableElement(arg);
assert methodElement != null;
if (arg.getParent() instanceof ExpressionStatement) {
// Avoid "unused return value" warning.
return false;
}
String methodName = nameTable.getMethodSelector(methodElement);
if (methodName.equals("hash") && methodElement.getReturnType().getKind() == TypeKind.INT) {
return true;
}
return false;
} | java | private boolean returnValueNeedsIntCast(Expression arg) {
ExecutableElement methodElement = TreeUtil.getExecutableElement(arg);
assert methodElement != null;
if (arg.getParent() instanceof ExpressionStatement) {
// Avoid "unused return value" warning.
return false;
}
String methodName = nameTable.getMethodSelector(methodElement);
if (methodName.equals("hash") && methodElement.getReturnType().getKind() == TypeKind.INT) {
return true;
}
return false;
} | [
"private",
"boolean",
"returnValueNeedsIntCast",
"(",
"Expression",
"arg",
")",
"{",
"ExecutableElement",
"methodElement",
"=",
"TreeUtil",
".",
"getExecutableElement",
"(",
"arg",
")",
";",
"assert",
"methodElement",
"!=",
"null",
";",
"if",
"(",
"arg",
".",
"g... | Some native objective-c methods are declared to return NSUInteger. | [
"Some",
"native",
"objective",
"-",
"c",
"methods",
"are",
"declared",
"to",
"return",
"NSUInteger",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/translate/CastResolver.java#L277-L291 |
33,206 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/translate/CastResolver.java | CastResolver.endVisit | @Override
public void endVisit(MethodDeclaration node) {
ExecutableElement element = node.getExecutableElement();
if (!ElementUtil.getName(element).equals("compareTo") || node.getBody() == null) {
return;
}
DeclaredType comparableType = typeUtil.findSupertype(
ElementUtil.getDeclaringClass(element).asType(), "java.lang.Comparable");
if (comparableType == null) {
return;
}
List<? extends TypeMirror> typeArguments = comparableType.getTypeArguments();
List<? extends VariableElement> parameters = element.getParameters();
if (typeArguments.size() != 1 || parameters.size() != 1
|| !typeArguments.get(0).equals(parameters.get(0).asType())) {
return;
}
VariableElement param = node.getParameter(0).getVariableElement();
FunctionInvocation castCheck = createCastCheck(typeArguments.get(0), new SimpleName(param));
if (castCheck != null) {
node.getBody().addStatement(0, new ExpressionStatement(castCheck));
}
} | java | @Override
public void endVisit(MethodDeclaration node) {
ExecutableElement element = node.getExecutableElement();
if (!ElementUtil.getName(element).equals("compareTo") || node.getBody() == null) {
return;
}
DeclaredType comparableType = typeUtil.findSupertype(
ElementUtil.getDeclaringClass(element).asType(), "java.lang.Comparable");
if (comparableType == null) {
return;
}
List<? extends TypeMirror> typeArguments = comparableType.getTypeArguments();
List<? extends VariableElement> parameters = element.getParameters();
if (typeArguments.size() != 1 || parameters.size() != 1
|| !typeArguments.get(0).equals(parameters.get(0).asType())) {
return;
}
VariableElement param = node.getParameter(0).getVariableElement();
FunctionInvocation castCheck = createCastCheck(typeArguments.get(0), new SimpleName(param));
if (castCheck != null) {
node.getBody().addStatement(0, new ExpressionStatement(castCheck));
}
} | [
"@",
"Override",
"public",
"void",
"endVisit",
"(",
"MethodDeclaration",
"node",
")",
"{",
"ExecutableElement",
"element",
"=",
"node",
".",
"getExecutableElement",
"(",
")",
";",
"if",
"(",
"!",
"ElementUtil",
".",
"getName",
"(",
"element",
")",
".",
"equa... | Adds a cast check to compareTo methods. This helps Comparable types behave
well in sorted collections which rely on Java's runtime type checking. | [
"Adds",
"a",
"cast",
"check",
"to",
"compareTo",
"methods",
".",
"This",
"helps",
"Comparable",
"types",
"behave",
"well",
"in",
"sorted",
"collections",
"which",
"rely",
"on",
"Java",
"s",
"runtime",
"type",
"checking",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/translate/CastResolver.java#L382-L406 |
33,207 | google/j2objc | jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java | DecimalFormat.format | private StringBuffer format(long number, StringBuffer result,
FieldDelegate delegate) {
boolean isNegative = (number < 0);
if (isNegative) {
number = -number;
}
// In general, long values always represent real finite numbers, so
// we don't have to check for +/- Infinity or NaN. However, there
// is one case we have to be careful of: The multiplier can push
// a number near MIN_VALUE or MAX_VALUE outside the legal range. We
// check for this before multiplying, and if it happens we use
// BigInteger instead.
boolean useBigInteger = false;
if (number < 0) { // This can only happen if number == Long.MIN_VALUE.
if (multiplier != 0) {
useBigInteger = true;
}
} else if (multiplier != 1 && multiplier != 0) {
long cutoff = Long.MAX_VALUE / multiplier;
if (cutoff < 0) {
cutoff = -cutoff;
}
useBigInteger = (number > cutoff);
}
if (useBigInteger) {
if (isNegative) {
number = -number;
}
BigInteger bigIntegerValue = BigInteger.valueOf(number);
return format(bigIntegerValue, result, delegate, true);
}
number *= multiplier;
if (number == 0) {
isNegative = false;
} else {
if (multiplier < 0) {
number = -number;
isNegative = !isNegative;
}
}
synchronized(digitList) {
int maxIntDigits = super.getMaximumIntegerDigits();
int minIntDigits = super.getMinimumIntegerDigits();
int maxFraDigits = super.getMaximumFractionDigits();
int minFraDigits = super.getMinimumFractionDigits();
digitList.set(isNegative, number,
useExponentialNotation ? maxIntDigits + maxFraDigits : 0);
return subformat(result, delegate, isNegative, true,
maxIntDigits, minIntDigits, maxFraDigits, minFraDigits);
}
} | java | private StringBuffer format(long number, StringBuffer result,
FieldDelegate delegate) {
boolean isNegative = (number < 0);
if (isNegative) {
number = -number;
}
// In general, long values always represent real finite numbers, so
// we don't have to check for +/- Infinity or NaN. However, there
// is one case we have to be careful of: The multiplier can push
// a number near MIN_VALUE or MAX_VALUE outside the legal range. We
// check for this before multiplying, and if it happens we use
// BigInteger instead.
boolean useBigInteger = false;
if (number < 0) { // This can only happen if number == Long.MIN_VALUE.
if (multiplier != 0) {
useBigInteger = true;
}
} else if (multiplier != 1 && multiplier != 0) {
long cutoff = Long.MAX_VALUE / multiplier;
if (cutoff < 0) {
cutoff = -cutoff;
}
useBigInteger = (number > cutoff);
}
if (useBigInteger) {
if (isNegative) {
number = -number;
}
BigInteger bigIntegerValue = BigInteger.valueOf(number);
return format(bigIntegerValue, result, delegate, true);
}
number *= multiplier;
if (number == 0) {
isNegative = false;
} else {
if (multiplier < 0) {
number = -number;
isNegative = !isNegative;
}
}
synchronized(digitList) {
int maxIntDigits = super.getMaximumIntegerDigits();
int minIntDigits = super.getMinimumIntegerDigits();
int maxFraDigits = super.getMaximumFractionDigits();
int minFraDigits = super.getMinimumFractionDigits();
digitList.set(isNegative, number,
useExponentialNotation ? maxIntDigits + maxFraDigits : 0);
return subformat(result, delegate, isNegative, true,
maxIntDigits, minIntDigits, maxFraDigits, minFraDigits);
}
} | [
"private",
"StringBuffer",
"format",
"(",
"long",
"number",
",",
"StringBuffer",
"result",
",",
"FieldDelegate",
"delegate",
")",
"{",
"boolean",
"isNegative",
"=",
"(",
"number",
"<",
"0",
")",
";",
"if",
"(",
"isNegative",
")",
"{",
"number",
"=",
"-",
... | Format a long to produce a string.
@param number The long to format
@param result where the text is to be appended
@param delegate notified of locations of sub fields
@return The formatted number string
@exception ArithmeticException if rounding is needed with rounding
mode being set to RoundingMode.UNNECESSARY
@see java.text.FieldPosition | [
"Format",
"a",
"long",
"to",
"produce",
"a",
"string",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java#L661-L717 |
33,208 | google/j2objc | jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java | DecimalFormat.checkAndSetFastPathStatus | private void checkAndSetFastPathStatus() {
boolean fastPathWasOn = isFastPath;
if ((roundingMode == RoundingMode.HALF_EVEN) &&
(isGroupingUsed()) &&
(groupingSize == 3) &&
(secondaryGroupingSize == 0) &&
(multiplier == 1) &&
(!decimalSeparatorAlwaysShown) &&
(!useExponentialNotation)) {
// The fast-path algorithm is semi-hardcoded against
// minimumIntegerDigits and maximumIntegerDigits.
isFastPath = ((minimumIntegerDigits == 1) &&
(maximumIntegerDigits >= 10));
// The fast-path algorithm is hardcoded against
// minimumFractionDigits and maximumFractionDigits.
if (isFastPath) {
if (isCurrencyFormat) {
if ((minimumFractionDigits != 2) ||
(maximumFractionDigits != 2))
isFastPath = false;
} else if ((minimumFractionDigits != 0) ||
(maximumFractionDigits != 3))
isFastPath = false;
}
} else
isFastPath = false;
// Since some instance properties may have changed while still falling
// in the fast-path case, we need to reinitialize fastPathData anyway.
if (isFastPath) {
// We need to instantiate fastPathData if not already done.
if (fastPathData == null)
fastPathData = new FastPathData();
// Sets up the locale specific constants used when formatting.
// '0' is our default representation of zero.
fastPathData.zeroDelta = symbols.getZeroDigit() - '0';
fastPathData.groupingChar = symbols.getGroupingSeparator();
// Sets up fractional constants related to currency/decimal pattern.
fastPathData.fractionalMaxIntBound = (isCurrencyFormat) ? 99 : 999;
fastPathData.fractionalScaleFactor = (isCurrencyFormat) ? 100.0d : 1000.0d;
// Records the need for adding prefix or suffix
fastPathData.positiveAffixesRequired =
(positivePrefix.length() != 0) || (positiveSuffix.length() != 0);
fastPathData.negativeAffixesRequired =
(negativePrefix.length() != 0) || (negativeSuffix.length() != 0);
// Creates a cached char container for result, with max possible size.
int maxNbIntegralDigits = 10;
int maxNbGroups = 3;
int containerSize =
Math.max(positivePrefix.length(), negativePrefix.length()) +
maxNbIntegralDigits + maxNbGroups + 1 + maximumFractionDigits +
Math.max(positiveSuffix.length(), negativeSuffix.length());
fastPathData.fastPathContainer = new char[containerSize];
// Sets up prefix and suffix char arrays constants.
fastPathData.charsPositiveSuffix = positiveSuffix.toCharArray();
fastPathData.charsNegativeSuffix = negativeSuffix.toCharArray();
fastPathData.charsPositivePrefix = positivePrefix.toCharArray();
fastPathData.charsNegativePrefix = negativePrefix.toCharArray();
// Sets up fixed index positions for integral and fractional digits.
// Sets up decimal point in cached result container.
int longestPrefixLength =
Math.max(positivePrefix.length(), negativePrefix.length());
int decimalPointIndex =
maxNbIntegralDigits + maxNbGroups + longestPrefixLength;
fastPathData.integralLastIndex = decimalPointIndex - 1;
fastPathData.fractionalFirstIndex = decimalPointIndex + 1;
fastPathData.fastPathContainer[decimalPointIndex] =
isCurrencyFormat ?
symbols.getMonetaryDecimalSeparator() :
symbols.getDecimalSeparator();
} else if (fastPathWasOn) {
// Previous state was fast-path and is no more.
// Resets cached array constants.
fastPathData.fastPathContainer = null;
fastPathData.charsPositiveSuffix = null;
fastPathData.charsNegativeSuffix = null;
fastPathData.charsPositivePrefix = null;
fastPathData.charsNegativePrefix = null;
}
fastPathCheckNeeded = false;
} | java | private void checkAndSetFastPathStatus() {
boolean fastPathWasOn = isFastPath;
if ((roundingMode == RoundingMode.HALF_EVEN) &&
(isGroupingUsed()) &&
(groupingSize == 3) &&
(secondaryGroupingSize == 0) &&
(multiplier == 1) &&
(!decimalSeparatorAlwaysShown) &&
(!useExponentialNotation)) {
// The fast-path algorithm is semi-hardcoded against
// minimumIntegerDigits and maximumIntegerDigits.
isFastPath = ((minimumIntegerDigits == 1) &&
(maximumIntegerDigits >= 10));
// The fast-path algorithm is hardcoded against
// minimumFractionDigits and maximumFractionDigits.
if (isFastPath) {
if (isCurrencyFormat) {
if ((minimumFractionDigits != 2) ||
(maximumFractionDigits != 2))
isFastPath = false;
} else if ((minimumFractionDigits != 0) ||
(maximumFractionDigits != 3))
isFastPath = false;
}
} else
isFastPath = false;
// Since some instance properties may have changed while still falling
// in the fast-path case, we need to reinitialize fastPathData anyway.
if (isFastPath) {
// We need to instantiate fastPathData if not already done.
if (fastPathData == null)
fastPathData = new FastPathData();
// Sets up the locale specific constants used when formatting.
// '0' is our default representation of zero.
fastPathData.zeroDelta = symbols.getZeroDigit() - '0';
fastPathData.groupingChar = symbols.getGroupingSeparator();
// Sets up fractional constants related to currency/decimal pattern.
fastPathData.fractionalMaxIntBound = (isCurrencyFormat) ? 99 : 999;
fastPathData.fractionalScaleFactor = (isCurrencyFormat) ? 100.0d : 1000.0d;
// Records the need for adding prefix or suffix
fastPathData.positiveAffixesRequired =
(positivePrefix.length() != 0) || (positiveSuffix.length() != 0);
fastPathData.negativeAffixesRequired =
(negativePrefix.length() != 0) || (negativeSuffix.length() != 0);
// Creates a cached char container for result, with max possible size.
int maxNbIntegralDigits = 10;
int maxNbGroups = 3;
int containerSize =
Math.max(positivePrefix.length(), negativePrefix.length()) +
maxNbIntegralDigits + maxNbGroups + 1 + maximumFractionDigits +
Math.max(positiveSuffix.length(), negativeSuffix.length());
fastPathData.fastPathContainer = new char[containerSize];
// Sets up prefix and suffix char arrays constants.
fastPathData.charsPositiveSuffix = positiveSuffix.toCharArray();
fastPathData.charsNegativeSuffix = negativeSuffix.toCharArray();
fastPathData.charsPositivePrefix = positivePrefix.toCharArray();
fastPathData.charsNegativePrefix = negativePrefix.toCharArray();
// Sets up fixed index positions for integral and fractional digits.
// Sets up decimal point in cached result container.
int longestPrefixLength =
Math.max(positivePrefix.length(), negativePrefix.length());
int decimalPointIndex =
maxNbIntegralDigits + maxNbGroups + longestPrefixLength;
fastPathData.integralLastIndex = decimalPointIndex - 1;
fastPathData.fractionalFirstIndex = decimalPointIndex + 1;
fastPathData.fastPathContainer[decimalPointIndex] =
isCurrencyFormat ?
symbols.getMonetaryDecimalSeparator() :
symbols.getDecimalSeparator();
} else if (fastPathWasOn) {
// Previous state was fast-path and is no more.
// Resets cached array constants.
fastPathData.fastPathContainer = null;
fastPathData.charsPositiveSuffix = null;
fastPathData.charsNegativeSuffix = null;
fastPathData.charsPositivePrefix = null;
fastPathData.charsNegativePrefix = null;
}
fastPathCheckNeeded = false;
} | [
"private",
"void",
"checkAndSetFastPathStatus",
"(",
")",
"{",
"boolean",
"fastPathWasOn",
"=",
"isFastPath",
";",
"if",
"(",
"(",
"roundingMode",
"==",
"RoundingMode",
".",
"HALF_EVEN",
")",
"&&",
"(",
"isGroupingUsed",
"(",
")",
")",
"&&",
"(",
"groupingSize... | Check validity of using fast-path for this instance. If fast-path is valid
for this instance, sets fast-path state as true and initializes fast-path
utility fields as needed.
This method is supposed to be called rarely, otherwise that will break the
fast-path performance. That means avoiding frequent changes of the
properties of the instance, since for most properties, each time a change
happens, a call to this method is needed at the next format call.
FAST-PATH RULES:
Similar to the default DecimalFormat instantiation case.
More precisely:
- HALF_EVEN rounding mode,
- isGroupingUsed() is true,
- groupingSize of 3,
- multiplier is 1,
- Decimal separator not mandatory,
- No use of exponential notation,
- minimumIntegerDigits is exactly 1 and maximumIntegerDigits at least 10
- For number of fractional digits, the exact values found in the default case:
Currency : min = max = 2.
Decimal : min = 0. max = 3. | [
"Check",
"validity",
"of",
"using",
"fast",
"-",
"path",
"for",
"this",
"instance",
".",
"If",
"fast",
"-",
"path",
"is",
"valid",
"for",
"this",
"instance",
"sets",
"fast",
"-",
"path",
"state",
"as",
"true",
"and",
"initializes",
"fast",
"-",
"path",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java#L973-L1067 |
33,209 | google/j2objc | jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java | DecimalFormat.fastDoubleFormat | private void fastDoubleFormat(double d,
boolean negative) {
char[] container = fastPathData.fastPathContainer;
/*
* The principle of the algorithm is to :
* - Break the passed double into its integral and fractional parts
* converted into integers.
* - Then decide if rounding up must be applied or not by following
* the half-even rounding rule, first using approximated scaled
* fractional part.
* - For the difficult cases (approximated scaled fractional part
* being exactly 0.5d), we refine the rounding decision by calling
* exactRoundUp utility method that both calculates the exact roundoff
* on the approximation and takes correct rounding decision.
* - We round-up the fractional part if needed, possibly propagating the
* rounding to integral part if we meet a "all-nine" case for the
* scaled fractional part.
* - We then collect digits from the resulting integral and fractional
* parts, also setting the required grouping chars on the fly.
* - Then we localize the collected digits if needed, and
* - Finally prepend/append prefix/suffix if any is needed.
*/
// Exact integral part of d.
int integralPartAsInt = (int) d;
// Exact fractional part of d (since we subtract it's integral part).
double exactFractionalPart = d - (double) integralPartAsInt;
// Approximated scaled fractional part of d (due to multiplication).
double scaledFractional =
exactFractionalPart * fastPathData.fractionalScaleFactor;
// Exact integral part of scaled fractional above.
int fractionalPartAsInt = (int) scaledFractional;
// Exact fractional part of scaled fractional above.
scaledFractional = scaledFractional - (double) fractionalPartAsInt;
// Only when scaledFractional is exactly 0.5d do we have to do exact
// calculations and take fine-grained rounding decision, since
// approximated results above may lead to incorrect decision.
// Otherwise comparing against 0.5d (strictly greater or less) is ok.
boolean roundItUp = false;
if (scaledFractional >= 0.5d) {
if (scaledFractional == 0.5d)
// Rounding need fine-grained decision.
roundItUp = exactRoundUp(exactFractionalPart, fractionalPartAsInt);
else
roundItUp = true;
if (roundItUp) {
// Rounds up both fractional part (and also integral if needed).
if (fractionalPartAsInt < fastPathData.fractionalMaxIntBound) {
fractionalPartAsInt++;
} else {
// Propagates rounding to integral part since "all nines" case.
fractionalPartAsInt = 0;
integralPartAsInt++;
}
}
}
// Collecting digits.
collectFractionalDigits(fractionalPartAsInt, container,
fastPathData.fractionalFirstIndex);
collectIntegralDigits(integralPartAsInt, container,
fastPathData.integralLastIndex);
// Localizing digits.
if (fastPathData.zeroDelta != 0)
localizeDigits(container);
// Adding prefix and suffix.
if (negative) {
if (fastPathData.negativeAffixesRequired)
addAffixes(container,
fastPathData.charsNegativePrefix,
fastPathData.charsNegativeSuffix);
} else if (fastPathData.positiveAffixesRequired)
addAffixes(container,
fastPathData.charsPositivePrefix,
fastPathData.charsPositiveSuffix);
} | java | private void fastDoubleFormat(double d,
boolean negative) {
char[] container = fastPathData.fastPathContainer;
/*
* The principle of the algorithm is to :
* - Break the passed double into its integral and fractional parts
* converted into integers.
* - Then decide if rounding up must be applied or not by following
* the half-even rounding rule, first using approximated scaled
* fractional part.
* - For the difficult cases (approximated scaled fractional part
* being exactly 0.5d), we refine the rounding decision by calling
* exactRoundUp utility method that both calculates the exact roundoff
* on the approximation and takes correct rounding decision.
* - We round-up the fractional part if needed, possibly propagating the
* rounding to integral part if we meet a "all-nine" case for the
* scaled fractional part.
* - We then collect digits from the resulting integral and fractional
* parts, also setting the required grouping chars on the fly.
* - Then we localize the collected digits if needed, and
* - Finally prepend/append prefix/suffix if any is needed.
*/
// Exact integral part of d.
int integralPartAsInt = (int) d;
// Exact fractional part of d (since we subtract it's integral part).
double exactFractionalPart = d - (double) integralPartAsInt;
// Approximated scaled fractional part of d (due to multiplication).
double scaledFractional =
exactFractionalPart * fastPathData.fractionalScaleFactor;
// Exact integral part of scaled fractional above.
int fractionalPartAsInt = (int) scaledFractional;
// Exact fractional part of scaled fractional above.
scaledFractional = scaledFractional - (double) fractionalPartAsInt;
// Only when scaledFractional is exactly 0.5d do we have to do exact
// calculations and take fine-grained rounding decision, since
// approximated results above may lead to incorrect decision.
// Otherwise comparing against 0.5d (strictly greater or less) is ok.
boolean roundItUp = false;
if (scaledFractional >= 0.5d) {
if (scaledFractional == 0.5d)
// Rounding need fine-grained decision.
roundItUp = exactRoundUp(exactFractionalPart, fractionalPartAsInt);
else
roundItUp = true;
if (roundItUp) {
// Rounds up both fractional part (and also integral if needed).
if (fractionalPartAsInt < fastPathData.fractionalMaxIntBound) {
fractionalPartAsInt++;
} else {
// Propagates rounding to integral part since "all nines" case.
fractionalPartAsInt = 0;
integralPartAsInt++;
}
}
}
// Collecting digits.
collectFractionalDigits(fractionalPartAsInt, container,
fastPathData.fractionalFirstIndex);
collectIntegralDigits(integralPartAsInt, container,
fastPathData.integralLastIndex);
// Localizing digits.
if (fastPathData.zeroDelta != 0)
localizeDigits(container);
// Adding prefix and suffix.
if (negative) {
if (fastPathData.negativeAffixesRequired)
addAffixes(container,
fastPathData.charsNegativePrefix,
fastPathData.charsNegativeSuffix);
} else if (fastPathData.positiveAffixesRequired)
addAffixes(container,
fastPathData.charsPositivePrefix,
fastPathData.charsPositiveSuffix);
} | [
"private",
"void",
"fastDoubleFormat",
"(",
"double",
"d",
",",
"boolean",
"negative",
")",
"{",
"char",
"[",
"]",
"container",
"=",
"fastPathData",
".",
"fastPathContainer",
";",
"/*\n * The principle of the algorithm is to :\n * - Break the passed double int... | This is the main entry point for the fast-path format algorithm.
At this point we are sure to be in the expected conditions to run it.
This algorithm builds the formatted result and puts it in the dedicated
{@code fastPathData.fastPathContainer}.
@param d the double value to be formatted.
@param negative Flag precising if {@code d} is negative. | [
"This",
"is",
"the",
"main",
"entry",
"point",
"for",
"the",
"fast",
"-",
"path",
"format",
"algorithm",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java#L1458-L1543 |
33,210 | google/j2objc | jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java | DecimalFormat.setDecimalFormatSymbols | public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) {
try {
// don't allow multiple references
symbols = (DecimalFormatSymbols) newSymbols.clone();
expandAffixes();
fastPathCheckNeeded = true;
} catch (Exception foo) {
// should never happen
}
} | java | public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) {
try {
// don't allow multiple references
symbols = (DecimalFormatSymbols) newSymbols.clone();
expandAffixes();
fastPathCheckNeeded = true;
} catch (Exception foo) {
// should never happen
}
} | [
"public",
"void",
"setDecimalFormatSymbols",
"(",
"DecimalFormatSymbols",
"newSymbols",
")",
"{",
"try",
"{",
"// don't allow multiple references",
"symbols",
"=",
"(",
"DecimalFormatSymbols",
")",
"newSymbols",
".",
"clone",
"(",
")",
";",
"expandAffixes",
"(",
")",
... | Sets the decimal format symbols, which is generally not changed
by the programmer or user.
@param newSymbols desired DecimalFormatSymbols
@see java.text.DecimalFormatSymbols | [
"Sets",
"the",
"decimal",
"format",
"symbols",
"which",
"is",
"generally",
"not",
"changed",
"by",
"the",
"programmer",
"or",
"user",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java#L2377-L2386 |
33,211 | google/j2objc | jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java | DecimalFormat.expandAffixes | private void expandAffixes() {
// Reuse one StringBuffer for better performance
StringBuffer buffer = new StringBuffer();
if (posPrefixPattern != null) {
positivePrefix = expandAffix(posPrefixPattern, buffer);
positivePrefixFieldPositions = null;
}
if (posSuffixPattern != null) {
positiveSuffix = expandAffix(posSuffixPattern, buffer);
positiveSuffixFieldPositions = null;
}
if (negPrefixPattern != null) {
negativePrefix = expandAffix(negPrefixPattern, buffer);
negativePrefixFieldPositions = null;
}
if (negSuffixPattern != null) {
negativeSuffix = expandAffix(negSuffixPattern, buffer);
negativeSuffixFieldPositions = null;
}
} | java | private void expandAffixes() {
// Reuse one StringBuffer for better performance
StringBuffer buffer = new StringBuffer();
if (posPrefixPattern != null) {
positivePrefix = expandAffix(posPrefixPattern, buffer);
positivePrefixFieldPositions = null;
}
if (posSuffixPattern != null) {
positiveSuffix = expandAffix(posSuffixPattern, buffer);
positiveSuffixFieldPositions = null;
}
if (negPrefixPattern != null) {
negativePrefix = expandAffix(negPrefixPattern, buffer);
negativePrefixFieldPositions = null;
}
if (negSuffixPattern != null) {
negativeSuffix = expandAffix(negSuffixPattern, buffer);
negativeSuffixFieldPositions = null;
}
} | [
"private",
"void",
"expandAffixes",
"(",
")",
"{",
"// Reuse one StringBuffer for better performance",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"if",
"(",
"posPrefixPattern",
"!=",
"null",
")",
"{",
"positivePrefix",
"=",
"expandAffix",
"... | Expand the affix pattern strings into the expanded affix strings. If any
affix pattern string is null, do not expand it. This method should be
called any time the symbols or the affix patterns change in order to keep
the expanded affix strings up to date. | [
"Expand",
"the",
"affix",
"pattern",
"strings",
"into",
"the",
"expanded",
"affix",
"strings",
".",
"If",
"any",
"affix",
"pattern",
"string",
"is",
"null",
"do",
"not",
"expand",
"it",
".",
"This",
"method",
"should",
"be",
"called",
"any",
"time",
"the",... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java#L2782-L2801 |
33,212 | google/j2objc | jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java | DecimalFormat.appendAffix | private void appendAffix(StringBuffer buffer, String affix, boolean localized) {
boolean needQuote;
if (localized) {
needQuote = affix.indexOf(symbols.getZeroDigit()) >= 0
|| affix.indexOf(symbols.getGroupingSeparator()) >= 0
|| affix.indexOf(symbols.getDecimalSeparator()) >= 0
|| affix.indexOf(symbols.getPercent()) >= 0
|| affix.indexOf(symbols.getPerMill()) >= 0
|| affix.indexOf(symbols.getDigit()) >= 0
|| affix.indexOf(symbols.getPatternSeparator()) >= 0
|| affix.indexOf(symbols.getMinusSign()) >= 0
|| affix.indexOf(CURRENCY_SIGN) >= 0;
} else {
needQuote = affix.indexOf(PATTERN_ZERO_DIGIT) >= 0
|| affix.indexOf(PATTERN_GROUPING_SEPARATOR) >= 0
|| affix.indexOf(PATTERN_DECIMAL_SEPARATOR) >= 0
|| affix.indexOf(PATTERN_PERCENT) >= 0
|| affix.indexOf(PATTERN_PER_MILLE) >= 0
|| affix.indexOf(PATTERN_DIGIT) >= 0
|| affix.indexOf(PATTERN_SEPARATOR) >= 0
|| affix.indexOf(PATTERN_MINUS) >= 0
|| affix.indexOf(CURRENCY_SIGN) >= 0;
}
if (needQuote) buffer.append('\'');
if (affix.indexOf('\'') < 0) buffer.append(affix);
else {
for (int j=0; j<affix.length(); ++j) {
char c = affix.charAt(j);
buffer.append(c);
if (c == '\'') buffer.append(c);
}
}
if (needQuote) buffer.append('\'');
} | java | private void appendAffix(StringBuffer buffer, String affix, boolean localized) {
boolean needQuote;
if (localized) {
needQuote = affix.indexOf(symbols.getZeroDigit()) >= 0
|| affix.indexOf(symbols.getGroupingSeparator()) >= 0
|| affix.indexOf(symbols.getDecimalSeparator()) >= 0
|| affix.indexOf(symbols.getPercent()) >= 0
|| affix.indexOf(symbols.getPerMill()) >= 0
|| affix.indexOf(symbols.getDigit()) >= 0
|| affix.indexOf(symbols.getPatternSeparator()) >= 0
|| affix.indexOf(symbols.getMinusSign()) >= 0
|| affix.indexOf(CURRENCY_SIGN) >= 0;
} else {
needQuote = affix.indexOf(PATTERN_ZERO_DIGIT) >= 0
|| affix.indexOf(PATTERN_GROUPING_SEPARATOR) >= 0
|| affix.indexOf(PATTERN_DECIMAL_SEPARATOR) >= 0
|| affix.indexOf(PATTERN_PERCENT) >= 0
|| affix.indexOf(PATTERN_PER_MILLE) >= 0
|| affix.indexOf(PATTERN_DIGIT) >= 0
|| affix.indexOf(PATTERN_SEPARATOR) >= 0
|| affix.indexOf(PATTERN_MINUS) >= 0
|| affix.indexOf(CURRENCY_SIGN) >= 0;
}
if (needQuote) buffer.append('\'');
if (affix.indexOf('\'') < 0) buffer.append(affix);
else {
for (int j=0; j<affix.length(); ++j) {
char c = affix.charAt(j);
buffer.append(c);
if (c == '\'') buffer.append(c);
}
}
if (needQuote) buffer.append('\'');
} | [
"private",
"void",
"appendAffix",
"(",
"StringBuffer",
"buffer",
",",
"String",
"affix",
",",
"boolean",
"localized",
")",
"{",
"boolean",
"needQuote",
";",
"if",
"(",
"localized",
")",
"{",
"needQuote",
"=",
"affix",
".",
"indexOf",
"(",
"symbols",
".",
"... | Append an affix to the given StringBuffer, using quotes if
there are special characters. Single quotes themselves must be
escaped in either case. | [
"Append",
"an",
"affix",
"to",
"the",
"given",
"StringBuffer",
"using",
"quotes",
"if",
"there",
"are",
"special",
"characters",
".",
"Single",
"quotes",
"themselves",
"must",
"be",
"escaped",
"in",
"either",
"case",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java#L2992-L3025 |
33,213 | google/j2objc | jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java | DecimalFormat.toPattern | private String toPattern(boolean localized) {
StringBuffer result = new StringBuffer();
for (int j = 1; j >= 0; --j) {
if (j == 1)
appendAffix(result, posPrefixPattern, positivePrefix, localized);
else appendAffix(result, negPrefixPattern, negativePrefix, localized);
int i;
int digitCount = useExponentialNotation
? getMaximumIntegerDigits()
: Math.max(groupingSize + secondaryGroupingSize, getMinimumIntegerDigits())+1;
for (i = digitCount; i > 0; --i) {
if (i != digitCount && isGroupingUsed() && groupingSize != 0 &&
(secondaryGroupingSize > 0 && i > groupingSize
? (i - groupingSize) % secondaryGroupingSize == 0
: i % groupingSize == 0)) {
result.append(localized ? symbols.getGroupingSeparator() :
PATTERN_GROUPING_SEPARATOR);
}
result.append(i <= getMinimumIntegerDigits()
? (localized ? symbols.getZeroDigit() : PATTERN_ZERO_DIGIT)
: (localized ? symbols.getDigit() : PATTERN_DIGIT));
}
if (getMaximumFractionDigits() > 0 || decimalSeparatorAlwaysShown)
result.append(localized ? symbols.getDecimalSeparator() :
PATTERN_DECIMAL_SEPARATOR);
for (i = 0; i < getMaximumFractionDigits(); ++i) {
if (i < getMinimumFractionDigits()) {
result.append(localized ? symbols.getZeroDigit() :
PATTERN_ZERO_DIGIT);
} else {
result.append(localized ? symbols.getDigit() :
PATTERN_DIGIT);
}
}
if (useExponentialNotation)
{
result.append(localized ? symbols.getExponentSeparator() :
PATTERN_EXPONENT);
for (i=0; i<minExponentDigits; ++i)
result.append(localized ? symbols.getZeroDigit() :
PATTERN_ZERO_DIGIT);
}
if (j == 1) {
appendAffix(result, posSuffixPattern, positiveSuffix, localized);
if ((negSuffixPattern == posSuffixPattern && // n == p == null
negativeSuffix.equals(positiveSuffix))
|| (negSuffixPattern != null &&
negSuffixPattern.equals(posSuffixPattern))) {
if ((negPrefixPattern != null && posPrefixPattern != null &&
negPrefixPattern.equals("'-" + posPrefixPattern)) ||
(negPrefixPattern == posPrefixPattern && // n == p == null
negativePrefix.equals(symbols.getMinusSign() + positivePrefix)))
break;
}
result.append(localized ? symbols.getPatternSeparator() :
PATTERN_SEPARATOR);
} else appendAffix(result, negSuffixPattern, negativeSuffix, localized);
}
return result.toString();
} | java | private String toPattern(boolean localized) {
StringBuffer result = new StringBuffer();
for (int j = 1; j >= 0; --j) {
if (j == 1)
appendAffix(result, posPrefixPattern, positivePrefix, localized);
else appendAffix(result, negPrefixPattern, negativePrefix, localized);
int i;
int digitCount = useExponentialNotation
? getMaximumIntegerDigits()
: Math.max(groupingSize + secondaryGroupingSize, getMinimumIntegerDigits())+1;
for (i = digitCount; i > 0; --i) {
if (i != digitCount && isGroupingUsed() && groupingSize != 0 &&
(secondaryGroupingSize > 0 && i > groupingSize
? (i - groupingSize) % secondaryGroupingSize == 0
: i % groupingSize == 0)) {
result.append(localized ? symbols.getGroupingSeparator() :
PATTERN_GROUPING_SEPARATOR);
}
result.append(i <= getMinimumIntegerDigits()
? (localized ? symbols.getZeroDigit() : PATTERN_ZERO_DIGIT)
: (localized ? symbols.getDigit() : PATTERN_DIGIT));
}
if (getMaximumFractionDigits() > 0 || decimalSeparatorAlwaysShown)
result.append(localized ? symbols.getDecimalSeparator() :
PATTERN_DECIMAL_SEPARATOR);
for (i = 0; i < getMaximumFractionDigits(); ++i) {
if (i < getMinimumFractionDigits()) {
result.append(localized ? symbols.getZeroDigit() :
PATTERN_ZERO_DIGIT);
} else {
result.append(localized ? symbols.getDigit() :
PATTERN_DIGIT);
}
}
if (useExponentialNotation)
{
result.append(localized ? symbols.getExponentSeparator() :
PATTERN_EXPONENT);
for (i=0; i<minExponentDigits; ++i)
result.append(localized ? symbols.getZeroDigit() :
PATTERN_ZERO_DIGIT);
}
if (j == 1) {
appendAffix(result, posSuffixPattern, positiveSuffix, localized);
if ((negSuffixPattern == posSuffixPattern && // n == p == null
negativeSuffix.equals(positiveSuffix))
|| (negSuffixPattern != null &&
negSuffixPattern.equals(posSuffixPattern))) {
if ((negPrefixPattern != null && posPrefixPattern != null &&
negPrefixPattern.equals("'-" + posPrefixPattern)) ||
(negPrefixPattern == posPrefixPattern && // n == p == null
negativePrefix.equals(symbols.getMinusSign() + positivePrefix)))
break;
}
result.append(localized ? symbols.getPatternSeparator() :
PATTERN_SEPARATOR);
} else appendAffix(result, negSuffixPattern, negativeSuffix, localized);
}
return result.toString();
} | [
"private",
"String",
"toPattern",
"(",
"boolean",
"localized",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"1",
";",
"j",
">=",
"0",
";",
"--",
"j",
")",
"{",
"if",
"(",
"j",
"==",
"... | Does the real work of generating a pattern. | [
"Does",
"the",
"real",
"work",
"of",
"generating",
"a",
"pattern",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/text/DecimalFormat.java#L3029-L3088 |
33,214 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/BOCSU.java | BOCSU.getNegDivMod | private static final long getNegDivMod(int number, int factor)
{
int modulo = number % factor;
long result = number / factor;
if (modulo < 0) {
-- result;
modulo += factor;
}
return (result << 32) | modulo;
} | java | private static final long getNegDivMod(int number, int factor)
{
int modulo = number % factor;
long result = number / factor;
if (modulo < 0) {
-- result;
modulo += factor;
}
return (result << 32) | modulo;
} | [
"private",
"static",
"final",
"long",
"getNegDivMod",
"(",
"int",
"number",
",",
"int",
"factor",
")",
"{",
"int",
"modulo",
"=",
"number",
"%",
"factor",
";",
"long",
"result",
"=",
"number",
"/",
"factor",
";",
"if",
"(",
"modulo",
"<",
"0",
")",
"... | Integer division and modulo with negative numerators
yields negative modulo results and quotients that are one more than
what we need here.
@param number which operations are to be performed on
@param factor the factor to use for division
@return (result of division) << 32 | modulo | [
"Integer",
"division",
"and",
"modulo",
"with",
"negative",
"numerators",
"yields",
"negative",
"modulo",
"results",
"and",
"quotients",
"that",
"are",
"one",
"more",
"than",
"what",
"we",
"need",
"here",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/BOCSU.java#L240-L249 |
33,215 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/sql/DriverManager.java | DriverManager.getDrivers | @CallerSensitive
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<Driver>();
ClassLoader callerClassLoader = ClassLoader.getSystemClassLoader();
// Walk through the loaded registeredDrivers.
for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerClassLoader)) {
result.addElement(aDriver.driver);
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
return (result.elements());
} | java | @CallerSensitive
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<Driver>();
ClassLoader callerClassLoader = ClassLoader.getSystemClassLoader();
// Walk through the loaded registeredDrivers.
for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerClassLoader)) {
result.addElement(aDriver.driver);
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
return (result.elements());
} | [
"@",
"CallerSensitive",
"public",
"static",
"java",
".",
"util",
".",
"Enumeration",
"<",
"Driver",
">",
"getDrivers",
"(",
")",
"{",
"java",
".",
"util",
".",
"Vector",
"<",
"Driver",
">",
"result",
"=",
"new",
"java",
".",
"util",
".",
"Vector",
"<",... | Retrieves an Enumeration with all of the currently loaded JDBC drivers
to which the current caller has access.
<P><B>Note:</B> The classname of a driver can be found using
<CODE>d.getClass().getName()</CODE>
@return the list of JDBC Drivers loaded by the caller's class loader | [
"Retrieves",
"an",
"Enumeration",
"with",
"all",
"of",
"the",
"currently",
"loaded",
"JDBC",
"drivers",
"to",
"which",
"the",
"current",
"caller",
"has",
"access",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/sql/DriverManager.java#L343-L360 |
33,216 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/sql/DriverManager.java | DriverManager.println | public static void println(String message) {
synchronized (logSync) {
if (logWriter != null) {
logWriter.println(message);
// automatic flushing is never enabled, so we must do it ourselves
logWriter.flush();
}
}
} | java | public static void println(String message) {
synchronized (logSync) {
if (logWriter != null) {
logWriter.println(message);
// automatic flushing is never enabled, so we must do it ourselves
logWriter.flush();
}
}
} | [
"public",
"static",
"void",
"println",
"(",
"String",
"message",
")",
"{",
"synchronized",
"(",
"logSync",
")",
"{",
"if",
"(",
"logWriter",
"!=",
"null",
")",
"{",
"logWriter",
".",
"println",
"(",
"message",
")",
";",
"// automatic flushing is never enabled,... | Prints a message to the current JDBC log stream.
@param message a log or tracing message | [
"Prints",
"a",
"message",
"to",
"the",
"current",
"JDBC",
"log",
"stream",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/sql/DriverManager.java#L437-L446 |
33,217 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java | ArabicShaping.shape | public int shape(char[] source, int sourceStart, int sourceLength,
char[] dest, int destStart, int destSize) throws ArabicShapingException {
if (source == null) {
throw new IllegalArgumentException("source can not be null");
}
if (sourceStart < 0 || sourceLength < 0 || sourceStart + sourceLength > source.length) {
throw new IllegalArgumentException("bad source start (" + sourceStart +
") or length (" + sourceLength +
") for buffer of length " + source.length);
}
if (dest == null && destSize != 0) {
throw new IllegalArgumentException("null dest requires destSize == 0");
}
if ((destSize != 0) &&
(destStart < 0 || destSize < 0 || destStart + destSize > dest.length)) {
throw new IllegalArgumentException("bad dest start (" + destStart +
") or size (" + destSize +
") for buffer of length " + dest.length);
}
/* Validate input options */
if ( ((options&TASHKEEL_MASK) != 0) &&
!(((options & TASHKEEL_MASK)==TASHKEEL_BEGIN) ||
((options & TASHKEEL_MASK)==TASHKEEL_END) ||
((options & TASHKEEL_MASK)==TASHKEEL_RESIZE) ||
((options & TASHKEEL_MASK)==TASHKEEL_REPLACE_BY_TATWEEL))) {
throw new IllegalArgumentException("Wrong Tashkeel argument");
}
///CLOVER:OFF
//According to Steven Loomis, the code is unreachable when you OR all the constants within the if statements
if(((options&LAMALEF_MASK) != 0) &&
!(((options & LAMALEF_MASK)==LAMALEF_BEGIN) ||
((options & LAMALEF_MASK)==LAMALEF_END) ||
((options & LAMALEF_MASK)==LAMALEF_RESIZE) ||
((options & LAMALEF_MASK)==LAMALEF_AUTO) ||
((options & LAMALEF_MASK)==LAMALEF_NEAR))) {
throw new IllegalArgumentException("Wrong Lam Alef argument");
}
///CLOVER:ON
/* Validate Tashkeel (Tashkeel replacement options should be enabled in shaping mode only)*/
if(((options&TASHKEEL_MASK) != 0) && (options&LETTERS_MASK) == LETTERS_UNSHAPE) {
throw new IllegalArgumentException("Tashkeel replacement should not be enabled in deshaping mode ");
}
return internalShape(source, sourceStart, sourceLength, dest, destStart, destSize);
} | java | public int shape(char[] source, int sourceStart, int sourceLength,
char[] dest, int destStart, int destSize) throws ArabicShapingException {
if (source == null) {
throw new IllegalArgumentException("source can not be null");
}
if (sourceStart < 0 || sourceLength < 0 || sourceStart + sourceLength > source.length) {
throw new IllegalArgumentException("bad source start (" + sourceStart +
") or length (" + sourceLength +
") for buffer of length " + source.length);
}
if (dest == null && destSize != 0) {
throw new IllegalArgumentException("null dest requires destSize == 0");
}
if ((destSize != 0) &&
(destStart < 0 || destSize < 0 || destStart + destSize > dest.length)) {
throw new IllegalArgumentException("bad dest start (" + destStart +
") or size (" + destSize +
") for buffer of length " + dest.length);
}
/* Validate input options */
if ( ((options&TASHKEEL_MASK) != 0) &&
!(((options & TASHKEEL_MASK)==TASHKEEL_BEGIN) ||
((options & TASHKEEL_MASK)==TASHKEEL_END) ||
((options & TASHKEEL_MASK)==TASHKEEL_RESIZE) ||
((options & TASHKEEL_MASK)==TASHKEEL_REPLACE_BY_TATWEEL))) {
throw new IllegalArgumentException("Wrong Tashkeel argument");
}
///CLOVER:OFF
//According to Steven Loomis, the code is unreachable when you OR all the constants within the if statements
if(((options&LAMALEF_MASK) != 0) &&
!(((options & LAMALEF_MASK)==LAMALEF_BEGIN) ||
((options & LAMALEF_MASK)==LAMALEF_END) ||
((options & LAMALEF_MASK)==LAMALEF_RESIZE) ||
((options & LAMALEF_MASK)==LAMALEF_AUTO) ||
((options & LAMALEF_MASK)==LAMALEF_NEAR))) {
throw new IllegalArgumentException("Wrong Lam Alef argument");
}
///CLOVER:ON
/* Validate Tashkeel (Tashkeel replacement options should be enabled in shaping mode only)*/
if(((options&TASHKEEL_MASK) != 0) && (options&LETTERS_MASK) == LETTERS_UNSHAPE) {
throw new IllegalArgumentException("Tashkeel replacement should not be enabled in deshaping mode ");
}
return internalShape(source, sourceStart, sourceLength, dest, destStart, destSize);
} | [
"public",
"int",
"shape",
"(",
"char",
"[",
"]",
"source",
",",
"int",
"sourceStart",
",",
"int",
"sourceLength",
",",
"char",
"[",
"]",
"dest",
",",
"int",
"destStart",
",",
"int",
"destSize",
")",
"throws",
"ArabicShapingException",
"{",
"if",
"(",
"so... | Convert a range of text in the source array, putting the result
into a range of text in the destination array, and return the number
of characters written.
@param source An array containing the input text
@param sourceStart The start of the range of text to convert
@param sourceLength The length of the range of text to convert
@param dest The destination array that will receive the result.
It may be <code>NULL</code> only if <code>destSize</code> is 0.
@param destStart The start of the range of the destination buffer to use.
@param destSize The size (capacity) of the destination buffer.
If <code>destSize</code> is 0, then no output is produced,
but the necessary buffer size is returned ("preflighting"). This
does not validate the text against the options, for example,
if letters are being unshaped, and spaces are being consumed
following lamalef, this will not detect a lamalef without a
corresponding space. An error will be thrown when the actual
conversion is attempted.
@return The number of chars written to the destination buffer.
If an error occurs, then no output was written, or it may be
incomplete.
@throws ArabicShapingException if the text cannot be converted according to the options. | [
"Convert",
"a",
"range",
"of",
"text",
"in",
"the",
"source",
"array",
"putting",
"the",
"result",
"into",
"a",
"range",
"of",
"text",
"in",
"the",
"destination",
"array",
"and",
"return",
"the",
"number",
"of",
"characters",
"written",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java#L88-L133 |
33,218 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java | ArabicShaping.shape | public void shape(char[] source, int start, int length) throws ArabicShapingException {
if ((options & LAMALEF_MASK) == LAMALEF_RESIZE) {
throw new ArabicShapingException("Cannot shape in place with length option resize.");
}
shape(source, start, length, source, start, length);
} | java | public void shape(char[] source, int start, int length) throws ArabicShapingException {
if ((options & LAMALEF_MASK) == LAMALEF_RESIZE) {
throw new ArabicShapingException("Cannot shape in place with length option resize.");
}
shape(source, start, length, source, start, length);
} | [
"public",
"void",
"shape",
"(",
"char",
"[",
"]",
"source",
",",
"int",
"start",
",",
"int",
"length",
")",
"throws",
"ArabicShapingException",
"{",
"if",
"(",
"(",
"options",
"&",
"LAMALEF_MASK",
")",
"==",
"LAMALEF_RESIZE",
")",
"{",
"throw",
"new",
"A... | Convert a range of text in place. This may only be used if the Length option
does not grow or shrink the text.
@param source An array containing the input text
@param start The start of the range of text to convert
@param length The length of the range of text to convert
@throws ArabicShapingException if the text cannot be converted according to the options. | [
"Convert",
"a",
"range",
"of",
"text",
"in",
"place",
".",
"This",
"may",
"only",
"be",
"used",
"if",
"the",
"Length",
"option",
"does",
"not",
"grow",
"or",
"shrink",
"the",
"text",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java#L144-L149 |
33,219 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java | ArabicShaping.shape | public String shape(String text) throws ArabicShapingException {
char[] src = text.toCharArray();
char[] dest = src;
if (((options & LAMALEF_MASK) == LAMALEF_RESIZE) &&
((options & LETTERS_MASK) == LETTERS_UNSHAPE)) {
dest = new char[src.length * 2]; // max
}
int len = shape(src, 0, src.length, dest, 0, dest.length);
return new String(dest, 0, len);
} | java | public String shape(String text) throws ArabicShapingException {
char[] src = text.toCharArray();
char[] dest = src;
if (((options & LAMALEF_MASK) == LAMALEF_RESIZE) &&
((options & LETTERS_MASK) == LETTERS_UNSHAPE)) {
dest = new char[src.length * 2]; // max
}
int len = shape(src, 0, src.length, dest, 0, dest.length);
return new String(dest, 0, len);
} | [
"public",
"String",
"shape",
"(",
"String",
"text",
")",
"throws",
"ArabicShapingException",
"{",
"char",
"[",
"]",
"src",
"=",
"text",
".",
"toCharArray",
"(",
")",
";",
"char",
"[",
"]",
"dest",
"=",
"src",
";",
"if",
"(",
"(",
"(",
"options",
"&",... | Convert a string, returning the new string.
@param text the string to convert
@return the converted string
@throws ArabicShapingException if the string cannot be converted according to the options. | [
"Convert",
"a",
"string",
"returning",
"the",
"new",
"string",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java#L158-L169 |
33,220 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/atomic/AtomicInteger.java | AtomicInteger.accumulateAndGet | public final int accumulateAndGet(int x,
IntBinaryOperator accumulatorFunction) {
int prev, next;
do {
prev = get();
next = accumulatorFunction.applyAsInt(prev, x);
} while (!compareAndSet(prev, next));
return next;
} | java | public final int accumulateAndGet(int x,
IntBinaryOperator accumulatorFunction) {
int prev, next;
do {
prev = get();
next = accumulatorFunction.applyAsInt(prev, x);
} while (!compareAndSet(prev, next));
return next;
} | [
"public",
"final",
"int",
"accumulateAndGet",
"(",
"int",
"x",
",",
"IntBinaryOperator",
"accumulatorFunction",
")",
"{",
"int",
"prev",
",",
"next",
";",
"do",
"{",
"prev",
"=",
"get",
"(",
")",
";",
"next",
"=",
"accumulatorFunction",
".",
"applyAsInt",
... | Atomically updates the current value with the results of
applying the given function to the current and given values,
returning the updated value. The function should be
side-effect-free, since it may be re-applied when attempted
updates fail due to contention among threads. The function
is applied with the current value as its first argument,
and the given update as the second argument.
@param x the update value
@param accumulatorFunction a side-effect-free function of two arguments
@return the updated value
@since 1.8 | [
"Atomically",
"updates",
"the",
"current",
"value",
"with",
"the",
"results",
"of",
"applying",
"the",
"given",
"function",
"to",
"the",
"current",
"and",
"given",
"values",
"returning",
"the",
"updated",
"value",
".",
"The",
"function",
"should",
"be",
"side"... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/atomic/AtomicInteger.java#L289-L297 |
33,221 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/Phaser.java | Phaser.internalAwaitAdvance | private int internalAwaitAdvance(int phase, QNode node) {
// assert root == this;
releaseWaiters(phase-1); // ensure old queue clean
boolean queued = false; // true when node is enqueued
int lastUnarrived = 0; // to increase spins upon change
int spins = SPINS_PER_ARRIVAL;
long s;
int p;
while ((p = (int)((s = state) >>> PHASE_SHIFT)) == phase) {
if (node == null) { // spinning in noninterruptible mode
int unarrived = (int)s & UNARRIVED_MASK;
if (unarrived != lastUnarrived &&
(lastUnarrived = unarrived) < NCPU)
spins += SPINS_PER_ARRIVAL;
boolean interrupted = Thread.interrupted();
if (interrupted || --spins < 0) { // need node to record intr
node = new QNode(this, phase, false, false, 0L);
node.wasInterrupted = interrupted;
}
}
else if (node.isReleasable()) // done or aborted
break;
else if (!queued) { // push onto queue
AtomicReference<QNode> head = (phase & 1) == 0 ? evenQ : oddQ;
QNode q = node.next = head.get();
if ((q == null || q.phase == phase) &&
(int)(state >>> PHASE_SHIFT) == phase) // avoid stale enq
queued = head.compareAndSet(q, node);
}
else {
try {
ForkJoinPool.managedBlock(node);
} catch (InterruptedException cantHappen) {
node.wasInterrupted = true;
}
}
}
if (node != null) {
if (node.thread != null)
node.thread = null; // avoid need for unpark()
if (node.wasInterrupted && !node.interruptible)
Thread.currentThread().interrupt();
if (p == phase && (p = (int)(state >>> PHASE_SHIFT)) == phase)
return abortWait(phase); // possibly clean up on abort
}
releaseWaiters(phase);
return p;
} | java | private int internalAwaitAdvance(int phase, QNode node) {
// assert root == this;
releaseWaiters(phase-1); // ensure old queue clean
boolean queued = false; // true when node is enqueued
int lastUnarrived = 0; // to increase spins upon change
int spins = SPINS_PER_ARRIVAL;
long s;
int p;
while ((p = (int)((s = state) >>> PHASE_SHIFT)) == phase) {
if (node == null) { // spinning in noninterruptible mode
int unarrived = (int)s & UNARRIVED_MASK;
if (unarrived != lastUnarrived &&
(lastUnarrived = unarrived) < NCPU)
spins += SPINS_PER_ARRIVAL;
boolean interrupted = Thread.interrupted();
if (interrupted || --spins < 0) { // need node to record intr
node = new QNode(this, phase, false, false, 0L);
node.wasInterrupted = interrupted;
}
}
else if (node.isReleasable()) // done or aborted
break;
else if (!queued) { // push onto queue
AtomicReference<QNode> head = (phase & 1) == 0 ? evenQ : oddQ;
QNode q = node.next = head.get();
if ((q == null || q.phase == phase) &&
(int)(state >>> PHASE_SHIFT) == phase) // avoid stale enq
queued = head.compareAndSet(q, node);
}
else {
try {
ForkJoinPool.managedBlock(node);
} catch (InterruptedException cantHappen) {
node.wasInterrupted = true;
}
}
}
if (node != null) {
if (node.thread != null)
node.thread = null; // avoid need for unpark()
if (node.wasInterrupted && !node.interruptible)
Thread.currentThread().interrupt();
if (p == phase && (p = (int)(state >>> PHASE_SHIFT)) == phase)
return abortWait(phase); // possibly clean up on abort
}
releaseWaiters(phase);
return p;
} | [
"private",
"int",
"internalAwaitAdvance",
"(",
"int",
"phase",
",",
"QNode",
"node",
")",
"{",
"// assert root == this;",
"releaseWaiters",
"(",
"phase",
"-",
"1",
")",
";",
"// ensure old queue clean",
"boolean",
"queued",
"=",
"false",
";",
"// true when node is e... | Possibly blocks and waits for phase to advance unless aborted.
Call only on root phaser.
@param phase current phase
@param node if non-null, the wait node to track interrupt and timeout;
if null, denotes noninterruptible wait
@return current phase | [
"Possibly",
"blocks",
"and",
"waits",
"for",
"phase",
"to",
"advance",
"unless",
"aborted",
".",
"Call",
"only",
"on",
"root",
"phaser",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/Phaser.java#L1031-L1079 |
33,222 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SelectFormat.java | SelectFormat.applyPattern | public void applyPattern(String pattern) {
this.pattern = pattern;
if (msgPattern == null) {
msgPattern = new MessagePattern();
}
try {
msgPattern.parseSelectStyle(pattern);
} catch(RuntimeException e) {
reset();
throw e;
}
} | java | public void applyPattern(String pattern) {
this.pattern = pattern;
if (msgPattern == null) {
msgPattern = new MessagePattern();
}
try {
msgPattern.parseSelectStyle(pattern);
} catch(RuntimeException e) {
reset();
throw e;
}
} | [
"public",
"void",
"applyPattern",
"(",
"String",
"pattern",
")",
"{",
"this",
".",
"pattern",
"=",
"pattern",
";",
"if",
"(",
"msgPattern",
"==",
"null",
")",
"{",
"msgPattern",
"=",
"new",
"MessagePattern",
"(",
")",
";",
"}",
"try",
"{",
"msgPattern",
... | Sets the pattern used by this select format.
Patterns and their interpretation are specified in the class description.
@param pattern the pattern for this select format.
@throws IllegalArgumentException when the pattern is not a valid select format pattern. | [
"Sets",
"the",
"pattern",
"used",
"by",
"this",
"select",
"format",
".",
"Patterns",
"and",
"their",
"interpretation",
"are",
"specified",
"in",
"the",
"class",
"description",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SelectFormat.java#L190-L201 |
33,223 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SelectFormat.java | SelectFormat.format | public final String format(String keyword) {
//Check for the validity of the keyword
if (!PatternProps.isIdentifier(keyword)) {
throw new IllegalArgumentException("Invalid formatting argument.");
}
// If no pattern was applied, throw an exception
if (msgPattern == null || msgPattern.countParts() == 0) {
throw new IllegalStateException("Invalid format error.");
}
// Get the appropriate sub-message.
int msgStart = findSubMessage(msgPattern, 0, keyword);
if (!msgPattern.jdkAposMode()) {
int msgLimit = msgPattern.getLimitPartIndex(msgStart);
return msgPattern.getPatternString().substring(msgPattern.getPart(msgStart).getLimit(),
msgPattern.getPatternIndex(msgLimit));
}
// JDK compatibility mode: Remove SKIP_SYNTAX.
StringBuilder result = null;
int prevIndex = msgPattern.getPart(msgStart).getLimit();
for (int i = msgStart;;) {
MessagePattern.Part part = msgPattern.getPart(++i);
MessagePattern.Part.Type type = part.getType();
int index = part.getIndex();
if (type == MessagePattern.Part.Type.MSG_LIMIT) {
if (result == null) {
return pattern.substring(prevIndex, index);
} else {
return result.append(pattern, prevIndex, index).toString();
}
} else if (type == MessagePattern.Part.Type.SKIP_SYNTAX) {
if (result == null) {
result = new StringBuilder();
}
result.append(pattern, prevIndex, index);
prevIndex = part.getLimit();
} else if (type == MessagePattern.Part.Type.ARG_START) {
if (result == null) {
result = new StringBuilder();
}
result.append(pattern, prevIndex, index);
prevIndex = index;
i = msgPattern.getLimitPartIndex(i);
index = msgPattern.getPart(i).getLimit();
MessagePattern.appendReducedApostrophes(pattern, prevIndex, index, result);
prevIndex = index;
}
}
} | java | public final String format(String keyword) {
//Check for the validity of the keyword
if (!PatternProps.isIdentifier(keyword)) {
throw new IllegalArgumentException("Invalid formatting argument.");
}
// If no pattern was applied, throw an exception
if (msgPattern == null || msgPattern.countParts() == 0) {
throw new IllegalStateException("Invalid format error.");
}
// Get the appropriate sub-message.
int msgStart = findSubMessage(msgPattern, 0, keyword);
if (!msgPattern.jdkAposMode()) {
int msgLimit = msgPattern.getLimitPartIndex(msgStart);
return msgPattern.getPatternString().substring(msgPattern.getPart(msgStart).getLimit(),
msgPattern.getPatternIndex(msgLimit));
}
// JDK compatibility mode: Remove SKIP_SYNTAX.
StringBuilder result = null;
int prevIndex = msgPattern.getPart(msgStart).getLimit();
for (int i = msgStart;;) {
MessagePattern.Part part = msgPattern.getPart(++i);
MessagePattern.Part.Type type = part.getType();
int index = part.getIndex();
if (type == MessagePattern.Part.Type.MSG_LIMIT) {
if (result == null) {
return pattern.substring(prevIndex, index);
} else {
return result.append(pattern, prevIndex, index).toString();
}
} else if (type == MessagePattern.Part.Type.SKIP_SYNTAX) {
if (result == null) {
result = new StringBuilder();
}
result.append(pattern, prevIndex, index);
prevIndex = part.getLimit();
} else if (type == MessagePattern.Part.Type.ARG_START) {
if (result == null) {
result = new StringBuilder();
}
result.append(pattern, prevIndex, index);
prevIndex = index;
i = msgPattern.getLimitPartIndex(i);
index = msgPattern.getPart(i).getLimit();
MessagePattern.appendReducedApostrophes(pattern, prevIndex, index, result);
prevIndex = index;
}
}
} | [
"public",
"final",
"String",
"format",
"(",
"String",
"keyword",
")",
"{",
"//Check for the validity of the keyword",
"if",
"(",
"!",
"PatternProps",
".",
"isIdentifier",
"(",
"keyword",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid form... | Selects the phrase for the given keyword.
@param keyword a phrase selection keyword.
@return the string containing the formatted select message.
@throws IllegalArgumentException when the given keyword is not a "pattern identifier" | [
"Selects",
"the",
"phrase",
"for",
"the",
"given",
"keyword",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SelectFormat.java#L249-L297 |
33,224 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/NodeSorter.java | NodeSorter.mergesort | void mergesort(Vector a, Vector b, int l, int r, XPathContext support)
throws TransformerException
{
if ((r - l) > 0)
{
int m = (r + l) / 2;
mergesort(a, b, l, m, support);
mergesort(a, b, m + 1, r, support);
int i, j, k;
for (i = m; i >= l; i--)
{
// b[i] = a[i];
// Use insert if we need to increment vector size.
if (i >= b.size())
b.insertElementAt(a.elementAt(i), i);
else
b.setElementAt(a.elementAt(i), i);
}
i = l;
for (j = (m + 1); j <= r; j++)
{
// b[r+m+1-j] = a[j];
if (r + m + 1 - j >= b.size())
b.insertElementAt(a.elementAt(j), r + m + 1 - j);
else
b.setElementAt(a.elementAt(j), r + m + 1 - j);
}
j = r;
int compVal;
for (k = l; k <= r; k++)
{
// if(b[i] < b[j])
if (i == j)
compVal = -1;
else
compVal = compare((NodeCompareElem) b.elementAt(i),
(NodeCompareElem) b.elementAt(j), 0, support);
if (compVal < 0)
{
// a[k]=b[i];
a.setElementAt(b.elementAt(i), k);
i++;
}
else if (compVal > 0)
{
// a[k]=b[j];
a.setElementAt(b.elementAt(j), k);
j--;
}
}
}
} | java | void mergesort(Vector a, Vector b, int l, int r, XPathContext support)
throws TransformerException
{
if ((r - l) > 0)
{
int m = (r + l) / 2;
mergesort(a, b, l, m, support);
mergesort(a, b, m + 1, r, support);
int i, j, k;
for (i = m; i >= l; i--)
{
// b[i] = a[i];
// Use insert if we need to increment vector size.
if (i >= b.size())
b.insertElementAt(a.elementAt(i), i);
else
b.setElementAt(a.elementAt(i), i);
}
i = l;
for (j = (m + 1); j <= r; j++)
{
// b[r+m+1-j] = a[j];
if (r + m + 1 - j >= b.size())
b.insertElementAt(a.elementAt(j), r + m + 1 - j);
else
b.setElementAt(a.elementAt(j), r + m + 1 - j);
}
j = r;
int compVal;
for (k = l; k <= r; k++)
{
// if(b[i] < b[j])
if (i == j)
compVal = -1;
else
compVal = compare((NodeCompareElem) b.elementAt(i),
(NodeCompareElem) b.elementAt(j), 0, support);
if (compVal < 0)
{
// a[k]=b[i];
a.setElementAt(b.elementAt(i), k);
i++;
}
else if (compVal > 0)
{
// a[k]=b[j];
a.setElementAt(b.elementAt(j), k);
j--;
}
}
}
} | [
"void",
"mergesort",
"(",
"Vector",
"a",
",",
"Vector",
"b",
",",
"int",
"l",
",",
"int",
"r",
",",
"XPathContext",
"support",
")",
"throws",
"TransformerException",
"{",
"if",
"(",
"(",
"r",
"-",
"l",
")",
">",
"0",
")",
"{",
"int",
"m",
"=",
"(... | This implements a standard Mergesort, as described in
Robert Sedgewick's Algorithms book. This is a better
sort for our purpose than the Quicksort because it
maintains the original document order of the input if
the order isn't changed by the sort.
@param a First vector of nodes to compare
@param b Second vector of nodes to compare
@param l Left boundary of partition
@param r Right boundary of partition
@param support XPath context to use
@throws TransformerException | [
"This",
"implements",
"a",
"standard",
"Mergesort",
"as",
"described",
"in",
"Robert",
"Sedgewick",
"s",
"Algorithms",
"book",
".",
"This",
"is",
"a",
"better",
"sort",
"for",
"our",
"purpose",
"than",
"the",
"Quicksort",
"because",
"it",
"maintains",
"the",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/NodeSorter.java#L295-L363 |
33,225 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/AbstractSpinedBuffer.java | AbstractSpinedBuffer.chunkSize | protected int chunkSize(int n) {
int power = (n == 0 || n == 1)
? initialChunkPower
: Math.min(initialChunkPower + n - 1, AbstractSpinedBuffer.MAX_CHUNK_POWER);
return 1 << power;
} | java | protected int chunkSize(int n) {
int power = (n == 0 || n == 1)
? initialChunkPower
: Math.min(initialChunkPower + n - 1, AbstractSpinedBuffer.MAX_CHUNK_POWER);
return 1 << power;
} | [
"protected",
"int",
"chunkSize",
"(",
"int",
"n",
")",
"{",
"int",
"power",
"=",
"(",
"n",
"==",
"0",
"||",
"n",
"==",
"1",
")",
"?",
"initialChunkPower",
":",
"Math",
".",
"min",
"(",
"initialChunkPower",
"+",
"n",
"-",
"1",
",",
"AbstractSpinedBuff... | How big should the nth chunk be? | [
"How",
"big",
"should",
"the",
"nth",
"chunk",
"be?"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/AbstractSpinedBuffer.java#L116-L121 |
33,226 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java | ElemLiteralResult.getLiteralResultAttributeNS | public AVT getLiteralResultAttributeNS(String namespaceURI, String localName)
{
if (null != m_avts)
{
int nAttrs = m_avts.size();
for (int i = (nAttrs - 1); i >= 0; i--)
{
AVT avt = (AVT) m_avts.get(i);
if (avt.getName().equals(localName) &&
avt.getURI().equals(namespaceURI))
{
return avt;
}
} // end for
}
return null;
} | java | public AVT getLiteralResultAttributeNS(String namespaceURI, String localName)
{
if (null != m_avts)
{
int nAttrs = m_avts.size();
for (int i = (nAttrs - 1); i >= 0; i--)
{
AVT avt = (AVT) m_avts.get(i);
if (avt.getName().equals(localName) &&
avt.getURI().equals(namespaceURI))
{
return avt;
}
} // end for
}
return null;
} | [
"public",
"AVT",
"getLiteralResultAttributeNS",
"(",
"String",
"namespaceURI",
",",
"String",
"localName",
")",
"{",
"if",
"(",
"null",
"!=",
"m_avts",
")",
"{",
"int",
"nAttrs",
"=",
"m_avts",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"... | Get a literal result attribute by name.
@param namespaceURI Namespace URI of attribute node to get
@param localName Local part of qualified name of attribute node to get
@return literal result attribute (AVT) | [
"Get",
"a",
"literal",
"result",
"attribute",
"by",
"name",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java#L190-L210 |
33,227 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java | ElemLiteralResult.resolvePrefixTables | public void resolvePrefixTables() throws TransformerException
{
super.resolvePrefixTables();
StylesheetRoot stylesheet = getStylesheetRoot();
if ((null != m_namespace) && (m_namespace.length() > 0))
{
NamespaceAlias nsa = stylesheet.getNamespaceAliasComposed(m_namespace);
if (null != nsa)
{
m_namespace = nsa.getResultNamespace();
// String resultPrefix = nsa.getResultPrefix();
String resultPrefix = nsa.getStylesheetPrefix(); // As per xsl WG, Mike Kay
if ((null != resultPrefix) && (resultPrefix.length() > 0))
m_rawName = resultPrefix + ":" + m_localName;
else
m_rawName = m_localName;
}
}
if (null != m_avts)
{
int n = m_avts.size();
for (int i = 0; i < n; i++)
{
AVT avt = (AVT) m_avts.get(i);
// Should this stuff be a method on AVT?
String ns = avt.getURI();
if ((null != ns) && (ns.length() > 0))
{
NamespaceAlias nsa =
stylesheet.getNamespaceAliasComposed(m_namespace); // %REVIEW% ns?
if (null != nsa)
{
String namespace = nsa.getResultNamespace();
// String resultPrefix = nsa.getResultPrefix();
String resultPrefix = nsa.getStylesheetPrefix(); // As per XSL WG
String rawName = avt.getName();
if ((null != resultPrefix) && (resultPrefix.length() > 0))
rawName = resultPrefix + ":" + rawName;
avt.setURI(namespace);
avt.setRawName(rawName);
}
}
}
}
} | java | public void resolvePrefixTables() throws TransformerException
{
super.resolvePrefixTables();
StylesheetRoot stylesheet = getStylesheetRoot();
if ((null != m_namespace) && (m_namespace.length() > 0))
{
NamespaceAlias nsa = stylesheet.getNamespaceAliasComposed(m_namespace);
if (null != nsa)
{
m_namespace = nsa.getResultNamespace();
// String resultPrefix = nsa.getResultPrefix();
String resultPrefix = nsa.getStylesheetPrefix(); // As per xsl WG, Mike Kay
if ((null != resultPrefix) && (resultPrefix.length() > 0))
m_rawName = resultPrefix + ":" + m_localName;
else
m_rawName = m_localName;
}
}
if (null != m_avts)
{
int n = m_avts.size();
for (int i = 0; i < n; i++)
{
AVT avt = (AVT) m_avts.get(i);
// Should this stuff be a method on AVT?
String ns = avt.getURI();
if ((null != ns) && (ns.length() > 0))
{
NamespaceAlias nsa =
stylesheet.getNamespaceAliasComposed(m_namespace); // %REVIEW% ns?
if (null != nsa)
{
String namespace = nsa.getResultNamespace();
// String resultPrefix = nsa.getResultPrefix();
String resultPrefix = nsa.getStylesheetPrefix(); // As per XSL WG
String rawName = avt.getName();
if ((null != resultPrefix) && (resultPrefix.length() > 0))
rawName = resultPrefix + ":" + rawName;
avt.setURI(namespace);
avt.setRawName(rawName);
}
}
}
}
} | [
"public",
"void",
"resolvePrefixTables",
"(",
")",
"throws",
"TransformerException",
"{",
"super",
".",
"resolvePrefixTables",
"(",
")",
";",
"StylesheetRoot",
"stylesheet",
"=",
"getStylesheetRoot",
"(",
")",
";",
"if",
"(",
"(",
"null",
"!=",
"m_namespace",
")... | Augment resolvePrefixTables, resolving the namespace aliases once
the superclass has resolved the tables.
@throws TransformerException | [
"Augment",
"resolvePrefixTables",
"resolving",
"the",
"namespace",
"aliases",
"once",
"the",
"superclass",
"has",
"resolved",
"the",
"tables",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java#L332-L390 |
33,228 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java | ElemLiteralResult.needToCheckExclude | boolean needToCheckExclude()
{
if (null == m_excludeResultPrefixes && null == getPrefixTable()
&& m_ExtensionElementURIs==null // JJK Bugzilla 1133
)
return false;
else
{
// Create a new prefix table if one has not already been created.
if (null == getPrefixTable())
setPrefixTable(new java.util.ArrayList());
return true;
}
} | java | boolean needToCheckExclude()
{
if (null == m_excludeResultPrefixes && null == getPrefixTable()
&& m_ExtensionElementURIs==null // JJK Bugzilla 1133
)
return false;
else
{
// Create a new prefix table if one has not already been created.
if (null == getPrefixTable())
setPrefixTable(new java.util.ArrayList());
return true;
}
} | [
"boolean",
"needToCheckExclude",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"m_excludeResultPrefixes",
"&&",
"null",
"==",
"getPrefixTable",
"(",
")",
"&&",
"m_ExtensionElementURIs",
"==",
"null",
"// JJK Bugzilla 1133",
")",
"return",
"false",
";",
"else",
"{",
"/... | Return whether we need to check namespace prefixes
against the exclude result prefixes or extensions lists.
Note that this will create a new prefix table if one
has not been created already.
NEEDSDOC ($objectName$) @return | [
"Return",
"whether",
"we",
"need",
"to",
"check",
"namespace",
"prefixes",
"against",
"the",
"exclude",
"result",
"prefixes",
"or",
"extensions",
"lists",
".",
"Note",
"that",
"this",
"will",
"create",
"a",
"new",
"prefix",
"table",
"if",
"one",
"has",
"not"... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java#L400-L415 |
33,229 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java | ElemLiteralResult.getPrefix | public String getPrefix()
{
int len=m_rawName.length()-m_localName.length()-1;
return (len>0)
? m_rawName.substring(0,len)
: "";
} | java | public String getPrefix()
{
int len=m_rawName.length()-m_localName.length()-1;
return (len>0)
? m_rawName.substring(0,len)
: "";
} | [
"public",
"String",
"getPrefix",
"(",
")",
"{",
"int",
"len",
"=",
"m_rawName",
".",
"length",
"(",
")",
"-",
"m_localName",
".",
"length",
"(",
")",
"-",
"1",
";",
"return",
"(",
"len",
">",
"0",
")",
"?",
"m_rawName",
".",
"substring",
"(",
"0",
... | Get the prefix part of the raw name of the Literal Result Element.
@return The prefix, or the empty string if noprefix was provided. | [
"Get",
"the",
"prefix",
"part",
"of",
"the",
"raw",
"name",
"of",
"the",
"Literal",
"Result",
"Element",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java#L517-L523 |
33,230 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java | ElemLiteralResult.throwDOMException | public void throwDOMException(short code, String msg)
{
String themsg = XSLMessages.createMessage(msg, null);
throw new DOMException(code, themsg);
} | java | public void throwDOMException(short code, String msg)
{
String themsg = XSLMessages.createMessage(msg, null);
throw new DOMException(code, themsg);
} | [
"public",
"void",
"throwDOMException",
"(",
"short",
"code",
",",
"String",
"msg",
")",
"{",
"String",
"themsg",
"=",
"XSLMessages",
".",
"createMessage",
"(",
"msg",
",",
"null",
")",
";",
"throw",
"new",
"DOMException",
"(",
"code",
",",
"themsg",
")",
... | Throw a DOMException
@param msg key of the error that occured. | [
"Throw",
"a",
"DOMException"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemLiteralResult.java#L1470-L1476 |
33,231 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java | NFSubstitution.makeSubstitution | public static NFSubstitution makeSubstitution(int pos,
NFRule rule,
NFRule rulePredecessor,
NFRuleSet ruleSet,
RuleBasedNumberFormat formatter,
String description) {
// if the description is empty, return a NullSubstitution
if (description.length() == 0) {
return null;
}
switch (description.charAt(0)) {
case '<':
if (rule.getBaseValue() == NFRule.NEGATIVE_NUMBER_RULE) {
// throw an exception if the rule is a negative number rule
///CLOVER:OFF
// If you look at the call hierarchy of this method, the rule would
// never be directly modified by the user and therefore makes the
// following pointless unless the user changes the ruleset.
throw new IllegalArgumentException("<< not allowed in negative-number rule");
///CLOVER:ON
}
else if (rule.getBaseValue() == NFRule.IMPROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.PROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.MASTER_RULE)
{
// if the rule is a fraction rule, return an IntegralPartSubstitution
return new IntegralPartSubstitution(pos, ruleSet, description);
}
else if (ruleSet.isFractionSet()) {
// if the rule set containing the rule is a fraction
// rule set, return a NumeratorSubstitution
return new NumeratorSubstitution(pos, rule.getBaseValue(),
formatter.getDefaultRuleSet(), description);
}
else {
// otherwise, return a MultiplierSubstitution
return new MultiplierSubstitution(pos, rule, ruleSet,
description);
}
case '>':
if (rule.getBaseValue() == NFRule.NEGATIVE_NUMBER_RULE) {
// if the rule is a negative-number rule, return
// an AbsoluteValueSubstitution
return new AbsoluteValueSubstitution(pos, ruleSet, description);
}
else if (rule.getBaseValue() == NFRule.IMPROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.PROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.MASTER_RULE)
{
// if the rule is a fraction rule, return a
// FractionalPartSubstitution
return new FractionalPartSubstitution(pos, ruleSet, description);
}
else if (ruleSet.isFractionSet()) {
// if the rule set owning the rule is a fraction rule set,
// throw an exception
///CLOVER:OFF
// If you look at the call hierarchy of this method, the rule would
// never be directly modified by the user and therefore makes the
// following pointless unless the user changes the ruleset.
throw new IllegalArgumentException(">> not allowed in fraction rule set");
///CLOVER:ON
}
else {
// otherwise, return a ModulusSubstitution
return new ModulusSubstitution(pos, rule, rulePredecessor,
ruleSet, description);
}
case '=':
return new SameValueSubstitution(pos, ruleSet, description);
default:
// and if it's anything else, throw an exception
///CLOVER:OFF
// If you look at the call hierarchy of this method, the rule would
// never be directly modified by the user and therefore makes the
// following pointless unless the user changes the ruleset.
throw new IllegalArgumentException("Illegal substitution character");
///CLOVER:ON
}
} | java | public static NFSubstitution makeSubstitution(int pos,
NFRule rule,
NFRule rulePredecessor,
NFRuleSet ruleSet,
RuleBasedNumberFormat formatter,
String description) {
// if the description is empty, return a NullSubstitution
if (description.length() == 0) {
return null;
}
switch (description.charAt(0)) {
case '<':
if (rule.getBaseValue() == NFRule.NEGATIVE_NUMBER_RULE) {
// throw an exception if the rule is a negative number rule
///CLOVER:OFF
// If you look at the call hierarchy of this method, the rule would
// never be directly modified by the user and therefore makes the
// following pointless unless the user changes the ruleset.
throw new IllegalArgumentException("<< not allowed in negative-number rule");
///CLOVER:ON
}
else if (rule.getBaseValue() == NFRule.IMPROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.PROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.MASTER_RULE)
{
// if the rule is a fraction rule, return an IntegralPartSubstitution
return new IntegralPartSubstitution(pos, ruleSet, description);
}
else if (ruleSet.isFractionSet()) {
// if the rule set containing the rule is a fraction
// rule set, return a NumeratorSubstitution
return new NumeratorSubstitution(pos, rule.getBaseValue(),
formatter.getDefaultRuleSet(), description);
}
else {
// otherwise, return a MultiplierSubstitution
return new MultiplierSubstitution(pos, rule, ruleSet,
description);
}
case '>':
if (rule.getBaseValue() == NFRule.NEGATIVE_NUMBER_RULE) {
// if the rule is a negative-number rule, return
// an AbsoluteValueSubstitution
return new AbsoluteValueSubstitution(pos, ruleSet, description);
}
else if (rule.getBaseValue() == NFRule.IMPROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.PROPER_FRACTION_RULE
|| rule.getBaseValue() == NFRule.MASTER_RULE)
{
// if the rule is a fraction rule, return a
// FractionalPartSubstitution
return new FractionalPartSubstitution(pos, ruleSet, description);
}
else if (ruleSet.isFractionSet()) {
// if the rule set owning the rule is a fraction rule set,
// throw an exception
///CLOVER:OFF
// If you look at the call hierarchy of this method, the rule would
// never be directly modified by the user and therefore makes the
// following pointless unless the user changes the ruleset.
throw new IllegalArgumentException(">> not allowed in fraction rule set");
///CLOVER:ON
}
else {
// otherwise, return a ModulusSubstitution
return new ModulusSubstitution(pos, rule, rulePredecessor,
ruleSet, description);
}
case '=':
return new SameValueSubstitution(pos, ruleSet, description);
default:
// and if it's anything else, throw an exception
///CLOVER:OFF
// If you look at the call hierarchy of this method, the rule would
// never be directly modified by the user and therefore makes the
// following pointless unless the user changes the ruleset.
throw new IllegalArgumentException("Illegal substitution character");
///CLOVER:ON
}
} | [
"public",
"static",
"NFSubstitution",
"makeSubstitution",
"(",
"int",
"pos",
",",
"NFRule",
"rule",
",",
"NFRule",
"rulePredecessor",
",",
"NFRuleSet",
"ruleSet",
",",
"RuleBasedNumberFormat",
"formatter",
",",
"String",
"description",
")",
"{",
"// if the description... | Parses the description, creates the right kind of substitution,
and initializes it based on the description.
@param pos The substitution's position in the rule text of the
rule that owns it.
@param rule The rule containing this substitution
@param rulePredecessor The rule preceding the one that contains
this substitution in the rule set's rule list (this is used
only for >>> substitutions).
@param ruleSet The rule set containing the rule containing this
substitution
@param formatter The RuleBasedNumberFormat that ultimately owns
this substitution
@param description The description to parse to build the substitution
(this is just the substring of the rule's description containing
the substitution token itself)
@return A new substitution constructed according to the description | [
"Parses",
"the",
"description",
"creates",
"the",
"right",
"kind",
"of",
"substitution",
"and",
"initializes",
"it",
"based",
"on",
"the",
"description",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java#L69-L150 |
33,232 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java | MultiplierSubstitution.setDivisor | public void setDivisor(int radix, short exponent) {
divisor = NFRule.power(radix, exponent);
if (divisor == 0) {
throw new IllegalStateException("Substitution with divisor 0");
}
} | java | public void setDivisor(int radix, short exponent) {
divisor = NFRule.power(radix, exponent);
if (divisor == 0) {
throw new IllegalStateException("Substitution with divisor 0");
}
} | [
"public",
"void",
"setDivisor",
"(",
"int",
"radix",
",",
"short",
"exponent",
")",
"{",
"divisor",
"=",
"NFRule",
".",
"power",
"(",
"radix",
",",
"exponent",
")",
";",
"if",
"(",
"divisor",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
... | Sets the substitution's divisor based on the values passed in.
@param radix The radix of the divisor.
@param exponent The exponent of the divisor. | [
"Sets",
"the",
"substitution",
"s",
"divisor",
"based",
"on",
"the",
"values",
"passed",
"in",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java#L672-L678 |
33,233 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java | ModulusSubstitution.doSubstitution | public void doSubstitution(long number, StringBuilder toInsertInto, int position, int recursionCount) {
// if this isn't a >>> substitution, just use the inherited version
// of this function (which uses either a rule set or a DecimalFormat
// to format its substitution value)
if (ruleToUse == null) {
super.doSubstitution(number, toInsertInto, position, recursionCount);
} else {
// a >>> substitution goes straight to a particular rule to
// format the substitution value
long numberToFormat = transformNumber(number);
ruleToUse.doFormat(numberToFormat, toInsertInto, position + pos, recursionCount);
}
} | java | public void doSubstitution(long number, StringBuilder toInsertInto, int position, int recursionCount) {
// if this isn't a >>> substitution, just use the inherited version
// of this function (which uses either a rule set or a DecimalFormat
// to format its substitution value)
if (ruleToUse == null) {
super.doSubstitution(number, toInsertInto, position, recursionCount);
} else {
// a >>> substitution goes straight to a particular rule to
// format the substitution value
long numberToFormat = transformNumber(number);
ruleToUse.doFormat(numberToFormat, toInsertInto, position + pos, recursionCount);
}
} | [
"public",
"void",
"doSubstitution",
"(",
"long",
"number",
",",
"StringBuilder",
"toInsertInto",
",",
"int",
"position",
",",
"int",
"recursionCount",
")",
"{",
"// if this isn't a >>> substitution, just use the inherited version",
"// of this function (which uses either a rule s... | If this is a >>> substitution, use ruleToUse to fill in
the substitution. Otherwise, just use the superclass function.
@param number The number being formatted
@param toInsertInto The string to insert the result of this substitution
into
@param position The position of the rule text in toInsertInto | [
"If",
"this",
"is",
"a",
">",
";",
">",
";",
">",
";",
"substitution",
"use",
"ruleToUse",
"to",
"fill",
"in",
"the",
"substitution",
".",
"Otherwise",
"just",
"use",
"the",
"superclass",
"function",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java#L879-L892 |
33,234 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java | ModulusSubstitution.doParse | public Number doParse(String text, ParsePosition parsePosition, double baseValue,
double upperBound, boolean lenientParse) {
// if this isn't a >>> substitution, we can just use the
// inherited parse() routine to do the parsing
if (ruleToUse == null) {
return super.doParse(text, parsePosition, baseValue, upperBound, lenientParse);
} else {
// but if it IS a >>> substitution, we have to do it here: we
// use the specific rule's doParse() method, and then we have to
// do some of the other work of NFRuleSet.parse()
Number tempResult = ruleToUse.doParse(text, parsePosition, false, upperBound);
if (parsePosition.getIndex() != 0) {
double result = tempResult.doubleValue();
result = composeRuleValue(result, baseValue);
if (result == (long)result) {
return Long.valueOf((long)result);
} else {
return new Double(result);
}
} else {
return tempResult;
}
}
} | java | public Number doParse(String text, ParsePosition parsePosition, double baseValue,
double upperBound, boolean lenientParse) {
// if this isn't a >>> substitution, we can just use the
// inherited parse() routine to do the parsing
if (ruleToUse == null) {
return super.doParse(text, parsePosition, baseValue, upperBound, lenientParse);
} else {
// but if it IS a >>> substitution, we have to do it here: we
// use the specific rule's doParse() method, and then we have to
// do some of the other work of NFRuleSet.parse()
Number tempResult = ruleToUse.doParse(text, parsePosition, false, upperBound);
if (parsePosition.getIndex() != 0) {
double result = tempResult.doubleValue();
result = composeRuleValue(result, baseValue);
if (result == (long)result) {
return Long.valueOf((long)result);
} else {
return new Double(result);
}
} else {
return tempResult;
}
}
} | [
"public",
"Number",
"doParse",
"(",
"String",
"text",
",",
"ParsePosition",
"parsePosition",
",",
"double",
"baseValue",
",",
"double",
"upperBound",
",",
"boolean",
"lenientParse",
")",
"{",
"// if this isn't a >>> substitution, we can just use the",
"// inherited parse() ... | If this is a >>> substitution, match only against ruleToUse.
Otherwise, use the superclass function.
@param text The string to parse
@param parsePosition Ignored on entry, updated on exit to point to
the first unmatched character.
@param baseValue The partial parse result prior to calling this
routine. | [
"If",
"this",
"is",
"a",
">",
";",
">",
";",
">",
";",
"substitution",
"match",
"only",
"against",
"ruleToUse",
".",
"Otherwise",
"use",
"the",
"superclass",
"function",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java#L951-L977 |
33,235 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java | FractionalPartSubstitution.doSubstitution | public void doSubstitution(double number, StringBuilder toInsertInto, int position, int recursionCount) {
if (!byDigits) {
// if we're not in "byDigits" mode, just use the inherited
// doSubstitution() routine
super.doSubstitution(number, toInsertInto, position, recursionCount);
}
else {
// if we're in "byDigits" mode, transform the value into an integer
// by moving the decimal point eight places to the right and
// pulling digits off the right one at a time, formatting each digit
// as an integer using this substitution's owning rule set
// (this is slower, but more accurate, than doing it from the
// other end)
// just print to string and then use that
DigitList dl = new DigitList();
dl.set(number, 20, true);
boolean pad = false;
while (dl.count > Math.max(0, dl.decimalAt)) {
if (pad && useSpaces) {
toInsertInto.insert(position + pos, ' ');
} else {
pad = true;
}
ruleSet.format(dl.digits[--dl.count] - '0', toInsertInto, position + pos, recursionCount);
}
while (dl.decimalAt < 0) {
if (pad && useSpaces) {
toInsertInto.insert(position + pos, ' ');
} else {
pad = true;
}
ruleSet.format(0, toInsertInto, position + pos, recursionCount);
++dl.decimalAt;
}
}
} | java | public void doSubstitution(double number, StringBuilder toInsertInto, int position, int recursionCount) {
if (!byDigits) {
// if we're not in "byDigits" mode, just use the inherited
// doSubstitution() routine
super.doSubstitution(number, toInsertInto, position, recursionCount);
}
else {
// if we're in "byDigits" mode, transform the value into an integer
// by moving the decimal point eight places to the right and
// pulling digits off the right one at a time, formatting each digit
// as an integer using this substitution's owning rule set
// (this is slower, but more accurate, than doing it from the
// other end)
// just print to string and then use that
DigitList dl = new DigitList();
dl.set(number, 20, true);
boolean pad = false;
while (dl.count > Math.max(0, dl.decimalAt)) {
if (pad && useSpaces) {
toInsertInto.insert(position + pos, ' ');
} else {
pad = true;
}
ruleSet.format(dl.digits[--dl.count] - '0', toInsertInto, position + pos, recursionCount);
}
while (dl.decimalAt < 0) {
if (pad && useSpaces) {
toInsertInto.insert(position + pos, ' ');
} else {
pad = true;
}
ruleSet.format(0, toInsertInto, position + pos, recursionCount);
++dl.decimalAt;
}
}
} | [
"public",
"void",
"doSubstitution",
"(",
"double",
"number",
",",
"StringBuilder",
"toInsertInto",
",",
"int",
"position",
",",
"int",
"recursionCount",
")",
"{",
"if",
"(",
"!",
"byDigits",
")",
"{",
"// if we're not in \"byDigits\" mode, just use the inherited",
"//... | If in "by digits" mode, fills in the substitution one decimal digit
at a time using the rule set containing this substitution.
Otherwise, uses the superclass function.
@param number The number being formatted
@param toInsertInto The string to insert the result of formatting
the substitution into
@param position The position of the owning rule's rule text in
toInsertInto | [
"If",
"in",
"by",
"digits",
"mode",
"fills",
"in",
"the",
"substitution",
"one",
"decimal",
"digit",
"at",
"a",
"time",
"using",
"the",
"rule",
"set",
"containing",
"this",
"substitution",
".",
"Otherwise",
"uses",
"the",
"superclass",
"function",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java#L1174-L1211 |
33,236 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java | FractionalPartSubstitution.doParse | public Number doParse(String text, ParsePosition parsePosition, double baseValue,
double upperBound, boolean lenientParse) {
// if we're not in byDigits mode, we can just use the inherited
// doParse()
if (!byDigits) {
return super.doParse(text, parsePosition, baseValue, 0, lenientParse);
}
else {
// if we ARE in byDigits mode, parse the text one digit at a time
// using this substitution's owning rule set (we do this by setting
// upperBound to 10 when calling doParse() ) until we reach
// nonmatching text
String workText = text;
ParsePosition workPos = new ParsePosition(1);
double result;
int digit;
DigitList dl = new DigitList();
while (workText.length() > 0 && workPos.getIndex() != 0) {
workPos.setIndex(0);
digit = ruleSet.parse(workText, workPos, 10).intValue();
if (lenientParse && workPos.getIndex() == 0) {
Number n = ruleSet.owner.getDecimalFormat().parse(workText, workPos);
if (n != null) {
digit = n.intValue();
}
}
if (workPos.getIndex() != 0) {
dl.append('0'+digit);
parsePosition.setIndex(parsePosition.getIndex() + workPos.getIndex());
workText = workText.substring(workPos.getIndex());
while (workText.length() > 0 && workText.charAt(0) == ' ') {
workText = workText.substring(1);
parsePosition.setIndex(parsePosition.getIndex() + 1);
}
}
}
result = dl.count == 0 ? 0 : dl.getDouble();
result = composeRuleValue(result, baseValue);
return new Double(result);
}
} | java | public Number doParse(String text, ParsePosition parsePosition, double baseValue,
double upperBound, boolean lenientParse) {
// if we're not in byDigits mode, we can just use the inherited
// doParse()
if (!byDigits) {
return super.doParse(text, parsePosition, baseValue, 0, lenientParse);
}
else {
// if we ARE in byDigits mode, parse the text one digit at a time
// using this substitution's owning rule set (we do this by setting
// upperBound to 10 when calling doParse() ) until we reach
// nonmatching text
String workText = text;
ParsePosition workPos = new ParsePosition(1);
double result;
int digit;
DigitList dl = new DigitList();
while (workText.length() > 0 && workPos.getIndex() != 0) {
workPos.setIndex(0);
digit = ruleSet.parse(workText, workPos, 10).intValue();
if (lenientParse && workPos.getIndex() == 0) {
Number n = ruleSet.owner.getDecimalFormat().parse(workText, workPos);
if (n != null) {
digit = n.intValue();
}
}
if (workPos.getIndex() != 0) {
dl.append('0'+digit);
parsePosition.setIndex(parsePosition.getIndex() + workPos.getIndex());
workText = workText.substring(workPos.getIndex());
while (workText.length() > 0 && workText.charAt(0) == ' ') {
workText = workText.substring(1);
parsePosition.setIndex(parsePosition.getIndex() + 1);
}
}
}
result = dl.count == 0 ? 0 : dl.getDouble();
result = composeRuleValue(result, baseValue);
return new Double(result);
}
} | [
"public",
"Number",
"doParse",
"(",
"String",
"text",
",",
"ParsePosition",
"parsePosition",
",",
"double",
"baseValue",
",",
"double",
"upperBound",
",",
"boolean",
"lenientParse",
")",
"{",
"// if we're not in byDigits mode, we can just use the inherited",
"// doParse()",... | If in "by digits" mode, parses the string as if it were a string
of individual digits; otherwise, uses the superclass function.
@param text The string to parse
@param parsePosition Ignored on entry, but updated on exit to point
to the first unmatched character
@param baseValue The partial parse result prior to entering this
function
@param upperBound Only consider rules with base values lower than
this when filling in the substitution
@param lenientParse If true, try matching the text as numerals if
matching as words doesn't work
@return If the match was successful, the current partial parse
result; otherwise new Long(0). The result is either a Long or
a Double. | [
"If",
"in",
"by",
"digits",
"mode",
"parses",
"the",
"string",
"as",
"if",
"it",
"were",
"a",
"string",
"of",
"individual",
"digits",
";",
"otherwise",
"uses",
"the",
"superclass",
"function",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java#L1252-L1296 |
33,237 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java | NumeratorSubstitution.doParse | public Number doParse(String text, ParsePosition parsePosition, double baseValue,
double upperBound, boolean lenientParse) {
// we don't have to do anything special to do the parsing here,
// but we have to turn lenient parsing off-- if we leave it on,
// it SERIOUSLY messes up the algorithm
// if withZeros is true, we need to count the zeros
// and use that to adjust the parse result
int zeroCount = 0;
if (withZeros) {
String workText = text;
ParsePosition workPos = new ParsePosition(1);
//int digit;
while (workText.length() > 0 && workPos.getIndex() != 0) {
workPos.setIndex(0);
/*digit = */ruleSet.parse(workText, workPos, 1).intValue(); // parse zero or nothing at all
if (workPos.getIndex() == 0) {
// we failed, either there were no more zeros, or the number was formatted with digits
// either way, we're done
break;
}
++zeroCount;
parsePosition.setIndex(parsePosition.getIndex() + workPos.getIndex());
workText = workText.substring(workPos.getIndex());
while (workText.length() > 0 && workText.charAt(0) == ' ') {
workText = workText.substring(1);
parsePosition.setIndex(parsePosition.getIndex() + 1);
}
}
text = text.substring(parsePosition.getIndex()); // arrgh!
parsePosition.setIndex(0);
}
// we've parsed off the zeros, now let's parse the rest from our current position
Number result = super.doParse(text, parsePosition, withZeros ? 1 : baseValue, upperBound, false);
if (withZeros) {
// any base value will do in this case. is there a way to
// force this to not bother trying all the base values?
// compute the 'effective' base and prescale the value down
long n = result.longValue();
long d = 1;
while (d <= n) {
d *= 10;
}
// now add the zeros
while (zeroCount > 0) {
d *= 10;
--zeroCount;
}
// d is now our true denominator
result = new Double(n/(double)d);
}
return result;
} | java | public Number doParse(String text, ParsePosition parsePosition, double baseValue,
double upperBound, boolean lenientParse) {
// we don't have to do anything special to do the parsing here,
// but we have to turn lenient parsing off-- if we leave it on,
// it SERIOUSLY messes up the algorithm
// if withZeros is true, we need to count the zeros
// and use that to adjust the parse result
int zeroCount = 0;
if (withZeros) {
String workText = text;
ParsePosition workPos = new ParsePosition(1);
//int digit;
while (workText.length() > 0 && workPos.getIndex() != 0) {
workPos.setIndex(0);
/*digit = */ruleSet.parse(workText, workPos, 1).intValue(); // parse zero or nothing at all
if (workPos.getIndex() == 0) {
// we failed, either there were no more zeros, or the number was formatted with digits
// either way, we're done
break;
}
++zeroCount;
parsePosition.setIndex(parsePosition.getIndex() + workPos.getIndex());
workText = workText.substring(workPos.getIndex());
while (workText.length() > 0 && workText.charAt(0) == ' ') {
workText = workText.substring(1);
parsePosition.setIndex(parsePosition.getIndex() + 1);
}
}
text = text.substring(parsePosition.getIndex()); // arrgh!
parsePosition.setIndex(0);
}
// we've parsed off the zeros, now let's parse the rest from our current position
Number result = super.doParse(text, parsePosition, withZeros ? 1 : baseValue, upperBound, false);
if (withZeros) {
// any base value will do in this case. is there a way to
// force this to not bother trying all the base values?
// compute the 'effective' base and prescale the value down
long n = result.longValue();
long d = 1;
while (d <= n) {
d *= 10;
}
// now add the zeros
while (zeroCount > 0) {
d *= 10;
--zeroCount;
}
// d is now our true denominator
result = new Double(n/(double)d);
}
return result;
} | [
"public",
"Number",
"doParse",
"(",
"String",
"text",
",",
"ParsePosition",
"parsePosition",
",",
"double",
"baseValue",
",",
"double",
"upperBound",
",",
"boolean",
"lenientParse",
")",
"{",
"// we don't have to do anything special to do the parsing here,",
"// but we have... | Dispatches to the inherited version of this function, but makes
sure that lenientParse is off. | [
"Dispatches",
"to",
"the",
"inherited",
"version",
"of",
"this",
"function",
"but",
"makes",
"sure",
"that",
"lenientParse",
"is",
"off",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFSubstitution.java#L1559-L1618 |
33,238 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java | DTMAxisIteratorBase.cloneIterator | public DTMAxisIterator cloneIterator()
{
try
{
final DTMAxisIteratorBase clone = (DTMAxisIteratorBase) super.clone();
clone._isRestartable = false;
// return clone.reset();
return clone;
}
catch (CloneNotSupportedException e)
{
throw new org.apache.xml.utils.WrappedRuntimeException(e);
}
} | java | public DTMAxisIterator cloneIterator()
{
try
{
final DTMAxisIteratorBase clone = (DTMAxisIteratorBase) super.clone();
clone._isRestartable = false;
// return clone.reset();
return clone;
}
catch (CloneNotSupportedException e)
{
throw new org.apache.xml.utils.WrappedRuntimeException(e);
}
} | [
"public",
"DTMAxisIterator",
"cloneIterator",
"(",
")",
"{",
"try",
"{",
"final",
"DTMAxisIteratorBase",
"clone",
"=",
"(",
"DTMAxisIteratorBase",
")",
"super",
".",
"clone",
"(",
")",
";",
"clone",
".",
"_isRestartable",
"=",
"false",
";",
"// return clone.rese... | Returns a deep copy of this iterator. Cloned iterators may not be
restartable. The iterator being cloned may or may not become
non-restartable as a side effect of this operation.
@return a deep copy of this iterator. | [
"Returns",
"a",
"deep",
"copy",
"of",
"this",
"iterator",
".",
"Cloned",
"iterators",
"may",
"not",
"be",
"restartable",
".",
"The",
"iterator",
"being",
"cloned",
"may",
"or",
"may",
"not",
"become",
"non",
"-",
"restartable",
"as",
"a",
"side",
"effect",... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java#L175-L191 |
33,239 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java | DTMAxisIteratorBase.getNodeByPosition | public int getNodeByPosition(int position)
{
if (position > 0) {
final int pos = isReverse() ? getLast() - position + 1
: position;
int node;
while ((node = next()) != DTMAxisIterator.END) {
if (pos == getPosition()) {
return node;
}
}
}
return END;
} | java | public int getNodeByPosition(int position)
{
if (position > 0) {
final int pos = isReverse() ? getLast() - position + 1
: position;
int node;
while ((node = next()) != DTMAxisIterator.END) {
if (pos == getPosition()) {
return node;
}
}
}
return END;
} | [
"public",
"int",
"getNodeByPosition",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
">",
"0",
")",
"{",
"final",
"int",
"pos",
"=",
"isReverse",
"(",
")",
"?",
"getLast",
"(",
")",
"-",
"position",
"+",
"1",
":",
"position",
";",
"int",
... | Return the node at the given position.
@param position The position
@return The node at the given position. | [
"Return",
"the",
"node",
"at",
"the",
"given",
"position",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java#L266-L279 |
33,240 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.isPrivateInnerType | public static boolean isPrivateInnerType(TypeElement type) {
switch (type.getNestingKind()) {
case ANONYMOUS:
case LOCAL:
return true;
case MEMBER:
return isPrivate(type) || isPrivateInnerType((TypeElement) type.getEnclosingElement());
case TOP_LEVEL:
return isPrivate(type);
}
throw new AssertionError("Unknown NestingKind");
} | java | public static boolean isPrivateInnerType(TypeElement type) {
switch (type.getNestingKind()) {
case ANONYMOUS:
case LOCAL:
return true;
case MEMBER:
return isPrivate(type) || isPrivateInnerType((TypeElement) type.getEnclosingElement());
case TOP_LEVEL:
return isPrivate(type);
}
throw new AssertionError("Unknown NestingKind");
} | [
"public",
"static",
"boolean",
"isPrivateInnerType",
"(",
"TypeElement",
"type",
")",
"{",
"switch",
"(",
"type",
".",
"getNestingKind",
"(",
")",
")",
"{",
"case",
"ANONYMOUS",
":",
"case",
"LOCAL",
":",
"return",
"true",
";",
"case",
"MEMBER",
":",
"retu... | Tests if this type element is private to it's source file. A public type declared
within a private type is considered private. | [
"Tests",
"if",
"this",
"type",
"element",
"is",
"private",
"to",
"it",
"s",
"source",
"file",
".",
"A",
"public",
"type",
"declared",
"within",
"a",
"private",
"type",
"is",
"considered",
"private",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L312-L323 |
33,241 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.hasOuterContext | public static boolean hasOuterContext(TypeElement type) {
switch (type.getNestingKind()) {
case ANONYMOUS:
case LOCAL:
return !isStatic(type.getEnclosingElement());
case MEMBER:
return !isStatic(type);
case TOP_LEVEL:
return false;
}
throw new AssertionError("Unknown NestingKind");
} | java | public static boolean hasOuterContext(TypeElement type) {
switch (type.getNestingKind()) {
case ANONYMOUS:
case LOCAL:
return !isStatic(type.getEnclosingElement());
case MEMBER:
return !isStatic(type);
case TOP_LEVEL:
return false;
}
throw new AssertionError("Unknown NestingKind");
} | [
"public",
"static",
"boolean",
"hasOuterContext",
"(",
"TypeElement",
"type",
")",
"{",
"switch",
"(",
"type",
".",
"getNestingKind",
"(",
")",
")",
"{",
"case",
"ANONYMOUS",
":",
"case",
"LOCAL",
":",
"return",
"!",
"isStatic",
"(",
"type",
".",
"getEnclo... | Determines if a type element can access fields and methods from an outer class. | [
"Determines",
"if",
"a",
"type",
"element",
"can",
"access",
"fields",
"and",
"methods",
"from",
"an",
"outer",
"class",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L328-L339 |
33,242 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.parsePropertyAttribute | public static Set<String> parsePropertyAttribute(AnnotationMirror annotation) {
assert getName(annotation.getAnnotationType().asElement()).equals("Property");
String attributesStr = (String) getAnnotationValue(annotation, "value");
Set<String> attributes = new HashSet<>();
if (attributesStr != null) {
attributes.addAll(Arrays.asList(attributesStr.split(",\\s*")));
attributes.remove(""); // Clear any empty strings.
}
return attributes;
} | java | public static Set<String> parsePropertyAttribute(AnnotationMirror annotation) {
assert getName(annotation.getAnnotationType().asElement()).equals("Property");
String attributesStr = (String) getAnnotationValue(annotation, "value");
Set<String> attributes = new HashSet<>();
if (attributesStr != null) {
attributes.addAll(Arrays.asList(attributesStr.split(",\\s*")));
attributes.remove(""); // Clear any empty strings.
}
return attributes;
} | [
"public",
"static",
"Set",
"<",
"String",
">",
"parsePropertyAttribute",
"(",
"AnnotationMirror",
"annotation",
")",
"{",
"assert",
"getName",
"(",
"annotation",
".",
"getAnnotationType",
"(",
")",
".",
"asElement",
"(",
")",
")",
".",
"equals",
"(",
"\"Proper... | Returns the attributes of a Property annotation. | [
"Returns",
"the",
"attributes",
"of",
"a",
"Property",
"annotation",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L416-L425 |
33,243 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.findGetterMethod | public static ExecutableElement findGetterMethod(
String propertyName, TypeMirror propertyType, TypeElement declaringClass, boolean isStatic) {
// Try Objective-C getter naming convention.
ExecutableElement getter = ElementUtil.findMethod(declaringClass, propertyName);
if (getter == null) {
// Try Java getter naming conventions.
String prefix = TypeUtil.isBoolean(propertyType) ? "is" : "get";
getter = ElementUtil.findMethod(declaringClass, prefix + NameTable.capitalize(propertyName));
}
return getter != null && isStatic == isStatic(getter) ? getter : null;
} | java | public static ExecutableElement findGetterMethod(
String propertyName, TypeMirror propertyType, TypeElement declaringClass, boolean isStatic) {
// Try Objective-C getter naming convention.
ExecutableElement getter = ElementUtil.findMethod(declaringClass, propertyName);
if (getter == null) {
// Try Java getter naming conventions.
String prefix = TypeUtil.isBoolean(propertyType) ? "is" : "get";
getter = ElementUtil.findMethod(declaringClass, prefix + NameTable.capitalize(propertyName));
}
return getter != null && isStatic == isStatic(getter) ? getter : null;
} | [
"public",
"static",
"ExecutableElement",
"findGetterMethod",
"(",
"String",
"propertyName",
",",
"TypeMirror",
"propertyType",
",",
"TypeElement",
"declaringClass",
",",
"boolean",
"isStatic",
")",
"{",
"// Try Objective-C getter naming convention.",
"ExecutableElement",
"get... | Locate method which matches either Java or Objective C getter name patterns. | [
"Locate",
"method",
"which",
"matches",
"either",
"Java",
"or",
"Objective",
"C",
"getter",
"name",
"patterns",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L482-L492 |
33,244 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.fromModifierSet | public static int fromModifierSet(Set<Modifier> set) {
int modifiers = 0;
if (set.contains(Modifier.PUBLIC)) {
modifiers |= java.lang.reflect.Modifier.PUBLIC;
}
if (set.contains(Modifier.PRIVATE)) {
modifiers |= java.lang.reflect.Modifier.PRIVATE;
}
if (set.contains(Modifier.PROTECTED)) {
modifiers |= java.lang.reflect.Modifier.PROTECTED;
}
if (set.contains(Modifier.STATIC)) {
modifiers |= java.lang.reflect.Modifier.STATIC;
}
if (set.contains(Modifier.FINAL)) {
modifiers |= java.lang.reflect.Modifier.FINAL;
}
if (set.contains(Modifier.SYNCHRONIZED)) {
modifiers |= java.lang.reflect.Modifier.SYNCHRONIZED;
}
if (set.contains(Modifier.VOLATILE)) {
modifiers |= java.lang.reflect.Modifier.VOLATILE;
}
if (set.contains(Modifier.TRANSIENT)) {
modifiers |= java.lang.reflect.Modifier.TRANSIENT;
}
if (set.contains(Modifier.NATIVE)) {
modifiers |= java.lang.reflect.Modifier.NATIVE;
}
if (set.contains(Modifier.ABSTRACT)) {
modifiers |= java.lang.reflect.Modifier.ABSTRACT;
}
if (set.contains(Modifier.STRICTFP)) {
modifiers |= java.lang.reflect.Modifier.STRICT;
}
return modifiers;
} | java | public static int fromModifierSet(Set<Modifier> set) {
int modifiers = 0;
if (set.contains(Modifier.PUBLIC)) {
modifiers |= java.lang.reflect.Modifier.PUBLIC;
}
if (set.contains(Modifier.PRIVATE)) {
modifiers |= java.lang.reflect.Modifier.PRIVATE;
}
if (set.contains(Modifier.PROTECTED)) {
modifiers |= java.lang.reflect.Modifier.PROTECTED;
}
if (set.contains(Modifier.STATIC)) {
modifiers |= java.lang.reflect.Modifier.STATIC;
}
if (set.contains(Modifier.FINAL)) {
modifiers |= java.lang.reflect.Modifier.FINAL;
}
if (set.contains(Modifier.SYNCHRONIZED)) {
modifiers |= java.lang.reflect.Modifier.SYNCHRONIZED;
}
if (set.contains(Modifier.VOLATILE)) {
modifiers |= java.lang.reflect.Modifier.VOLATILE;
}
if (set.contains(Modifier.TRANSIENT)) {
modifiers |= java.lang.reflect.Modifier.TRANSIENT;
}
if (set.contains(Modifier.NATIVE)) {
modifiers |= java.lang.reflect.Modifier.NATIVE;
}
if (set.contains(Modifier.ABSTRACT)) {
modifiers |= java.lang.reflect.Modifier.ABSTRACT;
}
if (set.contains(Modifier.STRICTFP)) {
modifiers |= java.lang.reflect.Modifier.STRICT;
}
return modifiers;
} | [
"public",
"static",
"int",
"fromModifierSet",
"(",
"Set",
"<",
"Modifier",
">",
"set",
")",
"{",
"int",
"modifiers",
"=",
"0",
";",
"if",
"(",
"set",
".",
"contains",
"(",
"Modifier",
".",
"PUBLIC",
")",
")",
"{",
"modifiers",
"|=",
"java",
".",
"lan... | This conversion is lossy because there is no bit for "default" the JVM spec. | [
"This",
"conversion",
"is",
"lossy",
"because",
"there",
"is",
"no",
"bit",
"for",
"default",
"the",
"JVM",
"spec",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L581-L617 |
33,245 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.hasNamedAnnotation | public static boolean hasNamedAnnotation(AnnotatedConstruct ac, String name) {
for (AnnotationMirror annotation : ac.getAnnotationMirrors()) {
if (getName(annotation.getAnnotationType().asElement()).equals(name)) {
return true;
}
}
return false;
} | java | public static boolean hasNamedAnnotation(AnnotatedConstruct ac, String name) {
for (AnnotationMirror annotation : ac.getAnnotationMirrors()) {
if (getName(annotation.getAnnotationType().asElement()).equals(name)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasNamedAnnotation",
"(",
"AnnotatedConstruct",
"ac",
",",
"String",
"name",
")",
"{",
"for",
"(",
"AnnotationMirror",
"annotation",
":",
"ac",
".",
"getAnnotationMirrors",
"(",
")",
")",
"{",
"if",
"(",
"getName",
"(",
"annotat... | Less strict version of the above where we don't care about the annotation's package. | [
"Less",
"strict",
"version",
"of",
"the",
"above",
"where",
"we",
"don",
"t",
"care",
"about",
"the",
"annotation",
"s",
"package",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L662-L669 |
33,246 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.hasNamedAnnotation | public static boolean hasNamedAnnotation(AnnotatedConstruct ac, Pattern pattern) {
for (AnnotationMirror annotation : ac.getAnnotationMirrors()) {
if (pattern.matcher(getName(annotation.getAnnotationType().asElement())).matches()) {
return true;
}
}
return false;
} | java | public static boolean hasNamedAnnotation(AnnotatedConstruct ac, Pattern pattern) {
for (AnnotationMirror annotation : ac.getAnnotationMirrors()) {
if (pattern.matcher(getName(annotation.getAnnotationType().asElement())).matches()) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasNamedAnnotation",
"(",
"AnnotatedConstruct",
"ac",
",",
"Pattern",
"pattern",
")",
"{",
"for",
"(",
"AnnotationMirror",
"annotation",
":",
"ac",
".",
"getAnnotationMirrors",
"(",
")",
")",
"{",
"if",
"(",
"pattern",
".",
"mat... | Similar to the above but matches against a pattern. | [
"Similar",
"to",
"the",
"above",
"but",
"matches",
"against",
"a",
"pattern",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L672-L679 |
33,247 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.getSortedAnnotationMembers | public static List<ExecutableElement> getSortedAnnotationMembers(TypeElement annotation) {
List<ExecutableElement> members = Lists.newArrayList(getMethods(annotation));
Collections.sort(members, (m1, m2) -> getName(m1).compareTo(getName(m2)));
return members;
} | java | public static List<ExecutableElement> getSortedAnnotationMembers(TypeElement annotation) {
List<ExecutableElement> members = Lists.newArrayList(getMethods(annotation));
Collections.sort(members, (m1, m2) -> getName(m1).compareTo(getName(m2)));
return members;
} | [
"public",
"static",
"List",
"<",
"ExecutableElement",
">",
"getSortedAnnotationMembers",
"(",
"TypeElement",
"annotation",
")",
"{",
"List",
"<",
"ExecutableElement",
">",
"members",
"=",
"Lists",
".",
"newArrayList",
"(",
"getMethods",
"(",
"annotation",
")",
")"... | Returns an alphabetically sorted list of an annotation type's members.
This is necessary since an annotation's values can be specified in any
order, but the annotation's constructor needs to be invoked using its
declaration order. | [
"Returns",
"an",
"alphabetically",
"sorted",
"list",
"of",
"an",
"annotation",
"type",
"s",
"members",
".",
"This",
"is",
"necessary",
"since",
"an",
"annotation",
"s",
"values",
"can",
"be",
"specified",
"in",
"any",
"order",
"but",
"the",
"annotation",
"s"... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L749-L753 |
33,248 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.suppressesWarning | @SuppressWarnings("unchecked")
public static boolean suppressesWarning(String warning, Element element) {
if (element == null || isPackage(element)) {
return false;
}
AnnotationMirror annotation = getAnnotation(element, SuppressWarnings.class);
if (annotation != null) {
for (AnnotationValue elem
: (List<? extends AnnotationValue>) getAnnotationValue(annotation, "value")) {
if (warning.equals(elem.getValue())) {
return true;
}
}
}
return suppressesWarning(warning, element.getEnclosingElement());
} | java | @SuppressWarnings("unchecked")
public static boolean suppressesWarning(String warning, Element element) {
if (element == null || isPackage(element)) {
return false;
}
AnnotationMirror annotation = getAnnotation(element, SuppressWarnings.class);
if (annotation != null) {
for (AnnotationValue elem
: (List<? extends AnnotationValue>) getAnnotationValue(annotation, "value")) {
if (warning.equals(elem.getValue())) {
return true;
}
}
}
return suppressesWarning(warning, element.getEnclosingElement());
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"boolean",
"suppressesWarning",
"(",
"String",
"warning",
",",
"Element",
"element",
")",
"{",
"if",
"(",
"element",
"==",
"null",
"||",
"isPackage",
"(",
"element",
")",
")",
"{",
"retu... | Returns true if there's a SuppressedWarning annotation with the specified warning.
The SuppressWarnings annotation can be inherited from the owning method or class,
but does not have package scope. | [
"Returns",
"true",
"if",
"there",
"s",
"a",
"SuppressedWarning",
"annotation",
"with",
"the",
"specified",
"warning",
".",
"The",
"SuppressWarnings",
"annotation",
"can",
"be",
"inherited",
"from",
"the",
"owning",
"method",
"or",
"class",
"but",
"does",
"not",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L769-L784 |
33,249 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.getType | public TypeMirror getType(Element element) {
return elementTypeMap.containsKey(element) ? elementTypeMap.get(element) : element.asType();
} | java | public TypeMirror getType(Element element) {
return elementTypeMap.containsKey(element) ? elementTypeMap.get(element) : element.asType();
} | [
"public",
"TypeMirror",
"getType",
"(",
"Element",
"element",
")",
"{",
"return",
"elementTypeMap",
".",
"containsKey",
"(",
"element",
")",
"?",
"elementTypeMap",
".",
"get",
"(",
"element",
")",
":",
"element",
".",
"asType",
"(",
")",
";",
"}"
] | Returns the associated type mirror for an element. | [
"Returns",
"the",
"associated",
"type",
"mirror",
"for",
"an",
"element",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L799-L801 |
33,250 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.isNonnull | public static boolean isNonnull(Element element, boolean parametersNonnullByDefault) {
return hasNonnullAnnotation(element)
|| isConstructor(element) // Java constructors are always non-null.
|| (isParameter(element)
&& parametersNonnullByDefault
&& !((VariableElement) element).asType().getKind().isPrimitive());
} | java | public static boolean isNonnull(Element element, boolean parametersNonnullByDefault) {
return hasNonnullAnnotation(element)
|| isConstructor(element) // Java constructors are always non-null.
|| (isParameter(element)
&& parametersNonnullByDefault
&& !((VariableElement) element).asType().getKind().isPrimitive());
} | [
"public",
"static",
"boolean",
"isNonnull",
"(",
"Element",
"element",
",",
"boolean",
"parametersNonnullByDefault",
")",
"{",
"return",
"hasNonnullAnnotation",
"(",
"element",
")",
"||",
"isConstructor",
"(",
"element",
")",
"// Java constructors are always non-null.",
... | Returns whether an element is marked as always being non-null. Field, method,
and parameter elements can be defined as non-null with a Nonnull annotation.
Method parameters can also be defined as non-null by annotating the owning
package or type element with the ParametersNonnullByDefault annotation. | [
"Returns",
"whether",
"an",
"element",
"is",
"marked",
"as",
"always",
"being",
"non",
"-",
"null",
".",
"Field",
"method",
"and",
"parameter",
"elements",
"can",
"be",
"defined",
"as",
"non",
"-",
"null",
"with",
"a",
"Nonnull",
"annotation",
".",
"Method... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L809-L815 |
33,251 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java | ElementUtil.getSourceFile | public static String getSourceFile(TypeElement type) {
if (type instanceof ClassSymbol) {
JavaFileObject srcFile = ((ClassSymbol) type).sourcefile;
if (srcFile != null) {
return srcFile.getName();
}
}
return null;
} | java | public static String getSourceFile(TypeElement type) {
if (type instanceof ClassSymbol) {
JavaFileObject srcFile = ((ClassSymbol) type).sourcefile;
if (srcFile != null) {
return srcFile.getName();
}
}
return null;
} | [
"public",
"static",
"String",
"getSourceFile",
"(",
"TypeElement",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"ClassSymbol",
")",
"{",
"JavaFileObject",
"srcFile",
"=",
"(",
"(",
"ClassSymbol",
")",
"type",
")",
".",
"sourcefile",
";",
"if",
"(",
"... | Returns the source file name for a type element. Returns null if the element
isn't a javac ClassSymbol, or if it is defined by a classfile which was compiled
without a source attribute. | [
"Returns",
"the",
"source",
"file",
"name",
"for",
"a",
"type",
"element",
".",
"Returns",
"null",
"if",
"the",
"element",
"isn",
"t",
"a",
"javac",
"ClassSymbol",
"or",
"if",
"it",
"is",
"defined",
"by",
"a",
"classfile",
"which",
"was",
"compiled",
"wi... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ElementUtil.java#L822-L830 |
33,252 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/SystemIDResolver.java | SystemIDResolver.isAbsolutePath | public static boolean isAbsolutePath(String systemId)
{
if(systemId == null)
return false;
final File file = new File(systemId);
return file.isAbsolute();
} | java | public static boolean isAbsolutePath(String systemId)
{
if(systemId == null)
return false;
final File file = new File(systemId);
return file.isAbsolute();
} | [
"public",
"static",
"boolean",
"isAbsolutePath",
"(",
"String",
"systemId",
")",
"{",
"if",
"(",
"systemId",
"==",
"null",
")",
"return",
"false",
";",
"final",
"File",
"file",
"=",
"new",
"File",
"(",
"systemId",
")",
";",
"return",
"file",
".",
"isAbso... | Return true if the local path is an absolute path.
@param systemId The path string
@return true if the path is absolute | [
"Return",
"true",
"if",
"the",
"local",
"path",
"is",
"an",
"absolute",
"path",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/SystemIDResolver.java#L148-L155 |
33,253 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/SystemIDResolver.java | SystemIDResolver.replaceChars | private static String replaceChars(String str)
{
StringBuffer buf = new StringBuffer(str);
int length = buf.length();
for (int i = 0; i < length; i++)
{
char currentChar = buf.charAt(i);
// Replace space with "%20"
if (currentChar == ' ')
{
buf.setCharAt(i, '%');
buf.insert(i+1, "20");
length = length + 2;
i = i + 2;
}
// Replace backslash with forward slash
else if (currentChar == '\\')
{
buf.setCharAt(i, '/');
}
}
return buf.toString();
} | java | private static String replaceChars(String str)
{
StringBuffer buf = new StringBuffer(str);
int length = buf.length();
for (int i = 0; i < length; i++)
{
char currentChar = buf.charAt(i);
// Replace space with "%20"
if (currentChar == ' ')
{
buf.setCharAt(i, '%');
buf.insert(i+1, "20");
length = length + 2;
i = i + 2;
}
// Replace backslash with forward slash
else if (currentChar == '\\')
{
buf.setCharAt(i, '/');
}
}
return buf.toString();
} | [
"private",
"static",
"String",
"replaceChars",
"(",
"String",
"str",
")",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
"str",
")",
";",
"int",
"length",
"=",
"buf",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
... | Replace spaces with "%20" and backslashes with forward slashes in
the input string to generate a well-formed URI string.
@param str The input string
@return The string after conversion | [
"Replace",
"spaces",
"with",
"%20",
"and",
"backslashes",
"with",
"forward",
"slashes",
"in",
"the",
"input",
"string",
"to",
"generate",
"a",
"well",
"-",
"formed",
"URI",
"string",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/SystemIDResolver.java#L183-L206 |
33,254 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.newList | public static ProviderList newList(Provider ... providers) {
ProviderConfig[] configs = new ProviderConfig[providers.length];
for (int i = 0; i < providers.length; i++) {
configs[i] = new ProviderConfig(providers[i]);
}
return new ProviderList(configs, true);
} | java | public static ProviderList newList(Provider ... providers) {
ProviderConfig[] configs = new ProviderConfig[providers.length];
for (int i = 0; i < providers.length; i++) {
configs[i] = new ProviderConfig(providers[i]);
}
return new ProviderList(configs, true);
} | [
"public",
"static",
"ProviderList",
"newList",
"(",
"Provider",
"...",
"providers",
")",
"{",
"ProviderConfig",
"[",
"]",
"configs",
"=",
"new",
"ProviderConfig",
"[",
"providers",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",... | This method is for use by SunJSSE. | [
"This",
"method",
"is",
"for",
"use",
"by",
"SunJSSE",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L134-L140 |
33,255 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.getJarList | ProviderList getJarList(String[] jarClassNames) {
List<ProviderConfig> newConfigs = new ArrayList<>();
for (String className : jarClassNames) {
ProviderConfig newConfig = new ProviderConfig(className);
for (ProviderConfig config : configs) {
// if the equivalent object is present in this provider list,
// use the old object rather than the new object.
// this ensures that when the provider is loaded in the
// new thread local list, it will also become available
// in this provider list
if (config.equals(newConfig)) {
newConfig = config;
break;
}
}
newConfigs.add(newConfig);
}
ProviderConfig[] configArray = newConfigs.toArray(PC0);
return new ProviderList(configArray, false);
} | java | ProviderList getJarList(String[] jarClassNames) {
List<ProviderConfig> newConfigs = new ArrayList<>();
for (String className : jarClassNames) {
ProviderConfig newConfig = new ProviderConfig(className);
for (ProviderConfig config : configs) {
// if the equivalent object is present in this provider list,
// use the old object rather than the new object.
// this ensures that when the provider is loaded in the
// new thread local list, it will also become available
// in this provider list
if (config.equals(newConfig)) {
newConfig = config;
break;
}
}
newConfigs.add(newConfig);
}
ProviderConfig[] configArray = newConfigs.toArray(PC0);
return new ProviderList(configArray, false);
} | [
"ProviderList",
"getJarList",
"(",
"String",
"[",
"]",
"jarClassNames",
")",
"{",
"List",
"<",
"ProviderConfig",
">",
"newConfigs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"className",
":",
"jarClassNames",
")",
"{",
"ProviderConf... | Construct a special ProviderList for JAR verification. It consists
of the providers specified via jarClassNames, which must be on the
bootclasspath and cannot be in signed JAR files. This is to avoid
possible recursion and deadlock during verification. | [
"Construct",
"a",
"special",
"ProviderList",
"for",
"JAR",
"verification",
".",
"It",
"consists",
"of",
"the",
"providers",
"specified",
"via",
"jarClassNames",
"which",
"must",
"be",
"on",
"the",
"bootclasspath",
"and",
"cannot",
"be",
"in",
"signed",
"JAR",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L209-L228 |
33,256 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.getProvider | Provider getProvider(int index) {
Provider p = configs[index].getProvider();
return (p != null) ? p : EMPTY_PROVIDER;
} | java | Provider getProvider(int index) {
Provider p = configs[index].getProvider();
return (p != null) ? p : EMPTY_PROVIDER;
} | [
"Provider",
"getProvider",
"(",
"int",
"index",
")",
"{",
"Provider",
"p",
"=",
"configs",
"[",
"index",
"]",
".",
"getProvider",
"(",
")",
";",
"return",
"(",
"p",
"!=",
"null",
")",
"?",
"p",
":",
"EMPTY_PROVIDER",
";",
"}"
] | Return the Provider at the specified index. Returns EMPTY_PROVIDER
if the provider could not be loaded at this time. | [
"Return",
"the",
"Provider",
"at",
"the",
"specified",
"index",
".",
"Returns",
"EMPTY_PROVIDER",
"if",
"the",
"provider",
"could",
"not",
"be",
"loaded",
"at",
"this",
"time",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L238-L241 |
33,257 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.getProvider | public Provider getProvider(String name) {
ProviderConfig config = getProviderConfig(name);
return (config == null) ? null : config.getProvider();
} | java | public Provider getProvider(String name) {
ProviderConfig config = getProviderConfig(name);
return (config == null) ? null : config.getProvider();
} | [
"public",
"Provider",
"getProvider",
"(",
"String",
"name",
")",
"{",
"ProviderConfig",
"config",
"=",
"getProviderConfig",
"(",
"name",
")",
";",
"return",
"(",
"config",
"==",
"null",
")",
"?",
"null",
":",
"config",
".",
"getProvider",
"(",
")",
";",
... | return the Provider with the specified name or null | [
"return",
"the",
"Provider",
"with",
"the",
"specified",
"name",
"or",
"null"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L258-L261 |
33,258 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.getIndex | public int getIndex(String name) {
for (int i = 0; i < configs.length; i++) {
Provider p = getProvider(i);
if (p.getName().equals(name)) {
return i;
}
}
return -1;
} | java | public int getIndex(String name) {
for (int i = 0; i < configs.length; i++) {
Provider p = getProvider(i);
if (p.getName().equals(name)) {
return i;
}
}
return -1;
} | [
"public",
"int",
"getIndex",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"configs",
".",
"length",
";",
"i",
"++",
")",
"{",
"Provider",
"p",
"=",
"getProvider",
"(",
"i",
")",
";",
"if",
"(",
"p",
".",
"... | Return the index at which the provider with the specified name is
installed or -1 if it is not present in this ProviderList. | [
"Return",
"the",
"index",
"at",
"which",
"the",
"provider",
"with",
"the",
"specified",
"name",
"is",
"installed",
"or",
"-",
"1",
"if",
"it",
"is",
"not",
"present",
"in",
"this",
"ProviderList",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L267-L275 |
33,259 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.loadAll | private int loadAll() {
if (allLoaded) {
return configs.length;
}
if (debug != null) {
debug.println("Loading all providers");
new Exception("Call trace").printStackTrace();
}
int n = 0;
for (int i = 0; i < configs.length; i++) {
Provider p = configs[i].getProvider();
if (p != null) {
n++;
}
}
if (n == configs.length) {
allLoaded = true;
}
return n;
} | java | private int loadAll() {
if (allLoaded) {
return configs.length;
}
if (debug != null) {
debug.println("Loading all providers");
new Exception("Call trace").printStackTrace();
}
int n = 0;
for (int i = 0; i < configs.length; i++) {
Provider p = configs[i].getProvider();
if (p != null) {
n++;
}
}
if (n == configs.length) {
allLoaded = true;
}
return n;
} | [
"private",
"int",
"loadAll",
"(",
")",
"{",
"if",
"(",
"allLoaded",
")",
"{",
"return",
"configs",
".",
"length",
";",
"}",
"if",
"(",
"debug",
"!=",
"null",
")",
"{",
"debug",
".",
"println",
"(",
"\"Loading all providers\"",
")",
";",
"new",
"Excepti... | attempt to load all Providers not already loaded | [
"attempt",
"to",
"load",
"all",
"Providers",
"not",
"already",
"loaded"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L278-L297 |
33,260 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.removeInvalid | ProviderList removeInvalid() {
int n = loadAll();
if (n == configs.length) {
return this;
}
ProviderConfig[] newConfigs = new ProviderConfig[n];
for (int i = 0, j = 0; i < configs.length; i++) {
ProviderConfig config = configs[i];
if (config.isLoaded()) {
newConfigs[j++] = config;
}
}
return new ProviderList(newConfigs, true);
} | java | ProviderList removeInvalid() {
int n = loadAll();
if (n == configs.length) {
return this;
}
ProviderConfig[] newConfigs = new ProviderConfig[n];
for (int i = 0, j = 0; i < configs.length; i++) {
ProviderConfig config = configs[i];
if (config.isLoaded()) {
newConfigs[j++] = config;
}
}
return new ProviderList(newConfigs, true);
} | [
"ProviderList",
"removeInvalid",
"(",
")",
"{",
"int",
"n",
"=",
"loadAll",
"(",
")",
";",
"if",
"(",
"n",
"==",
"configs",
".",
"length",
")",
"{",
"return",
"this",
";",
"}",
"ProviderConfig",
"[",
"]",
"newConfigs",
"=",
"new",
"ProviderConfig",
"["... | Try to load all Providers and return the ProviderList. If one or
more Providers could not be loaded, a new ProviderList with those
entries removed is returned. Otherwise, the method returns this. | [
"Try",
"to",
"load",
"all",
"Providers",
"and",
"return",
"the",
"ProviderList",
".",
"If",
"one",
"or",
"more",
"Providers",
"could",
"not",
"be",
"loaded",
"a",
"new",
"ProviderList",
"with",
"those",
"entries",
"removed",
"is",
"returned",
".",
"Otherwise... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L304-L317 |
33,261 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.getService | public Service getService(String type, String name) {
for (int i = 0; i < configs.length; i++) {
Provider p = getProvider(i);
Service s = p.getService(type, name);
if (s != null) {
return s;
}
}
return null;
} | java | public Service getService(String type, String name) {
for (int i = 0; i < configs.length; i++) {
Provider p = getProvider(i);
Service s = p.getService(type, name);
if (s != null) {
return s;
}
}
return null;
} | [
"public",
"Service",
"getService",
"(",
"String",
"type",
",",
"String",
"name",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"configs",
".",
"length",
";",
"i",
"++",
")",
"{",
"Provider",
"p",
"=",
"getProvider",
"(",
"i",
")",
";... | Return a Service describing an implementation of the specified
algorithm from the Provider with the highest precedence that
supports that algorithm. Return null if no Provider supports this
algorithm. | [
"Return",
"a",
"Service",
"describing",
"an",
"implementation",
"of",
"the",
"specified",
"algorithm",
"from",
"the",
"Provider",
"with",
"the",
"highest",
"precedence",
"that",
"supports",
"that",
"algorithm",
".",
"Return",
"null",
"if",
"no",
"Provider",
"sup... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L335-L344 |
33,262 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java | ProviderList.getServices | public List<Service> getServices(String type, String algorithm) {
return new ServiceList(type, algorithm);
} | java | public List<Service> getServices(String type, String algorithm) {
return new ServiceList(type, algorithm);
} | [
"public",
"List",
"<",
"Service",
">",
"getServices",
"(",
"String",
"type",
",",
"String",
"algorithm",
")",
"{",
"return",
"new",
"ServiceList",
"(",
"type",
",",
"algorithm",
")",
";",
"}"
] | Return a List containing all the Services describing implementations
of the specified algorithms in precedence order. If no implementation
exists, this method returns an empty List.
The elements of this list are determined lazily on demand.
The List returned is NOT thread safe. | [
"Return",
"a",
"List",
"containing",
"all",
"the",
"Services",
"describing",
"implementations",
"of",
"the",
"specified",
"algorithms",
"in",
"precedence",
"order",
".",
"If",
"no",
"implementation",
"exists",
"this",
"method",
"returns",
"an",
"empty",
"List",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/ProviderList.java#L355-L357 |
33,263 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Formatter.java | Formatter.format | public Formatter format(String format, Object ... args) {
return format(l, format, args);
} | java | public Formatter format(String format, Object ... args) {
return format(l, format, args);
} | [
"public",
"Formatter",
"format",
"(",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"format",
"(",
"l",
",",
"format",
",",
"args",
")",
";",
"}"
] | Writes a formatted string to this object's destination using the
specified format string and arguments. The locale used is the one
defined during the construction of this formatter.
@param format
A format string as described in <a href="#syntax">Format string
syntax</a>.
@param args
Arguments referenced by the format specifiers in the format
string. If there are more arguments than format specifiers, the
extra arguments are ignored. The maximum number of arguments is
limited by the maximum dimension of a Java array as defined by
<cite>The Java™ Virtual Machine Specification</cite>.
@throws IllegalFormatException
If a format string contains an illegal syntax, a format
specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other
illegal conditions. For specification of all possible
formatting errors, see the <a href="#detail">Details</a>
section of the formatter class specification.
@throws FormatterClosedException
If this formatter has been closed by invoking its {@link
#close()} method
@return This formatter | [
"Writes",
"a",
"formatted",
"string",
"to",
"this",
"object",
"s",
"destination",
"using",
"the",
"specified",
"format",
"string",
"and",
"arguments",
".",
"The",
"locale",
"used",
"is",
"the",
"one",
"defined",
"during",
"the",
"construction",
"of",
"this",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Formatter.java#L2450-L2452 |
33,264 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Formatter.java | Formatter.format | public Formatter format(Locale l, String format, Object ... args) {
ensureOpen();
// index of last argument referenced
int last = -1;
// last ordinary index
int lasto = -1;
FormatString[] fsa = parse(format);
for (int i = 0; i < fsa.length; i++) {
FormatString fs = fsa[i];
int index = fs.index();
try {
switch (index) {
case -2: // fixed string, "%n", or "%%"
fs.print(null, l);
break;
case -1: // relative index
if (last < 0 || (args != null && last > args.length - 1))
throw new MissingFormatArgumentException(fs.toString());
fs.print((args == null ? null : args[last]), l);
break;
case 0: // ordinary index
lasto++;
last = lasto;
if (args != null && lasto > args.length - 1)
throw new MissingFormatArgumentException(fs.toString());
fs.print((args == null ? null : args[lasto]), l);
break;
default: // explicit index
last = index - 1;
if (args != null && last > args.length - 1)
throw new MissingFormatArgumentException(fs.toString());
fs.print((args == null ? null : args[last]), l);
break;
}
} catch (IOException x) {
lastException = x;
}
}
return this;
} | java | public Formatter format(Locale l, String format, Object ... args) {
ensureOpen();
// index of last argument referenced
int last = -1;
// last ordinary index
int lasto = -1;
FormatString[] fsa = parse(format);
for (int i = 0; i < fsa.length; i++) {
FormatString fs = fsa[i];
int index = fs.index();
try {
switch (index) {
case -2: // fixed string, "%n", or "%%"
fs.print(null, l);
break;
case -1: // relative index
if (last < 0 || (args != null && last > args.length - 1))
throw new MissingFormatArgumentException(fs.toString());
fs.print((args == null ? null : args[last]), l);
break;
case 0: // ordinary index
lasto++;
last = lasto;
if (args != null && lasto > args.length - 1)
throw new MissingFormatArgumentException(fs.toString());
fs.print((args == null ? null : args[lasto]), l);
break;
default: // explicit index
last = index - 1;
if (args != null && last > args.length - 1)
throw new MissingFormatArgumentException(fs.toString());
fs.print((args == null ? null : args[last]), l);
break;
}
} catch (IOException x) {
lastException = x;
}
}
return this;
} | [
"public",
"Formatter",
"format",
"(",
"Locale",
"l",
",",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"ensureOpen",
"(",
")",
";",
"// index of last argument referenced",
"int",
"last",
"=",
"-",
"1",
";",
"// last ordinary index",
"int",
"last... | Writes a formatted string to this object's destination using the
specified locale, format string, and arguments.
@param l
The {@linkplain java.util.Locale locale} to apply during
formatting. If {@code l} is {@code null} then no localization
is applied. This does not change this object's locale that was
set during construction.
@param format
A format string as described in <a href="#syntax">Format string
syntax</a>
@param args
Arguments referenced by the format specifiers in the format
string. If there are more arguments than format specifiers, the
extra arguments are ignored. The maximum number of arguments is
limited by the maximum dimension of a Java array as defined by
<cite>The Java™ Virtual Machine Specification</cite>.
@throws IllegalFormatException
If a format string contains an illegal syntax, a format
specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other
illegal conditions. For specification of all possible
formatting errors, see the <a href="#detail">Details</a>
section of the formatter class specification.
@throws FormatterClosedException
If this formatter has been closed by invoking its {@link
#close()} method
@return This formatter | [
"Writes",
"a",
"formatted",
"string",
"to",
"this",
"object",
"s",
"destination",
"using",
"the",
"specified",
"locale",
"format",
"string",
"and",
"arguments",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Formatter.java#L2489-L2530 |
33,265 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Formatter.java | Formatter.parse | private FormatString[] parse(String s) {
ArrayList<FormatString> al = new ArrayList<>();
for (int i = 0, len = s.length(); i < len; ) {
int nextPercent = s.indexOf('%', i);
if (s.charAt(i) != '%') {
// This is plain-text part, find the maximal plain-text
// sequence and store it.
int plainTextStart = i;
int plainTextEnd = (nextPercent == -1) ? len: nextPercent;
al.add(new FixedString(s.substring(plainTextStart,
plainTextEnd)));
i = plainTextEnd;
} else {
// We have a format specifier
FormatSpecifierParser fsp = new FormatSpecifierParser(s, i + 1);
al.add(fsp.getFormatSpecifier());
i = fsp.getEndIdx();
}
}
return al.toArray(new FormatString[al.size()]);
} | java | private FormatString[] parse(String s) {
ArrayList<FormatString> al = new ArrayList<>();
for (int i = 0, len = s.length(); i < len; ) {
int nextPercent = s.indexOf('%', i);
if (s.charAt(i) != '%') {
// This is plain-text part, find the maximal plain-text
// sequence and store it.
int plainTextStart = i;
int plainTextEnd = (nextPercent == -1) ? len: nextPercent;
al.add(new FixedString(s.substring(plainTextStart,
plainTextEnd)));
i = plainTextEnd;
} else {
// We have a format specifier
FormatSpecifierParser fsp = new FormatSpecifierParser(s, i + 1);
al.add(fsp.getFormatSpecifier());
i = fsp.getEndIdx();
}
}
return al.toArray(new FormatString[al.size()]);
} | [
"private",
"FormatString",
"[",
"]",
"parse",
"(",
"String",
"s",
")",
"{",
"ArrayList",
"<",
"FormatString",
">",
"al",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"len",
"=",
"s",
".",
"length",
"(",
")"... | Finds format specifiers in the format string. | [
"Finds",
"format",
"specifiers",
"in",
"the",
"format",
"string",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Formatter.java#L2536-L2556 |
33,266 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.failsChecks | public boolean failsChecks(String text, CheckResult checkResult) {
int length = text.length();
int result = 0;
if (checkResult != null) {
checkResult.position = 0;
checkResult.numerics = null;
checkResult.restrictionLevel = null;
}
if (0 != (this.fChecks & RESTRICTION_LEVEL)) {
RestrictionLevel textRestrictionLevel = getRestrictionLevel(text);
if (textRestrictionLevel.compareTo(fRestrictionLevel) > 0) {
result |= RESTRICTION_LEVEL;
}
if (checkResult != null) {
checkResult.restrictionLevel = textRestrictionLevel;
}
}
if (0 != (this.fChecks & MIXED_NUMBERS)) {
UnicodeSet numerics = new UnicodeSet();
getNumerics(text, numerics);
if (numerics.size() > 1) {
result |= MIXED_NUMBERS;
}
if (checkResult != null) {
checkResult.numerics = numerics;
}
}
if (0 != (this.fChecks & CHAR_LIMIT)) {
int i;
int c;
for (i = 0; i < length;) {
// U16_NEXT(text, i, length, c);
c = Character.codePointAt(text, i);
i = Character.offsetByCodePoints(text, i, 1);
if (!this.fAllowedCharsSet.contains(c)) {
result |= CHAR_LIMIT;
break;
}
}
}
if (0 != (this.fChecks & INVISIBLE)) {
// This check needs to be done on NFD input
String nfdText = nfdNormalizer.normalize(text);
// scan for more than one occurrence of the same non-spacing mark
// in a sequence of non-spacing marks.
int i;
int c;
int firstNonspacingMark = 0;
boolean haveMultipleMarks = false;
UnicodeSet marksSeenSoFar = new UnicodeSet(); // Set of combining marks in a
// single combining sequence.
for (i = 0; i < length;) {
c = Character.codePointAt(nfdText, i);
i = Character.offsetByCodePoints(nfdText, i, 1);
if (Character.getType(c) != UCharacterCategory.NON_SPACING_MARK) {
firstNonspacingMark = 0;
if (haveMultipleMarks) {
marksSeenSoFar.clear();
haveMultipleMarks = false;
}
continue;
}
if (firstNonspacingMark == 0) {
firstNonspacingMark = c;
continue;
}
if (!haveMultipleMarks) {
marksSeenSoFar.add(firstNonspacingMark);
haveMultipleMarks = true;
}
if (marksSeenSoFar.contains(c)) {
// report the error, and stop scanning.
// No need to find more than the first failure.
result |= INVISIBLE;
break;
}
marksSeenSoFar.add(c);
}
}
if (checkResult != null) {
checkResult.checks = result;
}
return (0 != result);
} | java | public boolean failsChecks(String text, CheckResult checkResult) {
int length = text.length();
int result = 0;
if (checkResult != null) {
checkResult.position = 0;
checkResult.numerics = null;
checkResult.restrictionLevel = null;
}
if (0 != (this.fChecks & RESTRICTION_LEVEL)) {
RestrictionLevel textRestrictionLevel = getRestrictionLevel(text);
if (textRestrictionLevel.compareTo(fRestrictionLevel) > 0) {
result |= RESTRICTION_LEVEL;
}
if (checkResult != null) {
checkResult.restrictionLevel = textRestrictionLevel;
}
}
if (0 != (this.fChecks & MIXED_NUMBERS)) {
UnicodeSet numerics = new UnicodeSet();
getNumerics(text, numerics);
if (numerics.size() > 1) {
result |= MIXED_NUMBERS;
}
if (checkResult != null) {
checkResult.numerics = numerics;
}
}
if (0 != (this.fChecks & CHAR_LIMIT)) {
int i;
int c;
for (i = 0; i < length;) {
// U16_NEXT(text, i, length, c);
c = Character.codePointAt(text, i);
i = Character.offsetByCodePoints(text, i, 1);
if (!this.fAllowedCharsSet.contains(c)) {
result |= CHAR_LIMIT;
break;
}
}
}
if (0 != (this.fChecks & INVISIBLE)) {
// This check needs to be done on NFD input
String nfdText = nfdNormalizer.normalize(text);
// scan for more than one occurrence of the same non-spacing mark
// in a sequence of non-spacing marks.
int i;
int c;
int firstNonspacingMark = 0;
boolean haveMultipleMarks = false;
UnicodeSet marksSeenSoFar = new UnicodeSet(); // Set of combining marks in a
// single combining sequence.
for (i = 0; i < length;) {
c = Character.codePointAt(nfdText, i);
i = Character.offsetByCodePoints(nfdText, i, 1);
if (Character.getType(c) != UCharacterCategory.NON_SPACING_MARK) {
firstNonspacingMark = 0;
if (haveMultipleMarks) {
marksSeenSoFar.clear();
haveMultipleMarks = false;
}
continue;
}
if (firstNonspacingMark == 0) {
firstNonspacingMark = c;
continue;
}
if (!haveMultipleMarks) {
marksSeenSoFar.add(firstNonspacingMark);
haveMultipleMarks = true;
}
if (marksSeenSoFar.contains(c)) {
// report the error, and stop scanning.
// No need to find more than the first failure.
result |= INVISIBLE;
break;
}
marksSeenSoFar.add(c);
}
}
if (checkResult != null) {
checkResult.checks = result;
}
return (0 != result);
} | [
"public",
"boolean",
"failsChecks",
"(",
"String",
"text",
",",
"CheckResult",
"checkResult",
")",
"{",
"int",
"length",
"=",
"text",
".",
"length",
"(",
")",
";",
"int",
"result",
"=",
"0",
";",
"if",
"(",
"checkResult",
"!=",
"null",
")",
"{",
"check... | Check the specified string for possible security issues. The text to be checked will typically be an identifier
of some sort. The set of checks to be performed was specified when building the SpoofChecker.
@param text
A String to be checked for possible security issues.
@param checkResult
Output parameter, indicates which specific tests failed. May be null if the information is not wanted.
@return True there any issue is found with the input string. | [
"Check",
"the",
"specified",
"string",
"for",
"possible",
"security",
"issues",
".",
"The",
"text",
"to",
"be",
"checked",
"will",
"typically",
"be",
"an",
"identifier",
"of",
"some",
"sort",
".",
"The",
"set",
"of",
"checks",
"to",
"be",
"performed",
"was... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1223-L1312 |
33,267 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.areConfusable | public int areConfusable(String s1, String s2) {
//
// See section 4 of UAX 39 for the algorithm for checking whether two strings are confusable,
// and for definitions of the types (single, whole, mixed-script) of confusables.
// We only care about a few of the check flags. Ignore the others.
// If no tests relevant to this function have been specified, signal an error.
// TODO: is this really the right thing to do? It's probably an error on
// the caller's part, but logically we would just return 0 (no error).
if ((this.fChecks & CONFUSABLE) == 0) {
throw new IllegalArgumentException("No confusable checks are enabled.");
}
// Compute the skeletons and check for confusability.
String s1Skeleton = getSkeleton(s1);
String s2Skeleton = getSkeleton(s2);
if (!s1Skeleton.equals(s2Skeleton)) {
return 0;
}
// If we get here, the strings are confusable. Now we just need to set the flags for the appropriate classes
// of confusables according to UTS 39 section 4.
// Start by computing the resolved script sets of s1 and s2.
ScriptSet s1RSS = new ScriptSet();
getResolvedScriptSet(s1, s1RSS);
ScriptSet s2RSS = new ScriptSet();
getResolvedScriptSet(s2, s2RSS);
// Turn on all applicable flags
int result = 0;
if (s1RSS.intersects(s2RSS)) {
result |= SINGLE_SCRIPT_CONFUSABLE;
} else {
result |= MIXED_SCRIPT_CONFUSABLE;
if (!s1RSS.isEmpty() && !s2RSS.isEmpty()) {
result |= WHOLE_SCRIPT_CONFUSABLE;
}
}
// Turn off flags that the user doesn't want
result &= fChecks;
return result;
} | java | public int areConfusable(String s1, String s2) {
//
// See section 4 of UAX 39 for the algorithm for checking whether two strings are confusable,
// and for definitions of the types (single, whole, mixed-script) of confusables.
// We only care about a few of the check flags. Ignore the others.
// If no tests relevant to this function have been specified, signal an error.
// TODO: is this really the right thing to do? It's probably an error on
// the caller's part, but logically we would just return 0 (no error).
if ((this.fChecks & CONFUSABLE) == 0) {
throw new IllegalArgumentException("No confusable checks are enabled.");
}
// Compute the skeletons and check for confusability.
String s1Skeleton = getSkeleton(s1);
String s2Skeleton = getSkeleton(s2);
if (!s1Skeleton.equals(s2Skeleton)) {
return 0;
}
// If we get here, the strings are confusable. Now we just need to set the flags for the appropriate classes
// of confusables according to UTS 39 section 4.
// Start by computing the resolved script sets of s1 and s2.
ScriptSet s1RSS = new ScriptSet();
getResolvedScriptSet(s1, s1RSS);
ScriptSet s2RSS = new ScriptSet();
getResolvedScriptSet(s2, s2RSS);
// Turn on all applicable flags
int result = 0;
if (s1RSS.intersects(s2RSS)) {
result |= SINGLE_SCRIPT_CONFUSABLE;
} else {
result |= MIXED_SCRIPT_CONFUSABLE;
if (!s1RSS.isEmpty() && !s2RSS.isEmpty()) {
result |= WHOLE_SCRIPT_CONFUSABLE;
}
}
// Turn off flags that the user doesn't want
result &= fChecks;
return result;
} | [
"public",
"int",
"areConfusable",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"//",
"// See section 4 of UAX 39 for the algorithm for checking whether two strings are confusable,",
"// and for definitions of the types (single, whole, mixed-script) of confusables.",
"// We only ca... | Check the whether two specified strings are visually confusable. The types of confusability to be tested - single
script, mixed script, or whole script - are determined by the check options set for the SpoofChecker.
The tests to be performed are controlled by the flags SINGLE_SCRIPT_CONFUSABLE MIXED_SCRIPT_CONFUSABLE
WHOLE_SCRIPT_CONFUSABLE At least one of these tests must be selected.
ANY_CASE is a modifier for the tests. Select it if the identifiers may be of mixed case. If identifiers are case
folded for comparison and display to the user, do not select the ANY_CASE option.
@param s1
The first of the two strings to be compared for confusability.
@param s2
The second of the two strings to be compared for confusability.
@return Non-zero if s1 and s1 are confusable. If not 0, the value will indicate the type(s) of confusability
found, as defined by spoof check test constants. | [
"Check",
"the",
"whether",
"two",
"specified",
"strings",
"are",
"visually",
"confusable",
".",
"The",
"types",
"of",
"confusability",
"to",
"be",
"tested",
"-",
"single",
"script",
"mixed",
"script",
"or",
"whole",
"script",
"-",
"are",
"determined",
"by",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1344-L1387 |
33,268 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.getSkeleton | public String getSkeleton(CharSequence str) {
// Apply the skeleton mapping to the NFD normalized input string
// Accumulate the skeleton, possibly unnormalized, in a String.
String nfdId = nfdNormalizer.normalize(str);
int normalizedLen = nfdId.length();
StringBuilder skelSB = new StringBuilder();
for (int inputIndex = 0; inputIndex < normalizedLen;) {
int c = Character.codePointAt(nfdId, inputIndex);
inputIndex += Character.charCount(c);
this.fSpoofData.confusableLookup(c, skelSB);
}
String skelStr = skelSB.toString();
skelStr = nfdNormalizer.normalize(skelStr);
return skelStr;
} | java | public String getSkeleton(CharSequence str) {
// Apply the skeleton mapping to the NFD normalized input string
// Accumulate the skeleton, possibly unnormalized, in a String.
String nfdId = nfdNormalizer.normalize(str);
int normalizedLen = nfdId.length();
StringBuilder skelSB = new StringBuilder();
for (int inputIndex = 0; inputIndex < normalizedLen;) {
int c = Character.codePointAt(nfdId, inputIndex);
inputIndex += Character.charCount(c);
this.fSpoofData.confusableLookup(c, skelSB);
}
String skelStr = skelSB.toString();
skelStr = nfdNormalizer.normalize(skelStr);
return skelStr;
} | [
"public",
"String",
"getSkeleton",
"(",
"CharSequence",
"str",
")",
"{",
"// Apply the skeleton mapping to the NFD normalized input string",
"// Accumulate the skeleton, possibly unnormalized, in a String.",
"String",
"nfdId",
"=",
"nfdNormalizer",
".",
"normalize",
"(",
"str",
"... | Get the "skeleton" for an identifier string. Skeletons are a transformation of the input string; Two strings are
confusable if their skeletons are identical. See Unicode UAX 39 for additional information.
Using skeletons directly makes it possible to quickly check whether an identifier is confusable with any of some
large set of existing identifiers, by creating an efficiently searchable collection of the skeletons.
Skeletons are computed using the algorithm and data described in Unicode UAX 39.
@param str
The input string whose skeleton will be generated.
@return The output skeleton string.
@hide draft / provisional / internal are hidden on Android | [
"Get",
"the",
"skeleton",
"for",
"an",
"identifier",
"string",
".",
"Skeletons",
"are",
"a",
"transformation",
"of",
"the",
"input",
"string",
";",
"Two",
"strings",
"are",
"confusable",
"if",
"their",
"skeletons",
"are",
"identical",
".",
"See",
"Unicode",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1404-L1418 |
33,269 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.getAugmentedScriptSet | private static void getAugmentedScriptSet(int codePoint, ScriptSet result) {
result.clear();
UScript.getScriptExtensions(codePoint, result);
// Section 5.1 step 1
if (result.get(UScript.HAN)) {
result.set(UScript.HAN_WITH_BOPOMOFO);
result.set(UScript.JAPANESE);
result.set(UScript.KOREAN);
}
if (result.get(UScript.HIRAGANA)) {
result.set(UScript.JAPANESE);
}
if (result.get(UScript.KATAKANA)) {
result.set(UScript.JAPANESE);
}
if (result.get(UScript.HANGUL)) {
result.set(UScript.KOREAN);
}
if (result.get(UScript.BOPOMOFO)) {
result.set(UScript.HAN_WITH_BOPOMOFO);
}
// Section 5.1 step 2
if (result.get(UScript.COMMON) || result.get(UScript.INHERITED)) {
result.setAll();
}
} | java | private static void getAugmentedScriptSet(int codePoint, ScriptSet result) {
result.clear();
UScript.getScriptExtensions(codePoint, result);
// Section 5.1 step 1
if (result.get(UScript.HAN)) {
result.set(UScript.HAN_WITH_BOPOMOFO);
result.set(UScript.JAPANESE);
result.set(UScript.KOREAN);
}
if (result.get(UScript.HIRAGANA)) {
result.set(UScript.JAPANESE);
}
if (result.get(UScript.KATAKANA)) {
result.set(UScript.JAPANESE);
}
if (result.get(UScript.HANGUL)) {
result.set(UScript.KOREAN);
}
if (result.get(UScript.BOPOMOFO)) {
result.set(UScript.HAN_WITH_BOPOMOFO);
}
// Section 5.1 step 2
if (result.get(UScript.COMMON) || result.get(UScript.INHERITED)) {
result.setAll();
}
} | [
"private",
"static",
"void",
"getAugmentedScriptSet",
"(",
"int",
"codePoint",
",",
"ScriptSet",
"result",
")",
"{",
"result",
".",
"clear",
"(",
")",
";",
"UScript",
".",
"getScriptExtensions",
"(",
"codePoint",
",",
"result",
")",
";",
"// Section 5.1 step 1",... | Computes the augmented script set for a code point, according to UTS 39 section 5.1. | [
"Computes",
"the",
"augmented",
"script",
"set",
"for",
"a",
"code",
"point",
"according",
"to",
"UTS",
"39",
"section",
"5",
".",
"1",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1487-L1514 |
33,270 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.getResolvedScriptSet | private void getResolvedScriptSet(CharSequence input, ScriptSet result) {
getResolvedScriptSetWithout(input, UScript.CODE_LIMIT, result);
} | java | private void getResolvedScriptSet(CharSequence input, ScriptSet result) {
getResolvedScriptSetWithout(input, UScript.CODE_LIMIT, result);
} | [
"private",
"void",
"getResolvedScriptSet",
"(",
"CharSequence",
"input",
",",
"ScriptSet",
"result",
")",
"{",
"getResolvedScriptSetWithout",
"(",
"input",
",",
"UScript",
".",
"CODE_LIMIT",
",",
"result",
")",
";",
"}"
] | Computes the resolved script set for a string, according to UTS 39 section 5.1. | [
"Computes",
"the",
"resolved",
"script",
"set",
"for",
"a",
"string",
"according",
"to",
"UTS",
"39",
"section",
"5",
".",
"1",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1519-L1521 |
33,271 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.getResolvedScriptSetWithout | private void getResolvedScriptSetWithout(CharSequence input, int script, ScriptSet result) {
result.setAll();
ScriptSet temp = new ScriptSet();
for (int utf16Offset = 0; utf16Offset < input.length();) {
int codePoint = Character.codePointAt(input, utf16Offset);
utf16Offset += Character.charCount(codePoint);
// Compute the augmented script set for the character
getAugmentedScriptSet(codePoint, temp);
// Intersect the augmented script set with the resolved script set, but only if the character doesn't
// have the script specified in the function call
if (script == UScript.CODE_LIMIT || !temp.get(script)) {
result.and(temp);
}
}
} | java | private void getResolvedScriptSetWithout(CharSequence input, int script, ScriptSet result) {
result.setAll();
ScriptSet temp = new ScriptSet();
for (int utf16Offset = 0; utf16Offset < input.length();) {
int codePoint = Character.codePointAt(input, utf16Offset);
utf16Offset += Character.charCount(codePoint);
// Compute the augmented script set for the character
getAugmentedScriptSet(codePoint, temp);
// Intersect the augmented script set with the resolved script set, but only if the character doesn't
// have the script specified in the function call
if (script == UScript.CODE_LIMIT || !temp.get(script)) {
result.and(temp);
}
}
} | [
"private",
"void",
"getResolvedScriptSetWithout",
"(",
"CharSequence",
"input",
",",
"int",
"script",
",",
"ScriptSet",
"result",
")",
"{",
"result",
".",
"setAll",
"(",
")",
";",
"ScriptSet",
"temp",
"=",
"new",
"ScriptSet",
"(",
")",
";",
"for",
"(",
"in... | Computes the resolved script set for a string, omitting characters having the specified script. If
UScript.CODE_LIMIT is passed as the second argument, all characters are included. | [
"Computes",
"the",
"resolved",
"script",
"set",
"for",
"a",
"string",
"omitting",
"characters",
"having",
"the",
"specified",
"script",
".",
"If",
"UScript",
".",
"CODE_LIMIT",
"is",
"passed",
"as",
"the",
"second",
"argument",
"all",
"characters",
"are",
"inc... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1527-L1544 |
33,272 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.getNumerics | private void getNumerics(String input, UnicodeSet result) {
result.clear();
for (int utf16Offset = 0; utf16Offset < input.length();) {
int codePoint = Character.codePointAt(input, utf16Offset);
utf16Offset += Character.charCount(codePoint);
// Store a representative character for each kind of decimal digit
if (UCharacter.getType(codePoint) == UCharacterCategory.DECIMAL_DIGIT_NUMBER) {
// Store the zero character as a representative for comparison.
// Unicode guarantees it is codePoint - value
result.add(codePoint - UCharacter.getNumericValue(codePoint));
}
}
} | java | private void getNumerics(String input, UnicodeSet result) {
result.clear();
for (int utf16Offset = 0; utf16Offset < input.length();) {
int codePoint = Character.codePointAt(input, utf16Offset);
utf16Offset += Character.charCount(codePoint);
// Store a representative character for each kind of decimal digit
if (UCharacter.getType(codePoint) == UCharacterCategory.DECIMAL_DIGIT_NUMBER) {
// Store the zero character as a representative for comparison.
// Unicode guarantees it is codePoint - value
result.add(codePoint - UCharacter.getNumericValue(codePoint));
}
}
} | [
"private",
"void",
"getNumerics",
"(",
"String",
"input",
",",
"UnicodeSet",
"result",
")",
"{",
"result",
".",
"clear",
"(",
")",
";",
"for",
"(",
"int",
"utf16Offset",
"=",
"0",
";",
"utf16Offset",
"<",
"input",
".",
"length",
"(",
")",
";",
")",
"... | Computes the set of numerics for a string, according to UTS 39 section 5.3. | [
"Computes",
"the",
"set",
"of",
"numerics",
"for",
"a",
"string",
"according",
"to",
"UTS",
"39",
"section",
"5",
".",
"3",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1549-L1563 |
33,273 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.getRestrictionLevel | private RestrictionLevel getRestrictionLevel(String input) {
// Section 5.2 step 1:
if (!fAllowedCharsSet.containsAll(input)) {
return RestrictionLevel.UNRESTRICTIVE;
}
// Section 5.2 step 2:
if (ASCII.containsAll(input)) {
return RestrictionLevel.ASCII;
}
// Section 5.2 steps 3:
ScriptSet resolvedScriptSet = new ScriptSet();
getResolvedScriptSet(input, resolvedScriptSet);
// Section 5.2 step 4:
if (!resolvedScriptSet.isEmpty()) {
return RestrictionLevel.SINGLE_SCRIPT_RESTRICTIVE;
}
// Section 5.2 step 5:
ScriptSet resolvedNoLatn = new ScriptSet();
getResolvedScriptSetWithout(input, UScript.LATIN, resolvedNoLatn);
// Section 5.2 step 6:
if (resolvedNoLatn.get(UScript.HAN_WITH_BOPOMOFO) || resolvedNoLatn.get(UScript.JAPANESE)
|| resolvedNoLatn.get(UScript.KOREAN)) {
return RestrictionLevel.HIGHLY_RESTRICTIVE;
}
// Section 5.2 step 7:
if (!resolvedNoLatn.isEmpty() && !resolvedNoLatn.get(UScript.CYRILLIC) && !resolvedNoLatn.get(UScript.GREEK)
&& !resolvedNoLatn.get(UScript.CHEROKEE)) {
return RestrictionLevel.MODERATELY_RESTRICTIVE;
}
// Section 5.2 step 8:
return RestrictionLevel.MINIMALLY_RESTRICTIVE;
} | java | private RestrictionLevel getRestrictionLevel(String input) {
// Section 5.2 step 1:
if (!fAllowedCharsSet.containsAll(input)) {
return RestrictionLevel.UNRESTRICTIVE;
}
// Section 5.2 step 2:
if (ASCII.containsAll(input)) {
return RestrictionLevel.ASCII;
}
// Section 5.2 steps 3:
ScriptSet resolvedScriptSet = new ScriptSet();
getResolvedScriptSet(input, resolvedScriptSet);
// Section 5.2 step 4:
if (!resolvedScriptSet.isEmpty()) {
return RestrictionLevel.SINGLE_SCRIPT_RESTRICTIVE;
}
// Section 5.2 step 5:
ScriptSet resolvedNoLatn = new ScriptSet();
getResolvedScriptSetWithout(input, UScript.LATIN, resolvedNoLatn);
// Section 5.2 step 6:
if (resolvedNoLatn.get(UScript.HAN_WITH_BOPOMOFO) || resolvedNoLatn.get(UScript.JAPANESE)
|| resolvedNoLatn.get(UScript.KOREAN)) {
return RestrictionLevel.HIGHLY_RESTRICTIVE;
}
// Section 5.2 step 7:
if (!resolvedNoLatn.isEmpty() && !resolvedNoLatn.get(UScript.CYRILLIC) && !resolvedNoLatn.get(UScript.GREEK)
&& !resolvedNoLatn.get(UScript.CHEROKEE)) {
return RestrictionLevel.MODERATELY_RESTRICTIVE;
}
// Section 5.2 step 8:
return RestrictionLevel.MINIMALLY_RESTRICTIVE;
} | [
"private",
"RestrictionLevel",
"getRestrictionLevel",
"(",
"String",
"input",
")",
"{",
"// Section 5.2 step 1:",
"if",
"(",
"!",
"fAllowedCharsSet",
".",
"containsAll",
"(",
"input",
")",
")",
"{",
"return",
"RestrictionLevel",
".",
"UNRESTRICTIVE",
";",
"}",
"//... | Computes the restriction level of a string, according to UTS 39 section 5.2. | [
"Computes",
"the",
"restriction",
"level",
"of",
"a",
"string",
"according",
"to",
"UTS",
"39",
"section",
"5",
".",
"2",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1568-L1606 |
33,274 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java | IndexedCollectionCertStore.buildIndex | private void buildIndex(Collection<?> coll) {
certSubjects = new HashMap<X500Principal, Object>();
crlIssuers = new HashMap<X500Principal, Object>();
otherCertificates = null;
otherCRLs = null;
for (Object obj : coll) {
if (obj instanceof X509Certificate) {
indexCertificate((X509Certificate)obj);
} else if (obj instanceof X509CRL) {
indexCRL((X509CRL)obj);
} else if (obj instanceof Certificate) {
if (otherCertificates == null) {
otherCertificates = new HashSet<Certificate>();
}
otherCertificates.add((Certificate)obj);
} else if (obj instanceof CRL) {
if (otherCRLs == null) {
otherCRLs = new HashSet<CRL>();
}
otherCRLs.add((CRL)obj);
} else {
// ignore
}
}
if (otherCertificates == null) {
otherCertificates = Collections.<Certificate>emptySet();
}
if (otherCRLs == null) {
otherCRLs = Collections.<CRL>emptySet();
}
} | java | private void buildIndex(Collection<?> coll) {
certSubjects = new HashMap<X500Principal, Object>();
crlIssuers = new HashMap<X500Principal, Object>();
otherCertificates = null;
otherCRLs = null;
for (Object obj : coll) {
if (obj instanceof X509Certificate) {
indexCertificate((X509Certificate)obj);
} else if (obj instanceof X509CRL) {
indexCRL((X509CRL)obj);
} else if (obj instanceof Certificate) {
if (otherCertificates == null) {
otherCertificates = new HashSet<Certificate>();
}
otherCertificates.add((Certificate)obj);
} else if (obj instanceof CRL) {
if (otherCRLs == null) {
otherCRLs = new HashSet<CRL>();
}
otherCRLs.add((CRL)obj);
} else {
// ignore
}
}
if (otherCertificates == null) {
otherCertificates = Collections.<Certificate>emptySet();
}
if (otherCRLs == null) {
otherCRLs = Collections.<CRL>emptySet();
}
} | [
"private",
"void",
"buildIndex",
"(",
"Collection",
"<",
"?",
">",
"coll",
")",
"{",
"certSubjects",
"=",
"new",
"HashMap",
"<",
"X500Principal",
",",
"Object",
">",
"(",
")",
";",
"crlIssuers",
"=",
"new",
"HashMap",
"<",
"X500Principal",
",",
"Object",
... | Index the specified Collection copying all references to Certificates
and CRLs. | [
"Index",
"the",
"specified",
"Collection",
"copying",
"all",
"references",
"to",
"Certificates",
"and",
"CRLs",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java#L140-L170 |
33,275 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java | IndexedCollectionCertStore.indexCertificate | private void indexCertificate(X509Certificate cert) {
X500Principal subject = cert.getSubjectX500Principal();
Object oldEntry = certSubjects.put(subject, cert);
if (oldEntry != null) { // assume this is unlikely
if (oldEntry instanceof X509Certificate) {
if (cert.equals(oldEntry)) {
return;
}
List<X509Certificate> list = new ArrayList<>(2);
list.add(cert);
list.add((X509Certificate)oldEntry);
certSubjects.put(subject, list);
} else {
@SuppressWarnings("unchecked") // See certSubjects javadoc.
List<X509Certificate> list = (List<X509Certificate>)oldEntry;
if (list.contains(cert) == false) {
list.add(cert);
}
certSubjects.put(subject, list);
}
}
} | java | private void indexCertificate(X509Certificate cert) {
X500Principal subject = cert.getSubjectX500Principal();
Object oldEntry = certSubjects.put(subject, cert);
if (oldEntry != null) { // assume this is unlikely
if (oldEntry instanceof X509Certificate) {
if (cert.equals(oldEntry)) {
return;
}
List<X509Certificate> list = new ArrayList<>(2);
list.add(cert);
list.add((X509Certificate)oldEntry);
certSubjects.put(subject, list);
} else {
@SuppressWarnings("unchecked") // See certSubjects javadoc.
List<X509Certificate> list = (List<X509Certificate>)oldEntry;
if (list.contains(cert) == false) {
list.add(cert);
}
certSubjects.put(subject, list);
}
}
} | [
"private",
"void",
"indexCertificate",
"(",
"X509Certificate",
"cert",
")",
"{",
"X500Principal",
"subject",
"=",
"cert",
".",
"getSubjectX500Principal",
"(",
")",
";",
"Object",
"oldEntry",
"=",
"certSubjects",
".",
"put",
"(",
"subject",
",",
"cert",
")",
";... | Add an X509Certificate to the index. | [
"Add",
"an",
"X509Certificate",
"to",
"the",
"index",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java#L175-L196 |
33,276 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java | IndexedCollectionCertStore.indexCRL | private void indexCRL(X509CRL crl) {
X500Principal issuer = crl.getIssuerX500Principal();
Object oldEntry = crlIssuers.put(issuer, crl);
if (oldEntry != null) { // assume this is unlikely
if (oldEntry instanceof X509CRL) {
if (crl.equals(oldEntry)) {
return;
}
List<X509CRL> list = new ArrayList<>(2);
list.add(crl);
list.add((X509CRL)oldEntry);
crlIssuers.put(issuer, list);
} else {
// See crlIssuers javadoc.
@SuppressWarnings("unchecked")
List<X509CRL> list = (List<X509CRL>)oldEntry;
if (list.contains(crl) == false) {
list.add(crl);
}
crlIssuers.put(issuer, list);
}
}
} | java | private void indexCRL(X509CRL crl) {
X500Principal issuer = crl.getIssuerX500Principal();
Object oldEntry = crlIssuers.put(issuer, crl);
if (oldEntry != null) { // assume this is unlikely
if (oldEntry instanceof X509CRL) {
if (crl.equals(oldEntry)) {
return;
}
List<X509CRL> list = new ArrayList<>(2);
list.add(crl);
list.add((X509CRL)oldEntry);
crlIssuers.put(issuer, list);
} else {
// See crlIssuers javadoc.
@SuppressWarnings("unchecked")
List<X509CRL> list = (List<X509CRL>)oldEntry;
if (list.contains(crl) == false) {
list.add(crl);
}
crlIssuers.put(issuer, list);
}
}
} | [
"private",
"void",
"indexCRL",
"(",
"X509CRL",
"crl",
")",
"{",
"X500Principal",
"issuer",
"=",
"crl",
".",
"getIssuerX500Principal",
"(",
")",
";",
"Object",
"oldEntry",
"=",
"crlIssuers",
".",
"put",
"(",
"issuer",
",",
"crl",
")",
";",
"if",
"(",
"old... | Add an X509CRL to the index. | [
"Add",
"an",
"X509CRL",
"to",
"the",
"index",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java#L201-L223 |
33,277 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java | IndexedCollectionCertStore.matchX509Certs | private void matchX509Certs(CertSelector selector,
Collection<Certificate> matches) {
for (Object obj : certSubjects.values()) {
if (obj instanceof X509Certificate) {
X509Certificate cert = (X509Certificate)obj;
if (selector.match(cert)) {
matches.add(cert);
}
} else {
// See certSubjects javadoc.
@SuppressWarnings("unchecked")
List<X509Certificate> list = (List<X509Certificate>)obj;
for (X509Certificate cert : list) {
if (selector.match(cert)) {
matches.add(cert);
}
}
}
}
} | java | private void matchX509Certs(CertSelector selector,
Collection<Certificate> matches) {
for (Object obj : certSubjects.values()) {
if (obj instanceof X509Certificate) {
X509Certificate cert = (X509Certificate)obj;
if (selector.match(cert)) {
matches.add(cert);
}
} else {
// See certSubjects javadoc.
@SuppressWarnings("unchecked")
List<X509Certificate> list = (List<X509Certificate>)obj;
for (X509Certificate cert : list) {
if (selector.match(cert)) {
matches.add(cert);
}
}
}
}
} | [
"private",
"void",
"matchX509Certs",
"(",
"CertSelector",
"selector",
",",
"Collection",
"<",
"Certificate",
">",
"matches",
")",
"{",
"for",
"(",
"Object",
"obj",
":",
"certSubjects",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"X50... | Iterate through all the X509Certificates and add matches to the
collection. | [
"Iterate",
"through",
"all",
"the",
"X509Certificates",
"and",
"add",
"matches",
"to",
"the",
"collection",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java#L308-L328 |
33,278 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java | IndexedCollectionCertStore.matchX509CRLs | private void matchX509CRLs(CRLSelector selector, Collection<CRL> matches) {
for (Object obj : crlIssuers.values()) {
if (obj instanceof X509CRL) {
X509CRL crl = (X509CRL)obj;
if (selector.match(crl)) {
matches.add(crl);
}
} else {
// See crlIssuers javadoc.
@SuppressWarnings("unchecked")
List<X509CRL> list = (List<X509CRL>)obj;
for (X509CRL crl : list) {
if (selector.match(crl)) {
matches.add(crl);
}
}
}
}
} | java | private void matchX509CRLs(CRLSelector selector, Collection<CRL> matches) {
for (Object obj : crlIssuers.values()) {
if (obj instanceof X509CRL) {
X509CRL crl = (X509CRL)obj;
if (selector.match(crl)) {
matches.add(crl);
}
} else {
// See crlIssuers javadoc.
@SuppressWarnings("unchecked")
List<X509CRL> list = (List<X509CRL>)obj;
for (X509CRL crl : list) {
if (selector.match(crl)) {
matches.add(crl);
}
}
}
}
} | [
"private",
"void",
"matchX509CRLs",
"(",
"CRLSelector",
"selector",
",",
"Collection",
"<",
"CRL",
">",
"matches",
")",
"{",
"for",
"(",
"Object",
"obj",
":",
"crlIssuers",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"X509CRL",
")"... | Iterate through all the X509CRLs and add matches to the
collection. | [
"Iterate",
"through",
"all",
"the",
"X509CRLs",
"and",
"add",
"matches",
"to",
"the",
"collection",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/IndexedCollectionCertStore.java#L404-L422 |
33,279 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/UnImplNode.java | UnImplNode.renameNode | public Node renameNode(Node n,
String namespaceURI,
String name)
throws DOMException{
return n;
} | java | public Node renameNode(Node n,
String namespaceURI,
String name)
throws DOMException{
return n;
} | [
"public",
"Node",
"renameNode",
"(",
"Node",
"n",
",",
"String",
"namespaceURI",
",",
"String",
"name",
")",
"throws",
"DOMException",
"{",
"return",
"n",
";",
"}"
] | DOM Level 3
Renaming node | [
"DOM",
"Level",
"3",
"Renaming",
"node"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/UnImplNode.java#L1748-L1753 |
33,280 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemAttribute.java | ElemAttribute.resolvePrefix | protected String resolvePrefix(SerializationHandler rhandler,
String prefix, String nodeNamespace)
throws TransformerException
{
if (null != prefix && (prefix.length() == 0 || prefix.equals("xmlns")))
{
// Since we can't use default namespace, in this case we try and
// see if a prefix has already been defined or this namespace.
prefix = rhandler.getPrefix(nodeNamespace);
// System.out.println("nsPrefix: "+nsPrefix);
if (null == prefix || prefix.length() == 0 || prefix.equals("xmlns"))
{
if(nodeNamespace.length() > 0)
{
NamespaceMappings prefixMapping = rhandler.getNamespaceMappings();
prefix = prefixMapping.generateNextPrefix();
}
else
prefix = "";
}
}
return prefix;
} | java | protected String resolvePrefix(SerializationHandler rhandler,
String prefix, String nodeNamespace)
throws TransformerException
{
if (null != prefix && (prefix.length() == 0 || prefix.equals("xmlns")))
{
// Since we can't use default namespace, in this case we try and
// see if a prefix has already been defined or this namespace.
prefix = rhandler.getPrefix(nodeNamespace);
// System.out.println("nsPrefix: "+nsPrefix);
if (null == prefix || prefix.length() == 0 || prefix.equals("xmlns"))
{
if(nodeNamespace.length() > 0)
{
NamespaceMappings prefixMapping = rhandler.getNamespaceMappings();
prefix = prefixMapping.generateNextPrefix();
}
else
prefix = "";
}
}
return prefix;
} | [
"protected",
"String",
"resolvePrefix",
"(",
"SerializationHandler",
"rhandler",
",",
"String",
"prefix",
",",
"String",
"nodeNamespace",
")",
"throws",
"TransformerException",
"{",
"if",
"(",
"null",
"!=",
"prefix",
"&&",
"(",
"prefix",
".",
"length",
"(",
")",... | Resolve the namespace into a prefix. At this level, if no prefix exists,
then return a manufactured prefix.
@param rhandler The current result tree handler.
@param prefix The probable prefix if already known.
@param nodeNamespace The namespace, which should not be null.
@return The prefix to be used. | [
"Resolve",
"the",
"namespace",
"into",
"a",
"prefix",
".",
"At",
"this",
"level",
"if",
"no",
"prefix",
"exists",
"then",
"return",
"a",
"manufactured",
"prefix",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemAttribute.java#L124-L148 |
33,281 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemAttribute.java | ElemAttribute.validateNodeName | protected boolean validateNodeName(String nodeName)
{
if(null == nodeName)
return false;
if(nodeName.equals("xmlns"))
return false;
return XML11Char.isXML11ValidQName(nodeName);
} | java | protected boolean validateNodeName(String nodeName)
{
if(null == nodeName)
return false;
if(nodeName.equals("xmlns"))
return false;
return XML11Char.isXML11ValidQName(nodeName);
} | [
"protected",
"boolean",
"validateNodeName",
"(",
"String",
"nodeName",
")",
"{",
"if",
"(",
"null",
"==",
"nodeName",
")",
"return",
"false",
";",
"if",
"(",
"nodeName",
".",
"equals",
"(",
"\"xmlns\"",
")",
")",
"return",
"false",
";",
"return",
"XML11Cha... | Validate that the node name is good.
@param nodeName Name of the node being constructed, which may be null.
@return true if the node name is valid, false otherwise. | [
"Validate",
"that",
"the",
"node",
"name",
"is",
"good",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemAttribute.java#L157-L164 |
33,282 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/DoublePipeline.java | DoublePipeline.limit | @Override
public final DoubleStream limit(long maxSize) {
if (maxSize < 0)
throw new IllegalArgumentException(Long.toString(maxSize));
return SliceOps.makeDouble(this, (long) 0, maxSize);
} | java | @Override
public final DoubleStream limit(long maxSize) {
if (maxSize < 0)
throw new IllegalArgumentException(Long.toString(maxSize));
return SliceOps.makeDouble(this, (long) 0, maxSize);
} | [
"@",
"Override",
"public",
"final",
"DoubleStream",
"limit",
"(",
"long",
"maxSize",
")",
"{",
"if",
"(",
"maxSize",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"Long",
".",
"toString",
"(",
"maxSize",
")",
")",
";",
"return",
"SliceOps... | Stateful intermediate ops from DoubleStream | [
"Stateful",
"intermediate",
"ops",
"from",
"DoubleStream"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/DoublePipeline.java#L336-L341 |
33,283 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/BoolStack.java | BoolStack.grow | private void grow()
{
m_allocatedSize *= 2;
boolean newVector[] = new boolean[m_allocatedSize];
System.arraycopy(m_values, 0, newVector, 0, m_index + 1);
m_values = newVector;
} | java | private void grow()
{
m_allocatedSize *= 2;
boolean newVector[] = new boolean[m_allocatedSize];
System.arraycopy(m_values, 0, newVector, 0, m_index + 1);
m_values = newVector;
} | [
"private",
"void",
"grow",
"(",
")",
"{",
"m_allocatedSize",
"*=",
"2",
";",
"boolean",
"newVector",
"[",
"]",
"=",
"new",
"boolean",
"[",
"m_allocatedSize",
"]",
";",
"System",
".",
"arraycopy",
"(",
"m_values",
",",
"0",
",",
"newVector",
",",
"0",
"... | Grows the size of the stack | [
"Grows",
"the",
"size",
"of",
"the",
"stack"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/BoolStack.java#L184-L194 |
33,284 | google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/android/system/GaiException.java | GaiException.getMessage | @Override public String getMessage() {
String gaiName = OsConstants.gaiName(error);
if (gaiName == null) {
gaiName = "GAI_ error " + error;
}
String description = NetworkOs.gai_strerror(error);
return functionName + " failed: " + gaiName + " (" + description + ")";
} | java | @Override public String getMessage() {
String gaiName = OsConstants.gaiName(error);
if (gaiName == null) {
gaiName = "GAI_ error " + error;
}
String description = NetworkOs.gai_strerror(error);
return functionName + " failed: " + gaiName + " (" + description + ")";
} | [
"@",
"Override",
"public",
"String",
"getMessage",
"(",
")",
"{",
"String",
"gaiName",
"=",
"OsConstants",
".",
"gaiName",
"(",
"error",
")",
";",
"if",
"(",
"gaiName",
"==",
"null",
")",
"{",
"gaiName",
"=",
"\"GAI_ error \"",
"+",
"error",
";",
"}",
... | Converts the stashed function name and error value to a human-readable string.
We do this here rather than in the constructor so that callers only pay for
this if they need it. | [
"Converts",
"the",
"stashed",
"function",
"name",
"and",
"error",
"value",
"to",
"a",
"human",
"-",
"readable",
"string",
".",
"We",
"do",
"this",
"here",
"rather",
"than",
"in",
"the",
"constructor",
"so",
"that",
"callers",
"only",
"pay",
"for",
"this",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/android/system/GaiException.java#L60-L67 |
33,285 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/ZoneId.java | ZoneId.ofWithPrefix | private static ZoneId ofWithPrefix(String zoneId, int prefixLength, boolean checkAvailable) {
String prefix = zoneId.substring(0, prefixLength);
if (zoneId.length() == prefixLength) {
return ofOffset(prefix, ZoneOffset.UTC);
}
if (zoneId.charAt(prefixLength) != '+' && zoneId.charAt(prefixLength) != '-') {
return ZoneRegion.ofId(zoneId, checkAvailable); // drop through to ZoneRulesProvider
}
try {
ZoneOffset offset = ZoneOffset.of(zoneId.substring(prefixLength));
if (offset == ZoneOffset.UTC) {
return ofOffset(prefix, offset);
}
return ofOffset(prefix, offset);
} catch (DateTimeException ex) {
throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId, ex);
}
} | java | private static ZoneId ofWithPrefix(String zoneId, int prefixLength, boolean checkAvailable) {
String prefix = zoneId.substring(0, prefixLength);
if (zoneId.length() == prefixLength) {
return ofOffset(prefix, ZoneOffset.UTC);
}
if (zoneId.charAt(prefixLength) != '+' && zoneId.charAt(prefixLength) != '-') {
return ZoneRegion.ofId(zoneId, checkAvailable); // drop through to ZoneRulesProvider
}
try {
ZoneOffset offset = ZoneOffset.of(zoneId.substring(prefixLength));
if (offset == ZoneOffset.UTC) {
return ofOffset(prefix, offset);
}
return ofOffset(prefix, offset);
} catch (DateTimeException ex) {
throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId, ex);
}
} | [
"private",
"static",
"ZoneId",
"ofWithPrefix",
"(",
"String",
"zoneId",
",",
"int",
"prefixLength",
",",
"boolean",
"checkAvailable",
")",
"{",
"String",
"prefix",
"=",
"zoneId",
".",
"substring",
"(",
"0",
",",
"prefixLength",
")",
";",
"if",
"(",
"zoneId",... | Parse once a prefix is established.
@param zoneId the time-zone ID, not null
@param prefixLength the length of the prefix, 2 or 3
@return the zone ID, not null
@throws DateTimeException if the zone ID has an invalid format | [
"Parse",
"once",
"a",
"prefix",
"is",
"established",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/ZoneId.java#L430-L447 |
33,286 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemUnknown.java | ElemUnknown.executeFallbacks | private void executeFallbacks(
TransformerImpl transformer)
throws TransformerException
{
for (ElemTemplateElement child = m_firstChild; child != null;
child = child.m_nextSibling)
{
if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK)
{
try
{
transformer.pushElemTemplateElement(child);
((ElemFallback) child).executeFallback(transformer);
}
finally
{
transformer.popElemTemplateElement();
}
}
}
} | java | private void executeFallbacks(
TransformerImpl transformer)
throws TransformerException
{
for (ElemTemplateElement child = m_firstChild; child != null;
child = child.m_nextSibling)
{
if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK)
{
try
{
transformer.pushElemTemplateElement(child);
((ElemFallback) child).executeFallback(transformer);
}
finally
{
transformer.popElemTemplateElement();
}
}
}
} | [
"private",
"void",
"executeFallbacks",
"(",
"TransformerImpl",
"transformer",
")",
"throws",
"TransformerException",
"{",
"for",
"(",
"ElemTemplateElement",
"child",
"=",
"m_firstChild",
";",
"child",
"!=",
"null",
";",
"child",
"=",
"child",
".",
"m_nextSibling",
... | Execute the fallbacks when an extension is not available.
@param transformer non-null reference to the the current transform-time state.
@throws TransformerException | [
"Execute",
"the",
"fallbacks",
"when",
"an",
"extension",
"is",
"not",
"available",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemUnknown.java#L54-L75 |
33,287 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemUnknown.java | ElemUnknown.execute | public void execute(TransformerImpl transformer)
throws TransformerException
{
try {
if (hasFallbackChildren()) {
executeFallbacks(transformer);
} else {
// do nothing
}
} catch (TransformerException e) {
transformer.getErrorListener().fatalError(e);
}
} | java | public void execute(TransformerImpl transformer)
throws TransformerException
{
try {
if (hasFallbackChildren()) {
executeFallbacks(transformer);
} else {
// do nothing
}
} catch (TransformerException e) {
transformer.getErrorListener().fatalError(e);
}
} | [
"public",
"void",
"execute",
"(",
"TransformerImpl",
"transformer",
")",
"throws",
"TransformerException",
"{",
"try",
"{",
"if",
"(",
"hasFallbackChildren",
"(",
")",
")",
"{",
"executeFallbacks",
"(",
"transformer",
")",
";",
"}",
"else",
"{",
"// do nothing",... | Execute an unknown element.
Execute fallback if fallback child exists or do nothing
@param transformer non-null reference to the the current transform-time state.
@throws TransformerException | [
"Execute",
"an",
"unknown",
"element",
".",
"Execute",
"fallback",
"if",
"fallback",
"child",
"exists",
"or",
"do",
"nothing"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemUnknown.java#L103-L119 |
33,288 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/OutputStreamWriter.java | OutputStreamWriter.close | @Override
public void close() throws IOException {
synchronized (lock) {
if (encoder != null) {
drainEncoder();
flushBytes(false);
out.close();
encoder = null;
bytes = null;
}
}
} | java | @Override
public void close() throws IOException {
synchronized (lock) {
if (encoder != null) {
drainEncoder();
flushBytes(false);
out.close();
encoder = null;
bytes = null;
}
}
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"encoder",
"!=",
"null",
")",
"{",
"drainEncoder",
"(",
")",
";",
"flushBytes",
"(",
"false",
")",
";",
"out",
".",
... | Closes this writer. This implementation flushes the buffer as well as the
target stream. The target stream is then closed and the resources for the
buffer and converter are released.
<p>Only the first invocation of this method has any effect. Subsequent calls
do nothing.
@throws IOException
if an error occurs while closing this writer. | [
"Closes",
"this",
"writer",
".",
"This",
"implementation",
"flushes",
"the",
"buffer",
"as",
"well",
"as",
"the",
"target",
"stream",
".",
"The",
"target",
"stream",
"is",
"then",
"closed",
"and",
"the",
"resources",
"for",
"the",
"buffer",
"and",
"converter... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/OutputStreamWriter.java#L135-L146 |
33,289 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.rdns | public List<RDN> rdns() {
List<RDN> list = rdnList;
if (list == null) {
list = Collections.unmodifiableList(Arrays.asList(names));
rdnList = list;
}
return list;
} | java | public List<RDN> rdns() {
List<RDN> list = rdnList;
if (list == null) {
list = Collections.unmodifiableList(Arrays.asList(names));
rdnList = list;
}
return list;
} | [
"public",
"List",
"<",
"RDN",
">",
"rdns",
"(",
")",
"{",
"List",
"<",
"RDN",
">",
"list",
"=",
"rdnList",
";",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"list",
"=",
"Collections",
".",
"unmodifiableList",
"(",
"Arrays",
".",
"asList",
"(",
"name... | Return an immutable List of all RDNs in this X500Name. | [
"Return",
"an",
"immutable",
"List",
"of",
"all",
"RDNs",
"in",
"this",
"X500Name",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L326-L333 |
33,290 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.allAvas | public List<AVA> allAvas() {
List<AVA> list = allAvaList;
if (list == null) {
list = new ArrayList<AVA>();
for (int i = 0; i < names.length; i++) {
list.addAll(names[i].avas());
}
}
return list;
} | java | public List<AVA> allAvas() {
List<AVA> list = allAvaList;
if (list == null) {
list = new ArrayList<AVA>();
for (int i = 0; i < names.length; i++) {
list.addAll(names[i].avas());
}
}
return list;
} | [
"public",
"List",
"<",
"AVA",
">",
"allAvas",
"(",
")",
"{",
"List",
"<",
"AVA",
">",
"list",
"=",
"allAvaList",
";",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"list",
"=",
"new",
"ArrayList",
"<",
"AVA",
">",
"(",
")",
";",
"for",
"(",
"int",... | Return an immutable List of the the AVAs contained in all the
RDNs of this X500Name. | [
"Return",
"an",
"immutable",
"List",
"of",
"the",
"the",
"AVAs",
"contained",
"in",
"all",
"the",
"RDNs",
"of",
"this",
"X500Name",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L346-L355 |
33,291 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.isEmpty | public boolean isEmpty() {
int n = names.length;
if (n == 0) {
return true;
}
for (int i = 0; i < n; i++) {
if (names[i].assertion.length != 0) {
return false;
}
}
return true;
} | java | public boolean isEmpty() {
int n = names.length;
if (n == 0) {
return true;
}
for (int i = 0; i < n; i++) {
if (names[i].assertion.length != 0) {
return false;
}
}
return true;
} | [
"public",
"boolean",
"isEmpty",
"(",
")",
"{",
"int",
"n",
"=",
"names",
".",
"length",
";",
"if",
"(",
"n",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
... | Return whether this X500Name is empty. An X500Name is not empty
if it has at least one RDN containing at least one AVA. | [
"Return",
"whether",
"this",
"X500Name",
"is",
"empty",
".",
"An",
"X500Name",
"is",
"not",
"empty",
"if",
"it",
"has",
"at",
"least",
"one",
"RDN",
"containing",
"at",
"least",
"one",
"AVA",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L369-L380 |
33,292 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.encode | public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
for (int i = 0; i < names.length; i++) {
names[i].encode(tmp);
}
out.write(DerValue.tag_Sequence, tmp);
} | java | public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
for (int i = 0; i < names.length; i++) {
names[i].encode(tmp);
}
out.write(DerValue.tag_Sequence, tmp);
} | [
"public",
"void",
"encode",
"(",
"DerOutputStream",
"out",
")",
"throws",
"IOException",
"{",
"DerOutputStream",
"tmp",
"=",
"new",
"DerOutputStream",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"names",
".",
"length",
";",
"i",
"++... | Encodes the name in DER-encoded form.
@param out where to put the DER-encoded X.500 name | [
"Encodes",
"the",
"name",
"in",
"DER",
"-",
"encoded",
"form",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L828-L834 |
33,293 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.getEncodedInternal | public byte[] getEncodedInternal() throws IOException {
if (encoded == null) {
DerOutputStream out = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
for (int i = 0; i < names.length; i++) {
names[i].encode(tmp);
}
out.write(DerValue.tag_Sequence, tmp);
encoded = out.toByteArray();
}
return encoded;
} | java | public byte[] getEncodedInternal() throws IOException {
if (encoded == null) {
DerOutputStream out = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
for (int i = 0; i < names.length; i++) {
names[i].encode(tmp);
}
out.write(DerValue.tag_Sequence, tmp);
encoded = out.toByteArray();
}
return encoded;
} | [
"public",
"byte",
"[",
"]",
"getEncodedInternal",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"encoded",
"==",
"null",
")",
"{",
"DerOutputStream",
"out",
"=",
"new",
"DerOutputStream",
"(",
")",
";",
"DerOutputStream",
"tmp",
"=",
"new",
"DerOutputSt... | Returned the encoding as an uncloned byte array. Callers must
guarantee that they neither modify it not expose it to untrusted
code. | [
"Returned",
"the",
"encoding",
"as",
"an",
"uncloned",
"byte",
"array",
".",
"Callers",
"must",
"guarantee",
"that",
"they",
"neither",
"modify",
"it",
"not",
"expose",
"it",
"to",
"untrusted",
"code",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L841-L852 |
33,294 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.checkNoNewLinesNorTabsAtBeginningOfDN | private void checkNoNewLinesNorTabsAtBeginningOfDN(String input) {
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (c != ' ') {
if (c == '\t' || c == '\n') {
throw new IllegalArgumentException("DN cannot start with newline nor tab");
}
break;
}
}
} | java | private void checkNoNewLinesNorTabsAtBeginningOfDN(String input) {
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (c != ' ') {
if (c == '\t' || c == '\n') {
throw new IllegalArgumentException("DN cannot start with newline nor tab");
}
break;
}
}
} | [
"private",
"void",
"checkNoNewLinesNorTabsAtBeginningOfDN",
"(",
"String",
"input",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"input",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"input",
".",
"charAt",
"(",
... | Disallow new lines and tabs at the beginning of DN.
@throws java.lang.IllegalArgumentException if the DN starts with new line or tab. | [
"Disallow",
"new",
"lines",
"and",
"tabs",
"at",
"the",
"beginning",
"of",
"DN",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L956-L966 |
33,295 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.isWithinSubtree | private boolean isWithinSubtree(X500Name other) {
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (other.names.length == 0) {
return true;
}
if (this.names.length == 0) {
return false;
}
if (names.length < other.names.length) {
return false;
}
for (int i = 0; i < other.names.length; i++) {
if (!names[i].equals(other.names[i])) {
return false;
}
}
return true;
} | java | private boolean isWithinSubtree(X500Name other) {
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (other.names.length == 0) {
return true;
}
if (this.names.length == 0) {
return false;
}
if (names.length < other.names.length) {
return false;
}
for (int i = 0; i < other.names.length; i++) {
if (!names[i].equals(other.names[i])) {
return false;
}
}
return true;
} | [
"private",
"boolean",
"isWithinSubtree",
"(",
"X500Name",
"other",
")",
"{",
"if",
"(",
"this",
"==",
"other",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"other",
".",
"... | Compares this name with another and determines if
it is within the subtree of the other. Useful for
checking against the name constraints extension.
@return true iff this name is within the subtree of other. | [
"Compares",
"this",
"name",
"with",
"another",
"and",
"determines",
"if",
"it",
"is",
"within",
"the",
"subtree",
"of",
"the",
"other",
".",
"Useful",
"for",
"checking",
"against",
"the",
"name",
"constraints",
"extension",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L1312-L1334 |
33,296 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.commonAncestor | public X500Name commonAncestor(X500Name other) {
if (other == null) {
return null;
}
int otherLen = other.names.length;
int thisLen = this.names.length;
if (thisLen == 0 || otherLen == 0) {
return null;
}
int minLen = (thisLen < otherLen) ? thisLen: otherLen;
//Compare names from highest RDN down the naming tree
//Note that these are stored in RDN[0]...
int i=0;
for (; i < minLen; i++) {
if (!names[i].equals(other.names[i])) {
if (i == 0) {
return null;
} else {
break;
}
}
}
//Copy matching RDNs into new RDN array
RDN[] ancestor = new RDN[i];
for (int j=0; j < i; j++) {
ancestor[j] = names[j];
}
X500Name commonAncestor = null;
try {
commonAncestor = new X500Name(ancestor);
} catch (IOException ioe) {
return null;
}
return commonAncestor;
} | java | public X500Name commonAncestor(X500Name other) {
if (other == null) {
return null;
}
int otherLen = other.names.length;
int thisLen = this.names.length;
if (thisLen == 0 || otherLen == 0) {
return null;
}
int minLen = (thisLen < otherLen) ? thisLen: otherLen;
//Compare names from highest RDN down the naming tree
//Note that these are stored in RDN[0]...
int i=0;
for (; i < minLen; i++) {
if (!names[i].equals(other.names[i])) {
if (i == 0) {
return null;
} else {
break;
}
}
}
//Copy matching RDNs into new RDN array
RDN[] ancestor = new RDN[i];
for (int j=0; j < i; j++) {
ancestor[j] = names[j];
}
X500Name commonAncestor = null;
try {
commonAncestor = new X500Name(ancestor);
} catch (IOException ioe) {
return null;
}
return commonAncestor;
} | [
"public",
"X500Name",
"commonAncestor",
"(",
"X500Name",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"otherLen",
"=",
"other",
".",
"names",
".",
"length",
";",
"int",
"thisLen",
"=",
"this",
".",
... | Return lowest common ancestor of this name and other name
@param other another X500Name
@return X500Name of lowest common ancestor; null if none | [
"Return",
"lowest",
"common",
"ancestor",
"of",
"this",
"name",
"and",
"other",
"name"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L1354-L1392 |
33,297 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.asX500Principal | public X500Principal asX500Principal() {
if (x500Principal == null) {
try {
Object[] args = new Object[] {this};
x500Principal =
(X500Principal)principalConstructor.newInstance(args);
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
}
return x500Principal;
} | java | public X500Principal asX500Principal() {
if (x500Principal == null) {
try {
Object[] args = new Object[] {this};
x500Principal =
(X500Principal)principalConstructor.newInstance(args);
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
}
return x500Principal;
} | [
"public",
"X500Principal",
"asX500Principal",
"(",
")",
"{",
"if",
"(",
"x500Principal",
"==",
"null",
")",
"{",
"try",
"{",
"Object",
"[",
"]",
"args",
"=",
"new",
"Object",
"[",
"]",
"{",
"this",
"}",
";",
"x500Principal",
"=",
"(",
"X500Principal",
... | Get an X500Principal backed by this X500Name.
Note that we are using privileged reflection to access the hidden
package private constructor in X500Principal. | [
"Get",
"an",
"X500Principal",
"backed",
"by",
"this",
"X500Name",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L1437-L1448 |
33,298 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java | X500Name.asX500Name | public static X500Name asX500Name(X500Principal p) {
try {
X500Name name = (X500Name)principalField.get(p);
name.x500Principal = p;
return name;
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
} | java | public static X500Name asX500Name(X500Principal p) {
try {
X500Name name = (X500Name)principalField.get(p);
name.x500Principal = p;
return name;
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
} | [
"public",
"static",
"X500Name",
"asX500Name",
"(",
"X500Principal",
"p",
")",
"{",
"try",
"{",
"X500Name",
"name",
"=",
"(",
"X500Name",
")",
"principalField",
".",
"get",
"(",
"p",
")",
";",
"name",
".",
"x500Principal",
"=",
"p",
";",
"return",
"name",... | Get the X500Name contained in the given X500Principal.
Note that the X500Name is retrieved using reflection. | [
"Get",
"the",
"X500Name",
"contained",
"in",
"the",
"given",
"X500Principal",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X500Name.java#L1455-L1463 |
33,299 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java | AtomicIntegerFieldUpdater.updateAndGet | public final int updateAndGet(T obj, IntUnaryOperator updateFunction) {
int prev, next;
do {
prev = get(obj);
next = updateFunction.applyAsInt(prev);
} while (!compareAndSet(obj, prev, next));
return next;
} | java | public final int updateAndGet(T obj, IntUnaryOperator updateFunction) {
int prev, next;
do {
prev = get(obj);
next = updateFunction.applyAsInt(prev);
} while (!compareAndSet(obj, prev, next));
return next;
} | [
"public",
"final",
"int",
"updateAndGet",
"(",
"T",
"obj",
",",
"IntUnaryOperator",
"updateFunction",
")",
"{",
"int",
"prev",
",",
"next",
";",
"do",
"{",
"prev",
"=",
"get",
"(",
"obj",
")",
";",
"next",
"=",
"updateFunction",
".",
"applyAsInt",
"(",
... | Atomically updates the field of the given object managed by this updater
with the results of applying the given function, returning the updated
value. The function should be side-effect-free, since it may be
re-applied when attempted updates fail due to contention among threads.
@param obj An object whose field to get and set
@param updateFunction a side-effect-free function
@return the updated value
@since 1.8 | [
"Atomically",
"updates",
"the",
"field",
"of",
"the",
"given",
"object",
"managed",
"by",
"this",
"updater",
"with",
"the",
"results",
"of",
"applying",
"the",
"given",
"function",
"returning",
"the",
"updated",
"value",
".",
"The",
"function",
"should",
"be",... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java#L305-L312 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.