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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
34,600 | google/j2objc | cycle_finder/src/main/java/com/google/devtools/cyclefinder/NameUtil.java | NameUtil.getQualifiedName | public static String getQualifiedName(TypeMirror type) {
switch (type.getKind()) {
case DECLARED:
return getQualifiedNameForTypeElement((TypeElement) ((DeclaredType) type).asElement());
case TYPEVAR:
return getQualifiedNameForElement(((TypeVariable) type).asElement());
case INTERSECTION:
return "&";
case WILDCARD:
return "?";
default:
throw new AssertionError("Unexpected type: " + type + " with kind: " + type.getKind());
}
} | java | public static String getQualifiedName(TypeMirror type) {
switch (type.getKind()) {
case DECLARED:
return getQualifiedNameForTypeElement((TypeElement) ((DeclaredType) type).asElement());
case TYPEVAR:
return getQualifiedNameForElement(((TypeVariable) type).asElement());
case INTERSECTION:
return "&";
case WILDCARD:
return "?";
default:
throw new AssertionError("Unexpected type: " + type + " with kind: " + type.getKind());
}
} | [
"public",
"static",
"String",
"getQualifiedName",
"(",
"TypeMirror",
"type",
")",
"{",
"switch",
"(",
"type",
".",
"getKind",
"(",
")",
")",
"{",
"case",
"DECLARED",
":",
"return",
"getQualifiedNameForTypeElement",
"(",
"(",
"TypeElement",
")",
"(",
"(",
"De... | Gets the qualified name for this type, as expected by a NameList instance. | [
"Gets",
"the",
"qualified",
"name",
"for",
"this",
"type",
"as",
"expected",
"by",
"a",
"NameList",
"instance",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/cycle_finder/src/main/java/com/google/devtools/cyclefinder/NameUtil.java#L262-L275 |
34,601 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java | QuantityFormatter.addIfAbsent | public void addIfAbsent(CharSequence variant, String template) {
int idx = StandardPlural.indexFromString(variant);
if (templates[idx] != null) {
return;
}
templates[idx] = SimpleFormatter.compileMinMaxArguments(template, 0, 1);
} | java | public void addIfAbsent(CharSequence variant, String template) {
int idx = StandardPlural.indexFromString(variant);
if (templates[idx] != null) {
return;
}
templates[idx] = SimpleFormatter.compileMinMaxArguments(template, 0, 1);
} | [
"public",
"void",
"addIfAbsent",
"(",
"CharSequence",
"variant",
",",
"String",
"template",
")",
"{",
"int",
"idx",
"=",
"StandardPlural",
".",
"indexFromString",
"(",
"variant",
")",
";",
"if",
"(",
"templates",
"[",
"idx",
"]",
"!=",
"null",
")",
"{",
... | Adds a template if there is none yet for the plural form.
@param variant the plural variant, e.g "zero", "one", "two", "few", "many", "other"
@param template the text for that plural variant with "{0}" as the quantity. For
example, in English, the template for the "one" variant may be "{0} apple" while the
template for the "other" variant may be "{0} apples"
@throws IllegalArgumentException if variant is not recognized or
if template has more than just the {0} placeholder. | [
"Adds",
"a",
"template",
"if",
"there",
"is",
"none",
"yet",
"for",
"the",
"plural",
"form",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java#L42-L48 |
34,602 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java | QuantityFormatter.format | public String format(double number, NumberFormat numberFormat, PluralRules pluralRules) {
String formatStr = numberFormat.format(number);
StandardPlural p = selectPlural(number, numberFormat, pluralRules);
SimpleFormatter formatter = templates[p.ordinal()];
if (formatter == null) {
formatter = templates[StandardPlural.OTHER_INDEX];
assert formatter != null;
}
return formatter.format(formatStr);
} | java | public String format(double number, NumberFormat numberFormat, PluralRules pluralRules) {
String formatStr = numberFormat.format(number);
StandardPlural p = selectPlural(number, numberFormat, pluralRules);
SimpleFormatter formatter = templates[p.ordinal()];
if (formatter == null) {
formatter = templates[StandardPlural.OTHER_INDEX];
assert formatter != null;
}
return formatter.format(formatStr);
} | [
"public",
"String",
"format",
"(",
"double",
"number",
",",
"NumberFormat",
"numberFormat",
",",
"PluralRules",
"pluralRules",
")",
"{",
"String",
"formatStr",
"=",
"numberFormat",
".",
"format",
"(",
"number",
")",
";",
"StandardPlural",
"p",
"=",
"selectPlural... | Format formats a number with this object.
@param number the number to be formatted
@param numberFormat used to actually format the number.
@param pluralRules uses the number and the numberFormat to determine what plural
variant to use for fetching the formatting template.
@return the formatted string e.g '3 apples' | [
"Format",
"formats",
"a",
"number",
"with",
"this",
"object",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java#L65-L74 |
34,603 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java | QuantityFormatter.getByVariant | public SimpleFormatter getByVariant(CharSequence variant) {
assert isValid();
int idx = StandardPlural.indexOrOtherIndexFromString(variant);
SimpleFormatter template = templates[idx];
return (template == null && idx != StandardPlural.OTHER_INDEX) ?
templates[StandardPlural.OTHER_INDEX] : template;
} | java | public SimpleFormatter getByVariant(CharSequence variant) {
assert isValid();
int idx = StandardPlural.indexOrOtherIndexFromString(variant);
SimpleFormatter template = templates[idx];
return (template == null && idx != StandardPlural.OTHER_INDEX) ?
templates[StandardPlural.OTHER_INDEX] : template;
} | [
"public",
"SimpleFormatter",
"getByVariant",
"(",
"CharSequence",
"variant",
")",
"{",
"assert",
"isValid",
"(",
")",
";",
"int",
"idx",
"=",
"StandardPlural",
".",
"indexOrOtherIndexFromString",
"(",
"variant",
")",
";",
"SimpleFormatter",
"template",
"=",
"templ... | Gets the SimpleFormatter for a particular variant.
@param variant "zero", "one", "two", "few", "many", "other"
@return the SimpleFormatter | [
"Gets",
"the",
"SimpleFormatter",
"for",
"a",
"particular",
"variant",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java#L81-L87 |
34,604 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java | QuantityFormatter.format | public static StringBuilder format(String compiledPattern, CharSequence value,
StringBuilder appendTo, FieldPosition pos) {
int[] offsets = new int[1];
SimpleFormatterImpl.formatAndAppend(compiledPattern, appendTo, offsets, value);
if (pos.getBeginIndex() != 0 || pos.getEndIndex() != 0) {
if (offsets[0] >= 0) {
pos.setBeginIndex(pos.getBeginIndex() + offsets[0]);
pos.setEndIndex(pos.getEndIndex() + offsets[0]);
} else {
pos.setBeginIndex(0);
pos.setEndIndex(0);
}
}
return appendTo;
} | java | public static StringBuilder format(String compiledPattern, CharSequence value,
StringBuilder appendTo, FieldPosition pos) {
int[] offsets = new int[1];
SimpleFormatterImpl.formatAndAppend(compiledPattern, appendTo, offsets, value);
if (pos.getBeginIndex() != 0 || pos.getEndIndex() != 0) {
if (offsets[0] >= 0) {
pos.setBeginIndex(pos.getBeginIndex() + offsets[0]);
pos.setEndIndex(pos.getEndIndex() + offsets[0]);
} else {
pos.setBeginIndex(0);
pos.setEndIndex(0);
}
}
return appendTo;
} | [
"public",
"static",
"StringBuilder",
"format",
"(",
"String",
"compiledPattern",
",",
"CharSequence",
"value",
",",
"StringBuilder",
"appendTo",
",",
"FieldPosition",
"pos",
")",
"{",
"int",
"[",
"]",
"offsets",
"=",
"new",
"int",
"[",
"1",
"]",
";",
"Simple... | Formats the pattern with the value and adjusts the FieldPosition. | [
"Formats",
"the",
"pattern",
"with",
"the",
"value",
"and",
"adjusts",
"the",
"FieldPosition",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/QuantityFormatter.java#L126-L140 |
34,605 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Normalizer2.java | Normalizer2.normalize | public String normalize(CharSequence src) {
if(src instanceof String) {
// Fastpath: Do not construct a new String if the src is a String
// and is already normalized.
int spanLength=spanQuickCheckYes(src);
if(spanLength==src.length()) {
return (String)src;
}
StringBuilder sb=new StringBuilder(src.length()).append(src, 0, spanLength);
return normalizeSecondAndAppend(sb, src.subSequence(spanLength, src.length())).toString();
}
return normalize(src, new StringBuilder(src.length())).toString();
} | java | public String normalize(CharSequence src) {
if(src instanceof String) {
// Fastpath: Do not construct a new String if the src is a String
// and is already normalized.
int spanLength=spanQuickCheckYes(src);
if(spanLength==src.length()) {
return (String)src;
}
StringBuilder sb=new StringBuilder(src.length()).append(src, 0, spanLength);
return normalizeSecondAndAppend(sb, src.subSequence(spanLength, src.length())).toString();
}
return normalize(src, new StringBuilder(src.length())).toString();
} | [
"public",
"String",
"normalize",
"(",
"CharSequence",
"src",
")",
"{",
"if",
"(",
"src",
"instanceof",
"String",
")",
"{",
"// Fastpath: Do not construct a new String if the src is a String",
"// and is already normalized.",
"int",
"spanLength",
"=",
"spanQuickCheckYes",
"(... | Returns the normalized form of the source string.
@param src source string
@return normalized src | [
"Returns",
"the",
"normalized",
"form",
"of",
"the",
"source",
"string",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Normalizer2.java#L206-L218 |
34,606 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/CertificatePolicyMap.java | CertificatePolicyMap.encode | public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
issuerDomain.encode(tmp);
subjectDomain.encode(tmp);
out.write(DerValue.tag_Sequence,tmp);
} | java | public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
issuerDomain.encode(tmp);
subjectDomain.encode(tmp);
out.write(DerValue.tag_Sequence,tmp);
} | [
"public",
"void",
"encode",
"(",
"DerOutputStream",
"out",
")",
"throws",
"IOException",
"{",
"DerOutputStream",
"tmp",
"=",
"new",
"DerOutputStream",
"(",
")",
";",
"issuerDomain",
".",
"encode",
"(",
"tmp",
")",
";",
"subjectDomain",
".",
"encode",
"(",
"t... | Write the CertificatePolicyMap to the DerOutputStream.
@param out the DerOutputStream to write the object to.
@exception IOException on errors. | [
"Write",
"the",
"CertificatePolicyMap",
"to",
"the",
"DerOutputStream",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/CertificatePolicyMap.java#L99-L105 |
34,607 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/Mappings.java | Mappings.addMapping | private static void addMapping(Map<String, String> map, String key, String value, String kind) {
String oldValue = map.put(key, value);
if (oldValue != null && !oldValue.equals(value)) {
ErrorUtil.error(kind + " redefined; was \"" + oldValue + ", now " + value);
}
} | java | private static void addMapping(Map<String, String> map, String key, String value, String kind) {
String oldValue = map.put(key, value);
if (oldValue != null && !oldValue.equals(value)) {
ErrorUtil.error(kind + " redefined; was \"" + oldValue + ", now " + value);
}
} | [
"private",
"static",
"void",
"addMapping",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
",",
"String",
"key",
",",
"String",
"value",
",",
"String",
"kind",
")",
"{",
"String",
"oldValue",
"=",
"map",
".",
"put",
"(",
"key",
",",
"value",
")... | Adds a class, method or package-prefix property to its map, reporting an error
if that mapping was previously specified. | [
"Adds",
"a",
"class",
"method",
"or",
"package",
"-",
"prefix",
"property",
"to",
"its",
"map",
"reporting",
"an",
"error",
"if",
"that",
"mapping",
"was",
"previously",
"specified",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/Mappings.java#L121-L126 |
34,608 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/OCSP.java | OCSP.initializeTimeout | private static int initializeTimeout() {
// Integer tmp = java.security.AccessController.doPrivileged(
// new GetIntegerAction("com.sun.security.ocsp.timeout"));
Integer tmp = Integer.getInteger("com.sun.security.ocsp.timeout");
if (tmp == null || tmp < 0) {
return DEFAULT_CONNECT_TIMEOUT;
}
// Convert to milliseconds, as the system property will be
// specified in seconds
return tmp * 1000;
} | java | private static int initializeTimeout() {
// Integer tmp = java.security.AccessController.doPrivileged(
// new GetIntegerAction("com.sun.security.ocsp.timeout"));
Integer tmp = Integer.getInteger("com.sun.security.ocsp.timeout");
if (tmp == null || tmp < 0) {
return DEFAULT_CONNECT_TIMEOUT;
}
// Convert to milliseconds, as the system property will be
// specified in seconds
return tmp * 1000;
} | [
"private",
"static",
"int",
"initializeTimeout",
"(",
")",
"{",
"// Integer tmp = java.security.AccessController.doPrivileged(",
"// new GetIntegerAction(\"com.sun.security.ocsp.timeout\"));",
"Integer",
"tmp",
"=",
"Integer",
".",
"getInteger",
"(",
"\"com.sun.... | Initialize the timeout length by getting the OCSP timeout
system property. If the property has not been set, or if its
value is negative, set the timeout length to the default. | [
"Initialize",
"the",
"timeout",
"length",
"by",
"getting",
"the",
"OCSP",
"timeout",
"system",
"property",
".",
"If",
"the",
"property",
"has",
"not",
"been",
"set",
"or",
"if",
"its",
"value",
"is",
"negative",
"set",
"the",
"timeout",
"length",
"to",
"th... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/OCSP.java#L86-L96 |
34,609 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/OCSP.java | OCSP.check | public static RevocationStatus check(X509Certificate cert,
X509Certificate issuerCert,
URI responderURI,
X509Certificate responderCert,
Date date)
throws IOException, CertPathValidatorException
{
return check(cert, issuerCert, responderURI, responderCert, date,
Collections.<Extension>emptyList());
} | java | public static RevocationStatus check(X509Certificate cert,
X509Certificate issuerCert,
URI responderURI,
X509Certificate responderCert,
Date date)
throws IOException, CertPathValidatorException
{
return check(cert, issuerCert, responderURI, responderCert, date,
Collections.<Extension>emptyList());
} | [
"public",
"static",
"RevocationStatus",
"check",
"(",
"X509Certificate",
"cert",
",",
"X509Certificate",
"issuerCert",
",",
"URI",
"responderURI",
",",
"X509Certificate",
"responderCert",
",",
"Date",
"date",
")",
"throws",
"IOException",
",",
"CertPathValidatorExceptio... | Obtains the revocation status of a certificate using OCSP.
@param cert the certificate to be checked
@param issuerCert the issuer certificate
@param responderURI the URI of the OCSP responder
@param responderCert the OCSP responder's certificate
@param date the time the validity of the OCSP responder's certificate
should be checked against. If null, the current time is used.
@return the RevocationStatus
@throws IOException if there is an exception connecting to or
communicating with the OCSP responder
@throws CertPathValidatorException if an exception occurs while
encoding the OCSP Request or validating the OCSP Response | [
"Obtains",
"the",
"revocation",
"status",
"of",
"a",
"certificate",
"using",
"OCSP",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/OCSP.java#L152-L161 |
34,610 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java | LinkedList.linkBefore | void linkBefore(E e, Node<E> succ) {
// assert succ != null;
final Node<E> pred = succ.prev;
final Node<E> newNode = new Node<>(pred, e, succ);
succ.prev = newNode;
if (pred == null)
first = newNode;
else
pred.next = newNode;
size++;
modCount++;
} | java | void linkBefore(E e, Node<E> succ) {
// assert succ != null;
final Node<E> pred = succ.prev;
final Node<E> newNode = new Node<>(pred, e, succ);
succ.prev = newNode;
if (pred == null)
first = newNode;
else
pred.next = newNode;
size++;
modCount++;
} | [
"void",
"linkBefore",
"(",
"E",
"e",
",",
"Node",
"<",
"E",
">",
"succ",
")",
"{",
"// assert succ != null;",
"final",
"Node",
"<",
"E",
">",
"pred",
"=",
"succ",
".",
"prev",
";",
"final",
"Node",
"<",
"E",
">",
"newNode",
"=",
"new",
"Node",
"<>"... | Inserts element e before non-null Node succ. | [
"Inserts",
"element",
"e",
"before",
"non",
"-",
"null",
"Node",
"succ",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java#L157-L168 |
34,611 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java | LinkedList.unlinkFirst | private E unlinkFirst(Node<E> f) {
// assert f == first && f != null;
final E element = f.item;
final Node<E> next = f.next;
f.item = null;
f.next = null; // help GC
first = next;
if (next == null)
last = null;
else
next.prev = null;
size--;
modCount++;
return element;
} | java | private E unlinkFirst(Node<E> f) {
// assert f == first && f != null;
final E element = f.item;
final Node<E> next = f.next;
f.item = null;
f.next = null; // help GC
first = next;
if (next == null)
last = null;
else
next.prev = null;
size--;
modCount++;
return element;
} | [
"private",
"E",
"unlinkFirst",
"(",
"Node",
"<",
"E",
">",
"f",
")",
"{",
"// assert f == first && f != null;",
"final",
"E",
"element",
"=",
"f",
".",
"item",
";",
"final",
"Node",
"<",
"E",
">",
"next",
"=",
"f",
".",
"next",
";",
"f",
".",
"item",... | Unlinks non-null first node f. | [
"Unlinks",
"non",
"-",
"null",
"first",
"node",
"f",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java#L173-L187 |
34,612 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java | LinkedList.unlinkLast | private E unlinkLast(Node<E> l) {
// assert l == last && l != null;
final E element = l.item;
final Node<E> prev = l.prev;
l.item = null;
l.prev = null; // help GC
last = prev;
if (prev == null)
first = null;
else
prev.next = null;
size--;
modCount++;
return element;
} | java | private E unlinkLast(Node<E> l) {
// assert l == last && l != null;
final E element = l.item;
final Node<E> prev = l.prev;
l.item = null;
l.prev = null; // help GC
last = prev;
if (prev == null)
first = null;
else
prev.next = null;
size--;
modCount++;
return element;
} | [
"private",
"E",
"unlinkLast",
"(",
"Node",
"<",
"E",
">",
"l",
")",
"{",
"// assert l == last && l != null;",
"final",
"E",
"element",
"=",
"l",
".",
"item",
";",
"final",
"Node",
"<",
"E",
">",
"prev",
"=",
"l",
".",
"prev",
";",
"l",
".",
"item",
... | Unlinks non-null last node l. | [
"Unlinks",
"non",
"-",
"null",
"last",
"node",
"l",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java#L192-L206 |
34,613 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java | LinkedList.getFirst | public E getFirst() {
final Node<E> f = first;
if (f == null)
throw new NoSuchElementException();
return f.item;
} | java | public E getFirst() {
final Node<E> f = first;
if (f == null)
throw new NoSuchElementException();
return f.item;
} | [
"public",
"E",
"getFirst",
"(",
")",
"{",
"final",
"Node",
"<",
"E",
">",
"f",
"=",
"first",
";",
"if",
"(",
"f",
"==",
"null",
")",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"return",
"f",
".",
"item",
";",
"}"
] | Returns the first element in this list.
@return the first element in this list
@throws NoSuchElementException if this list is empty | [
"Returns",
"the",
"first",
"element",
"in",
"this",
"list",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java#L243-L248 |
34,614 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java | LinkedList.getLast | public E getLast() {
final Node<E> l = last;
if (l == null)
throw new NoSuchElementException();
return l.item;
} | java | public E getLast() {
final Node<E> l = last;
if (l == null)
throw new NoSuchElementException();
return l.item;
} | [
"public",
"E",
"getLast",
"(",
")",
"{",
"final",
"Node",
"<",
"E",
">",
"l",
"=",
"last",
";",
"if",
"(",
"l",
"==",
"null",
")",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"return",
"l",
".",
"item",
";",
"}"
] | Returns the last element in this list.
@return the last element in this list
@throws NoSuchElementException if this list is empty | [
"Returns",
"the",
"last",
"element",
"in",
"this",
"list",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java#L256-L261 |
34,615 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java | LinkedList.removeFirst | public E removeFirst() {
final Node<E> f = first;
if (f == null)
throw new NoSuchElementException();
return unlinkFirst(f);
} | java | public E removeFirst() {
final Node<E> f = first;
if (f == null)
throw new NoSuchElementException();
return unlinkFirst(f);
} | [
"public",
"E",
"removeFirst",
"(",
")",
"{",
"final",
"Node",
"<",
"E",
">",
"f",
"=",
"first",
";",
"if",
"(",
"f",
"==",
"null",
")",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"return",
"unlinkFirst",
"(",
"f",
")",
";",
"}"
] | Removes and returns the first element from this list.
@return the first element from this list
@throws NoSuchElementException if this list is empty | [
"Removes",
"and",
"returns",
"the",
"first",
"element",
"from",
"this",
"list",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java#L269-L274 |
34,616 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java | LinkedList.removeLast | public E removeLast() {
final Node<E> l = last;
if (l == null)
throw new NoSuchElementException();
return unlinkLast(l);
} | java | public E removeLast() {
final Node<E> l = last;
if (l == null)
throw new NoSuchElementException();
return unlinkLast(l);
} | [
"public",
"E",
"removeLast",
"(",
")",
"{",
"final",
"Node",
"<",
"E",
">",
"l",
"=",
"last",
";",
"if",
"(",
"l",
"==",
"null",
")",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"return",
"unlinkLast",
"(",
"l",
")",
";",
"}"
] | Removes and returns the last element from this list.
@return the last element from this list
@throws NoSuchElementException if this list is empty | [
"Removes",
"and",
"returns",
"the",
"last",
"element",
"from",
"this",
"list",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/LinkedList.java#L282-L287 |
34,617 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/JarURLConnection.java | JarURLConnection.getAttributes | public Attributes getAttributes() throws IOException {
JarEntry e = getJarEntry();
return e != null ? e.getAttributes() : null;
} | java | public Attributes getAttributes() throws IOException {
JarEntry e = getJarEntry();
return e != null ? e.getAttributes() : null;
} | [
"public",
"Attributes",
"getAttributes",
"(",
")",
"throws",
"IOException",
"{",
"JarEntry",
"e",
"=",
"getJarEntry",
"(",
")",
";",
"return",
"e",
"!=",
"null",
"?",
"e",
".",
"getAttributes",
"(",
")",
":",
"null",
";",
"}"
] | Return the Attributes object for this connection if the URL
for it points to a JAR file entry, null otherwise.
@return the Attributes object for this connection if the URL
for it points to a JAR file entry, null otherwise.
@exception IOException if getting the JAR entry causes an
IOException to be thrown.
@see #getJarEntry | [
"Return",
"the",
"Attributes",
"object",
"for",
"this",
"connection",
"if",
"the",
"URL",
"for",
"it",
"points",
"to",
"a",
"JAR",
"file",
"entry",
"null",
"otherwise",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/JarURLConnection.java#L264-L267 |
34,618 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/JarURLConnection.java | JarURLConnection.getMainAttributes | public Attributes getMainAttributes() throws IOException {
Manifest man = getManifest();
return man != null ? man.getMainAttributes() : null;
} | java | public Attributes getMainAttributes() throws IOException {
Manifest man = getManifest();
return man != null ? man.getMainAttributes() : null;
} | [
"public",
"Attributes",
"getMainAttributes",
"(",
")",
"throws",
"IOException",
"{",
"Manifest",
"man",
"=",
"getManifest",
"(",
")",
";",
"return",
"man",
"!=",
"null",
"?",
"man",
".",
"getMainAttributes",
"(",
")",
":",
"null",
";",
"}"
] | Returns the main Attributes for the JAR file for this
connection.
@return the main Attributes for the JAR file for this
connection.
@exception IOException if getting the manifest causes an
IOException to be thrown.
@see #getJarFile
@see #getManifest | [
"Returns",
"the",
"main",
"Attributes",
"for",
"the",
"JAR",
"file",
"for",
"this",
"connection",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/JarURLConnection.java#L282-L285 |
34,619 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TransliterationRuleSet.java | TransliterationRuleSet.addRule | public void addRule(TransliterationRule rule) {
ruleVector.add(rule);
int len;
if ((len = rule.getAnteContextLength()) > maxContextLength) {
maxContextLength = len;
}
rules = null;
} | java | public void addRule(TransliterationRule rule) {
ruleVector.add(rule);
int len;
if ((len = rule.getAnteContextLength()) > maxContextLength) {
maxContextLength = len;
}
rules = null;
} | [
"public",
"void",
"addRule",
"(",
"TransliterationRule",
"rule",
")",
"{",
"ruleVector",
".",
"add",
"(",
"rule",
")",
";",
"int",
"len",
";",
"if",
"(",
"(",
"len",
"=",
"rule",
".",
"getAnteContextLength",
"(",
")",
")",
">",
"maxContextLength",
")",
... | Add a rule to this set. Rules are added in order, and order is
significant.
@param rule the rule to add | [
"Add",
"a",
"rule",
"to",
"this",
"set",
".",
"Rules",
"are",
"added",
"in",
"order",
"and",
"order",
"is",
"significant",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TransliterationRuleSet.java#L78-L86 |
34,620 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TransliterationRuleSet.java | TransliterationRuleSet.freeze | public void freeze() {
/* Construct the rule array and index table. We reorder the
* rules by sorting them into 256 bins. Each bin contains all
* rules matching the index value for that bin. A rule
* matches an index value if string whose first key character
* has a low byte equal to the index value can match the rule.
*
* Each bin contains zero or more rules, in the same order
* they were found originally. However, the total rules in
* the bins may exceed the number in the original vector,
* since rules that have a variable as their first key
* character will generally fall into more than one bin.
*
* That is, each bin contains all rules that either have that
* first index value as their first key character, or have
* a set containing the index value as their first character.
*/
int n = ruleVector.size();
index = new int[257]; // [sic]
List<TransliterationRule> v = new ArrayList<TransliterationRule>(2*n); // heuristic; adjust as needed
/* Precompute the index values. This saves a LOT of time.
*/
int[] indexValue = new int[n];
for (int j=0; j<n; ++j) {
TransliterationRule r = ruleVector.get(j);
indexValue[j] = r.getIndexValue();
}
for (int x=0; x<256; ++x) {
index[x] = v.size();
for (int j=0; j<n; ++j) {
if (indexValue[j] >= 0) {
if (indexValue[j] == x) {
v.add(ruleVector.get(j));
}
} else {
// If the indexValue is < 0, then the first key character is
// a set, and we must use the more time-consuming
// matchesIndexValue check. In practice this happens
// rarely, so we seldom tread this code path.
TransliterationRule r = ruleVector.get(j);
if (r.matchesIndexValue(x)) {
v.add(r);
}
}
}
}
index[256] = v.size();
/* Freeze things into an array.
*/
rules = new TransliterationRule[v.size()];
v.toArray(rules);
StringBuilder errors = null;
/* Check for masking. This is MUCH faster than our old check,
* which was each rule against each following rule, since we
* only have to check for masking within each bin now. It's
* 256*O(n2^2) instead of O(n1^2), where n1 is the total rule
* count, and n2 is the per-bin rule count. But n2<<n1, so
* it's a big win.
*/
for (int x=0; x<256; ++x) {
for (int j=index[x]; j<index[x+1]-1; ++j) {
TransliterationRule r1 = rules[j];
for (int k=j+1; k<index[x+1]; ++k) {
TransliterationRule r2 = rules[k];
if (r1.masks(r2)) {
if (errors == null) {
errors = new StringBuilder();
} else {
errors.append("\n");
}
errors.append("Rule " + r1 + " masks " + r2);
}
}
}
}
if (errors != null) {
throw new IllegalArgumentException(errors.toString());
}
} | java | public void freeze() {
/* Construct the rule array and index table. We reorder the
* rules by sorting them into 256 bins. Each bin contains all
* rules matching the index value for that bin. A rule
* matches an index value if string whose first key character
* has a low byte equal to the index value can match the rule.
*
* Each bin contains zero or more rules, in the same order
* they were found originally. However, the total rules in
* the bins may exceed the number in the original vector,
* since rules that have a variable as their first key
* character will generally fall into more than one bin.
*
* That is, each bin contains all rules that either have that
* first index value as their first key character, or have
* a set containing the index value as their first character.
*/
int n = ruleVector.size();
index = new int[257]; // [sic]
List<TransliterationRule> v = new ArrayList<TransliterationRule>(2*n); // heuristic; adjust as needed
/* Precompute the index values. This saves a LOT of time.
*/
int[] indexValue = new int[n];
for (int j=0; j<n; ++j) {
TransliterationRule r = ruleVector.get(j);
indexValue[j] = r.getIndexValue();
}
for (int x=0; x<256; ++x) {
index[x] = v.size();
for (int j=0; j<n; ++j) {
if (indexValue[j] >= 0) {
if (indexValue[j] == x) {
v.add(ruleVector.get(j));
}
} else {
// If the indexValue is < 0, then the first key character is
// a set, and we must use the more time-consuming
// matchesIndexValue check. In practice this happens
// rarely, so we seldom tread this code path.
TransliterationRule r = ruleVector.get(j);
if (r.matchesIndexValue(x)) {
v.add(r);
}
}
}
}
index[256] = v.size();
/* Freeze things into an array.
*/
rules = new TransliterationRule[v.size()];
v.toArray(rules);
StringBuilder errors = null;
/* Check for masking. This is MUCH faster than our old check,
* which was each rule against each following rule, since we
* only have to check for masking within each bin now. It's
* 256*O(n2^2) instead of O(n1^2), where n1 is the total rule
* count, and n2 is the per-bin rule count. But n2<<n1, so
* it's a big win.
*/
for (int x=0; x<256; ++x) {
for (int j=index[x]; j<index[x+1]-1; ++j) {
TransliterationRule r1 = rules[j];
for (int k=j+1; k<index[x+1]; ++k) {
TransliterationRule r2 = rules[k];
if (r1.masks(r2)) {
if (errors == null) {
errors = new StringBuilder();
} else {
errors.append("\n");
}
errors.append("Rule " + r1 + " masks " + r2);
}
}
}
}
if (errors != null) {
throw new IllegalArgumentException(errors.toString());
}
} | [
"public",
"void",
"freeze",
"(",
")",
"{",
"/* Construct the rule array and index table. We reorder the\n * rules by sorting them into 256 bins. Each bin contains all\n * rules matching the index value for that bin. A rule\n * matches an index value if string whose first key c... | Close this rule set to further additions, check it for masked rules,
and index it to optimize performance.
@exception IllegalArgumentException if some rules are masked | [
"Close",
"this",
"rule",
"set",
"to",
"further",
"additions",
"check",
"it",
"for",
"masked",
"rules",
"and",
"index",
"it",
"to",
"optimize",
"performance",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TransliterationRuleSet.java#L93-L176 |
34,621 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TransliterationRuleSet.java | TransliterationRuleSet.toRules | String toRules(boolean escapeUnprintable) {
int i;
int count = ruleVector.size();
StringBuilder ruleSource = new StringBuilder();
for (i=0; i<count; ++i) {
if (i != 0) {
ruleSource.append('\n');
}
TransliterationRule r = ruleVector.get(i);
ruleSource.append(r.toRule(escapeUnprintable));
}
return ruleSource.toString();
} | java | String toRules(boolean escapeUnprintable) {
int i;
int count = ruleVector.size();
StringBuilder ruleSource = new StringBuilder();
for (i=0; i<count; ++i) {
if (i != 0) {
ruleSource.append('\n');
}
TransliterationRule r = ruleVector.get(i);
ruleSource.append(r.toRule(escapeUnprintable));
}
return ruleSource.toString();
} | [
"String",
"toRules",
"(",
"boolean",
"escapeUnprintable",
")",
"{",
"int",
"i",
";",
"int",
"count",
"=",
"ruleVector",
".",
"size",
"(",
")",
";",
"StringBuilder",
"ruleSource",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";... | Create rule strings that represents this rule set. | [
"Create",
"rule",
"strings",
"that",
"represents",
"this",
"rule",
"set",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TransliterationRuleSet.java#L230-L242 |
34,622 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/translate/SwitchRewriter.java | SwitchRewriter.fixVariableDeclarations | private void fixVariableDeclarations(SwitchStatement node) {
List<Statement> statements = node.getStatements();
Block block = new Block();
List<Statement> blockStmts = block.getStatements();
for (int i = 0; i < statements.size(); i++) {
Statement stmt = statements.get(i);
if (stmt instanceof VariableDeclarationStatement) {
VariableDeclarationStatement declStmt = (VariableDeclarationStatement) stmt;
statements.remove(i--);
List<VariableDeclarationFragment> fragments = declStmt.getFragments();
for (VariableDeclarationFragment decl : fragments) {
Expression initializer = decl.getInitializer();
if (initializer != null) {
Assignment assignment = new Assignment(
new SimpleName(decl.getVariableElement()), TreeUtil.remove(initializer));
statements.add(++i, new ExpressionStatement(assignment));
}
}
blockStmts.add(declStmt);
}
}
if (blockStmts.size() > 0) {
// There is at least one variable declaration, so copy this switch
// statement into the new block and replace it in the parent list.
node.replaceWith(block);
blockStmts.add(node);
}
} | java | private void fixVariableDeclarations(SwitchStatement node) {
List<Statement> statements = node.getStatements();
Block block = new Block();
List<Statement> blockStmts = block.getStatements();
for (int i = 0; i < statements.size(); i++) {
Statement stmt = statements.get(i);
if (stmt instanceof VariableDeclarationStatement) {
VariableDeclarationStatement declStmt = (VariableDeclarationStatement) stmt;
statements.remove(i--);
List<VariableDeclarationFragment> fragments = declStmt.getFragments();
for (VariableDeclarationFragment decl : fragments) {
Expression initializer = decl.getInitializer();
if (initializer != null) {
Assignment assignment = new Assignment(
new SimpleName(decl.getVariableElement()), TreeUtil.remove(initializer));
statements.add(++i, new ExpressionStatement(assignment));
}
}
blockStmts.add(declStmt);
}
}
if (blockStmts.size() > 0) {
// There is at least one variable declaration, so copy this switch
// statement into the new block and replace it in the parent list.
node.replaceWith(block);
blockStmts.add(node);
}
} | [
"private",
"void",
"fixVariableDeclarations",
"(",
"SwitchStatement",
"node",
")",
"{",
"List",
"<",
"Statement",
">",
"statements",
"=",
"node",
".",
"getStatements",
"(",
")",
";",
"Block",
"block",
"=",
"new",
"Block",
"(",
")",
";",
"List",
"<",
"State... | Moves all variable declarations above the first case statement. | [
"Moves",
"all",
"variable",
"declarations",
"above",
"the",
"first",
"case",
"statement",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/translate/SwitchRewriter.java#L101-L128 |
34,623 | google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/libcore/reflect/AnnotatedElements.java | AnnotatedElements.insertAnnotationValues | private static <T extends Annotation> void insertAnnotationValues(Annotation annotation,
Class<T> annotationClass, ArrayList<T> unfoldedAnnotations) {
// annotation is a complex annotation which has elements of instance annotationClass
// (whose static type is T).
//
// @interface SomeName { <--- = annotation.getClass()
// ...
// T[] value(); <--- T.class == annotationClass
// }
//
// Use reflection to access these values.
Class<T[]> annotationArrayClass =
(Class<T[]>)((T[])Array.newInstance(annotationClass, 0)).getClass();
Method valuesMethod;
try {
valuesMethod = annotation.getClass().getDeclaredMethod("value");
// This will always succeed unless the annotation and its repeatable annotation class were
// recompiled separately, then this is a binary incompatibility error.
} catch (NoSuchMethodException e) {
throw new AssertionError("annotation container = " + annotation +
"annotation element class = " + annotationClass + "; missing value() method");
} catch (SecurityException e) {
throw new IncompleteAnnotationException(annotation.getClass(), "value");
}
// Ensure that value() returns a T[]
if (!valuesMethod.getReturnType().isArray()) {
throw new AssertionError("annotation container = " + annotation +
"annotation element class = " + annotationClass + "; value() doesn't return array");
}
// Ensure that the T[] value() is actually the correct type (T==annotationClass).
if (!annotationClass.equals(valuesMethod.getReturnType().getComponentType())) {
throw new AssertionError("annotation container = " + annotation +
"annotation element class = " + annotationClass + "; value() returns incorrect type");
}
// Append those values into the existing list.
T[] nestedAnnotations;
try {
nestedAnnotations = (T[])valuesMethod.invoke(annotation); // Safe because of #getMethod.
} catch (IllegalAccessException|InvocationTargetException e) {
throw new AssertionError(e);
}
for (int i = 0; i < nestedAnnotations.length; ++i) {
unfoldedAnnotations.add(nestedAnnotations[i]);
}
} | java | private static <T extends Annotation> void insertAnnotationValues(Annotation annotation,
Class<T> annotationClass, ArrayList<T> unfoldedAnnotations) {
// annotation is a complex annotation which has elements of instance annotationClass
// (whose static type is T).
//
// @interface SomeName { <--- = annotation.getClass()
// ...
// T[] value(); <--- T.class == annotationClass
// }
//
// Use reflection to access these values.
Class<T[]> annotationArrayClass =
(Class<T[]>)((T[])Array.newInstance(annotationClass, 0)).getClass();
Method valuesMethod;
try {
valuesMethod = annotation.getClass().getDeclaredMethod("value");
// This will always succeed unless the annotation and its repeatable annotation class were
// recompiled separately, then this is a binary incompatibility error.
} catch (NoSuchMethodException e) {
throw new AssertionError("annotation container = " + annotation +
"annotation element class = " + annotationClass + "; missing value() method");
} catch (SecurityException e) {
throw new IncompleteAnnotationException(annotation.getClass(), "value");
}
// Ensure that value() returns a T[]
if (!valuesMethod.getReturnType().isArray()) {
throw new AssertionError("annotation container = " + annotation +
"annotation element class = " + annotationClass + "; value() doesn't return array");
}
// Ensure that the T[] value() is actually the correct type (T==annotationClass).
if (!annotationClass.equals(valuesMethod.getReturnType().getComponentType())) {
throw new AssertionError("annotation container = " + annotation +
"annotation element class = " + annotationClass + "; value() returns incorrect type");
}
// Append those values into the existing list.
T[] nestedAnnotations;
try {
nestedAnnotations = (T[])valuesMethod.invoke(annotation); // Safe because of #getMethod.
} catch (IllegalAccessException|InvocationTargetException e) {
throw new AssertionError(e);
}
for (int i = 0; i < nestedAnnotations.length; ++i) {
unfoldedAnnotations.add(nestedAnnotations[i]);
}
} | [
"private",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"void",
"insertAnnotationValues",
"(",
"Annotation",
"annotation",
",",
"Class",
"<",
"T",
">",
"annotationClass",
",",
"ArrayList",
"<",
"T",
">",
"unfoldedAnnotations",
")",
"{",
"// annotation is a co... | Extracts annotations from a container annotation and inserts them into a list.
<p>
Given a complex annotation "annotation", it should have a "T[] value()" method on it.
Call that method and add all of the nested annotations into unfoldedAnnotations list.
</p> | [
"Extracts",
"annotations",
"from",
"a",
"container",
"annotation",
"and",
"inserts",
"them",
"into",
"a",
"list",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/libcore/reflect/AnnotatedElements.java#L78-L127 |
34,624 | google/j2objc | jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java | ReflectionUtil.matchClassNamePrefix | public static boolean matchClassNamePrefix(String actual, String expected) {
return actual.equals(expected) || actual.equals(getCamelCase(expected));
} | java | public static boolean matchClassNamePrefix(String actual, String expected) {
return actual.equals(expected) || actual.equals(getCamelCase(expected));
} | [
"public",
"static",
"boolean",
"matchClassNamePrefix",
"(",
"String",
"actual",
",",
"String",
"expected",
")",
"{",
"return",
"actual",
".",
"equals",
"(",
"expected",
")",
"||",
"actual",
".",
"equals",
"(",
"getCamelCase",
"(",
"expected",
")",
")",
";",
... | When reflection is stripped, the transpiled code uses NSStringFromClass to return the name of a
class. For example, instead of getting something like java.lang.Throwable, we get
JavaLangThrowable.
<p>This method assumes that {@code actual} and {@code expected} contain a class name as prefix.
Firts, it compares directly {@code actual} to {@code expected}; if it fails, then it compares
{@actual} to the cammel case version of {@code expected}. | [
"When",
"reflection",
"is",
"stripped",
"the",
"transpiled",
"code",
"uses",
"NSStringFromClass",
"to",
"return",
"the",
"name",
"of",
"a",
"class",
".",
"For",
"example",
"instead",
"of",
"getting",
"something",
"like",
"java",
".",
"lang",
".",
"Throwable",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java#L36-L38 |
34,625 | google/j2objc | jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java | ReflectionUtil.getSerialVersionUID | public static long getSerialVersionUID(Class<? extends Serializable> clazz) {
try {
return clazz.getField("serialVersionUID").getLong(null);
} catch (NoSuchFieldException | IllegalAccessException ex) {
// ignored.
return 0;
}
} | java | public static long getSerialVersionUID(Class<? extends Serializable> clazz) {
try {
return clazz.getField("serialVersionUID").getLong(null);
} catch (NoSuchFieldException | IllegalAccessException ex) {
// ignored.
return 0;
}
} | [
"public",
"static",
"long",
"getSerialVersionUID",
"(",
"Class",
"<",
"?",
"extends",
"Serializable",
">",
"clazz",
")",
"{",
"try",
"{",
"return",
"clazz",
".",
"getField",
"(",
"\"serialVersionUID\"",
")",
".",
"getLong",
"(",
"null",
")",
";",
"}",
"cat... | Transpiled code that directly acccess the serialVersionUID field when reflection is stripped
won't compile because this field is also stripped.
<p>Accessing it via reflection allows the non-stripped code to keep the same behavior and
allows the stripped code to compile. Note that in the later case, a ReflectionStrippedError
will be thrown, this is OK because serialization code is not supported when reflection is
stripped. | [
"Transpiled",
"code",
"that",
"directly",
"acccess",
"the",
"serialVersionUID",
"field",
"when",
"reflection",
"is",
"stripped",
"won",
"t",
"compile",
"because",
"this",
"field",
"is",
"also",
"stripped",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java#L55-L62 |
34,626 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UTS46.java | UTS46.checkLabelBiDi | private void
checkLabelBiDi(CharSequence label, int labelStart, int labelLength, Info info) {
// IDNA2008 BiDi rule
// Get the directionality of the first character.
int c;
int i=labelStart;
c=Character.codePointAt(label, i);
i+=Character.charCount(c);
int firstMask=U_MASK(UBiDiProps.INSTANCE.getClass(c));
// 1. The first character must be a character with BIDI property L, R
// or AL. If it has the R or AL property, it is an RTL label; if it
// has the L property, it is an LTR label.
if((firstMask&~L_R_AL_MASK)!=0) {
setNotOkBiDi(info);
}
// Get the directionality of the last non-NSM character.
int lastMask;
int labelLimit=labelStart+labelLength;
for(;;) {
if(i>=labelLimit) {
lastMask=firstMask;
break;
}
c=Character.codePointBefore(label, labelLimit);
labelLimit-=Character.charCount(c);
int dir=UBiDiProps.INSTANCE.getClass(c);
if(dir!=UCharacterDirection.DIR_NON_SPACING_MARK) {
lastMask=U_MASK(dir);
break;
}
}
// 3. In an RTL label, the end of the label must be a character with
// BIDI property R, AL, EN or AN, followed by zero or more
// characters with BIDI property NSM.
// 6. In an LTR label, the end of the label must be a character with
// BIDI property L or EN, followed by zero or more characters with
// BIDI property NSM.
if( (firstMask&L_MASK)!=0 ?
(lastMask&~L_EN_MASK)!=0 :
(lastMask&~R_AL_EN_AN_MASK)!=0
) {
setNotOkBiDi(info);
}
// Get the directionalities of the intervening characters.
int mask=0;
while(i<labelLimit) {
c=Character.codePointAt(label, i);
i+=Character.charCount(c);
mask|=U_MASK(UBiDiProps.INSTANCE.getClass(c));
}
if((firstMask&L_MASK)!=0) {
// 5. In an LTR label, only characters with the BIDI properties L, EN,
// ES, CS, ET, ON, BN and NSM are allowed.
if((mask&~L_EN_ES_CS_ET_ON_BN_NSM_MASK)!=0) {
setNotOkBiDi(info);
}
} else {
// 2. In an RTL label, only characters with the BIDI properties R, AL,
// AN, EN, ES, CS, ET, ON, BN and NSM are allowed.
if((mask&~R_AL_AN_EN_ES_CS_ET_ON_BN_NSM_MASK)!=0) {
setNotOkBiDi(info);
}
// 4. In an RTL label, if an EN is present, no AN may be present, and
// vice versa.
if((mask&EN_AN_MASK)==EN_AN_MASK) {
setNotOkBiDi(info);
}
}
// An RTL label is a label that contains at least one character of type
// R, AL or AN. [...]
// A "BIDI domain name" is a domain name that contains at least one RTL
// label. [...]
// The following rule, consisting of six conditions, applies to labels
// in BIDI domain names.
if(((firstMask|mask|lastMask)&R_AL_AN_MASK)!=0) {
setBiDi(info);
}
} | java | private void
checkLabelBiDi(CharSequence label, int labelStart, int labelLength, Info info) {
// IDNA2008 BiDi rule
// Get the directionality of the first character.
int c;
int i=labelStart;
c=Character.codePointAt(label, i);
i+=Character.charCount(c);
int firstMask=U_MASK(UBiDiProps.INSTANCE.getClass(c));
// 1. The first character must be a character with BIDI property L, R
// or AL. If it has the R or AL property, it is an RTL label; if it
// has the L property, it is an LTR label.
if((firstMask&~L_R_AL_MASK)!=0) {
setNotOkBiDi(info);
}
// Get the directionality of the last non-NSM character.
int lastMask;
int labelLimit=labelStart+labelLength;
for(;;) {
if(i>=labelLimit) {
lastMask=firstMask;
break;
}
c=Character.codePointBefore(label, labelLimit);
labelLimit-=Character.charCount(c);
int dir=UBiDiProps.INSTANCE.getClass(c);
if(dir!=UCharacterDirection.DIR_NON_SPACING_MARK) {
lastMask=U_MASK(dir);
break;
}
}
// 3. In an RTL label, the end of the label must be a character with
// BIDI property R, AL, EN or AN, followed by zero or more
// characters with BIDI property NSM.
// 6. In an LTR label, the end of the label must be a character with
// BIDI property L or EN, followed by zero or more characters with
// BIDI property NSM.
if( (firstMask&L_MASK)!=0 ?
(lastMask&~L_EN_MASK)!=0 :
(lastMask&~R_AL_EN_AN_MASK)!=0
) {
setNotOkBiDi(info);
}
// Get the directionalities of the intervening characters.
int mask=0;
while(i<labelLimit) {
c=Character.codePointAt(label, i);
i+=Character.charCount(c);
mask|=U_MASK(UBiDiProps.INSTANCE.getClass(c));
}
if((firstMask&L_MASK)!=0) {
// 5. In an LTR label, only characters with the BIDI properties L, EN,
// ES, CS, ET, ON, BN and NSM are allowed.
if((mask&~L_EN_ES_CS_ET_ON_BN_NSM_MASK)!=0) {
setNotOkBiDi(info);
}
} else {
// 2. In an RTL label, only characters with the BIDI properties R, AL,
// AN, EN, ES, CS, ET, ON, BN and NSM are allowed.
if((mask&~R_AL_AN_EN_ES_CS_ET_ON_BN_NSM_MASK)!=0) {
setNotOkBiDi(info);
}
// 4. In an RTL label, if an EN is present, no AN may be present, and
// vice versa.
if((mask&EN_AN_MASK)==EN_AN_MASK) {
setNotOkBiDi(info);
}
}
// An RTL label is a label that contains at least one character of type
// R, AL or AN. [...]
// A "BIDI domain name" is a domain name that contains at least one RTL
// label. [...]
// The following rule, consisting of six conditions, applies to labels
// in BIDI domain names.
if(((firstMask|mask|lastMask)&R_AL_AN_MASK)!=0) {
setBiDi(info);
}
} | [
"private",
"void",
"checkLabelBiDi",
"(",
"CharSequence",
"label",
",",
"int",
"labelStart",
",",
"int",
"labelLength",
",",
"Info",
"info",
")",
"{",
"// IDNA2008 BiDi rule",
"// Get the directionality of the first character.",
"int",
"c",
";",
"int",
"i",
"=",
"la... | processing several earlier labels. | [
"processing",
"several",
"earlier",
"labels",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UTS46.java#L547-L624 |
34,627 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/KeyUtil.java | KeyUtil.getKeySize | public static final int getKeySize(Key key) {
int size = -1;
if (key instanceof Length) {
try {
Length ruler = (Length)key;
size = ruler.length();
} catch (UnsupportedOperationException usoe) {
// ignore the exception
}
if (size >= 0) {
return size;
}
}
// try to parse the length from key specification
if (key instanceof SecretKey) {
SecretKey sk = (SecretKey)key;
String format = sk.getFormat();
if ("RAW".equals(format) && sk.getEncoded() != null) {
size = (sk.getEncoded().length * 8);
} // Otherwise, it may be a unextractable key of PKCS#11, or
// a key we are not able to handle.
} else if (key instanceof RSAKey) {
RSAKey pubk = (RSAKey)key;
size = pubk.getModulus().bitLength();
} else if (key instanceof ECKey) {
ECKey pubk = (ECKey)key;
ECParameterSpec params = pubk.getParams();
// According to RFC 3279 section 2.3.5, EC keys are allowed
// to inherit parameters in an X.509 certificate issuer's
// key parameters, so the parameters may be null. The parent
// key will be rejected if its parameters don't pass, so this
// is okay.
if (params != null) {
size = params.getOrder().bitLength();
}
} else if (key instanceof DSAKey) {
DSAKey pubk = (DSAKey)key;
DSAParams params = pubk.getParams();
// According to RFC 3279 section 2.3.2, DSA keys are allowed
// to inherit parameters in an X.509 certificate issuer's
// key parameters, so the parameters may be null. The parent
// key will be rejected if its parameters don't pass, so this
// is okay.
if (params != null) {
size = params.getP().bitLength();
}
} else if (key instanceof DHKey) {
DHKey pubk = (DHKey)key;
size = pubk.getParams().getP().bitLength();
} // Otherwise, it may be a unextractable key of PKCS#11, or
// a key we are not able to handle.
return size;
} | java | public static final int getKeySize(Key key) {
int size = -1;
if (key instanceof Length) {
try {
Length ruler = (Length)key;
size = ruler.length();
} catch (UnsupportedOperationException usoe) {
// ignore the exception
}
if (size >= 0) {
return size;
}
}
// try to parse the length from key specification
if (key instanceof SecretKey) {
SecretKey sk = (SecretKey)key;
String format = sk.getFormat();
if ("RAW".equals(format) && sk.getEncoded() != null) {
size = (sk.getEncoded().length * 8);
} // Otherwise, it may be a unextractable key of PKCS#11, or
// a key we are not able to handle.
} else if (key instanceof RSAKey) {
RSAKey pubk = (RSAKey)key;
size = pubk.getModulus().bitLength();
} else if (key instanceof ECKey) {
ECKey pubk = (ECKey)key;
ECParameterSpec params = pubk.getParams();
// According to RFC 3279 section 2.3.5, EC keys are allowed
// to inherit parameters in an X.509 certificate issuer's
// key parameters, so the parameters may be null. The parent
// key will be rejected if its parameters don't pass, so this
// is okay.
if (params != null) {
size = params.getOrder().bitLength();
}
} else if (key instanceof DSAKey) {
DSAKey pubk = (DSAKey)key;
DSAParams params = pubk.getParams();
// According to RFC 3279 section 2.3.2, DSA keys are allowed
// to inherit parameters in an X.509 certificate issuer's
// key parameters, so the parameters may be null. The parent
// key will be rejected if its parameters don't pass, so this
// is okay.
if (params != null) {
size = params.getP().bitLength();
}
} else if (key instanceof DHKey) {
DHKey pubk = (DHKey)key;
size = pubk.getParams().getP().bitLength();
} // Otherwise, it may be a unextractable key of PKCS#11, or
// a key we are not able to handle.
return size;
} | [
"public",
"static",
"final",
"int",
"getKeySize",
"(",
"Key",
"key",
")",
"{",
"int",
"size",
"=",
"-",
"1",
";",
"if",
"(",
"key",
"instanceof",
"Length",
")",
"{",
"try",
"{",
"Length",
"ruler",
"=",
"(",
"Length",
")",
"key",
";",
"size",
"=",
... | Returns the key size of the given key object in bits.
@param key the key object, cannot be null
@return the key size of the given key object in bits, or -1 if the
key size is not accessible | [
"Returns",
"the",
"key",
"size",
"of",
"the",
"given",
"key",
"object",
"in",
"bits",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/KeyUtil.java#L58-L114 |
34,628 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/KeyUtil.java | KeyUtil.validateDHPublicKey | private static void validateDHPublicKey(DHPublicKey publicKey)
throws InvalidKeyException {
DHParameterSpec paramSpec = publicKey.getParams();
BigInteger p = paramSpec.getP();
BigInteger g = paramSpec.getG();
BigInteger y = publicKey.getY();
validateDHPublicKey(p, g, y);
} | java | private static void validateDHPublicKey(DHPublicKey publicKey)
throws InvalidKeyException {
DHParameterSpec paramSpec = publicKey.getParams();
BigInteger p = paramSpec.getP();
BigInteger g = paramSpec.getG();
BigInteger y = publicKey.getY();
validateDHPublicKey(p, g, y);
} | [
"private",
"static",
"void",
"validateDHPublicKey",
"(",
"DHPublicKey",
"publicKey",
")",
"throws",
"InvalidKeyException",
"{",
"DHParameterSpec",
"paramSpec",
"=",
"publicKey",
".",
"getParams",
"(",
")",
";",
"BigInteger",
"p",
"=",
"paramSpec",
".",
"getP",
"("... | Returns whether the Diffie-Hellman public key is valid or not.
Per RFC 2631 and NIST SP800-56A, the following algorithm is used to
validate Diffie-Hellman public keys:
1. Verify that y lies within the interval [2,p-1]. If it does not,
the key is invalid.
2. Compute y^q mod p. If the result == 1, the key is valid.
Otherwise the key is invalid. | [
"Returns",
"whether",
"the",
"Diffie",
"-",
"Hellman",
"public",
"key",
"is",
"valid",
"or",
"not",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/KeyUtil.java#L188-L197 |
34,629 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Double.java | Double.doubleToLongBits | public static long doubleToLongBits(double value) {
long result = doubleToRawLongBits(value);
// Check for NaN based on values of bit fields, maximum
// exponent and nonzero significand.
if ( ((result & DoubleConsts.EXP_BIT_MASK) ==
DoubleConsts.EXP_BIT_MASK) &&
(result & DoubleConsts.SIGNIF_BIT_MASK) != 0L)
result = 0x7ff8000000000000L;
return result;
} | java | public static long doubleToLongBits(double value) {
long result = doubleToRawLongBits(value);
// Check for NaN based on values of bit fields, maximum
// exponent and nonzero significand.
if ( ((result & DoubleConsts.EXP_BIT_MASK) ==
DoubleConsts.EXP_BIT_MASK) &&
(result & DoubleConsts.SIGNIF_BIT_MASK) != 0L)
result = 0x7ff8000000000000L;
return result;
} | [
"public",
"static",
"long",
"doubleToLongBits",
"(",
"double",
"value",
")",
"{",
"long",
"result",
"=",
"doubleToRawLongBits",
"(",
"value",
")",
";",
"// Check for NaN based on values of bit fields, maximum",
"// exponent and nonzero significand.",
"if",
"(",
"(",
"(",
... | Returns a representation of the specified floating-point value
according to the IEEE 754 floating-point "double
format" bit layout.
<p>Bit 63 (the bit that is selected by the mask
{@code 0x8000000000000000L}) represents the sign of the
floating-point number. Bits
62-52 (the bits that are selected by the mask
{@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
(the bits that are selected by the mask
{@code 0x000fffffffffffffL}) represent the significand
(sometimes called the mantissa) of the floating-point number.
<p>If the argument is positive infinity, the result is
{@code 0x7ff0000000000000L}.
<p>If the argument is negative infinity, the result is
{@code 0xfff0000000000000L}.
<p>If the argument is NaN, the result is
{@code 0x7ff8000000000000L}.
<p>In all cases, the result is a {@code long} integer that, when
given to the {@link #longBitsToDouble(long)} method, will produce a
floating-point value the same as the argument to
{@code doubleToLongBits} (except all NaN values are
collapsed to a single "canonical" NaN value).
@param value a {@code double} precision floating-point number.
@return the bits that represent the floating-point number. | [
"Returns",
"a",
"representation",
"of",
"the",
"specified",
"floating",
"-",
"point",
"value",
"according",
"to",
"the",
"IEEE",
"754",
"floating",
"-",
"point",
"double",
"format",
"bit",
"layout",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Double.java#L836-L845 |
34,630 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/WeakHashMap.java | WeakHashMap.removeMapping | boolean removeMapping(Object o) {
if (!(o instanceof Map.Entry))
return false;
Entry<K,V>[] tab = getTable();
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
Object k = maskNull(entry.getKey());
int h = sun.misc.Hashing.singleWordWangJenkinsHash(k);
int i = indexFor(h, tab.length);
Entry<K,V> prev = tab[i];
Entry<K,V> e = prev;
while (e != null) {
Entry<K,V> next = e.next;
if (h == e.hash && e.equals(entry)) {
modCount++;
size--;
if (prev == e)
tab[i] = next;
else
prev.next = next;
return true;
}
prev = e;
e = next;
}
return false;
} | java | boolean removeMapping(Object o) {
if (!(o instanceof Map.Entry))
return false;
Entry<K,V>[] tab = getTable();
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
Object k = maskNull(entry.getKey());
int h = sun.misc.Hashing.singleWordWangJenkinsHash(k);
int i = indexFor(h, tab.length);
Entry<K,V> prev = tab[i];
Entry<K,V> e = prev;
while (e != null) {
Entry<K,V> next = e.next;
if (h == e.hash && e.equals(entry)) {
modCount++;
size--;
if (prev == e)
tab[i] = next;
else
prev.next = next;
return true;
}
prev = e;
e = next;
}
return false;
} | [
"boolean",
"removeMapping",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"!",
"(",
"o",
"instanceof",
"Map",
".",
"Entry",
")",
")",
"return",
"false",
";",
"Entry",
"<",
"K",
",",
"V",
">",
"[",
"]",
"tab",
"=",
"getTable",
"(",
")",
";",
"Map",
"... | Special version of remove needed by Entry set | [
"Special",
"version",
"of",
"remove",
"needed",
"by",
"Entry",
"set"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/WeakHashMap.java#L604-L631 |
34,631 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/WeakHashMap.java | WeakHashMap.containsNullValue | private boolean containsNullValue() {
Entry<K,V>[] tab = getTable();
for (int i = tab.length; i-- > 0;)
for (Entry<K,V> e = tab[i]; e != null; e = e.next)
if (e.value==null)
return true;
return false;
} | java | private boolean containsNullValue() {
Entry<K,V>[] tab = getTable();
for (int i = tab.length; i-- > 0;)
for (Entry<K,V> e = tab[i]; e != null; e = e.next)
if (e.value==null)
return true;
return false;
} | [
"private",
"boolean",
"containsNullValue",
"(",
")",
"{",
"Entry",
"<",
"K",
",",
"V",
">",
"[",
"]",
"tab",
"=",
"getTable",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"tab",
".",
"length",
";",
"i",
"--",
">",
"0",
";",
")",
"for",
"(",
"E... | Special-case code for containsValue with null argument | [
"Special",
"-",
"case",
"code",
"for",
"containsValue",
"with",
"null",
"argument"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/WeakHashMap.java#L677-L684 |
34,632 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/util/logging/PlatformLogger.java | PlatformLogger.redirectToJavaLoggerProxy | private void redirectToJavaLoggerProxy() {
DefaultLoggerProxy lp = DefaultLoggerProxy.class.cast(this.loggerProxy);
JavaLoggerProxy jlp = new JavaLoggerProxy(lp.name, lp.level);
// the order of assignments is important
this.javaLoggerProxy = jlp; // isLoggable checks javaLoggerProxy if set
this.loggerProxy = jlp;
} | java | private void redirectToJavaLoggerProxy() {
DefaultLoggerProxy lp = DefaultLoggerProxy.class.cast(this.loggerProxy);
JavaLoggerProxy jlp = new JavaLoggerProxy(lp.name, lp.level);
// the order of assignments is important
this.javaLoggerProxy = jlp; // isLoggable checks javaLoggerProxy if set
this.loggerProxy = jlp;
} | [
"private",
"void",
"redirectToJavaLoggerProxy",
"(",
")",
"{",
"DefaultLoggerProxy",
"lp",
"=",
"DefaultLoggerProxy",
".",
"class",
".",
"cast",
"(",
"this",
".",
"loggerProxy",
")",
";",
"JavaLoggerProxy",
"jlp",
"=",
"new",
"JavaLoggerProxy",
"(",
"lp",
".",
... | Creates a new JavaLoggerProxy and redirects the platform logger to it | [
"Creates",
"a",
"new",
"JavaLoggerProxy",
"and",
"redirects",
"the",
"platform",
"logger",
"to",
"it"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/util/logging/PlatformLogger.java#L225-L231 |
34,633 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/util/logging/PlatformLogger.java | PlatformLogger.setLevel | @Deprecated
public void setLevel(int newLevel) {
loggerProxy.setLevel(newLevel == 0 ? null : Level.valueOf(newLevel));
} | java | @Deprecated
public void setLevel(int newLevel) {
loggerProxy.setLevel(newLevel == 0 ? null : Level.valueOf(newLevel));
} | [
"@",
"Deprecated",
"public",
"void",
"setLevel",
"(",
"int",
"newLevel",
")",
"{",
"loggerProxy",
".",
"setLevel",
"(",
"newLevel",
"==",
"0",
"?",
"null",
":",
"Level",
".",
"valueOf",
"(",
"newLevel",
")",
")",
";",
"}"
] | Sets the log level.
@deprecated Use setLevel(Level) instead | [
"Sets",
"the",
"log",
"level",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/util/logging/PlatformLogger.java#L289-L292 |
34,634 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/util/logging/PlatformLogger.java | PlatformLogger.isLoggable | public boolean isLoggable(Level level) {
if (level == null) {
throw new NullPointerException();
}
// performance-sensitive method: use two monomorphic call-sites
JavaLoggerProxy jlp = javaLoggerProxy;
return jlp != null ? jlp.isLoggable(level) : loggerProxy.isLoggable(level);
} | java | public boolean isLoggable(Level level) {
if (level == null) {
throw new NullPointerException();
}
// performance-sensitive method: use two monomorphic call-sites
JavaLoggerProxy jlp = javaLoggerProxy;
return jlp != null ? jlp.isLoggable(level) : loggerProxy.isLoggable(level);
} | [
"public",
"boolean",
"isLoggable",
"(",
"Level",
"level",
")",
"{",
"if",
"(",
"level",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"// performance-sensitive method: use two monomorphic call-sites",
"JavaLoggerProxy",
"jlp",
"... | Returns true if a message of the given level would actually
be logged by this logger. | [
"Returns",
"true",
"if",
"a",
"message",
"of",
"the",
"given",
"level",
"would",
"actually",
"be",
"logged",
"by",
"this",
"logger",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/util/logging/PlatformLogger.java#L298-L305 |
34,635 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | TreeBin.tieBreakOrder | static int tieBreakOrder(Object a, Object b) {
int d;
if (a == null || b == null ||
(d = a.getClass().getName().
compareTo(b.getClass().getName())) == 0)
d = (System.identityHashCode(a) <= System.identityHashCode(b) ?
-1 : 1);
return d;
} | java | static int tieBreakOrder(Object a, Object b) {
int d;
if (a == null || b == null ||
(d = a.getClass().getName().
compareTo(b.getClass().getName())) == 0)
d = (System.identityHashCode(a) <= System.identityHashCode(b) ?
-1 : 1);
return d;
} | [
"static",
"int",
"tieBreakOrder",
"(",
"Object",
"a",
",",
"Object",
"b",
")",
"{",
"int",
"d",
";",
"if",
"(",
"a",
"==",
"null",
"||",
"b",
"==",
"null",
"||",
"(",
"d",
"=",
"a",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
".",
"c... | Tie-breaking utility for ordering insertions when equal
hashCodes and non-comparable. We don't require a total
order, just a consistent insertion rule to maintain
equivalence across rebalancings. Tie-breaking further than
necessary simplifies testing a bit. | [
"Tie",
"-",
"breaking",
"utility",
"for",
"ordering",
"insertions",
"when",
"equal",
"hashCodes",
"and",
"non",
"-",
"comparable",
".",
"We",
"don",
"t",
"require",
"a",
"total",
"order",
"just",
"a",
"consistent",
"insertion",
"rule",
"to",
"maintain",
"equ... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L2800-L2808 |
34,636 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | TreeBin.contendedLock | private final void contendedLock() {
boolean waiting = false;
for (int s;;) {
if (((s = lockState) & ~WAITER) == 0) {
if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) {
if (waiting)
waiter = null;
return;
}
}
else if ((s & WAITER) == 0) {
if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) {
waiting = true;
waiter = Thread.currentThread();
}
}
else if (waiting)
LockSupport.park(this);
}
} | java | private final void contendedLock() {
boolean waiting = false;
for (int s;;) {
if (((s = lockState) & ~WAITER) == 0) {
if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) {
if (waiting)
waiter = null;
return;
}
}
else if ((s & WAITER) == 0) {
if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) {
waiting = true;
waiter = Thread.currentThread();
}
}
else if (waiting)
LockSupport.park(this);
}
} | [
"private",
"final",
"void",
"contendedLock",
"(",
")",
"{",
"boolean",
"waiting",
"=",
"false",
";",
"for",
"(",
"int",
"s",
";",
";",
")",
"{",
"if",
"(",
"(",
"(",
"s",
"=",
"lockState",
")",
"&",
"~",
"WAITER",
")",
"==",
"0",
")",
"{",
"if"... | Possibly blocks awaiting root lock. | [
"Possibly",
"blocks",
"awaiting",
"root",
"lock",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L2875-L2894 |
34,637 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | TreeBin.find | final Node<K,V> find(int h, Object k) {
if (k != null) {
for (Node<K,V> e = first; e != null; ) {
int s; K ek;
if (((s = lockState) & (WAITER|WRITER)) != 0) {
if (e.hash == h &&
((ek = e.key) == k || (ek != null && k.equals(ek))))
return e;
e = e.next;
}
else if (U.compareAndSwapInt(this, LOCKSTATE, s,
s + READER)) {
TreeNode<K,V> r, p;
try {
p = ((r = root) == null ? null :
r.findTreeNode(h, k, null));
} finally {
Thread w;
if (U.getAndAddInt(this, LOCKSTATE, -READER) ==
(READER|WAITER) && (w = waiter) != null)
LockSupport.unpark(w);
}
return p;
}
}
}
return null;
} | java | final Node<K,V> find(int h, Object k) {
if (k != null) {
for (Node<K,V> e = first; e != null; ) {
int s; K ek;
if (((s = lockState) & (WAITER|WRITER)) != 0) {
if (e.hash == h &&
((ek = e.key) == k || (ek != null && k.equals(ek))))
return e;
e = e.next;
}
else if (U.compareAndSwapInt(this, LOCKSTATE, s,
s + READER)) {
TreeNode<K,V> r, p;
try {
p = ((r = root) == null ? null :
r.findTreeNode(h, k, null));
} finally {
Thread w;
if (U.getAndAddInt(this, LOCKSTATE, -READER) ==
(READER|WAITER) && (w = waiter) != null)
LockSupport.unpark(w);
}
return p;
}
}
}
return null;
} | [
"final",
"Node",
"<",
"K",
",",
"V",
">",
"find",
"(",
"int",
"h",
",",
"Object",
"k",
")",
"{",
"if",
"(",
"k",
"!=",
"null",
")",
"{",
"for",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"e",
"=",
"first",
";",
"e",
"!=",
"null",
";",
")",
"... | Returns matching node or null if none. Tries to search
using tree comparisons from root, but continues linear
search when lock not available. | [
"Returns",
"matching",
"node",
"or",
"null",
"if",
"none",
".",
"Tries",
"to",
"search",
"using",
"tree",
"comparisons",
"from",
"root",
"but",
"continues",
"linear",
"search",
"when",
"lock",
"not",
"available",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L2901-L2928 |
34,638 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | TreeBin.putTreeVal | final TreeNode<K,V> putTreeVal(int h, K k, V v) {
Class<?> kc = null;
boolean searched = false;
for (TreeNode<K,V> p = root;;) {
int dir, ph; K pk;
if (p == null) {
first = root = new TreeNode<K,V>(h, k, v, null, null);
break;
}
else if ((ph = p.hash) > h)
dir = -1;
else if (ph < h)
dir = 1;
else if ((pk = p.key) == k || (pk != null && k.equals(pk)))
return p;
else if ((kc == null &&
(kc = comparableClassFor(k)) == null) ||
(dir = compareComparables(kc, k, pk)) == 0) {
if (!searched) {
TreeNode<K,V> q, ch;
searched = true;
if (((ch = p.left) != null &&
(q = ch.findTreeNode(h, k, kc)) != null) ||
((ch = p.right) != null &&
(q = ch.findTreeNode(h, k, kc)) != null))
return q;
}
dir = tieBreakOrder(k, pk);
}
TreeNode<K,V> xp = p;
if ((p = (dir <= 0) ? p.left : p.right) == null) {
TreeNode<K,V> x, f = first;
first = x = new TreeNode<K,V>(h, k, v, f, xp);
if (f != null)
f.prev = x;
if (dir <= 0)
xp.left = x;
else
xp.right = x;
if (!xp.red)
x.red = true;
else {
lockRoot();
try {
root = balanceInsertion(root, x);
} finally {
unlockRoot();
}
}
break;
}
}
assert checkInvariants(root);
return null;
} | java | final TreeNode<K,V> putTreeVal(int h, K k, V v) {
Class<?> kc = null;
boolean searched = false;
for (TreeNode<K,V> p = root;;) {
int dir, ph; K pk;
if (p == null) {
first = root = new TreeNode<K,V>(h, k, v, null, null);
break;
}
else if ((ph = p.hash) > h)
dir = -1;
else if (ph < h)
dir = 1;
else if ((pk = p.key) == k || (pk != null && k.equals(pk)))
return p;
else if ((kc == null &&
(kc = comparableClassFor(k)) == null) ||
(dir = compareComparables(kc, k, pk)) == 0) {
if (!searched) {
TreeNode<K,V> q, ch;
searched = true;
if (((ch = p.left) != null &&
(q = ch.findTreeNode(h, k, kc)) != null) ||
((ch = p.right) != null &&
(q = ch.findTreeNode(h, k, kc)) != null))
return q;
}
dir = tieBreakOrder(k, pk);
}
TreeNode<K,V> xp = p;
if ((p = (dir <= 0) ? p.left : p.right) == null) {
TreeNode<K,V> x, f = first;
first = x = new TreeNode<K,V>(h, k, v, f, xp);
if (f != null)
f.prev = x;
if (dir <= 0)
xp.left = x;
else
xp.right = x;
if (!xp.red)
x.red = true;
else {
lockRoot();
try {
root = balanceInsertion(root, x);
} finally {
unlockRoot();
}
}
break;
}
}
assert checkInvariants(root);
return null;
} | [
"final",
"TreeNode",
"<",
"K",
",",
"V",
">",
"putTreeVal",
"(",
"int",
"h",
",",
"K",
"k",
",",
"V",
"v",
")",
"{",
"Class",
"<",
"?",
">",
"kc",
"=",
"null",
";",
"boolean",
"searched",
"=",
"false",
";",
"for",
"(",
"TreeNode",
"<",
"K",
"... | Finds or adds a node.
@return null if added | [
"Finds",
"or",
"adds",
"a",
"node",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L2934-L2989 |
34,639 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | TreeBin.rotateLeft | static <K,V> TreeNode<K,V> rotateLeft(TreeNode<K,V> root,
TreeNode<K,V> p) {
TreeNode<K,V> r, pp, rl;
if (p != null && (r = p.right) != null) {
if ((rl = p.right = r.left) != null)
rl.parent = p;
if ((pp = r.parent = p.parent) == null)
(root = r).red = false;
else if (pp.left == p)
pp.left = r;
else
pp.right = r;
r.left = p;
p.parent = r;
}
return root;
} | java | static <K,V> TreeNode<K,V> rotateLeft(TreeNode<K,V> root,
TreeNode<K,V> p) {
TreeNode<K,V> r, pp, rl;
if (p != null && (r = p.right) != null) {
if ((rl = p.right = r.left) != null)
rl.parent = p;
if ((pp = r.parent = p.parent) == null)
(root = r).red = false;
else if (pp.left == p)
pp.left = r;
else
pp.right = r;
r.left = p;
p.parent = r;
}
return root;
} | [
"static",
"<",
"K",
",",
"V",
">",
"TreeNode",
"<",
"K",
",",
"V",
">",
"rotateLeft",
"(",
"TreeNode",
"<",
"K",
",",
"V",
">",
"root",
",",
"TreeNode",
"<",
"K",
",",
"V",
">",
"p",
")",
"{",
"TreeNode",
"<",
"K",
",",
"V",
">",
"r",
",",
... | Red-black tree methods, all adapted from CLR | [
"Red",
"-",
"black",
"tree",
"methods",
"all",
"adapted",
"from",
"CLR"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L3100-L3116 |
34,640 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | TreeBin.checkInvariants | static <K,V> boolean checkInvariants(TreeNode<K,V> t) {
TreeNode<K,V> tp = t.parent, tl = t.left, tr = t.right,
tb = t.prev, tn = (TreeNode<K,V>)t.next;
if (tb != null && tb.next != t)
return false;
if (tn != null && tn.prev != t)
return false;
if (tp != null && t != tp.left && t != tp.right)
return false;
if (tl != null && (tl.parent != t || tl.hash > t.hash))
return false;
if (tr != null && (tr.parent != t || tr.hash < t.hash))
return false;
if (t.red && tl != null && tl.red && tr != null && tr.red)
return false;
if (tl != null && !checkInvariants(tl))
return false;
if (tr != null && !checkInvariants(tr))
return false;
return true;
} | java | static <K,V> boolean checkInvariants(TreeNode<K,V> t) {
TreeNode<K,V> tp = t.parent, tl = t.left, tr = t.right,
tb = t.prev, tn = (TreeNode<K,V>)t.next;
if (tb != null && tb.next != t)
return false;
if (tn != null && tn.prev != t)
return false;
if (tp != null && t != tp.left && t != tp.right)
return false;
if (tl != null && (tl.parent != t || tl.hash > t.hash))
return false;
if (tr != null && (tr.parent != t || tr.hash < t.hash))
return false;
if (t.red && tl != null && tl.red && tr != null && tr.red)
return false;
if (tl != null && !checkInvariants(tl))
return false;
if (tr != null && !checkInvariants(tr))
return false;
return true;
} | [
"static",
"<",
"K",
",",
"V",
">",
"boolean",
"checkInvariants",
"(",
"TreeNode",
"<",
"K",
",",
"V",
">",
"t",
")",
"{",
"TreeNode",
"<",
"K",
",",
"V",
">",
"tp",
"=",
"t",
".",
"parent",
",",
"tl",
"=",
"t",
".",
"left",
",",
"tr",
"=",
... | Checks invariants recursively for the tree of Nodes rooted at t. | [
"Checks",
"invariants",
"recursively",
"for",
"the",
"tree",
"of",
"Nodes",
"rooted",
"at",
"t",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L3286-L3306 |
34,641 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | Traverser.advance | final Node<K,V> advance() {
Node<K,V> e;
if ((e = next) != null)
e = e.next;
for (;;) {
Node<K,V>[] t; int i, n; // must use locals in checks
if (e != null)
return next = e;
if (baseIndex >= baseLimit || (t = tab) == null ||
(n = t.length) <= (i = index) || i < 0)
return next = null;
if ((e = tabAt(t, i)) != null && e.hash < 0) {
if (e instanceof ForwardingNode) {
tab = ((ForwardingNode<K,V>)e).nextTable;
e = null;
pushState(t, i, n);
continue;
}
else if (e instanceof TreeBin)
e = ((TreeBin<K,V>)e).first;
else
e = null;
}
if (stack != null)
recoverState(n);
else if ((index = i + baseSize) >= n)
index = ++baseIndex; // visit upper slots if present
}
} | java | final Node<K,V> advance() {
Node<K,V> e;
if ((e = next) != null)
e = e.next;
for (;;) {
Node<K,V>[] t; int i, n; // must use locals in checks
if (e != null)
return next = e;
if (baseIndex >= baseLimit || (t = tab) == null ||
(n = t.length) <= (i = index) || i < 0)
return next = null;
if ((e = tabAt(t, i)) != null && e.hash < 0) {
if (e instanceof ForwardingNode) {
tab = ((ForwardingNode<K,V>)e).nextTable;
e = null;
pushState(t, i, n);
continue;
}
else if (e instanceof TreeBin)
e = ((TreeBin<K,V>)e).first;
else
e = null;
}
if (stack != null)
recoverState(n);
else if ((index = i + baseSize) >= n)
index = ++baseIndex; // visit upper slots if present
}
} | [
"final",
"Node",
"<",
"K",
",",
"V",
">",
"advance",
"(",
")",
"{",
"Node",
"<",
"K",
",",
"V",
">",
"e",
";",
"if",
"(",
"(",
"e",
"=",
"next",
")",
"!=",
"null",
")",
"e",
"=",
"e",
".",
"next",
";",
"for",
"(",
";",
";",
")",
"{",
... | Advances if possible, returning next valid node, or null if none. | [
"Advances",
"if",
"possible",
"returning",
"next",
"valid",
"node",
"or",
"null",
"if",
"none",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L3375-L3403 |
34,642 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | Traverser.pushState | private void pushState(Node<K,V>[] t, int i, int n) {
TableStack<K,V> s = spare; // reuse if possible
if (s != null)
spare = s.next;
else
s = new TableStack<K,V>();
s.tab = t;
s.length = n;
s.index = i;
s.next = stack;
stack = s;
} | java | private void pushState(Node<K,V>[] t, int i, int n) {
TableStack<K,V> s = spare; // reuse if possible
if (s != null)
spare = s.next;
else
s = new TableStack<K,V>();
s.tab = t;
s.length = n;
s.index = i;
s.next = stack;
stack = s;
} | [
"private",
"void",
"pushState",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"[",
"]",
"t",
",",
"int",
"i",
",",
"int",
"n",
")",
"{",
"TableStack",
"<",
"K",
",",
"V",
">",
"s",
"=",
"spare",
";",
"// reuse if possible",
"if",
"(",
"s",
"!=",
"null"... | Saves traversal state upon encountering a forwarding node. | [
"Saves",
"traversal",
"state",
"upon",
"encountering",
"a",
"forwarding",
"node",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L3408-L3419 |
34,643 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java | Traverser.recoverState | private void recoverState(int n) {
TableStack<K,V> s; int len;
while ((s = stack) != null && (index += (len = s.length)) >= n) {
n = len;
index = s.index;
tab = s.tab;
s.tab = null;
TableStack<K,V> next = s.next;
s.next = spare; // save for reuse
stack = next;
spare = s;
}
if (s == null && (index += baseSize) >= n)
index = ++baseIndex;
} | java | private void recoverState(int n) {
TableStack<K,V> s; int len;
while ((s = stack) != null && (index += (len = s.length)) >= n) {
n = len;
index = s.index;
tab = s.tab;
s.tab = null;
TableStack<K,V> next = s.next;
s.next = spare; // save for reuse
stack = next;
spare = s;
}
if (s == null && (index += baseSize) >= n)
index = ++baseIndex;
} | [
"private",
"void",
"recoverState",
"(",
"int",
"n",
")",
"{",
"TableStack",
"<",
"K",
",",
"V",
">",
"s",
";",
"int",
"len",
";",
"while",
"(",
"(",
"s",
"=",
"stack",
")",
"!=",
"null",
"&&",
"(",
"index",
"+=",
"(",
"len",
"=",
"s",
".",
"l... | Possibly pops traversal state.
@param n length of current table | [
"Possibly",
"pops",
"traversal",
"state",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#L3426-L3440 |
34,644 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.applyPattern | public final UnicodeSet applyPattern(String pattern) {
checkFrozen();
return applyPattern(pattern, null, null, IGNORE_SPACE);
} | java | public final UnicodeSet applyPattern(String pattern) {
checkFrozen();
return applyPattern(pattern, null, null, IGNORE_SPACE);
} | [
"public",
"final",
"UnicodeSet",
"applyPattern",
"(",
"String",
"pattern",
")",
"{",
"checkFrozen",
"(",
")",
";",
"return",
"applyPattern",
"(",
"pattern",
",",
"null",
",",
"null",
",",
"IGNORE_SPACE",
")",
";",
"}"
] | Modifies this set to represent the set specified by the given pattern.
See the class description for the syntax of the pattern language.
Whitespace is ignored.
@param pattern a string specifying what characters are in the set
@exception java.lang.IllegalArgumentException if the pattern
contains a syntax error. | [
"Modifies",
"this",
"set",
"to",
"represent",
"the",
"set",
"specified",
"by",
"the",
"given",
"pattern",
".",
"See",
"the",
"class",
"description",
"for",
"the",
"syntax",
"of",
"the",
"pattern",
"language",
".",
"Whitespace",
"is",
"ignored",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L544-L547 |
34,645 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.applyPattern | public UnicodeSet applyPattern(String pattern, int options) {
checkFrozen();
return applyPattern(pattern, null, null, options);
} | java | public UnicodeSet applyPattern(String pattern, int options) {
checkFrozen();
return applyPattern(pattern, null, null, options);
} | [
"public",
"UnicodeSet",
"applyPattern",
"(",
"String",
"pattern",
",",
"int",
"options",
")",
"{",
"checkFrozen",
"(",
")",
";",
"return",
"applyPattern",
"(",
"pattern",
",",
"null",
",",
"null",
",",
"options",
")",
";",
"}"
] | Modifies this set to represent the set specified by the given pattern,
optionally ignoring whitespace.
See the class description for the syntax of the pattern language.
@param pattern a string specifying what characters are in the set
@param options a bitmask indicating which options to apply.
Valid options are IGNORE_SPACE and CASE.
@exception java.lang.IllegalArgumentException if the pattern
contains a syntax error. | [
"Modifies",
"this",
"set",
"to",
"represent",
"the",
"set",
"specified",
"by",
"the",
"given",
"pattern",
"optionally",
"ignoring",
"whitespace",
".",
"See",
"the",
"class",
"description",
"for",
"the",
"syntax",
"of",
"the",
"pattern",
"language",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L573-L576 |
34,646 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.resemblesPattern | public static boolean resemblesPattern(String pattern, int pos) {
return ((pos+1) < pattern.length() &&
pattern.charAt(pos) == '[') ||
resemblesPropertyPattern(pattern, pos);
} | java | public static boolean resemblesPattern(String pattern, int pos) {
return ((pos+1) < pattern.length() &&
pattern.charAt(pos) == '[') ||
resemblesPropertyPattern(pattern, pos);
} | [
"public",
"static",
"boolean",
"resemblesPattern",
"(",
"String",
"pattern",
",",
"int",
"pos",
")",
"{",
"return",
"(",
"(",
"pos",
"+",
"1",
")",
"<",
"pattern",
".",
"length",
"(",
")",
"&&",
"pattern",
".",
"charAt",
"(",
"pos",
")",
"==",
"'",
... | Return true if the given position, in the given pattern, appears
to be the start of a UnicodeSet pattern.
@hide unsupported on Android | [
"Return",
"true",
"if",
"the",
"given",
"position",
"in",
"the",
"given",
"pattern",
"appears",
"to",
"be",
"the",
"start",
"of",
"a",
"UnicodeSet",
"pattern",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L583-L587 |
34,647 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.toPattern | @Override
public String toPattern(boolean escapeUnprintable) {
if (pat != null && !escapeUnprintable) {
return pat;
}
StringBuilder result = new StringBuilder();
return _toPattern(result, escapeUnprintable).toString();
} | java | @Override
public String toPattern(boolean escapeUnprintable) {
if (pat != null && !escapeUnprintable) {
return pat;
}
StringBuilder result = new StringBuilder();
return _toPattern(result, escapeUnprintable).toString();
} | [
"@",
"Override",
"public",
"String",
"toPattern",
"(",
"boolean",
"escapeUnprintable",
")",
"{",
"if",
"(",
"pat",
"!=",
"null",
"&&",
"!",
"escapeUnprintable",
")",
"{",
"return",
"pat",
";",
"}",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",... | Returns a string representation of this set. If the result of
calling this function is passed to a UnicodeSet constructor, it
will produce another set that is equal to this one. | [
"Returns",
"a",
"string",
"representation",
"of",
"this",
"set",
".",
"If",
"the",
"result",
"of",
"calling",
"this",
"function",
"is",
"passed",
"to",
"a",
"UnicodeSet",
"constructor",
"it",
"will",
"produce",
"another",
"set",
"that",
"is",
"equal",
"to",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L678-L685 |
34,648 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.matchesAt | @Deprecated
public int matchesAt(CharSequence text, int offset) {
int lastLen = -1;
strings:
if (strings.size() != 0) {
char firstChar = text.charAt(offset);
String trial = null;
// find the first string starting with firstChar
Iterator<String> it = strings.iterator();
while (it.hasNext()) {
trial = it.next();
char firstStringChar = trial.charAt(0);
if (firstStringChar < firstChar) continue;
if (firstStringChar > firstChar) break strings;
}
// now keep checking string until we get the longest one
for (;;) {
int tempLen = matchesAt(text, offset, trial);
if (lastLen > tempLen) break strings;
lastLen = tempLen;
if (!it.hasNext()) break;
trial = it.next();
}
}
if (lastLen < 2) {
int cp = UTF16.charAt(text, offset);
if (contains(cp)) lastLen = UTF16.getCharCount(cp);
}
return offset+lastLen;
} | java | @Deprecated
public int matchesAt(CharSequence text, int offset) {
int lastLen = -1;
strings:
if (strings.size() != 0) {
char firstChar = text.charAt(offset);
String trial = null;
// find the first string starting with firstChar
Iterator<String> it = strings.iterator();
while (it.hasNext()) {
trial = it.next();
char firstStringChar = trial.charAt(0);
if (firstStringChar < firstChar) continue;
if (firstStringChar > firstChar) break strings;
}
// now keep checking string until we get the longest one
for (;;) {
int tempLen = matchesAt(text, offset, trial);
if (lastLen > tempLen) break strings;
lastLen = tempLen;
if (!it.hasNext()) break;
trial = it.next();
}
}
if (lastLen < 2) {
int cp = UTF16.charAt(text, offset);
if (contains(cp)) lastLen = UTF16.getCharCount(cp);
}
return offset+lastLen;
} | [
"@",
"Deprecated",
"public",
"int",
"matchesAt",
"(",
"CharSequence",
"text",
",",
"int",
"offset",
")",
"{",
"int",
"lastLen",
"=",
"-",
"1",
";",
"strings",
":",
"if",
"(",
"strings",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"char",
"firstChar",... | Tests whether the text matches at the offset. If so, returns the end of the longest substring that it matches. If not, returns -1.
@deprecated This API is ICU internal only.
@hide original deprecated declaration
@hide draft / provisional / internal are hidden on Android | [
"Tests",
"whether",
"the",
"text",
"matches",
"at",
"the",
"offset",
".",
"If",
"so",
"returns",
"the",
"end",
"of",
"the",
"longest",
"substring",
"that",
"it",
"matches",
".",
"If",
"not",
"returns",
"-",
"1",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1016-L1048 |
34,649 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.add_unchecked | private UnicodeSet add_unchecked(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
}
if (end < MIN_VALUE || end > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(end, 6));
}
if (start < end) {
add(range(start, end), 2, 0);
} else if (start == end) {
add(start);
}
return this;
} | java | private UnicodeSet add_unchecked(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
}
if (end < MIN_VALUE || end > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(end, 6));
}
if (start < end) {
add(range(start, end), 2, 0);
} else if (start == end) {
add(start);
}
return this;
} | [
"private",
"UnicodeSet",
"add_unchecked",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"<",
"MIN_VALUE",
"||",
"start",
">",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid code point U+\"",
"+",
"Uti... | for internal use, after checkFrozen has been called | [
"for",
"internal",
"use",
"after",
"checkFrozen",
"has",
"been",
"called"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1164-L1177 |
34,650 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.add_unchecked | private final UnicodeSet add_unchecked(int c) {
if (c < MIN_VALUE || c > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(c, 6));
}
// find smallest i such that c < list[i]
// if odd, then it is IN the set
// if even, then it is OUT of the set
int i = findCodePoint(c);
// already in set?
if ((i & 1) != 0) return this;
// HIGH is 0x110000
// assert(list[len-1] == HIGH);
// empty = [HIGH]
// [start_0, limit_0, start_1, limit_1, HIGH]
// [..., start_k-1, limit_k-1, start_k, limit_k, ..., HIGH]
// ^
// list[i]
// i == 0 means c is before the first range
// TODO: Is the "list[i]-1" a typo? Even if you pass MAX_VALUE into
// add_unchecked, the maximum value that "c" will be compared to
// is "MAX_VALUE-1" meaning that "if (c == MAX_VALUE)" will
// never be reached according to this logic.
if (c == list[i]-1) {
// c is before start of next range
list[i] = c;
// if we touched the HIGH mark, then add a new one
if (c == MAX_VALUE) {
ensureCapacity(len+1);
list[len++] = HIGH;
}
if (i > 0 && c == list[i-1]) {
// collapse adjacent ranges
// [..., start_k-1, c, c, limit_k, ..., HIGH]
// ^
// list[i]
System.arraycopy(list, i+1, list, i-1, len-i-1);
len -= 2;
}
}
else if (i > 0 && c == list[i-1]) {
// c is after end of prior range
list[i-1]++;
// no need to chcek for collapse here
}
else {
// At this point we know the new char is not adjacent to
// any existing ranges, and it is not 10FFFF.
// [..., start_k-1, limit_k-1, start_k, limit_k, ..., HIGH]
// ^
// list[i]
// [..., start_k-1, limit_k-1, c, c+1, start_k, limit_k, ..., HIGH]
// ^
// list[i]
// Don't use ensureCapacity() to save on copying.
// NOTE: This has no measurable impact on performance,
// but it might help in some usage patterns.
if (len+2 > list.length) {
int[] temp = new int[len + 2 + GROW_EXTRA];
if (i != 0) System.arraycopy(list, 0, temp, 0, i);
System.arraycopy(list, i, temp, i+2, len-i);
list = temp;
} else {
System.arraycopy(list, i, list, i+2, len-i);
}
list[i] = c;
list[i+1] = c+1;
len += 2;
}
pat = null;
return this;
} | java | private final UnicodeSet add_unchecked(int c) {
if (c < MIN_VALUE || c > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(c, 6));
}
// find smallest i such that c < list[i]
// if odd, then it is IN the set
// if even, then it is OUT of the set
int i = findCodePoint(c);
// already in set?
if ((i & 1) != 0) return this;
// HIGH is 0x110000
// assert(list[len-1] == HIGH);
// empty = [HIGH]
// [start_0, limit_0, start_1, limit_1, HIGH]
// [..., start_k-1, limit_k-1, start_k, limit_k, ..., HIGH]
// ^
// list[i]
// i == 0 means c is before the first range
// TODO: Is the "list[i]-1" a typo? Even if you pass MAX_VALUE into
// add_unchecked, the maximum value that "c" will be compared to
// is "MAX_VALUE-1" meaning that "if (c == MAX_VALUE)" will
// never be reached according to this logic.
if (c == list[i]-1) {
// c is before start of next range
list[i] = c;
// if we touched the HIGH mark, then add a new one
if (c == MAX_VALUE) {
ensureCapacity(len+1);
list[len++] = HIGH;
}
if (i > 0 && c == list[i-1]) {
// collapse adjacent ranges
// [..., start_k-1, c, c, limit_k, ..., HIGH]
// ^
// list[i]
System.arraycopy(list, i+1, list, i-1, len-i-1);
len -= 2;
}
}
else if (i > 0 && c == list[i-1]) {
// c is after end of prior range
list[i-1]++;
// no need to chcek for collapse here
}
else {
// At this point we know the new char is not adjacent to
// any existing ranges, and it is not 10FFFF.
// [..., start_k-1, limit_k-1, start_k, limit_k, ..., HIGH]
// ^
// list[i]
// [..., start_k-1, limit_k-1, c, c+1, start_k, limit_k, ..., HIGH]
// ^
// list[i]
// Don't use ensureCapacity() to save on copying.
// NOTE: This has no measurable impact on performance,
// but it might help in some usage patterns.
if (len+2 > list.length) {
int[] temp = new int[len + 2 + GROW_EXTRA];
if (i != 0) System.arraycopy(list, 0, temp, 0, i);
System.arraycopy(list, i, temp, i+2, len-i);
list = temp;
} else {
System.arraycopy(list, i, list, i+2, len-i);
}
list[i] = c;
list[i+1] = c+1;
len += 2;
}
pat = null;
return this;
} | [
"private",
"final",
"UnicodeSet",
"add_unchecked",
"(",
"int",
"c",
")",
"{",
"if",
"(",
"c",
"<",
"MIN_VALUE",
"||",
"c",
">",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid code point U+\"",
"+",
"Utility",
".",
"hex",
"... | for internal use only, after checkFrozen has been called | [
"for",
"internal",
"use",
"only",
"after",
"checkFrozen",
"has",
"been",
"called"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1209-L1294 |
34,651 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.retain | public final UnicodeSet retain(CharSequence cs) {
int cp = getSingleCP(cs);
if (cp < 0) {
String s = cs.toString();
boolean isIn = strings.contains(s);
if (isIn && size() == 1) {
return this;
}
clear();
strings.add(s);
pat = null;
} else {
retain(cp, cp);
}
return this;
} | java | public final UnicodeSet retain(CharSequence cs) {
int cp = getSingleCP(cs);
if (cp < 0) {
String s = cs.toString();
boolean isIn = strings.contains(s);
if (isIn && size() == 1) {
return this;
}
clear();
strings.add(s);
pat = null;
} else {
retain(cp, cp);
}
return this;
} | [
"public",
"final",
"UnicodeSet",
"retain",
"(",
"CharSequence",
"cs",
")",
"{",
"int",
"cp",
"=",
"getSingleCP",
"(",
"cs",
")",
";",
"if",
"(",
"cp",
"<",
"0",
")",
"{",
"String",
"s",
"=",
"cs",
".",
"toString",
"(",
")",
";",
"boolean",
"isIn",
... | Retain the specified string in this set if it is present.
Upon return this set will be empty if it did not contain s, or
will only contain s if it did contain s.
@param cs the string to be retained
@return this object, for chaining | [
"Retain",
"the",
"specified",
"string",
"in",
"this",
"set",
"if",
"it",
"is",
"present",
".",
"Upon",
"return",
"this",
"set",
"will",
"be",
"empty",
"if",
"it",
"did",
"not",
"contain",
"s",
"or",
"will",
"only",
"contain",
"s",
"if",
"it",
"did",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1463-L1479 |
34,652 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.remove | public final UnicodeSet remove(CharSequence s) {
int cp = getSingleCP(s);
if (cp < 0) {
strings.remove(s.toString());
pat = null;
} else {
remove(cp, cp);
}
return this;
} | java | public final UnicodeSet remove(CharSequence s) {
int cp = getSingleCP(s);
if (cp < 0) {
strings.remove(s.toString());
pat = null;
} else {
remove(cp, cp);
}
return this;
} | [
"public",
"final",
"UnicodeSet",
"remove",
"(",
"CharSequence",
"s",
")",
"{",
"int",
"cp",
"=",
"getSingleCP",
"(",
"s",
")",
";",
"if",
"(",
"cp",
"<",
"0",
")",
"{",
"strings",
".",
"remove",
"(",
"s",
".",
"toString",
"(",
")",
")",
";",
"pat... | Removes the specified string from this set if it is present.
The set will not contain the specified string once the call
returns.
@param s the string to be removed
@return this object, for chaining | [
"Removes",
"the",
"specified",
"string",
"from",
"this",
"set",
"if",
"it",
"is",
"present",
".",
"The",
"set",
"will",
"not",
"contain",
"the",
"specified",
"string",
"once",
"the",
"call",
"returns",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1524-L1533 |
34,653 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.contains | @Override
public boolean contains(int c) {
if (c < MIN_VALUE || c > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(c, 6));
}
if (bmpSet != null) {
return bmpSet.contains(c);
}
if (stringSpan != null) {
return stringSpan.contains(c);
}
/*
// Set i to the index of the start item greater than ch
// We know we will terminate without length test!
int i = -1;
while (true) {
if (c < list[++i]) break;
}
*/
int i = findCodePoint(c);
return ((i & 1) != 0); // return true if odd
} | java | @Override
public boolean contains(int c) {
if (c < MIN_VALUE || c > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(c, 6));
}
if (bmpSet != null) {
return bmpSet.contains(c);
}
if (stringSpan != null) {
return stringSpan.contains(c);
}
/*
// Set i to the index of the start item greater than ch
// We know we will terminate without length test!
int i = -1;
while (true) {
if (c < list[++i]) break;
}
*/
int i = findCodePoint(c);
return ((i & 1) != 0); // return true if odd
} | [
"@",
"Override",
"public",
"boolean",
"contains",
"(",
"int",
"c",
")",
"{",
"if",
"(",
"c",
"<",
"MIN_VALUE",
"||",
"c",
">",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid code point U+\"",
"+",
"Utility",
".",
"hex",
... | Returns true if this set contains the given character.
@param c character to be checked for containment
@return true if the test condition is met | [
"Returns",
"true",
"if",
"this",
"set",
"contains",
"the",
"given",
"character",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1619-L1643 |
34,654 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.contains | public boolean contains(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
}
if (end < MIN_VALUE || end > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(end, 6));
}
//int i = -1;
//while (true) {
// if (start < list[++i]) break;
//}
int i = findCodePoint(start);
return ((i & 1) != 0 && end < list[i]);
} | java | public boolean contains(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
}
if (end < MIN_VALUE || end > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(end, 6));
}
//int i = -1;
//while (true) {
// if (start < list[++i]) break;
//}
int i = findCodePoint(start);
return ((i & 1) != 0 && end < list[i]);
} | [
"public",
"boolean",
"contains",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"<",
"MIN_VALUE",
"||",
"start",
">",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid code point U+\"",
"+",
"Utility",
... | Returns true if this set contains every character
of the given range.
@param start first character, inclusive, of the range
@param end last character, inclusive, of the range
@return true if the test condition is met | [
"Returns",
"true",
"if",
"this",
"set",
"contains",
"every",
"character",
"of",
"the",
"given",
"range",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1808-L1821 |
34,655 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.containsAll | public boolean containsAll(UnicodeSet b) {
// The specified set is a subset if all of its pairs are contained in
// this set. This implementation accesses the lists directly for speed.
// TODO: this could be faster if size() were cached. But that would affect building speed
// so it needs investigation.
int[] listB = b.list;
boolean needA = true;
boolean needB = true;
int aPtr = 0;
int bPtr = 0;
int aLen = len - 1;
int bLen = b.len - 1;
int startA = 0, startB = 0, limitA = 0, limitB = 0;
while (true) {
// double iterations are such a pain...
if (needA) {
if (aPtr >= aLen) {
// ran out of A. If B is also exhausted, then break;
if (needB && bPtr >= bLen) {
break;
}
return false;
}
startA = list[aPtr++];
limitA = list[aPtr++];
}
if (needB) {
if (bPtr >= bLen) {
// ran out of B. Since we got this far, we have an A and we are ok so far
break;
}
startB = listB[bPtr++];
limitB = listB[bPtr++];
}
// if B doesn't overlap and is greater than A, get new A
if (startB >= limitA) {
needA = true;
needB = false;
continue;
}
// if B is wholy contained in A, then get a new B
if (startB >= startA && limitB <= limitA) {
needA = false;
needB = true;
continue;
}
// all other combinations mean we fail
return false;
}
if (!strings.containsAll(b.strings)) return false;
return true;
} | java | public boolean containsAll(UnicodeSet b) {
// The specified set is a subset if all of its pairs are contained in
// this set. This implementation accesses the lists directly for speed.
// TODO: this could be faster if size() were cached. But that would affect building speed
// so it needs investigation.
int[] listB = b.list;
boolean needA = true;
boolean needB = true;
int aPtr = 0;
int bPtr = 0;
int aLen = len - 1;
int bLen = b.len - 1;
int startA = 0, startB = 0, limitA = 0, limitB = 0;
while (true) {
// double iterations are such a pain...
if (needA) {
if (aPtr >= aLen) {
// ran out of A. If B is also exhausted, then break;
if (needB && bPtr >= bLen) {
break;
}
return false;
}
startA = list[aPtr++];
limitA = list[aPtr++];
}
if (needB) {
if (bPtr >= bLen) {
// ran out of B. Since we got this far, we have an A and we are ok so far
break;
}
startB = listB[bPtr++];
limitB = listB[bPtr++];
}
// if B doesn't overlap and is greater than A, get new A
if (startB >= limitA) {
needA = true;
needB = false;
continue;
}
// if B is wholy contained in A, then get a new B
if (startB >= startA && limitB <= limitA) {
needA = false;
needB = true;
continue;
}
// all other combinations mean we fail
return false;
}
if (!strings.containsAll(b.strings)) return false;
return true;
} | [
"public",
"boolean",
"containsAll",
"(",
"UnicodeSet",
"b",
")",
"{",
"// The specified set is a subset if all of its pairs are contained in",
"// this set. This implementation accesses the lists directly for speed.",
"// TODO: this could be faster if size() were cached. But that would affect bu... | Returns true if this set contains all the characters and strings
of the given set.
@param b set to be checked for containment
@return true if the test condition is met | [
"Returns",
"true",
"if",
"this",
"set",
"contains",
"all",
"the",
"characters",
"and",
"strings",
"of",
"the",
"given",
"set",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1845-L1897 |
34,656 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.containsAll | private boolean containsAll(String s, int i) {
if (i >= s.length()) {
return true;
}
int cp= UTF16.charAt(s, i);
if (contains(cp) && containsAll(s, i+UTF16.getCharCount(cp))) {
return true;
}
for (String setStr : strings) {
if (s.startsWith(setStr, i) && containsAll(s, i+setStr.length())) {
return true;
}
}
return false;
} | java | private boolean containsAll(String s, int i) {
if (i >= s.length()) {
return true;
}
int cp= UTF16.charAt(s, i);
if (contains(cp) && containsAll(s, i+UTF16.getCharCount(cp))) {
return true;
}
for (String setStr : strings) {
if (s.startsWith(setStr, i) && containsAll(s, i+setStr.length())) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"containsAll",
"(",
"String",
"s",
",",
"int",
"i",
")",
"{",
"if",
"(",
"i",
">=",
"s",
".",
"length",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"int",
"cp",
"=",
"UTF16",
".",
"charAt",
"(",
"s",
",",
"i",
")",
"... | Recursive routine called if we fail to find a match in containsAll, and there are strings
@param s source string
@param i point to match to the end on
@return true if ok | [
"Recursive",
"routine",
"called",
"if",
"we",
"fail",
"to",
"find",
"a",
"match",
"in",
"containsAll",
"and",
"there",
"are",
"strings"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1948-L1963 |
34,657 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.getRegexEquivalent | @Deprecated
public String getRegexEquivalent() {
if (strings.size() == 0) {
return toString();
}
StringBuilder result = new StringBuilder("(?:");
appendNewPattern(result, true, false);
for (String s : strings) {
result.append('|');
_appendToPat(result, s, true);
}
return result.append(")").toString();
} | java | @Deprecated
public String getRegexEquivalent() {
if (strings.size() == 0) {
return toString();
}
StringBuilder result = new StringBuilder("(?:");
appendNewPattern(result, true, false);
for (String s : strings) {
result.append('|');
_appendToPat(result, s, true);
}
return result.append(")").toString();
} | [
"@",
"Deprecated",
"public",
"String",
"getRegexEquivalent",
"(",
")",
"{",
"if",
"(",
"strings",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"toString",
"(",
")",
";",
"}",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"\"(?:\""... | Get the Regex equivalent for this UnicodeSet
@return regex pattern equivalent to this UnicodeSet
@deprecated This API is ICU internal only.
@hide original deprecated declaration
@hide draft / provisional / internal are hidden on Android | [
"Get",
"the",
"Regex",
"equivalent",
"for",
"this",
"UnicodeSet"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1972-L1984 |
34,658 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.containsNone | public boolean containsNone(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
}
if (end < MIN_VALUE || end > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(end, 6));
}
int i = -1;
while (true) {
if (start < list[++i]) break;
}
return ((i & 1) == 0 && end < list[i]);
} | java | public boolean containsNone(int start, int end) {
if (start < MIN_VALUE || start > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
}
if (end < MIN_VALUE || end > MAX_VALUE) {
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(end, 6));
}
int i = -1;
while (true) {
if (start < list[++i]) break;
}
return ((i & 1) == 0 && end < list[i]);
} | [
"public",
"boolean",
"containsNone",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"<",
"MIN_VALUE",
"||",
"start",
">",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid code point U+\"",
"+",
"Utility"... | Returns true if this set contains none of the characters
of the given range.
@param start first character, inclusive, of the range
@param end last character, inclusive, of the range
@return true if the test condition is met | [
"Returns",
"true",
"if",
"this",
"set",
"contains",
"none",
"of",
"the",
"characters",
"of",
"the",
"given",
"range",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L1993-L2005 |
34,659 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.complementAll | public UnicodeSet complementAll(UnicodeSet c) {
checkFrozen();
xor(c.list, c.len, 0);
SortedSetRelation.doOperation(strings, SortedSetRelation.COMPLEMENTALL, c.strings);
return this;
} | java | public UnicodeSet complementAll(UnicodeSet c) {
checkFrozen();
xor(c.list, c.len, 0);
SortedSetRelation.doOperation(strings, SortedSetRelation.COMPLEMENTALL, c.strings);
return this;
} | [
"public",
"UnicodeSet",
"complementAll",
"(",
"UnicodeSet",
"c",
")",
"{",
"checkFrozen",
"(",
")",
";",
"xor",
"(",
"c",
".",
"list",
",",
"c",
".",
"len",
",",
"0",
")",
";",
"SortedSetRelation",
".",
"doOperation",
"(",
"strings",
",",
"SortedSetRelat... | Complements in this set all elements contained in the specified
set. Any character in the other set will be removed if it is
in this set, or will be added if it is not in this set.
@param c set that defines which elements will be complemented from
this set. | [
"Complements",
"in",
"this",
"set",
"all",
"elements",
"contained",
"in",
"the",
"specified",
"set",
".",
"Any",
"character",
"in",
"the",
"other",
"set",
"will",
"be",
"removed",
"if",
"it",
"is",
"in",
"this",
"set",
"or",
"will",
"be",
"added",
"if",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L2185-L2190 |
34,660 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.clear | public UnicodeSet clear() {
checkFrozen();
list[0] = HIGH;
len = 1;
pat = null;
strings.clear();
return this;
} | java | public UnicodeSet clear() {
checkFrozen();
list[0] = HIGH;
len = 1;
pat = null;
strings.clear();
return this;
} | [
"public",
"UnicodeSet",
"clear",
"(",
")",
"{",
"checkFrozen",
"(",
")",
";",
"list",
"[",
"0",
"]",
"=",
"HIGH",
";",
"len",
"=",
"1",
";",
"pat",
"=",
"null",
";",
"strings",
".",
"clear",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Removes all of the elements from this set. This set will be
empty after this call returns. | [
"Removes",
"all",
"of",
"the",
"elements",
"from",
"this",
"set",
".",
"This",
"set",
"will",
"be",
"empty",
"after",
"this",
"call",
"returns",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L2196-L2203 |
34,661 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.compact | public UnicodeSet compact() {
checkFrozen();
if (len != list.length) {
int[] temp = new int[len];
System.arraycopy(list, 0, temp, 0, len);
list = temp;
}
rangeList = null;
buffer = null;
return this;
} | java | public UnicodeSet compact() {
checkFrozen();
if (len != list.length) {
int[] temp = new int[len];
System.arraycopy(list, 0, temp, 0, len);
list = temp;
}
rangeList = null;
buffer = null;
return this;
} | [
"public",
"UnicodeSet",
"compact",
"(",
")",
"{",
"checkFrozen",
"(",
")",
";",
"if",
"(",
"len",
"!=",
"list",
".",
"length",
")",
"{",
"int",
"[",
"]",
"temp",
"=",
"new",
"int",
"[",
"len",
"]",
";",
"System",
".",
"arraycopy",
"(",
"list",
",... | Reallocate this objects internal structures to take up the least
possible space, without changing this object's value. | [
"Reallocate",
"this",
"objects",
"internal",
"structures",
"to",
"take",
"up",
"the",
"least",
"possible",
"space",
"without",
"changing",
"this",
"object",
"s",
"value",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L2243-L2253 |
34,662 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.range | private int[] range(int start, int end) {
if (rangeList == null) {
rangeList = new int[] { start, end+1, HIGH };
} else {
rangeList[0] = start;
rangeList[1] = end+1;
}
return rangeList;
} | java | private int[] range(int start, int end) {
if (rangeList == null) {
rangeList = new int[] { start, end+1, HIGH };
} else {
rangeList[0] = start;
rangeList[1] = end+1;
}
return rangeList;
} | [
"private",
"int",
"[",
"]",
"range",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"rangeList",
"==",
"null",
")",
"{",
"rangeList",
"=",
"new",
"int",
"[",
"]",
"{",
"start",
",",
"end",
"+",
"1",
",",
"HIGH",
"}",
";",
"}",
"... | Assumes start <= end. | [
"Assumes",
"start",
"<",
"=",
"end",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L2868-L2876 |
34,663 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.applyFilter | private UnicodeSet applyFilter(Filter filter, int src) {
// Logically, walk through all Unicode characters, noting the start
// and end of each range for which filter.contain(c) is
// true. Add each range to a set.
//
// To improve performance, use an inclusions set which
// encodes information about character ranges that are known
// to have identical properties.
// getInclusions(src) contains exactly the first characters of
// same-value ranges for the given properties "source".
clear();
int startHasProperty = -1;
UnicodeSet inclusions = getInclusions(src);
int limitRange = inclusions.getRangeCount();
for (int j=0; j<limitRange; ++j) {
// get current range
int start = inclusions.getRangeStart(j);
int end = inclusions.getRangeEnd(j);
// for all the code points in the range, process
for (int ch = start; ch <= end; ++ch) {
// only add to the unicodeset on inflection points --
// where the hasProperty value changes to false
if (filter.contains(ch)) {
if (startHasProperty < 0) {
startHasProperty = ch;
}
} else if (startHasProperty >= 0) {
add_unchecked(startHasProperty, ch-1);
startHasProperty = -1;
}
}
}
if (startHasProperty >= 0) {
add_unchecked(startHasProperty, 0x10FFFF);
}
return this;
} | java | private UnicodeSet applyFilter(Filter filter, int src) {
// Logically, walk through all Unicode characters, noting the start
// and end of each range for which filter.contain(c) is
// true. Add each range to a set.
//
// To improve performance, use an inclusions set which
// encodes information about character ranges that are known
// to have identical properties.
// getInclusions(src) contains exactly the first characters of
// same-value ranges for the given properties "source".
clear();
int startHasProperty = -1;
UnicodeSet inclusions = getInclusions(src);
int limitRange = inclusions.getRangeCount();
for (int j=0; j<limitRange; ++j) {
// get current range
int start = inclusions.getRangeStart(j);
int end = inclusions.getRangeEnd(j);
// for all the code points in the range, process
for (int ch = start; ch <= end; ++ch) {
// only add to the unicodeset on inflection points --
// where the hasProperty value changes to false
if (filter.contains(ch)) {
if (startHasProperty < 0) {
startHasProperty = ch;
}
} else if (startHasProperty >= 0) {
add_unchecked(startHasProperty, ch-1);
startHasProperty = -1;
}
}
}
if (startHasProperty >= 0) {
add_unchecked(startHasProperty, 0x10FFFF);
}
return this;
} | [
"private",
"UnicodeSet",
"applyFilter",
"(",
"Filter",
"filter",
",",
"int",
"src",
")",
"{",
"// Logically, walk through all Unicode characters, noting the start",
"// and end of each range for which filter.contain(c) is",
"// true. Add each range to a set.",
"//",
"// To improve per... | Generic filter-based scanning code for UCD property UnicodeSets. | [
"Generic",
"filter",
"-",
"based",
"scanning",
"code",
"for",
"UCD",
"property",
"UnicodeSets",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3217-L3258 |
34,664 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.mungeCharName | private static String mungeCharName(String source) {
source = PatternProps.trimWhiteSpace(source);
StringBuilder buf = null;
for (int i=0; i<source.length(); ++i) {
char ch = source.charAt(i);
if (PatternProps.isWhiteSpace(ch)) {
if (buf == null) {
buf = new StringBuilder().append(source, 0, i);
} else if (buf.charAt(buf.length() - 1) == ' ') {
continue;
}
ch = ' '; // convert to ' '
}
if (buf != null) {
buf.append(ch);
}
}
return buf == null ? source : buf.toString();
} | java | private static String mungeCharName(String source) {
source = PatternProps.trimWhiteSpace(source);
StringBuilder buf = null;
for (int i=0; i<source.length(); ++i) {
char ch = source.charAt(i);
if (PatternProps.isWhiteSpace(ch)) {
if (buf == null) {
buf = new StringBuilder().append(source, 0, i);
} else if (buf.charAt(buf.length() - 1) == ' ') {
continue;
}
ch = ' '; // convert to ' '
}
if (buf != null) {
buf.append(ch);
}
}
return buf == null ? source : buf.toString();
} | [
"private",
"static",
"String",
"mungeCharName",
"(",
"String",
"source",
")",
"{",
"source",
"=",
"PatternProps",
".",
"trimWhiteSpace",
"(",
"source",
")",
";",
"StringBuilder",
"buf",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
... | Remove leading and trailing Pattern_White_Space and compress
internal Pattern_White_Space to a single space character. | [
"Remove",
"leading",
"and",
"trailing",
"Pattern_White_Space",
"and",
"compress",
"internal",
"Pattern_White_Space",
"to",
"a",
"single",
"space",
"character",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3265-L3283 |
34,665 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.applyIntPropertyValue | public UnicodeSet applyIntPropertyValue(int prop, int value) {
checkFrozen();
if (prop == UProperty.GENERAL_CATEGORY_MASK) {
applyFilter(new GeneralCategoryMaskFilter(value), UCharacterProperty.SRC_CHAR);
} else if (prop == UProperty.SCRIPT_EXTENSIONS) {
applyFilter(new ScriptExtensionsFilter(value), UCharacterProperty.SRC_PROPSVEC);
} else {
applyFilter(new IntPropertyFilter(prop, value), UCharacterProperty.INSTANCE.getSource(prop));
}
return this;
} | java | public UnicodeSet applyIntPropertyValue(int prop, int value) {
checkFrozen();
if (prop == UProperty.GENERAL_CATEGORY_MASK) {
applyFilter(new GeneralCategoryMaskFilter(value), UCharacterProperty.SRC_CHAR);
} else if (prop == UProperty.SCRIPT_EXTENSIONS) {
applyFilter(new ScriptExtensionsFilter(value), UCharacterProperty.SRC_PROPSVEC);
} else {
applyFilter(new IntPropertyFilter(prop, value), UCharacterProperty.INSTANCE.getSource(prop));
}
return this;
} | [
"public",
"UnicodeSet",
"applyIntPropertyValue",
"(",
"int",
"prop",
",",
"int",
"value",
")",
"{",
"checkFrozen",
"(",
")",
";",
"if",
"(",
"prop",
"==",
"UProperty",
".",
"GENERAL_CATEGORY_MASK",
")",
"{",
"applyFilter",
"(",
"new",
"GeneralCategoryMaskFilter"... | Modifies this set to contain those code points which have the
given value for the given binary or enumerated property, as
returned by UCharacter.getIntPropertyValue. Prior contents of
this set are lost.
@param prop a property in the range
UProperty.BIN_START..UProperty.BIN_LIMIT-1 or
UProperty.INT_START..UProperty.INT_LIMIT-1 or.
UProperty.MASK_START..UProperty.MASK_LIMIT-1.
@param value a value in the range
UCharacter.getIntPropertyMinValue(prop)..
UCharacter.getIntPropertyMaxValue(prop), with one exception.
If prop is UProperty.GENERAL_CATEGORY_MASK, then value should not be
a UCharacter.getType() result, but rather a mask value produced
by logically ORing (1 << UCharacter.getType()) values together.
This allows grouped categories such as [:L:] to be represented.
@return a reference to this set | [
"Modifies",
"this",
"set",
"to",
"contain",
"those",
"code",
"points",
"which",
"have",
"the",
"given",
"value",
"for",
"the",
"given",
"binary",
"or",
"enumerated",
"property",
"as",
"returned",
"by",
"UCharacter",
".",
"getIntPropertyValue",
".",
"Prior",
"c... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3310-L3320 |
34,666 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.resemblesPropertyPattern | private static boolean resemblesPropertyPattern(String pattern, int pos) {
// Patterns are at least 5 characters long
if ((pos+5) > pattern.length()) {
return false;
}
// Look for an opening [:, [:^, \p, or \P
return pattern.regionMatches(pos, "[:", 0, 2) ||
pattern.regionMatches(true, pos, "\\p", 0, 2) ||
pattern.regionMatches(pos, "\\N", 0, 2);
} | java | private static boolean resemblesPropertyPattern(String pattern, int pos) {
// Patterns are at least 5 characters long
if ((pos+5) > pattern.length()) {
return false;
}
// Look for an opening [:, [:^, \p, or \P
return pattern.regionMatches(pos, "[:", 0, 2) ||
pattern.regionMatches(true, pos, "\\p", 0, 2) ||
pattern.regionMatches(pos, "\\N", 0, 2);
} | [
"private",
"static",
"boolean",
"resemblesPropertyPattern",
"(",
"String",
"pattern",
",",
"int",
"pos",
")",
"{",
"// Patterns are at least 5 characters long",
"if",
"(",
"(",
"pos",
"+",
"5",
")",
">",
"pattern",
".",
"length",
"(",
")",
")",
"{",
"return",
... | Return true if the given position, in the given pattern, appears
to be the start of a property set pattern. | [
"Return",
"true",
"if",
"the",
"given",
"position",
"in",
"the",
"given",
"pattern",
"appears",
"to",
"be",
"the",
"start",
"of",
"a",
"property",
"set",
"pattern",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3522-L3532 |
34,667 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.resemblesPropertyPattern | private static boolean resemblesPropertyPattern(RuleCharacterIterator chars,
int iterOpts) {
boolean result = false;
iterOpts &= ~RuleCharacterIterator.PARSE_ESCAPES;
Object pos = chars.getPos(null);
int c = chars.next(iterOpts);
if (c == '[' || c == '\\') {
int d = chars.next(iterOpts & ~RuleCharacterIterator.SKIP_WHITESPACE);
result = (c == '[') ? (d == ':') :
(d == 'N' || d == 'p' || d == 'P');
}
chars.setPos(pos);
return result;
} | java | private static boolean resemblesPropertyPattern(RuleCharacterIterator chars,
int iterOpts) {
boolean result = false;
iterOpts &= ~RuleCharacterIterator.PARSE_ESCAPES;
Object pos = chars.getPos(null);
int c = chars.next(iterOpts);
if (c == '[' || c == '\\') {
int d = chars.next(iterOpts & ~RuleCharacterIterator.SKIP_WHITESPACE);
result = (c == '[') ? (d == ':') :
(d == 'N' || d == 'p' || d == 'P');
}
chars.setPos(pos);
return result;
} | [
"private",
"static",
"boolean",
"resemblesPropertyPattern",
"(",
"RuleCharacterIterator",
"chars",
",",
"int",
"iterOpts",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"iterOpts",
"&=",
"~",
"RuleCharacterIterator",
".",
"PARSE_ESCAPES",
";",
"Object",
"pos",
... | Return true if the given iterator appears to point at a
property pattern. Regardless of the result, return with the
iterator unchanged.
@param chars iterator over the pattern characters. Upon return
it will be unchanged.
@param iterOpts RuleCharacterIterator options | [
"Return",
"true",
"if",
"the",
"given",
"iterator",
"appears",
"to",
"point",
"at",
"a",
"property",
"pattern",
".",
"Regardless",
"of",
"the",
"result",
"return",
"with",
"the",
"iterator",
"unchanged",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3542-L3555 |
34,668 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.applyPropertyPattern | private UnicodeSet applyPropertyPattern(String pattern, ParsePosition ppos, SymbolTable symbols) {
int pos = ppos.getIndex();
// On entry, ppos should point to one of the following locations:
// Minimum length is 5 characters, e.g. \p{L}
if ((pos+5) > pattern.length()) {
return null;
}
boolean posix = false; // true for [:pat:], false for \p{pat} \P{pat} \N{pat}
boolean isName = false; // true for \N{pat}, o/w false
boolean invert = false;
// Look for an opening [:, [:^, \p, or \P
if (pattern.regionMatches(pos, "[:", 0, 2)) {
posix = true;
pos = PatternProps.skipWhiteSpace(pattern, (pos+2));
if (pos < pattern.length() && pattern.charAt(pos) == '^') {
++pos;
invert = true;
}
} else if (pattern.regionMatches(true, pos, "\\p", 0, 2) ||
pattern.regionMatches(pos, "\\N", 0, 2)) {
char c = pattern.charAt(pos+1);
invert = (c == 'P');
isName = (c == 'N');
pos = PatternProps.skipWhiteSpace(pattern, (pos+2));
if (pos == pattern.length() || pattern.charAt(pos++) != '{') {
// Syntax error; "\p" or "\P" not followed by "{"
return null;
}
} else {
// Open delimiter not seen
return null;
}
// Look for the matching close delimiter, either :] or }
int close = pattern.indexOf(posix ? ":]" : "}", pos);
if (close < 0) {
// Syntax error; close delimiter missing
return null;
}
// Look for an '=' sign. If this is present, we will parse a
// medium \p{gc=Cf} or long \p{GeneralCategory=Format}
// pattern.
int equals = pattern.indexOf('=', pos);
String propName, valueName;
if (equals >= 0 && equals < close && !isName) {
// Equals seen; parse medium/long pattern
propName = pattern.substring(pos, equals);
valueName = pattern.substring(equals+1, close);
}
else {
// Handle case where no '=' is seen, and \N{}
propName = pattern.substring(pos, close);
valueName = "";
// Handle \N{name}
if (isName) {
// This is a little inefficient since it means we have to
// parse "na" back to UProperty.NAME even though we already
// know it's UProperty.NAME. If we refactor the API to
// support args of (int, String) then we can remove
// "na" and make this a little more efficient.
valueName = propName;
propName = "na";
}
}
applyPropertyAlias(propName, valueName, symbols);
if (invert) {
complement();
}
// Move to the limit position after the close delimiter
ppos.setIndex(close + (posix ? 2 : 1));
return this;
} | java | private UnicodeSet applyPropertyPattern(String pattern, ParsePosition ppos, SymbolTable symbols) {
int pos = ppos.getIndex();
// On entry, ppos should point to one of the following locations:
// Minimum length is 5 characters, e.g. \p{L}
if ((pos+5) > pattern.length()) {
return null;
}
boolean posix = false; // true for [:pat:], false for \p{pat} \P{pat} \N{pat}
boolean isName = false; // true for \N{pat}, o/w false
boolean invert = false;
// Look for an opening [:, [:^, \p, or \P
if (pattern.regionMatches(pos, "[:", 0, 2)) {
posix = true;
pos = PatternProps.skipWhiteSpace(pattern, (pos+2));
if (pos < pattern.length() && pattern.charAt(pos) == '^') {
++pos;
invert = true;
}
} else if (pattern.regionMatches(true, pos, "\\p", 0, 2) ||
pattern.regionMatches(pos, "\\N", 0, 2)) {
char c = pattern.charAt(pos+1);
invert = (c == 'P');
isName = (c == 'N');
pos = PatternProps.skipWhiteSpace(pattern, (pos+2));
if (pos == pattern.length() || pattern.charAt(pos++) != '{') {
// Syntax error; "\p" or "\P" not followed by "{"
return null;
}
} else {
// Open delimiter not seen
return null;
}
// Look for the matching close delimiter, either :] or }
int close = pattern.indexOf(posix ? ":]" : "}", pos);
if (close < 0) {
// Syntax error; close delimiter missing
return null;
}
// Look for an '=' sign. If this is present, we will parse a
// medium \p{gc=Cf} or long \p{GeneralCategory=Format}
// pattern.
int equals = pattern.indexOf('=', pos);
String propName, valueName;
if (equals >= 0 && equals < close && !isName) {
// Equals seen; parse medium/long pattern
propName = pattern.substring(pos, equals);
valueName = pattern.substring(equals+1, close);
}
else {
// Handle case where no '=' is seen, and \N{}
propName = pattern.substring(pos, close);
valueName = "";
// Handle \N{name}
if (isName) {
// This is a little inefficient since it means we have to
// parse "na" back to UProperty.NAME even though we already
// know it's UProperty.NAME. If we refactor the API to
// support args of (int, String) then we can remove
// "na" and make this a little more efficient.
valueName = propName;
propName = "na";
}
}
applyPropertyAlias(propName, valueName, symbols);
if (invert) {
complement();
}
// Move to the limit position after the close delimiter
ppos.setIndex(close + (posix ? 2 : 1));
return this;
} | [
"private",
"UnicodeSet",
"applyPropertyPattern",
"(",
"String",
"pattern",
",",
"ParsePosition",
"ppos",
",",
"SymbolTable",
"symbols",
")",
"{",
"int",
"pos",
"=",
"ppos",
".",
"getIndex",
"(",
")",
";",
"// On entry, ppos should point to one of the following locations... | Parse the given property pattern at the given parse position.
@param symbols TODO | [
"Parse",
"the",
"given",
"property",
"pattern",
"at",
"the",
"given",
"parse",
"position",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3561-L3643 |
34,669 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.applyPropertyPattern | private void applyPropertyPattern(RuleCharacterIterator chars,
Appendable rebuiltPat, SymbolTable symbols) {
String patStr = chars.lookahead();
ParsePosition pos = new ParsePosition(0);
applyPropertyPattern(patStr, pos, symbols);
if (pos.getIndex() == 0) {
syntaxError(chars, "Invalid property pattern");
}
chars.jumpahead(pos.getIndex());
append(rebuiltPat, patStr.substring(0, pos.getIndex()));
} | java | private void applyPropertyPattern(RuleCharacterIterator chars,
Appendable rebuiltPat, SymbolTable symbols) {
String patStr = chars.lookahead();
ParsePosition pos = new ParsePosition(0);
applyPropertyPattern(patStr, pos, symbols);
if (pos.getIndex() == 0) {
syntaxError(chars, "Invalid property pattern");
}
chars.jumpahead(pos.getIndex());
append(rebuiltPat, patStr.substring(0, pos.getIndex()));
} | [
"private",
"void",
"applyPropertyPattern",
"(",
"RuleCharacterIterator",
"chars",
",",
"Appendable",
"rebuiltPat",
",",
"SymbolTable",
"symbols",
")",
"{",
"String",
"patStr",
"=",
"chars",
".",
"lookahead",
"(",
")",
";",
"ParsePosition",
"pos",
"=",
"new",
"Pa... | Parse a property pattern.
@param chars iterator over the pattern characters. Upon return
it will be advanced to the first character after the parsed
pattern, or the end of the iteration if all characters are
parsed.
@param rebuiltPat the pattern that was parsed, rebuilt or
copied from the input pattern, as appropriate.
@param symbols TODO | [
"Parse",
"a",
"property",
"pattern",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3655-L3665 |
34,670 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.addCaseMapping | private static final void addCaseMapping(UnicodeSet set, int result, StringBuilder full) {
if(result >= 0) {
if(result > UCaseProps.MAX_STRING_LENGTH) {
// add a single-code point case mapping
set.add(result);
} else {
// add a string case mapping from full with length result
set.add(full.toString());
full.setLength(0);
}
}
// result < 0: the code point mapped to itself, no need to add it
// see UCaseProps
} | java | private static final void addCaseMapping(UnicodeSet set, int result, StringBuilder full) {
if(result >= 0) {
if(result > UCaseProps.MAX_STRING_LENGTH) {
// add a single-code point case mapping
set.add(result);
} else {
// add a string case mapping from full with length result
set.add(full.toString());
full.setLength(0);
}
}
// result < 0: the code point mapped to itself, no need to add it
// see UCaseProps
} | [
"private",
"static",
"final",
"void",
"addCaseMapping",
"(",
"UnicodeSet",
"set",
",",
"int",
"result",
",",
"StringBuilder",
"full",
")",
"{",
"if",
"(",
"result",
">=",
"0",
")",
"{",
"if",
"(",
"result",
">",
"UCaseProps",
".",
"MAX_STRING_LENGTH",
")",... | use str as a temporary string to avoid constructing one | [
"use",
"str",
"as",
"a",
"temporary",
"string",
"to",
"avoid",
"constructing",
"one"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3731-L3744 |
34,671 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.freeze | @Override
public UnicodeSet freeze() {
if (!isFrozen()) {
// Do most of what compact() does before freezing because
// compact() will not work when the set is frozen.
// Small modification: Don't shrink if the savings would be tiny (<=GROW_EXTRA).
// Delete buffer first to defragment memory less.
buffer = null;
if (list.length > (len + GROW_EXTRA)) {
// Make the capacity equal to len or 1.
// We don't want to realloc of 0 size.
int capacity = (len == 0) ? 1 : len;
int[] oldList = list;
list = new int[capacity];
for (int i = capacity; i-- > 0;) {
list[i] = oldList[i];
}
}
// Optimize contains() and span() and similar functions.
if (!strings.isEmpty()) {
stringSpan = new UnicodeSetStringSpan(this, new ArrayList<String>(strings), UnicodeSetStringSpan.ALL);
}
if (stringSpan == null || !stringSpan.needsStringSpanUTF16()) {
// Optimize for code point spans.
// There are no strings, or
// all strings are irrelevant for span() etc. because
// all of each string's code points are contained in this set.
// However, fully contained strings are relevant for spanAndCount(),
// so we create both objects.
bmpSet = new BMPSet(list, len);
}
}
return this;
} | java | @Override
public UnicodeSet freeze() {
if (!isFrozen()) {
// Do most of what compact() does before freezing because
// compact() will not work when the set is frozen.
// Small modification: Don't shrink if the savings would be tiny (<=GROW_EXTRA).
// Delete buffer first to defragment memory less.
buffer = null;
if (list.length > (len + GROW_EXTRA)) {
// Make the capacity equal to len or 1.
// We don't want to realloc of 0 size.
int capacity = (len == 0) ? 1 : len;
int[] oldList = list;
list = new int[capacity];
for (int i = capacity; i-- > 0;) {
list[i] = oldList[i];
}
}
// Optimize contains() and span() and similar functions.
if (!strings.isEmpty()) {
stringSpan = new UnicodeSetStringSpan(this, new ArrayList<String>(strings), UnicodeSetStringSpan.ALL);
}
if (stringSpan == null || !stringSpan.needsStringSpanUTF16()) {
// Optimize for code point spans.
// There are no strings, or
// all strings are irrelevant for span() etc. because
// all of each string's code points are contained in this set.
// However, fully contained strings are relevant for spanAndCount(),
// so we create both objects.
bmpSet = new BMPSet(list, len);
}
}
return this;
} | [
"@",
"Override",
"public",
"UnicodeSet",
"freeze",
"(",
")",
"{",
"if",
"(",
"!",
"isFrozen",
"(",
")",
")",
"{",
"// Do most of what compact() does before freezing because",
"// compact() will not work when the set is frozen.",
"// Small modification: Don't shrink if the savings... | Freeze this class, according to the Freezable interface.
@return this | [
"Freeze",
"this",
"class",
"according",
"to",
"the",
"Freezable",
"interface",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L3913-L3948 |
34,672 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.compareTo | public int compareTo(UnicodeSet o, ComparisonStyle style) {
if (style != ComparisonStyle.LEXICOGRAPHIC) {
int diff = size() - o.size();
if (diff != 0) {
return (diff < 0) == (style == ComparisonStyle.SHORTER_FIRST) ? -1 : 1;
}
}
int result;
for (int i = 0; ; ++i) {
if (0 != (result = list[i] - o.list[i])) {
// if either list ran out, compare to the last string
if (list[i] == HIGH) {
if (strings.isEmpty()) return 1;
String item = strings.first();
return compare(item, o.list[i]);
}
if (o.list[i] == HIGH) {
if (o.strings.isEmpty()) return -1;
String item = o.strings.first();
int compareResult = compare(item, list[i]);
return compareResult > 0 ? -1 : compareResult < 0 ? 1 : 0; // Reverse the order.
}
// otherwise return the result if even index, or the reversal if not
return (i & 1) == 0 ? result : -result;
}
if (list[i] == HIGH) {
break;
}
}
return compare(strings, o.strings);
} | java | public int compareTo(UnicodeSet o, ComparisonStyle style) {
if (style != ComparisonStyle.LEXICOGRAPHIC) {
int diff = size() - o.size();
if (diff != 0) {
return (diff < 0) == (style == ComparisonStyle.SHORTER_FIRST) ? -1 : 1;
}
}
int result;
for (int i = 0; ; ++i) {
if (0 != (result = list[i] - o.list[i])) {
// if either list ran out, compare to the last string
if (list[i] == HIGH) {
if (strings.isEmpty()) return 1;
String item = strings.first();
return compare(item, o.list[i]);
}
if (o.list[i] == HIGH) {
if (o.strings.isEmpty()) return -1;
String item = o.strings.first();
int compareResult = compare(item, list[i]);
return compareResult > 0 ? -1 : compareResult < 0 ? 1 : 0; // Reverse the order.
}
// otherwise return the result if even index, or the reversal if not
return (i & 1) == 0 ? result : -result;
}
if (list[i] == HIGH) {
break;
}
}
return compare(strings, o.strings);
} | [
"public",
"int",
"compareTo",
"(",
"UnicodeSet",
"o",
",",
"ComparisonStyle",
"style",
")",
"{",
"if",
"(",
"style",
"!=",
"ComparisonStyle",
".",
"LEXICOGRAPHIC",
")",
"{",
"int",
"diff",
"=",
"size",
"(",
")",
"-",
"o",
".",
"size",
"(",
")",
";",
... | Compares UnicodeSets, in three different ways.
@see java.lang.Comparable#compareTo(java.lang.Object) | [
"Compares",
"UnicodeSets",
"in",
"three",
"different",
"ways",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L4407-L4437 |
34,673 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.compare | public static <T extends Comparable<T>> int compare(Collection<T> collection1, Collection<T> collection2, ComparisonStyle style) {
if (style != ComparisonStyle.LEXICOGRAPHIC) {
int diff = collection1.size() - collection2.size();
if (diff != 0) {
return (diff < 0) == (style == ComparisonStyle.SHORTER_FIRST) ? -1 : 1;
}
}
return compare(collection1, collection2);
} | java | public static <T extends Comparable<T>> int compare(Collection<T> collection1, Collection<T> collection2, ComparisonStyle style) {
if (style != ComparisonStyle.LEXICOGRAPHIC) {
int diff = collection1.size() - collection2.size();
if (diff != 0) {
return (diff < 0) == (style == ComparisonStyle.SHORTER_FIRST) ? -1 : 1;
}
}
return compare(collection1, collection2);
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"T",
">",
">",
"int",
"compare",
"(",
"Collection",
"<",
"T",
">",
"collection1",
",",
"Collection",
"<",
"T",
">",
"collection2",
",",
"ComparisonStyle",
"style",
")",
"{",
"if",
"(",
"style",
... | Utility to compare two collections, optionally by size, and then lexicographically.
@hide unsupported on Android | [
"Utility",
"to",
"compare",
"two",
"collections",
"optionally",
"by",
"size",
"and",
"then",
"lexicographically",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L4514-L4522 |
34,674 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/AlgorithmParameters.java | AlgorithmParameters.init | public final void init(byte[] params) throws IOException {
if (this.initialized)
throw new IOException("already initialized");
paramSpi.engineInit(params);
this.initialized = true;
} | java | public final void init(byte[] params) throws IOException {
if (this.initialized)
throw new IOException("already initialized");
paramSpi.engineInit(params);
this.initialized = true;
} | [
"public",
"final",
"void",
"init",
"(",
"byte",
"[",
"]",
"params",
")",
"throws",
"IOException",
"{",
"if",
"(",
"this",
".",
"initialized",
")",
"throw",
"new",
"IOException",
"(",
"\"already initialized\"",
")",
";",
"paramSpi",
".",
"engineInit",
"(",
... | Imports the specified parameters and decodes them according to the
primary decoding format for parameters. The primary decoding
format for parameters is ASN.1, if an ASN.1 specification for this type
of parameters exists.
@param params the encoded parameters.
@exception IOException on decoding errors, or if this parameter object
has already been initialized. | [
"Imports",
"the",
"specified",
"parameters",
"and",
"decodes",
"them",
"according",
"to",
"the",
"primary",
"decoding",
"format",
"for",
"parameters",
".",
"The",
"primary",
"decoding",
"format",
"for",
"parameters",
"is",
"ASN",
".",
"1",
"if",
"an",
"ASN",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/AlgorithmParameters.java#L379-L384 |
34,675 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/PropsVectors.java | PropsVectors.areElementsSame | private boolean areElementsSame(int index1, int[] target, int index2,
int length) {
for (int i = 0; i < length; ++i) {
if (v[index1 + i] != target[index2 + i]) {
return false;
}
}
return true;
} | java | private boolean areElementsSame(int index1, int[] target, int index2,
int length) {
for (int i = 0; i < length; ++i) {
if (v[index1 + i] != target[index2 + i]) {
return false;
}
}
return true;
} | [
"private",
"boolean",
"areElementsSame",
"(",
"int",
"index1",
",",
"int",
"[",
"]",
"target",
",",
"int",
"index2",
",",
"int",
"length",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
... | starting from index2 to index2 + length - 1 | [
"starting",
"from",
"index2",
"to",
"index2",
"+",
"length",
"-",
"1"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/PropsVectors.java#L53-L61 |
34,676 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/PropsVectors.java | PropsVectors.findRow | private int findRow(int rangeStart) {
int index = 0;
// check the vicinity of the last-seen row (start
// searching with an unrolled loop)
index = prevRow * columns;
if (rangeStart >= v[index]) {
if (rangeStart < v[index + 1]) {
// same row as last seen
return index;
} else {
index += columns;
if (rangeStart < v[index + 1]) {
++prevRow;
return index;
} else {
index += columns;
if (rangeStart < v[index + 1]) {
prevRow += 2;
return index;
} else if ((rangeStart - v[index + 1]) < 10) {
// we are close, continue looping
prevRow += 2;
do {
++prevRow;
index += columns;
} while (rangeStart >= v[index + 1]);
return index;
}
}
}
} else if (rangeStart < v[1]) {
// the very first row
prevRow = 0;
return 0;
}
// do a binary search for the start of the range
int start = 0;
int mid = 0;
int limit = rows;
while (start < limit - 1) {
mid = (start + limit) / 2;
index = columns * mid;
if (rangeStart < v[index]) {
limit = mid;
} else if (rangeStart < v[index + 1]) {
prevRow = mid;
return index;
} else {
start = mid;
}
}
// must be found because all ranges together always cover
// all of Unicode
prevRow = start;
index = start * columns;
return index;
} | java | private int findRow(int rangeStart) {
int index = 0;
// check the vicinity of the last-seen row (start
// searching with an unrolled loop)
index = prevRow * columns;
if (rangeStart >= v[index]) {
if (rangeStart < v[index + 1]) {
// same row as last seen
return index;
} else {
index += columns;
if (rangeStart < v[index + 1]) {
++prevRow;
return index;
} else {
index += columns;
if (rangeStart < v[index + 1]) {
prevRow += 2;
return index;
} else if ((rangeStart - v[index + 1]) < 10) {
// we are close, continue looping
prevRow += 2;
do {
++prevRow;
index += columns;
} while (rangeStart >= v[index + 1]);
return index;
}
}
}
} else if (rangeStart < v[1]) {
// the very first row
prevRow = 0;
return 0;
}
// do a binary search for the start of the range
int start = 0;
int mid = 0;
int limit = rows;
while (start < limit - 1) {
mid = (start + limit) / 2;
index = columns * mid;
if (rangeStart < v[index]) {
limit = mid;
} else if (rangeStart < v[index + 1]) {
prevRow = mid;
return index;
} else {
start = mid;
}
}
// must be found because all ranges together always cover
// all of Unicode
prevRow = start;
index = start * columns;
return index;
} | [
"private",
"int",
"findRow",
"(",
"int",
"rangeStart",
")",
"{",
"int",
"index",
"=",
"0",
";",
"// check the vicinity of the last-seen row (start",
"// searching with an unrolled loop)",
"index",
"=",
"prevRow",
"*",
"columns",
";",
"if",
"(",
"rangeStart",
">=",
"... | points to the start of a row. | [
"points",
"to",
"the",
"start",
"of",
"a",
"row",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/PropsVectors.java#L67-L127 |
34,677 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/spec/DESKeySpec.java | DESKeySpec.isWeak | public static boolean isWeak(byte[] key, int offset)
throws InvalidKeyException {
if (key == null) {
throw new InvalidKeyException("null key");
}
if (key.length - offset < DES_KEY_LEN) {
throw new InvalidKeyException("Wrong key size");
}
for (int i = 0; i < WEAK_KEYS.length; i++) {
boolean found = true;
for (int j = 0; j < DES_KEY_LEN && found == true; j++) {
if (WEAK_KEYS[i][j] != key[j+offset]) {
found = false;
}
}
if (found == true) {
return found;
}
}
return false;
} | java | public static boolean isWeak(byte[] key, int offset)
throws InvalidKeyException {
if (key == null) {
throw new InvalidKeyException("null key");
}
if (key.length - offset < DES_KEY_LEN) {
throw new InvalidKeyException("Wrong key size");
}
for (int i = 0; i < WEAK_KEYS.length; i++) {
boolean found = true;
for (int j = 0; j < DES_KEY_LEN && found == true; j++) {
if (WEAK_KEYS[i][j] != key[j+offset]) {
found = false;
}
}
if (found == true) {
return found;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isWeak",
"(",
"byte",
"[",
"]",
"key",
",",
"int",
"offset",
")",
"throws",
"InvalidKeyException",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidKeyException",
"(",
"\"null key\"",
")",
";",
"}",
"... | Checks if the given DES key material is weak or semi-weak.
@param key the buffer with the DES key material.
@param offset the offset in <code>key</code>, where the DES key
material starts.
@return true if the given DES key material is weak or semi-weak, false
otherwise.
@exception InvalidKeyException if the given key material is
<code>null</code>, or starting at <code>offset</code> inclusive, is
shorter than 8 bytes. | [
"Checks",
"if",
"the",
"given",
"DES",
"key",
"material",
"is",
"weak",
"or",
"semi",
"-",
"weak",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/spec/DESKeySpec.java#L219-L239 |
34,678 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/UnicodeUtils.java | UnicodeUtils.hasValidCppCharacters | public static boolean hasValidCppCharacters(String s) {
for (char c : s.toCharArray()) {
if (!isValidCppCharacter(c)) {
return false;
}
}
return true;
} | java | public static boolean hasValidCppCharacters(String s) {
for (char c : s.toCharArray()) {
if (!isValidCppCharacter(c)) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"hasValidCppCharacters",
"(",
"String",
"s",
")",
"{",
"for",
"(",
"char",
"c",
":",
"s",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isValidCppCharacter",
"(",
"c",
")",
")",
"{",
"return",
"false",
";",
"... | Returns true if all characters in a string can be expressed as either
C++ universal characters or valid hexadecimal escape sequences. | [
"Returns",
"true",
"if",
"all",
"characters",
"in",
"a",
"string",
"can",
"be",
"expressed",
"as",
"either",
"C",
"++",
"universal",
"characters",
"or",
"valid",
"hexadecimal",
"escape",
"sequences",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/UnicodeUtils.java#L111-L118 |
34,679 | google/j2objc | jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java | Base64OutputStream.embiggen | private byte[] embiggen(byte[] b, int len) {
if (b == null || b.length < len) {
return new byte[len];
} else {
return b;
}
} | java | private byte[] embiggen(byte[] b, int len) {
if (b == null || b.length < len) {
return new byte[len];
} else {
return b;
}
} | [
"private",
"byte",
"[",
"]",
"embiggen",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"len",
")",
"{",
"if",
"(",
"b",
"==",
"null",
"||",
"b",
".",
"length",
"<",
"len",
")",
"{",
"return",
"new",
"byte",
"[",
"len",
"]",
";",
"}",
"else",
"{",
... | If b.length is at least len, return b. Otherwise return a new
byte array of length len. | [
"If",
"b",
".",
"length",
"is",
"at",
"least",
"len",
"return",
"b",
".",
"Otherwise",
"return",
"a",
"new",
"byte",
"array",
"of",
"length",
"len",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/frameworks/base/core/java/android/util/Base64OutputStream.java#L148-L154 |
34,680 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/OpMap.java | OpMap.shrink | void shrink()
{
int n = m_opMap.elementAt(MAPINDEX_LENGTH);
m_opMap.setToSize(n + 4);
m_opMap.setElementAt(0,n);
m_opMap.setElementAt(0,n+1);
m_opMap.setElementAt(0,n+2);
n = m_tokenQueue.size();
m_tokenQueue.setToSize(n + 4);
m_tokenQueue.setElementAt(null,n);
m_tokenQueue.setElementAt(null,n + 1);
m_tokenQueue.setElementAt(null,n + 2);
} | java | void shrink()
{
int n = m_opMap.elementAt(MAPINDEX_LENGTH);
m_opMap.setToSize(n + 4);
m_opMap.setElementAt(0,n);
m_opMap.setElementAt(0,n+1);
m_opMap.setElementAt(0,n+2);
n = m_tokenQueue.size();
m_tokenQueue.setToSize(n + 4);
m_tokenQueue.setElementAt(null,n);
m_tokenQueue.setElementAt(null,n + 1);
m_tokenQueue.setElementAt(null,n + 2);
} | [
"void",
"shrink",
"(",
")",
"{",
"int",
"n",
"=",
"m_opMap",
".",
"elementAt",
"(",
"MAPINDEX_LENGTH",
")",
";",
"m_opMap",
".",
"setToSize",
"(",
"n",
"+",
"4",
")",
";",
"m_opMap",
".",
"setElementAt",
"(",
"0",
",",
"n",
")",
";",
"m_opMap",
"."... | Replace the large arrays
with a small array. | [
"Replace",
"the",
"large",
"arrays",
"with",
"a",
"small",
"array",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/OpMap.java#L149-L166 |
34,681 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/OpMap.java | OpMap.getNextStepPos | public int getNextStepPos(int opPos)
{
int stepType = getOp(opPos);
if ((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES))
{
return getNextOpPos(opPos);
}
else if ((stepType >= OpCodes.FIRST_NODESET_OP)
&& (stepType <= OpCodes.LAST_NODESET_OP))
{
int newOpPos = getNextOpPos(opPos);
while (OpCodes.OP_PREDICATE == getOp(newOpPos))
{
newOpPos = getNextOpPos(newOpPos);
}
stepType = getOp(newOpPos);
if (!((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES)))
{
return OpCodes.ENDOP;
}
return newOpPos;
}
else
{
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_UNKNOWN_STEP, new Object[]{String.valueOf(stepType)}));
//"Programmer's assertion in getNextStepPos: unknown stepType: " + stepType);
}
} | java | public int getNextStepPos(int opPos)
{
int stepType = getOp(opPos);
if ((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES))
{
return getNextOpPos(opPos);
}
else if ((stepType >= OpCodes.FIRST_NODESET_OP)
&& (stepType <= OpCodes.LAST_NODESET_OP))
{
int newOpPos = getNextOpPos(opPos);
while (OpCodes.OP_PREDICATE == getOp(newOpPos))
{
newOpPos = getNextOpPos(newOpPos);
}
stepType = getOp(newOpPos);
if (!((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES)))
{
return OpCodes.ENDOP;
}
return newOpPos;
}
else
{
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_UNKNOWN_STEP, new Object[]{String.valueOf(stepType)}));
//"Programmer's assertion in getNextStepPos: unknown stepType: " + stepType);
}
} | [
"public",
"int",
"getNextStepPos",
"(",
"int",
"opPos",
")",
"{",
"int",
"stepType",
"=",
"getOp",
"(",
"opPos",
")",
";",
"if",
"(",
"(",
"stepType",
">=",
"OpCodes",
".",
"AXES_START_TYPES",
")",
"&&",
"(",
"stepType",
"<=",
"OpCodes",
".",
"AXES_END_T... | Given a location step position, return the end position, i.e. the
beginning of the next step.
@param opPos the position of a location step.
@return the position of the next location step. | [
"Given",
"a",
"location",
"step",
"position",
"return",
"the",
"end",
"position",
"i",
".",
"e",
".",
"the",
"beginning",
"of",
"the",
"next",
"step",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/OpMap.java#L210-L246 |
34,682 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/OpMap.java | OpMap.getStepNS | public String getStepNS(int opPosOfStep)
{
int argLenOfStep = getArgLengthOfStep(opPosOfStep);
// System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
if (argLenOfStep == 3)
{
int index = m_opMap.elementAt(opPosOfStep + 4);
if (index >= 0)
return (String) m_tokenQueue.elementAt(index);
else if (OpCodes.ELEMWILDCARD == index)
return NodeTest.WILD;
else
return null;
}
else
return null;
} | java | public String getStepNS(int opPosOfStep)
{
int argLenOfStep = getArgLengthOfStep(opPosOfStep);
// System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
if (argLenOfStep == 3)
{
int index = m_opMap.elementAt(opPosOfStep + 4);
if (index >= 0)
return (String) m_tokenQueue.elementAt(index);
else if (OpCodes.ELEMWILDCARD == index)
return NodeTest.WILD;
else
return null;
}
else
return null;
} | [
"public",
"String",
"getStepNS",
"(",
"int",
"opPosOfStep",
")",
"{",
"int",
"argLenOfStep",
"=",
"getArgLengthOfStep",
"(",
"opPosOfStep",
")",
";",
"// System.out.println(\"getStepNS.argLenOfStep: \"+argLenOfStep);",
"if",
"(",
"argLenOfStep",
"==",
"3",
")",
"{",
"... | Get the namespace of the step.
@param opPosOfStep The position of the FROM_XXX step.
@return The step's namespace, NodeTest.WILD, or null for null namespace. | [
"Get",
"the",
"namespace",
"of",
"the",
"step",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/compiler/OpMap.java#L391-L410 |
34,683 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/IPAddressName.java | IPAddressName.parseIPv4 | private void parseIPv4(String name) throws IOException {
// Parse name into byte-value address components
int slashNdx = name.indexOf('/');
if (slashNdx == -1) {
address = InetAddress.getByName(name).getAddress();
} else {
address = new byte[8];
// parse mask
byte[] mask = InetAddress.getByName
(name.substring(slashNdx+1)).getAddress();
// parse base address
byte[] host = InetAddress.getByName
(name.substring(0, slashNdx)).getAddress();
System.arraycopy(host, 0, address, 0, 4);
System.arraycopy(mask, 0, address, 4, 4);
}
} | java | private void parseIPv4(String name) throws IOException {
// Parse name into byte-value address components
int slashNdx = name.indexOf('/');
if (slashNdx == -1) {
address = InetAddress.getByName(name).getAddress();
} else {
address = new byte[8];
// parse mask
byte[] mask = InetAddress.getByName
(name.substring(slashNdx+1)).getAddress();
// parse base address
byte[] host = InetAddress.getByName
(name.substring(0, slashNdx)).getAddress();
System.arraycopy(host, 0, address, 0, 4);
System.arraycopy(mask, 0, address, 4, 4);
}
} | [
"private",
"void",
"parseIPv4",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"// Parse name into byte-value address components",
"int",
"slashNdx",
"=",
"name",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"slashNdx",
"==",
"-",
"1",
")",
... | Parse an IPv4 address.
@param name IPv4 address with optional mask values
@throws IOException on error | [
"Parse",
"an",
"IPv4",
"address",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/IPAddressName.java#L156-L176 |
34,684 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java | ObjectStreamField.compareTo | public int compareTo(Object o) {
ObjectStreamField f = (ObjectStreamField) o;
boolean thisPrimitive = this.isPrimitive();
boolean fPrimitive = f.isPrimitive();
// If one is primitive and the other isn't, we have enough info to
// compare
if (thisPrimitive != fPrimitive) {
return thisPrimitive ? -1 : 1;
}
// Either both primitives or both not primitives. Compare based on name.
return this.getName().compareTo(f.getName());
} | java | public int compareTo(Object o) {
ObjectStreamField f = (ObjectStreamField) o;
boolean thisPrimitive = this.isPrimitive();
boolean fPrimitive = f.isPrimitive();
// If one is primitive and the other isn't, we have enough info to
// compare
if (thisPrimitive != fPrimitive) {
return thisPrimitive ? -1 : 1;
}
// Either both primitives or both not primitives. Compare based on name.
return this.getName().compareTo(f.getName());
} | [
"public",
"int",
"compareTo",
"(",
"Object",
"o",
")",
"{",
"ObjectStreamField",
"f",
"=",
"(",
"ObjectStreamField",
")",
"o",
";",
"boolean",
"thisPrimitive",
"=",
"this",
".",
"isPrimitive",
"(",
")",
";",
"boolean",
"fPrimitive",
"=",
"f",
".",
"isPrimi... | Compares this field descriptor to the specified one. Checks first if one
of the compared fields has a primitive type and the other one not. If so,
the field with the primitive type is considered to be "smaller". If both
fields are equal, their names are compared.
@param o
the object to compare with.
@return -1 if this field is "smaller" than field {@code o}, 0 if both
fields are equal; 1 if this field is "greater" than field {@code
o}. | [
"Compares",
"this",
"field",
"descriptor",
"to",
"the",
"specified",
"one",
".",
"Checks",
"first",
"if",
"one",
"of",
"the",
"compared",
"fields",
"has",
"a",
"primitive",
"type",
"and",
"the",
"other",
"one",
"not",
".",
"If",
"so",
"the",
"field",
"wi... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java#L121-L134 |
34,685 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java | ObjectStreamField.getType | public Class<?> getType() {
Class<?> cl = getTypeInternal();
if (isDeserialized && !cl.isPrimitive()) {
return Object.class;
}
return cl;
} | java | public Class<?> getType() {
Class<?> cl = getTypeInternal();
if (isDeserialized && !cl.isPrimitive()) {
return Object.class;
}
return cl;
} | [
"public",
"Class",
"<",
"?",
">",
"getType",
"(",
")",
"{",
"Class",
"<",
"?",
">",
"cl",
"=",
"getTypeInternal",
"(",
")",
";",
"if",
"(",
"isDeserialized",
"&&",
"!",
"cl",
".",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"Object",
".",
"class",... | Gets the type of this field.
@return a {@code Class} object representing the type of the field. | [
"Gets",
"the",
"type",
"of",
"this",
"field",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java#L173-L179 |
34,686 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java | ObjectStreamField.getTypeString | public String getTypeString() {
if (isPrimitive()) {
return null;
}
if (typeString == null) {
Class<?> t = getTypeInternal();
String typeName = t.getName().replace('.', '/');
String str = (t.isArray()) ? typeName : ("L" + typeName + ';');
typeString = str.intern();
}
return typeString;
} | java | public String getTypeString() {
if (isPrimitive()) {
return null;
}
if (typeString == null) {
Class<?> t = getTypeInternal();
String typeName = t.getName().replace('.', '/');
String str = (t.isArray()) ? typeName : ("L" + typeName + ';');
typeString = str.intern();
}
return typeString;
} | [
"public",
"String",
"getTypeString",
"(",
")",
"{",
"if",
"(",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"typeString",
"==",
"null",
")",
"{",
"Class",
"<",
"?",
">",
"t",
"=",
"getTypeInternal",
"(",
")",
";",
"Stri... | Gets the type signature used by the VM to represent the type of this
field.
@return the signature of this field's class or {@code null} if this
field's type is primitive. | [
"Gets",
"the",
"type",
"signature",
"used",
"by",
"the",
"VM",
"to",
"represent",
"the",
"type",
"of",
"this",
"field",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java#L235-L246 |
34,687 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java | ObjectStreamField.defaultResolve | private boolean defaultResolve() {
switch (typeString.charAt(0)) {
case 'I':
type = int.class;
return true;
case 'B':
type = byte.class;
return true;
case 'C':
type = char.class;
return true;
case 'S':
type = short.class;
return true;
case 'Z':
type = boolean.class;
return true;
case 'J':
type = long.class;
return true;
case 'F':
type = float.class;
return true;
case 'D':
type = double.class;
return true;
default:
type = Object.class;
return false;
}
} | java | private boolean defaultResolve() {
switch (typeString.charAt(0)) {
case 'I':
type = int.class;
return true;
case 'B':
type = byte.class;
return true;
case 'C':
type = char.class;
return true;
case 'S':
type = short.class;
return true;
case 'Z':
type = boolean.class;
return true;
case 'J':
type = long.class;
return true;
case 'F':
type = float.class;
return true;
case 'D':
type = double.class;
return true;
default:
type = Object.class;
return false;
}
} | [
"private",
"boolean",
"defaultResolve",
"(",
")",
"{",
"switch",
"(",
"typeString",
".",
"charAt",
"(",
"0",
")",
")",
"{",
"case",
"'",
"'",
":",
"type",
"=",
"int",
".",
"class",
";",
"return",
"true",
";",
"case",
"'",
"'",
":",
"type",
"=",
"... | Resolves typeString into type. Returns true if the type is primitive
and false otherwise. | [
"Resolves",
"typeString",
"into",
"type",
".",
"Returns",
"true",
"if",
"the",
"type",
"is",
"primitive",
"and",
"false",
"otherwise",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectStreamField.java#L329-L359 |
34,688 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/translate/AbstractMethodRewriter.java | AbstractMethodRewriter.addReturnTypeNarrowingDeclarations | private void addReturnTypeNarrowingDeclarations(AbstractTypeDeclaration node) {
TypeElement type = node.getTypeElement();
// No need to run this if the entire class is dead.
if (deadCodeMap != null && deadCodeMap.containsClass(type, elementUtil)) {
return;
}
Map<String, ExecutablePair> newDeclarations = new HashMap<>();
Map<String, TypeMirror> resolvedReturnTypes = new HashMap<>();
for (DeclaredType inheritedType : typeUtil.getObjcOrderedInheritedTypes(type.asType())) {
TypeElement inheritedElem = (TypeElement) inheritedType.asElement();
for (ExecutableElement methodElem : ElementUtil.getMethods(inheritedElem)) {
if (ElementUtil.isPrivate(methodElem)) {
continue;
}
TypeMirror declaredReturnType = typeUtil.erasure(methodElem.getReturnType());
if (!TypeUtil.isReferenceType(declaredReturnType)) {
continue; // Short circuit
}
String selector = nameTable.getMethodSelector(methodElem);
ExecutableType methodType = typeUtil.asMemberOf(inheritedType, methodElem);
TypeMirror returnType = typeUtil.erasure(methodType.getReturnType());
TypeMirror resolvedReturnType = resolvedReturnTypes.get(selector);
if (resolvedReturnType == null) {
resolvedReturnType = declaredReturnType;
resolvedReturnTypes.put(selector, resolvedReturnType);
} else if (!typeUtil.isSubtype(returnType, resolvedReturnType)) {
continue;
}
if (resolvedReturnType != returnType
&& !nameTable.getObjCType(resolvedReturnType).equals(
nameTable.getObjCType(returnType))) {
newDeclarations.put(selector, new ExecutablePair(methodElem, methodType));
resolvedReturnTypes.put(selector, returnType);
}
}
}
for (Map.Entry<String, ExecutablePair> newDecl : newDeclarations.entrySet()) {
if (deadCodeMap != null
&& deadCodeMap.containsMethod(newDecl.getValue().element(), typeUtil)) {
continue;
}
node.addBodyDeclaration(newReturnTypeNarrowingDeclaration(
newDecl.getKey(), newDecl.getValue(), type));
}
} | java | private void addReturnTypeNarrowingDeclarations(AbstractTypeDeclaration node) {
TypeElement type = node.getTypeElement();
// No need to run this if the entire class is dead.
if (deadCodeMap != null && deadCodeMap.containsClass(type, elementUtil)) {
return;
}
Map<String, ExecutablePair> newDeclarations = new HashMap<>();
Map<String, TypeMirror> resolvedReturnTypes = new HashMap<>();
for (DeclaredType inheritedType : typeUtil.getObjcOrderedInheritedTypes(type.asType())) {
TypeElement inheritedElem = (TypeElement) inheritedType.asElement();
for (ExecutableElement methodElem : ElementUtil.getMethods(inheritedElem)) {
if (ElementUtil.isPrivate(methodElem)) {
continue;
}
TypeMirror declaredReturnType = typeUtil.erasure(methodElem.getReturnType());
if (!TypeUtil.isReferenceType(declaredReturnType)) {
continue; // Short circuit
}
String selector = nameTable.getMethodSelector(methodElem);
ExecutableType methodType = typeUtil.asMemberOf(inheritedType, methodElem);
TypeMirror returnType = typeUtil.erasure(methodType.getReturnType());
TypeMirror resolvedReturnType = resolvedReturnTypes.get(selector);
if (resolvedReturnType == null) {
resolvedReturnType = declaredReturnType;
resolvedReturnTypes.put(selector, resolvedReturnType);
} else if (!typeUtil.isSubtype(returnType, resolvedReturnType)) {
continue;
}
if (resolvedReturnType != returnType
&& !nameTable.getObjCType(resolvedReturnType).equals(
nameTable.getObjCType(returnType))) {
newDeclarations.put(selector, new ExecutablePair(methodElem, methodType));
resolvedReturnTypes.put(selector, returnType);
}
}
}
for (Map.Entry<String, ExecutablePair> newDecl : newDeclarations.entrySet()) {
if (deadCodeMap != null
&& deadCodeMap.containsMethod(newDecl.getValue().element(), typeUtil)) {
continue;
}
node.addBodyDeclaration(newReturnTypeNarrowingDeclaration(
newDecl.getKey(), newDecl.getValue(), type));
}
} | [
"private",
"void",
"addReturnTypeNarrowingDeclarations",
"(",
"AbstractTypeDeclaration",
"node",
")",
"{",
"TypeElement",
"type",
"=",
"node",
".",
"getTypeElement",
"(",
")",
";",
"// No need to run this if the entire class is dead.",
"if",
"(",
"deadCodeMap",
"!=",
"nul... | specific than what is already declared in inherited types. | [
"specific",
"than",
"what",
"is",
"already",
"declared",
"in",
"inherited",
"types",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/translate/AbstractMethodRewriter.java#L118-L165 |
34,689 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/ReferencePipeline.java | ReferencePipeline.unordered | @Override
public Stream<P_OUT> unordered() {
if (!isOrdered())
return this;
return new StatelessOp<P_OUT, P_OUT>(this, StreamShape.REFERENCE, StreamOpFlag.NOT_ORDERED) {
@Override
public Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
return sink;
}
};
} | java | @Override
public Stream<P_OUT> unordered() {
if (!isOrdered())
return this;
return new StatelessOp<P_OUT, P_OUT>(this, StreamShape.REFERENCE, StreamOpFlag.NOT_ORDERED) {
@Override
public Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
return sink;
}
};
} | [
"@",
"Override",
"public",
"Stream",
"<",
"P_OUT",
">",
"unordered",
"(",
")",
"{",
"if",
"(",
"!",
"isOrdered",
"(",
")",
")",
"return",
"this",
";",
"return",
"new",
"StatelessOp",
"<",
"P_OUT",
",",
"P_OUT",
">",
"(",
"this",
",",
"StreamShape",
"... | Stateless intermediate operations from Stream | [
"Stateless",
"intermediate",
"operations",
"from",
"Stream"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/ReferencePipeline.java#L148-L158 |
34,690 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/ReferencePipeline.java | ReferencePipeline.forEach | @Override
public void forEach(Consumer<? super P_OUT> action) {
evaluate(ForEachOps.makeRef(action, false));
} | java | @Override
public void forEach(Consumer<? super P_OUT> action) {
evaluate(ForEachOps.makeRef(action, false));
} | [
"@",
"Override",
"public",
"void",
"forEach",
"(",
"Consumer",
"<",
"?",
"super",
"P_OUT",
">",
"action",
")",
"{",
"evaluate",
"(",
"ForEachOps",
".",
"makeRef",
"(",
"action",
",",
"false",
")",
")",
";",
"}"
] | Terminal operations from Stream | [
"Terminal",
"operations",
"from",
"Stream"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/stream/ReferencePipeline.java#L417-L420 |
34,691 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java | VariableStack.clearLocalSlots | public void clearLocalSlots(int start, int len)
{
start += _currentFrameBottom;
System.arraycopy(m_nulls, 0, _stackFrames, start, len);
} | java | public void clearLocalSlots(int start, int len)
{
start += _currentFrameBottom;
System.arraycopy(m_nulls, 0, _stackFrames, start, len);
} | [
"public",
"void",
"clearLocalSlots",
"(",
"int",
"start",
",",
"int",
"len",
")",
"{",
"start",
"+=",
"_currentFrameBottom",
";",
"System",
".",
"arraycopy",
"(",
"m_nulls",
",",
"0",
",",
"_stackFrames",
",",
"start",
",",
"len",
")",
";",
"}"
] | Use this to clear the variables in a section of the stack. This is
used to clear the parameter section of the stack, so that default param
values can tell if they've already been set. It is important to note that
this function has a 1K limitation.
@param start The start position, relative to the current local stack frame.
@param len The number of slots to be cleared. | [
"Use",
"this",
"to",
"clear",
"the",
"variables",
"in",
"a",
"section",
"of",
"the",
"stack",
".",
"This",
"is",
"used",
"to",
"clear",
"the",
"parameter",
"section",
"of",
"the",
"stack",
"so",
"that",
"default",
"param",
"values",
"can",
"tell",
"if",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java#L408-L414 |
34,692 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java | VariableStack.getGlobalVariable | public XObject getGlobalVariable(XPathContext xctxt, final int index)
throws TransformerException
{
XObject val = _stackFrames[index];
// Lazy execution of variables.
if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
return (_stackFrames[index] = val.execute(xctxt));
return val;
} | java | public XObject getGlobalVariable(XPathContext xctxt, final int index)
throws TransformerException
{
XObject val = _stackFrames[index];
// Lazy execution of variables.
if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
return (_stackFrames[index] = val.execute(xctxt));
return val;
} | [
"public",
"XObject",
"getGlobalVariable",
"(",
"XPathContext",
"xctxt",
",",
"final",
"int",
"index",
")",
"throws",
"TransformerException",
"{",
"XObject",
"val",
"=",
"_stackFrames",
"[",
"index",
"]",
";",
"// Lazy execution of variables.",
"if",
"(",
"val",
".... | Get a global variable or parameter from the global stack frame.
@param xctxt The XPath context, which must be passed in order to
lazy evaluate variables.
@param index Global variable index relative to the global stack
frame bottom.
@return The value of the variable.
@throws TransformerException | [
"Get",
"a",
"global",
"variable",
"or",
"parameter",
"from",
"the",
"global",
"stack",
"frame",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java#L444-L455 |
34,693 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java | VariableStack.getVariableOrParam | public XObject getVariableOrParam(
XPathContext xctxt, org.apache.xml.utils.QName qname)
throws javax.xml.transform.TransformerException
{
org.apache.xml.utils.PrefixResolver prefixResolver =
xctxt.getNamespaceContext();
// Get the current ElemTemplateElement, which must be pushed in as the
// prefix resolver, and then walk backwards in document order, searching
// for an xsl:param element or xsl:variable element that matches our
// qname. If we reach the top level, use the StylesheetRoot's composed
// list of top level variables and parameters.
if (prefixResolver instanceof org.apache.xalan.templates.ElemTemplateElement)
{
org.apache.xalan.templates.ElemVariable vvar;
org.apache.xalan.templates.ElemTemplateElement prev =
(org.apache.xalan.templates.ElemTemplateElement) prefixResolver;
if (!(prev instanceof org.apache.xalan.templates.Stylesheet))
{
while ( !(prev.getParentNode() instanceof org.apache.xalan.templates.Stylesheet) )
{
org.apache.xalan.templates.ElemTemplateElement savedprev = prev;
while (null != (prev = prev.getPreviousSiblingElem()))
{
if (prev instanceof org.apache.xalan.templates.ElemVariable)
{
vvar = (org.apache.xalan.templates.ElemVariable) prev;
if (vvar.getName().equals(qname))
return getLocalVariable(xctxt, vvar.getIndex());
}
}
prev = savedprev.getParentElem();
}
}
vvar = prev.getStylesheetRoot().getVariableOrParamComposed(qname);
if (null != vvar)
return getGlobalVariable(xctxt, vvar.getIndex());
}
throw new javax.xml.transform.TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VAR_NOT_RESOLVABLE, new Object[]{qname.toString()})); //"Variable not resolvable: " + qname);
} | java | public XObject getVariableOrParam(
XPathContext xctxt, org.apache.xml.utils.QName qname)
throws javax.xml.transform.TransformerException
{
org.apache.xml.utils.PrefixResolver prefixResolver =
xctxt.getNamespaceContext();
// Get the current ElemTemplateElement, which must be pushed in as the
// prefix resolver, and then walk backwards in document order, searching
// for an xsl:param element or xsl:variable element that matches our
// qname. If we reach the top level, use the StylesheetRoot's composed
// list of top level variables and parameters.
if (prefixResolver instanceof org.apache.xalan.templates.ElemTemplateElement)
{
org.apache.xalan.templates.ElemVariable vvar;
org.apache.xalan.templates.ElemTemplateElement prev =
(org.apache.xalan.templates.ElemTemplateElement) prefixResolver;
if (!(prev instanceof org.apache.xalan.templates.Stylesheet))
{
while ( !(prev.getParentNode() instanceof org.apache.xalan.templates.Stylesheet) )
{
org.apache.xalan.templates.ElemTemplateElement savedprev = prev;
while (null != (prev = prev.getPreviousSiblingElem()))
{
if (prev instanceof org.apache.xalan.templates.ElemVariable)
{
vvar = (org.apache.xalan.templates.ElemVariable) prev;
if (vvar.getName().equals(qname))
return getLocalVariable(xctxt, vvar.getIndex());
}
}
prev = savedprev.getParentElem();
}
}
vvar = prev.getStylesheetRoot().getVariableOrParamComposed(qname);
if (null != vvar)
return getGlobalVariable(xctxt, vvar.getIndex());
}
throw new javax.xml.transform.TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VAR_NOT_RESOLVABLE, new Object[]{qname.toString()})); //"Variable not resolvable: " + qname);
} | [
"public",
"XObject",
"getVariableOrParam",
"(",
"XPathContext",
"xctxt",
",",
"org",
".",
"apache",
".",
"xml",
".",
"utils",
".",
"QName",
"qname",
")",
"throws",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerException",
"{",
"org",
".",
"apache",... | Get a variable based on it's qualified name.
This is for external use only.
@param xctxt The XPath context, which must be passed in order to
lazy evaluate variables.
@param qname The qualified name of the variable.
@return The evaluated value of the variable.
@throws javax.xml.transform.TransformerException | [
"Get",
"a",
"variable",
"based",
"on",
"it",
"s",
"qualified",
"name",
".",
"This",
"is",
"for",
"external",
"use",
"only",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java#L497-L545 |
34,694 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/GenderInfo.java | GenderInfo.getListGender | @Deprecated
public Gender getListGender(List<Gender> genders) {
if (genders.size() == 0) {
return Gender.OTHER; // degenerate case
}
if (genders.size() == 1) {
return genders.get(0); // degenerate case
}
switch(style) {
case NEUTRAL:
return Gender.OTHER;
case MIXED_NEUTRAL:
boolean hasFemale = false;
boolean hasMale = false;
for (Gender gender : genders) {
switch (gender) {
case FEMALE:
if (hasMale) {
return Gender.OTHER;
}
hasFemale = true;
break;
case MALE:
if (hasFemale) {
return Gender.OTHER;
}
hasMale = true;
break;
case OTHER:
return Gender.OTHER;
}
}
return hasMale ? Gender.MALE : Gender.FEMALE;
// Note: any OTHER would have caused a return in the loop, which always happens.
case MALE_TAINTS:
for (Gender gender : genders) {
if (gender != Gender.FEMALE) {
return Gender.MALE;
}
}
return Gender.FEMALE;
default:
return Gender.OTHER;
}
} | java | @Deprecated
public Gender getListGender(List<Gender> genders) {
if (genders.size() == 0) {
return Gender.OTHER; // degenerate case
}
if (genders.size() == 1) {
return genders.get(0); // degenerate case
}
switch(style) {
case NEUTRAL:
return Gender.OTHER;
case MIXED_NEUTRAL:
boolean hasFemale = false;
boolean hasMale = false;
for (Gender gender : genders) {
switch (gender) {
case FEMALE:
if (hasMale) {
return Gender.OTHER;
}
hasFemale = true;
break;
case MALE:
if (hasFemale) {
return Gender.OTHER;
}
hasMale = true;
break;
case OTHER:
return Gender.OTHER;
}
}
return hasMale ? Gender.MALE : Gender.FEMALE;
// Note: any OTHER would have caused a return in the loop, which always happens.
case MALE_TAINTS:
for (Gender gender : genders) {
if (gender != Gender.FEMALE) {
return Gender.MALE;
}
}
return Gender.FEMALE;
default:
return Gender.OTHER;
}
} | [
"@",
"Deprecated",
"public",
"Gender",
"getListGender",
"(",
"List",
"<",
"Gender",
">",
"genders",
")",
"{",
"if",
"(",
"genders",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"Gender",
".",
"OTHER",
";",
"// degenerate case",
"}",
"if",
"(",... | Get the gender of a list, based on locale usage.
@param genders a list of genders.
@return the gender of the list.
@deprecated This API is ICU internal only.
@hide draft / provisional / internal are hidden on Android | [
"Get",
"the",
"gender",
"of",
"a",
"list",
"based",
"on",
"locale",
"usage",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/GenderInfo.java#L166-L210 |
34,695 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/GeneralName.java | GeneralName.encode | public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
name.encode(tmp);
int nameType = name.getType();
if (nameType == GeneralNameInterface.NAME_ANY ||
nameType == GeneralNameInterface.NAME_X400 ||
nameType == GeneralNameInterface.NAME_EDI) {
// implicit, constructed form
out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte)nameType), tmp);
} else if (nameType == GeneralNameInterface.NAME_DIRECTORY) {
// explicit, constructed form since underlying tag is CHOICE
// (see X.680 section 30.6, part c)
out.write(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte)nameType), tmp);
} else {
// implicit, primitive form
out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
false, (byte)nameType), tmp);
}
} | java | public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
name.encode(tmp);
int nameType = name.getType();
if (nameType == GeneralNameInterface.NAME_ANY ||
nameType == GeneralNameInterface.NAME_X400 ||
nameType == GeneralNameInterface.NAME_EDI) {
// implicit, constructed form
out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte)nameType), tmp);
} else if (nameType == GeneralNameInterface.NAME_DIRECTORY) {
// explicit, constructed form since underlying tag is CHOICE
// (see X.680 section 30.6, part c)
out.write(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte)nameType), tmp);
} else {
// implicit, primitive form
out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
false, (byte)nameType), tmp);
}
} | [
"public",
"void",
"encode",
"(",
"DerOutputStream",
"out",
")",
"throws",
"IOException",
"{",
"DerOutputStream",
"tmp",
"=",
"new",
"DerOutputStream",
"(",
")",
";",
"name",
".",
"encode",
"(",
"tmp",
")",
";",
"int",
"nameType",
"=",
"name",
".",
"getType... | Encode the name to the specified DerOutputStream.
@param out the DerOutputStream to encode the the GeneralName to.
@exception IOException on encoding errors. | [
"Encode",
"the",
"name",
"to",
"the",
"specified",
"DerOutputStream",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/GeneralName.java#L227-L248 |
34,696 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java | ChineseCalendar.handleGetExtendedYear | protected int handleGetExtendedYear() {
int year;
if (newestStamp(ERA, YEAR, UNSET) <= getStamp(EXTENDED_YEAR)) {
year = internalGet(EXTENDED_YEAR, 1); // Default to year 1
} else {
int cycle = internalGet(ERA, 1) - 1; // 0-based cycle
// adjust to the instance specific epoch
year = cycle * 60 + internalGet(YEAR, 1) - (epochYear - CHINESE_EPOCH_YEAR);
}
return year;
} | java | protected int handleGetExtendedYear() {
int year;
if (newestStamp(ERA, YEAR, UNSET) <= getStamp(EXTENDED_YEAR)) {
year = internalGet(EXTENDED_YEAR, 1); // Default to year 1
} else {
int cycle = internalGet(ERA, 1) - 1; // 0-based cycle
// adjust to the instance specific epoch
year = cycle * 60 + internalGet(YEAR, 1) - (epochYear - CHINESE_EPOCH_YEAR);
}
return year;
} | [
"protected",
"int",
"handleGetExtendedYear",
"(",
")",
"{",
"int",
"year",
";",
"if",
"(",
"newestStamp",
"(",
"ERA",
",",
"YEAR",
",",
"UNSET",
")",
"<=",
"getStamp",
"(",
"EXTENDED_YEAR",
")",
")",
"{",
"year",
"=",
"internalGet",
"(",
"EXTENDED_YEAR",
... | Implement abstract Calendar method to return the extended year
defined by the current fields. This will use either the ERA and
YEAR field as the cycle and year-of-cycle, or the EXTENDED_YEAR
field as the continuous year count, depending on which is newer. | [
"Implement",
"abstract",
"Calendar",
"method",
"to",
"return",
"the",
"extended",
"year",
"defined",
"by",
"the",
"current",
"fields",
".",
"This",
"will",
"use",
"either",
"the",
"ERA",
"and",
"YEAR",
"field",
"as",
"the",
"cycle",
"and",
"year",
"-",
"of... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java#L432-L442 |
34,697 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java | ChineseCalendar.handleGetMonthLength | protected int handleGetMonthLength(int extendedYear, int month) {
int thisStart = handleComputeMonthStart(extendedYear, month, true) -
EPOCH_JULIAN_DAY + 1; // Julian day -> local days
int nextStart = newMoonNear(thisStart + SYNODIC_GAP, true);
return nextStart - thisStart;
} | java | protected int handleGetMonthLength(int extendedYear, int month) {
int thisStart = handleComputeMonthStart(extendedYear, month, true) -
EPOCH_JULIAN_DAY + 1; // Julian day -> local days
int nextStart = newMoonNear(thisStart + SYNODIC_GAP, true);
return nextStart - thisStart;
} | [
"protected",
"int",
"handleGetMonthLength",
"(",
"int",
"extendedYear",
",",
"int",
"month",
")",
"{",
"int",
"thisStart",
"=",
"handleComputeMonthStart",
"(",
"extendedYear",
",",
"month",
",",
"true",
")",
"-",
"EPOCH_JULIAN_DAY",
"+",
"1",
";",
"// Julian day... | Override Calendar method to return the number of days in the given
extended year and month.
<p>Note: This method also reads the IS_LEAP_MONTH field to determine
whether or not the given month is a leap month. | [
"Override",
"Calendar",
"method",
"to",
"return",
"the",
"number",
"of",
"days",
"in",
"the",
"given",
"extended",
"year",
"and",
"month",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java#L451-L456 |
34,698 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java | ChineseCalendar.newMoonNear | private int newMoonNear(int days, boolean after) {
astro.setTime(daysToMillis(days));
long newMoon = astro.getMoonTime(CalendarAstronomer.NEW_MOON, after);
return millisToDays(newMoon);
} | java | private int newMoonNear(int days, boolean after) {
astro.setTime(daysToMillis(days));
long newMoon = astro.getMoonTime(CalendarAstronomer.NEW_MOON, after);
return millisToDays(newMoon);
} | [
"private",
"int",
"newMoonNear",
"(",
"int",
"days",
",",
"boolean",
"after",
")",
"{",
"astro",
".",
"setTime",
"(",
"daysToMillis",
"(",
"days",
")",
")",
";",
"long",
"newMoon",
"=",
"astro",
".",
"getMoonTime",
"(",
"CalendarAstronomer",
".",
"NEW_MOON... | Return the closest new moon to the given date, searching either
forward or backward in time.
@param days days after January 1, 1970 0:00 Asia/Shanghai
@param after if true, search for a new moon on or after the given
date; otherwise, search for a new moon before it
@return days after January 1, 1970 0:00 Asia/Shanghai of the nearest
new moon after or before <code>days</code> | [
"Return",
"the",
"closest",
"new",
"moon",
"to",
"the",
"given",
"date",
"searching",
"either",
"forward",
"or",
"backward",
"in",
"time",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java#L712-L718 |
34,699 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java | ChineseCalendar.majorSolarTerm | private int majorSolarTerm(int days) {
astro.setTime(daysToMillis(days));
// Compute (floor(solarLongitude / (pi/6)) + 2) % 12
int term = ((int) Math.floor(6 * astro.getSunLongitude() / Math.PI) + 2) % 12;
if (term < 1) {
term += 12;
}
return term;
} | java | private int majorSolarTerm(int days) {
astro.setTime(daysToMillis(days));
// Compute (floor(solarLongitude / (pi/6)) + 2) % 12
int term = ((int) Math.floor(6 * astro.getSunLongitude() / Math.PI) + 2) % 12;
if (term < 1) {
term += 12;
}
return term;
} | [
"private",
"int",
"majorSolarTerm",
"(",
"int",
"days",
")",
"{",
"astro",
".",
"setTime",
"(",
"daysToMillis",
"(",
"days",
")",
")",
";",
"// Compute (floor(solarLongitude / (pi/6)) + 2) % 12",
"int",
"term",
"=",
"(",
"(",
"int",
")",
"Math",
".",
"floor",
... | Return the major solar term on or before a given date. This
will be an integer from 1..12, with 1 corresponding to 330 degrees,
2 to 0 degrees, 3 to 30 degrees,..., and 12 to 300 degrees.
@param days days after January 1, 1970 0:00 Asia/Shanghai | [
"Return",
"the",
"major",
"solar",
"term",
"on",
"or",
"before",
"a",
"given",
"date",
".",
"This",
"will",
"be",
"an",
"integer",
"from",
"1",
"..",
"12",
"with",
"1",
"corresponding",
"to",
"330",
"degrees",
"2",
"to",
"0",
"degrees",
"3",
"to",
"3... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ChineseCalendar.java#L737-L747 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.