id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33,100 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java | FuncExtFunction.getArg | public Expression getArg(int n) {
if (n >= 0 && n < m_argVec.size())
return (Expression) m_argVec.elementAt(n);
else
return null;
} | java | public Expression getArg(int n) {
if (n >= 0 && n < m_argVec.size())
return (Expression) m_argVec.elementAt(n);
else
return null;
} | [
"public",
"Expression",
"getArg",
"(",
"int",
"n",
")",
"{",
"if",
"(",
"n",
">=",
"0",
"&&",
"n",
"<",
"m_argVec",
".",
"size",
"(",
")",
")",
"return",
"(",
"Expression",
")",
"m_argVec",
".",
"elementAt",
"(",
"n",
")",
";",
"else",
"return",
... | Return the nth argument passed to the extension function.
@param n The argument number index.
@return The Expression object at the given index. | [
"Return",
"the",
"nth",
"argument",
"passed",
"to",
"the",
"extension",
"function",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java#L137-L142 |
33,101 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java | FuncExtFunction.callArgVisitors | public void callArgVisitors(XPathVisitor visitor)
{
for (int i = 0; i < m_argVec.size(); i++)
{
Expression exp = (Expression)m_argVec.elementAt(i);
exp.callVisitors(new ArgExtOwner(exp), visitor);
}
} | java | public void callArgVisitors(XPathVisitor visitor)
{
for (int i = 0; i < m_argVec.size(); i++)
{
Expression exp = (Expression)m_argVec.elementAt(i);
exp.callVisitors(new ArgExtOwner(exp), visitor);
}
} | [
"public",
"void",
"callArgVisitors",
"(",
"XPathVisitor",
"visitor",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m_argVec",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Expression",
"exp",
"=",
"(",
"Expression",
")",
"m_argVec",... | Call the visitors for the function arguments. | [
"Call",
"the",
"visitors",
"for",
"the",
"function",
"arguments",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java#L283-L291 |
33,102 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java | FuncExtFunction.exprSetParent | public void exprSetParent(ExpressionNode n)
{
super.exprSetParent(n);
int nArgs = m_argVec.size();
for (int i = 0; i < nArgs; i++)
{
Expression arg = (Expression) m_argVec.elementAt(i);
arg.exprSetParent(n);
}
} | java | public void exprSetParent(ExpressionNode n)
{
super.exprSetParent(n);
int nArgs = m_argVec.size();
for (int i = 0; i < nArgs; i++)
{
Expression arg = (Expression) m_argVec.elementAt(i);
arg.exprSetParent(n);
}
} | [
"public",
"void",
"exprSetParent",
"(",
"ExpressionNode",
"n",
")",
"{",
"super",
".",
"exprSetParent",
"(",
"n",
")",
";",
"int",
"nArgs",
"=",
"m_argVec",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nArgs",
";",
... | Set the parent node.
For an extension function, we also need to set the parent
node for all argument expressions.
@param n The parent node | [
"Set",
"the",
"parent",
"node",
".",
"For",
"an",
"extension",
"function",
"we",
"also",
"need",
"to",
"set",
"the",
"parent",
"node",
"for",
"all",
"argument",
"expressions",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java#L300-L313 |
33,103 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java | FuncExtFunction.reportWrongNumberArgs | protected void reportWrongNumberArgs() throws WrongNumberArgsException {
String fMsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
new Object[]{ "Programmer's assertion: the method FunctionMultiArgs.reportWrongNumberArgs() should never be called." });
throw new RuntimeException(fMsg);
} | java | protected void reportWrongNumberArgs() throws WrongNumberArgsException {
String fMsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
new Object[]{ "Programmer's assertion: the method FunctionMultiArgs.reportWrongNumberArgs() should never be called." });
throw new RuntimeException(fMsg);
} | [
"protected",
"void",
"reportWrongNumberArgs",
"(",
")",
"throws",
"WrongNumberArgsException",
"{",
"String",
"fMsg",
"=",
"XSLMessages",
".",
"createXPATHMessage",
"(",
"XPATHErrorResources",
".",
"ER_INCORRECT_PROGRAMMER_ASSERTION",
",",
"new",
"Object",
"[",
"]",
"{",... | Constructs and throws a WrongNumberArgException with the appropriate
message for this function object. This class supports an arbitrary
number of arguments, so this method must never be called.
@throws WrongNumberArgsException | [
"Constructs",
"and",
"throws",
"a",
"WrongNumberArgException",
"with",
"the",
"appropriate",
"message",
"for",
"this",
"function",
"object",
".",
"This",
"class",
"supports",
"an",
"arbitrary",
"number",
"of",
"arguments",
"so",
"this",
"method",
"must",
"never",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/functions/FuncExtFunction.java#L322-L328 |
33,104 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemTextLiteral.java | ElemTextLiteral.execute | public void execute(
TransformerImpl transformer)
throws TransformerException
{
try
{
SerializationHandler rth = transformer.getResultTreeHandler();
if (m_disableOutputEscaping)
{
rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
}
rth.characters(m_ch, 0, m_ch.length);
if (m_disableOutputEscaping)
{
rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
}
}
catch(SAXException se)
{
throw new TransformerException(se);
}
} | java | public void execute(
TransformerImpl transformer)
throws TransformerException
{
try
{
SerializationHandler rth = transformer.getResultTreeHandler();
if (m_disableOutputEscaping)
{
rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
}
rth.characters(m_ch, 0, m_ch.length);
if (m_disableOutputEscaping)
{
rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
}
}
catch(SAXException se)
{
throw new TransformerException(se);
}
} | [
"public",
"void",
"execute",
"(",
"TransformerImpl",
"transformer",
")",
"throws",
"TransformerException",
"{",
"try",
"{",
"SerializationHandler",
"rth",
"=",
"transformer",
".",
"getResultTreeHandler",
"(",
")",
";",
"if",
"(",
"m_disableOutputEscaping",
")",
"{",... | Copy the text literal to the result tree.
@param transformer non-null reference to the the current transform-time state.
@throws TransformerException | [
"Copy",
"the",
"text",
"literal",
"to",
"the",
"result",
"tree",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemTextLiteral.java#L200-L224 |
33,105 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.getRelativePath | public String getRelativePath() {
StringBuilder sb = new StringBuilder();
String pkg = typeRef.getPackageName().replace('.', '/');
if (pkg.length() > 0) {
sb.append(pkg);
sb.append('/');
}
appendDeclaringTypes(typeRef, '$', sb);
sb.append(typeRef.getSimpleName());
sb.append(".class");
return sb.toString();
} | java | public String getRelativePath() {
StringBuilder sb = new StringBuilder();
String pkg = typeRef.getPackageName().replace('.', '/');
if (pkg.length() > 0) {
sb.append(pkg);
sb.append('/');
}
appendDeclaringTypes(typeRef, '$', sb);
sb.append(typeRef.getSimpleName());
sb.append(".class");
return sb.toString();
} | [
"public",
"String",
"getRelativePath",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"pkg",
"=",
"typeRef",
".",
"getPackageName",
"(",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"if",
"... | Returns the relative classfile path. | [
"Returns",
"the",
"relative",
"classfile",
"path",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L115-L126 |
33,106 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.appendDeclaringTypes | private static void appendDeclaringTypes(TypeReference typeRef, char innerClassDelimiter,
StringBuilder sb) {
TypeReference declaringType = typeRef.getDeclaringType();
if (declaringType != null) {
appendDeclaringTypes(declaringType, innerClassDelimiter, sb);
sb.append(declaringType.getSimpleName());
sb.append(innerClassDelimiter);
}
} | java | private static void appendDeclaringTypes(TypeReference typeRef, char innerClassDelimiter,
StringBuilder sb) {
TypeReference declaringType = typeRef.getDeclaringType();
if (declaringType != null) {
appendDeclaringTypes(declaringType, innerClassDelimiter, sb);
sb.append(declaringType.getSimpleName());
sb.append(innerClassDelimiter);
}
} | [
"private",
"static",
"void",
"appendDeclaringTypes",
"(",
"TypeReference",
"typeRef",
",",
"char",
"innerClassDelimiter",
",",
"StringBuilder",
"sb",
")",
"{",
"TypeReference",
"declaringType",
"=",
"typeRef",
".",
"getDeclaringType",
"(",
")",
";",
"if",
"(",
"de... | Recurse depth-first so order of declaring types is correct. | [
"Recurse",
"depth",
"-",
"first",
"so",
"order",
"of",
"declaring",
"types",
"is",
"correct",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L129-L137 |
33,107 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.getFieldNode | public FieldDeclaration getFieldNode(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.FIELD) {
FieldDeclaration field = (FieldDeclaration) node;
if (field.getName().equals(name)
&& signature(field.getReturnType()).equals(signature)) {
return field;
}
}
}
return null;
} | java | public FieldDeclaration getFieldNode(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.FIELD) {
FieldDeclaration field = (FieldDeclaration) node;
if (field.getName().equals(name)
&& signature(field.getReturnType()).equals(signature)) {
return field;
}
}
}
return null;
} | [
"public",
"FieldDeclaration",
"getFieldNode",
"(",
"String",
"name",
",",
"String",
"signature",
")",
"{",
"for",
"(",
"EntityDeclaration",
"node",
":",
"type",
".",
"getMembers",
"(",
")",
")",
"{",
"if",
"(",
"node",
".",
"getEntityType",
"(",
")",
"==",... | Returns the Procyon field definition for a specified variable,
or null if not found. | [
"Returns",
"the",
"Procyon",
"field",
"definition",
"for",
"a",
"specified",
"variable",
"or",
"null",
"if",
"not",
"found",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L143-L154 |
33,108 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.getMethod | public MethodDeclaration getMethod(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.METHOD) {
MethodDeclaration method = (MethodDeclaration) node;
if (method.getName().equals(name) && signature.equals(signature(method))) {
return method;
}
}
}
return null;
} | java | public MethodDeclaration getMethod(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.METHOD) {
MethodDeclaration method = (MethodDeclaration) node;
if (method.getName().equals(name) && signature.equals(signature(method))) {
return method;
}
}
}
return null;
} | [
"public",
"MethodDeclaration",
"getMethod",
"(",
"String",
"name",
",",
"String",
"signature",
")",
"{",
"for",
"(",
"EntityDeclaration",
"node",
":",
"type",
".",
"getMembers",
"(",
")",
")",
"{",
"if",
"(",
"node",
".",
"getEntityType",
"(",
")",
"==",
... | Returns the Procyon method definition for a specified method,
or null if not found. | [
"Returns",
"the",
"Procyon",
"method",
"definition",
"for",
"a",
"specified",
"method",
"or",
"null",
"if",
"not",
"found",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L160-L170 |
33,109 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.getConstructor | public ConstructorDeclaration getConstructor(String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.CONSTRUCTOR) {
ConstructorDeclaration cons = (ConstructorDeclaration) node;
if (signature.equals(signature(cons))) {
return cons;
}
}
}
return null;
} | java | public ConstructorDeclaration getConstructor(String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.CONSTRUCTOR) {
ConstructorDeclaration cons = (ConstructorDeclaration) node;
if (signature.equals(signature(cons))) {
return cons;
}
}
}
return null;
} | [
"public",
"ConstructorDeclaration",
"getConstructor",
"(",
"String",
"signature",
")",
"{",
"for",
"(",
"EntityDeclaration",
"node",
":",
"type",
".",
"getMembers",
"(",
")",
")",
"{",
"if",
"(",
"node",
".",
"getEntityType",
"(",
")",
"==",
"EntityType",
".... | Returns the Procyon method definition for a specified constructor,
or null if not found. | [
"Returns",
"the",
"Procyon",
"method",
"definition",
"for",
"a",
"specified",
"constructor",
"or",
"null",
"if",
"not",
"found",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L176-L186 |
33,110 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/duration/BasicPeriodFormatterService.java | BasicPeriodFormatterService.getInstance | public static BasicPeriodFormatterService getInstance() {
if (instance == null) {
PeriodFormatterDataService ds = ResourceBasedPeriodFormatterDataService
.getInstance();
instance = new BasicPeriodFormatterService(ds);
}
return instance;
} | java | public static BasicPeriodFormatterService getInstance() {
if (instance == null) {
PeriodFormatterDataService ds = ResourceBasedPeriodFormatterDataService
.getInstance();
instance = new BasicPeriodFormatterService(ds);
}
return instance;
} | [
"public",
"static",
"BasicPeriodFormatterService",
"getInstance",
"(",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"PeriodFormatterDataService",
"ds",
"=",
"ResourceBasedPeriodFormatterDataService",
".",
"getInstance",
"(",
")",
";",
"instance",
"=",
"n... | Return the default service instance. This uses the default data service.
@return an BasicPeriodFormatterService | [
"Return",
"the",
"default",
"service",
"instance",
".",
"This",
"uses",
"the",
"default",
"data",
"service",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/duration/BasicPeriodFormatterService.java#L32-L39 |
33,111 | google/j2objc | jre_emul/android/frameworks/base/core/java/android/os/AsyncTask.java | AsyncTask.get | public final Result get(long timeout, TimeUnit unit) throws InterruptedException,
ExecutionException, TimeoutException {
return mFuture.get(timeout, unit);
} | java | public final Result get(long timeout, TimeUnit unit) throws InterruptedException,
ExecutionException, TimeoutException {
return mFuture.get(timeout, unit);
} | [
"public",
"final",
"Result",
"get",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"ExecutionException",
",",
"TimeoutException",
"{",
"return",
"mFuture",
".",
"get",
"(",
"timeout",
",",
"unit",
")",
";",
"}"
] | Waits if necessary for at most the given time for the computation
to complete, and then retrieves its result.
@param timeout Time to wait before cancelling the operation.
@param unit The time unit for the timeout.
@return The computed result.
@throws CancellationException If the computation was cancelled.
@throws ExecutionException If the computation threw an exception.
@throws InterruptedException If the current thread was interrupted
while waiting.
@throws TimeoutException If the wait timed out. | [
"Waits",
"if",
"necessary",
"for",
"at",
"most",
"the",
"given",
"time",
"for",
"the",
"computation",
"to",
"complete",
"and",
"then",
"retrieves",
"its",
"result",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/frameworks/base/core/java/android/os/AsyncTask.java#L495-L498 |
33,112 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/StringCharacterIterator.java | StringCharacterIterator.setText | @Deprecated
public void setText(String text) {
if (text == null) {
throw new NullPointerException();
}
this.text = text;
this.begin = 0;
this.end = text.length();
this.pos = 0;
} | java | @Deprecated
public void setText(String text) {
if (text == null) {
throw new NullPointerException();
}
this.text = text;
this.begin = 0;
this.end = text.length();
this.pos = 0;
} | [
"@",
"Deprecated",
"public",
"void",
"setText",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"this",
".",
"text",
"=",
"text",
";",
"this",
".",
"begin",
"=",
... | Reset this iterator to point to a new string. This package-visible
method is used by other java.text classes that want to avoid allocating
new StringCharacterIterator objects every time their setText method
is called.
@param text The String to be iterated over
@deprecated ICU 2.4. Use java.text.StringCharacterIterator instead. | [
"Reset",
"this",
"iterator",
"to",
"point",
"to",
"a",
"new",
"string",
".",
"This",
"package",
"-",
"visible",
"method",
"is",
"used",
"by",
"other",
"java",
".",
"text",
"classes",
"that",
"want",
"to",
"avoid",
"allocating",
"new",
"StringCharacterIterato... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/StringCharacterIterator.java#L105-L114 |
33,113 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.isBlockOrSF | public static boolean isBlockOrSF(String s) {
// we currently only support DSA and RSA PKCS7 blocks
if (s.endsWith(".SF") || s.endsWith(".DSA") ||
s.endsWith(".RSA") || s.endsWith(".EC")) {
return true;
}
return false;
} | java | public static boolean isBlockOrSF(String s) {
// we currently only support DSA and RSA PKCS7 blocks
if (s.endsWith(".SF") || s.endsWith(".DSA") ||
s.endsWith(".RSA") || s.endsWith(".EC")) {
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"isBlockOrSF",
"(",
"String",
"s",
")",
"{",
"// we currently only support DSA and RSA PKCS7 blocks",
"if",
"(",
"s",
".",
"endsWith",
"(",
"\".SF\"",
")",
"||",
"s",
".",
"endsWith",
"(",
"\".DSA\"",
")",
"||",
"s",
".",
"endsWi... | Utility method used by JarVerifier and JarSigner
to determine the signature file names and PKCS7 block
files names that are supported
@param s file name
@return true if the input file name is a supported
Signature File or PKCS7 block file name | [
"Utility",
"method",
"used",
"by",
"JarVerifier",
"and",
"JarSigner",
"to",
"determine",
"the",
"signature",
"file",
"names",
"and",
"PKCS7",
"block",
"files",
"names",
"that",
"are",
"supported"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L147-L154 |
33,114 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.getDigest | private MessageDigest getDigest(String algorithm)
{
if (createdDigests == null)
createdDigests = new HashMap<String, MessageDigest>();
MessageDigest digest = createdDigests.get(algorithm);
if (digest == null) {
try {
digest = MessageDigest.getInstance(algorithm);
createdDigests.put(algorithm, digest);
} catch (NoSuchAlgorithmException nsae) {
// ignore
}
}
return digest;
} | java | private MessageDigest getDigest(String algorithm)
{
if (createdDigests == null)
createdDigests = new HashMap<String, MessageDigest>();
MessageDigest digest = createdDigests.get(algorithm);
if (digest == null) {
try {
digest = MessageDigest.getInstance(algorithm);
createdDigests.put(algorithm, digest);
} catch (NoSuchAlgorithmException nsae) {
// ignore
}
}
return digest;
} | [
"private",
"MessageDigest",
"getDigest",
"(",
"String",
"algorithm",
")",
"{",
"if",
"(",
"createdDigests",
"==",
"null",
")",
"createdDigests",
"=",
"new",
"HashMap",
"<",
"String",
",",
"MessageDigest",
">",
"(",
")",
";",
"MessageDigest",
"digest",
"=",
"... | get digest from cache | [
"get",
"digest",
"from",
"cache"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L158-L174 |
33,115 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.process | public void process(Hashtable<String, CodeSigner[]> signers,
List manifestDigests)
throws IOException, SignatureException, NoSuchAlgorithmException,
JarException, CertificateException
{
// calls Signature.getInstance() and MessageDigest.getInstance()
// need to use local providers here, see Providers class
Object obj = null;
try {
obj = Providers.startJarVerification();
processImpl(signers, manifestDigests);
} finally {
Providers.stopJarVerification(obj);
}
} | java | public void process(Hashtable<String, CodeSigner[]> signers,
List manifestDigests)
throws IOException, SignatureException, NoSuchAlgorithmException,
JarException, CertificateException
{
// calls Signature.getInstance() and MessageDigest.getInstance()
// need to use local providers here, see Providers class
Object obj = null;
try {
obj = Providers.startJarVerification();
processImpl(signers, manifestDigests);
} finally {
Providers.stopJarVerification(obj);
}
} | [
"public",
"void",
"process",
"(",
"Hashtable",
"<",
"String",
",",
"CodeSigner",
"[",
"]",
">",
"signers",
",",
"List",
"manifestDigests",
")",
"throws",
"IOException",
",",
"SignatureException",
",",
"NoSuchAlgorithmException",
",",
"JarException",
",",
"Certific... | process the signature block file. Goes through the .SF file
and adds code signers for each section where the .SF section
hash was verified against the Manifest section. | [
"process",
"the",
"signature",
"block",
"file",
".",
"Goes",
"through",
"the",
".",
"SF",
"file",
"and",
"adds",
"code",
"signers",
"for",
"each",
"section",
"where",
"the",
".",
"SF",
"section",
"hash",
"was",
"verified",
"against",
"the",
"Manifest",
"se... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L183-L198 |
33,116 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.verifyManifestHash | private boolean verifyManifestHash(Manifest sf,
ManifestDigester md,
BASE64Decoder decoder,
List manifestDigests)
throws IOException
{
Attributes mattr = sf.getMainAttributes();
boolean manifestSigned = false;
// go through all the attributes and process *-Digest-Manifest entries
for (Map.Entry<Object,Object> se : mattr.entrySet()) {
String key = se.getKey().toString();
if (key.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST-MANIFEST")) {
// 16 is length of "-Digest-Manifest"
String algorithm = key.substring(0, key.length()-16);
manifestDigests.add(key);
manifestDigests.add(se.getValue());
MessageDigest digest = getDigest(algorithm);
if (digest != null) {
byte[] computedHash = md.manifestDigest(digest);
byte[] expectedHash =
decoder.decodeBuffer((String)se.getValue());
if (debug != null) {
debug.println("Signature File: Manifest digest " +
digest.getAlgorithm());
debug.println( " sigfile " + toHex(expectedHash));
debug.println( " computed " + toHex(computedHash));
debug.println();
}
if (MessageDigest.isEqual(computedHash,
expectedHash)) {
manifestSigned = true;
} else {
//XXX: we will continue and verify each section
}
}
}
}
return manifestSigned;
} | java | private boolean verifyManifestHash(Manifest sf,
ManifestDigester md,
BASE64Decoder decoder,
List manifestDigests)
throws IOException
{
Attributes mattr = sf.getMainAttributes();
boolean manifestSigned = false;
// go through all the attributes and process *-Digest-Manifest entries
for (Map.Entry<Object,Object> se : mattr.entrySet()) {
String key = se.getKey().toString();
if (key.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST-MANIFEST")) {
// 16 is length of "-Digest-Manifest"
String algorithm = key.substring(0, key.length()-16);
manifestDigests.add(key);
manifestDigests.add(se.getValue());
MessageDigest digest = getDigest(algorithm);
if (digest != null) {
byte[] computedHash = md.manifestDigest(digest);
byte[] expectedHash =
decoder.decodeBuffer((String)se.getValue());
if (debug != null) {
debug.println("Signature File: Manifest digest " +
digest.getAlgorithm());
debug.println( " sigfile " + toHex(expectedHash));
debug.println( " computed " + toHex(computedHash));
debug.println();
}
if (MessageDigest.isEqual(computedHash,
expectedHash)) {
manifestSigned = true;
} else {
//XXX: we will continue and verify each section
}
}
}
}
return manifestSigned;
} | [
"private",
"boolean",
"verifyManifestHash",
"(",
"Manifest",
"sf",
",",
"ManifestDigester",
"md",
",",
"BASE64Decoder",
"decoder",
",",
"List",
"manifestDigests",
")",
"throws",
"IOException",
"{",
"Attributes",
"mattr",
"=",
"sf",
".",
"getMainAttributes",
"(",
"... | See if the whole manifest was signed. | [
"See",
"if",
"the",
"whole",
"manifest",
"was",
"signed",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L277-L321 |
33,117 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.verifySection | private boolean verifySection(Attributes sfAttr,
String name,
ManifestDigester md,
BASE64Decoder decoder)
throws IOException
{
boolean oneDigestVerified = false;
ManifestDigester.Entry mde = md.get(name,block.isOldStyle());
if (mde == null) {
throw new SecurityException(
"no manifiest section for signature file entry "+name);
}
if (sfAttr != null) {
//sun.misc.HexDumpEncoder hex = new sun.misc.HexDumpEncoder();
//hex.encodeBuffer(data, System.out);
// go through all the attributes and process *-Digest entries
for (Map.Entry<Object,Object> se : sfAttr.entrySet()) {
String key = se.getKey().toString();
if (key.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST")) {
// 7 is length of "-Digest"
String algorithm = key.substring(0, key.length()-7);
MessageDigest digest = getDigest(algorithm);
if (digest != null) {
boolean ok = false;
byte[] expected =
decoder.decodeBuffer((String)se.getValue());
byte[] computed;
if (workaround) {
computed = mde.digestWorkaround(digest);
} else {
computed = mde.digest(digest);
}
if (debug != null) {
debug.println("Signature Block File: " +
name + " digest=" + digest.getAlgorithm());
debug.println(" expected " + toHex(expected));
debug.println(" computed " + toHex(computed));
debug.println();
}
if (MessageDigest.isEqual(computed, expected)) {
oneDigestVerified = true;
ok = true;
} else {
// attempt to fallback to the workaround
if (!workaround) {
computed = mde.digestWorkaround(digest);
if (MessageDigest.isEqual(computed, expected)) {
if (debug != null) {
debug.println(" re-computed " + toHex(computed));
debug.println();
}
workaround = true;
oneDigestVerified = true;
ok = true;
}
}
}
if (!ok){
throw new SecurityException("invalid " +
digest.getAlgorithm() +
" signature file digest for " + name);
}
}
}
}
}
return oneDigestVerified;
} | java | private boolean verifySection(Attributes sfAttr,
String name,
ManifestDigester md,
BASE64Decoder decoder)
throws IOException
{
boolean oneDigestVerified = false;
ManifestDigester.Entry mde = md.get(name,block.isOldStyle());
if (mde == null) {
throw new SecurityException(
"no manifiest section for signature file entry "+name);
}
if (sfAttr != null) {
//sun.misc.HexDumpEncoder hex = new sun.misc.HexDumpEncoder();
//hex.encodeBuffer(data, System.out);
// go through all the attributes and process *-Digest entries
for (Map.Entry<Object,Object> se : sfAttr.entrySet()) {
String key = se.getKey().toString();
if (key.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST")) {
// 7 is length of "-Digest"
String algorithm = key.substring(0, key.length()-7);
MessageDigest digest = getDigest(algorithm);
if (digest != null) {
boolean ok = false;
byte[] expected =
decoder.decodeBuffer((String)se.getValue());
byte[] computed;
if (workaround) {
computed = mde.digestWorkaround(digest);
} else {
computed = mde.digest(digest);
}
if (debug != null) {
debug.println("Signature Block File: " +
name + " digest=" + digest.getAlgorithm());
debug.println(" expected " + toHex(expected));
debug.println(" computed " + toHex(computed));
debug.println();
}
if (MessageDigest.isEqual(computed, expected)) {
oneDigestVerified = true;
ok = true;
} else {
// attempt to fallback to the workaround
if (!workaround) {
computed = mde.digestWorkaround(digest);
if (MessageDigest.isEqual(computed, expected)) {
if (debug != null) {
debug.println(" re-computed " + toHex(computed));
debug.println();
}
workaround = true;
oneDigestVerified = true;
ok = true;
}
}
}
if (!ok){
throw new SecurityException("invalid " +
digest.getAlgorithm() +
" signature file digest for " + name);
}
}
}
}
}
return oneDigestVerified;
} | [
"private",
"boolean",
"verifySection",
"(",
"Attributes",
"sfAttr",
",",
"String",
"name",
",",
"ManifestDigester",
"md",
",",
"BASE64Decoder",
"decoder",
")",
"throws",
"IOException",
"{",
"boolean",
"oneDigestVerified",
"=",
"false",
";",
"ManifestDigester",
".",
... | given the .SF digest header, and the data from the
section in the manifest, see if the hashes match.
if not, throw a SecurityException.
@return true if all the -Digest headers verified
@exception SecurityException if the hash was not equal | [
"given",
"the",
".",
"SF",
"digest",
"header",
"and",
"the",
"data",
"from",
"the",
"section",
"in",
"the",
"manifest",
"see",
"if",
"the",
"hashes",
"match",
".",
"if",
"not",
"throw",
"a",
"SecurityException",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L389-L466 |
33,118 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.toHex | static String toHex(byte[] data) {
StringBuffer sb = new StringBuffer(data.length*2);
for (int i=0; i<data.length; i++) {
sb.append(hexc[(data[i] >>4) & 0x0f]);
sb.append(hexc[data[i] & 0x0f]);
}
return sb.toString();
} | java | static String toHex(byte[] data) {
StringBuffer sb = new StringBuffer(data.length*2);
for (int i=0; i<data.length; i++) {
sb.append(hexc[(data[i] >>4) & 0x0f]);
sb.append(hexc[data[i] & 0x0f]);
}
return sb.toString();
} | [
"static",
"String",
"toHex",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
"data",
".",
"length",
"*",
"2",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
... | convert a byte array to a hex string for debugging purposes
@param data the binary data to be converted to a hex string
@return an ASCII hex string | [
"convert",
"a",
"byte",
"array",
"to",
"a",
"hex",
"string",
"for",
"debugging",
"purposes"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L595-L604 |
33,119 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.contains | static boolean contains(CodeSigner[] set, CodeSigner signer)
{
for (int i = 0; i < set.length; i++) {
if (set[i].equals(signer))
return true;
}
return false;
} | java | static boolean contains(CodeSigner[] set, CodeSigner signer)
{
for (int i = 0; i < set.length; i++) {
if (set[i].equals(signer))
return true;
}
return false;
} | [
"static",
"boolean",
"contains",
"(",
"CodeSigner",
"[",
"]",
"set",
",",
"CodeSigner",
"signer",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"set",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"set",
"[",
"i",
"]",
".",
... | returns true if set contains signer | [
"returns",
"true",
"if",
"set",
"contains",
"signer"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L607-L614 |
33,120 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.isSubSet | static boolean isSubSet(CodeSigner[] subset, CodeSigner[] set)
{
// check for the same object
if (set == subset)
return true;
boolean match;
for (int i = 0; i < subset.length; i++) {
if (!contains(set, subset[i]))
return false;
}
return true;
} | java | static boolean isSubSet(CodeSigner[] subset, CodeSigner[] set)
{
// check for the same object
if (set == subset)
return true;
boolean match;
for (int i = 0; i < subset.length; i++) {
if (!contains(set, subset[i]))
return false;
}
return true;
} | [
"static",
"boolean",
"isSubSet",
"(",
"CodeSigner",
"[",
"]",
"subset",
",",
"CodeSigner",
"[",
"]",
"set",
")",
"{",
"// check for the same object",
"if",
"(",
"set",
"==",
"subset",
")",
"return",
"true",
";",
"boolean",
"match",
";",
"for",
"(",
"int",
... | returns true if subset is a subset of set | [
"returns",
"true",
"if",
"subset",
"is",
"a",
"subset",
"of",
"set"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L617-L629 |
33,121 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java | SignatureFileVerifier.matches | static boolean matches(CodeSigner[] signers, CodeSigner[] oldSigners,
CodeSigner[] newSigners) {
// special case
if ((oldSigners == null) && (signers == newSigners))
return true;
boolean match;
// make sure all oldSigners are in signers
if ((oldSigners != null) && !isSubSet(oldSigners, signers))
return false;
// make sure all newSigners are in signers
if (!isSubSet(newSigners, signers)) {
return false;
}
// now make sure all the code signers in signers are
// also in oldSigners or newSigners
for (int i = 0; i < signers.length; i++) {
boolean found =
((oldSigners != null) && contains(oldSigners, signers[i])) ||
contains(newSigners, signers[i]);
if (!found)
return false;
}
return true;
} | java | static boolean matches(CodeSigner[] signers, CodeSigner[] oldSigners,
CodeSigner[] newSigners) {
// special case
if ((oldSigners == null) && (signers == newSigners))
return true;
boolean match;
// make sure all oldSigners are in signers
if ((oldSigners != null) && !isSubSet(oldSigners, signers))
return false;
// make sure all newSigners are in signers
if (!isSubSet(newSigners, signers)) {
return false;
}
// now make sure all the code signers in signers are
// also in oldSigners or newSigners
for (int i = 0; i < signers.length; i++) {
boolean found =
((oldSigners != null) && contains(oldSigners, signers[i])) ||
contains(newSigners, signers[i]);
if (!found)
return false;
}
return true;
} | [
"static",
"boolean",
"matches",
"(",
"CodeSigner",
"[",
"]",
"signers",
",",
"CodeSigner",
"[",
"]",
"oldSigners",
",",
"CodeSigner",
"[",
"]",
"newSigners",
")",
"{",
"// special case",
"if",
"(",
"(",
"oldSigners",
"==",
"null",
")",
"&&",
"(",
"signers"... | returns true if signer contains exactly the same code signers as
oldSigner and newSigner, false otherwise. oldSigner
is allowed to be null. | [
"returns",
"true",
"if",
"signer",
"contains",
"exactly",
"the",
"same",
"code",
"signers",
"as",
"oldSigner",
"and",
"newSigner",
"false",
"otherwise",
".",
"oldSigner",
"is",
"allowed",
"to",
"be",
"null",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/util/SignatureFileVerifier.java#L636-L665 |
33,122 | google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/org/xml/sax/helpers/NewInstance.java | NewInstance.newInstance | static Object newInstance (ClassLoader classLoader, String className)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException
{
Class driverClass;
if (classLoader == null) {
driverClass = Class.forName(className);
} else {
driverClass = classLoader.loadClass(className);
}
return driverClass.newInstance();
} | java | static Object newInstance (ClassLoader classLoader, String className)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException
{
Class driverClass;
if (classLoader == null) {
driverClass = Class.forName(className);
} else {
driverClass = classLoader.loadClass(className);
}
return driverClass.newInstance();
} | [
"static",
"Object",
"newInstance",
"(",
"ClassLoader",
"classLoader",
",",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
",",
"IllegalAccessException",
",",
"InstantiationException",
"{",
"Class",
"driverClass",
";",
"if",
"(",
"classLoader",
"==",
"... | Creates a new instance of the specified class name
Package private so this code is not exposed at the API level. | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"specified",
"class",
"name"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/org/xml/sax/helpers/NewInstance.java#L41-L52 |
33,123 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/jar/JarOutputStream.java | JarOutputStream.putNextEntry | public void putNextEntry(ZipEntry ze) throws IOException {
if (firstEntry) {
// Make sure that extra field data for first JAR
// entry includes JAR magic number id.
byte[] edata = ze.getExtra();
if (edata == null || !hasMagic(edata)) {
if (edata == null) {
edata = new byte[4];
} else {
// Prepend magic to existing extra data
byte[] tmp = new byte[edata.length + 4];
System.arraycopy(edata, 0, tmp, 4, edata.length);
edata = tmp;
}
set16(edata, 0, JAR_MAGIC); // extra field id
set16(edata, 2, 0); // extra field size
ze.setExtra(edata);
}
firstEntry = false;
}
super.putNextEntry(ze);
} | java | public void putNextEntry(ZipEntry ze) throws IOException {
if (firstEntry) {
// Make sure that extra field data for first JAR
// entry includes JAR magic number id.
byte[] edata = ze.getExtra();
if (edata == null || !hasMagic(edata)) {
if (edata == null) {
edata = new byte[4];
} else {
// Prepend magic to existing extra data
byte[] tmp = new byte[edata.length + 4];
System.arraycopy(edata, 0, tmp, 4, edata.length);
edata = tmp;
}
set16(edata, 0, JAR_MAGIC); // extra field id
set16(edata, 2, 0); // extra field size
ze.setExtra(edata);
}
firstEntry = false;
}
super.putNextEntry(ze);
} | [
"public",
"void",
"putNextEntry",
"(",
"ZipEntry",
"ze",
")",
"throws",
"IOException",
"{",
"if",
"(",
"firstEntry",
")",
"{",
"// Make sure that extra field data for first JAR",
"// entry includes JAR magic number id.",
"byte",
"[",
"]",
"edata",
"=",
"ze",
".",
"get... | Begins writing a new JAR file entry and positions the stream
to the start of the entry data. This method will also close
any previous entry. The default compression method will be
used if no compression method was specified for the entry.
The current time will be used if the entry has no set modification
time.
@param ze the ZIP/JAR entry to be written
@exception ZipException if a ZIP error has occurred
@exception IOException if an I/O error has occurred | [
"Begins",
"writing",
"a",
"new",
"JAR",
"file",
"entry",
"and",
"positions",
"the",
"stream",
"to",
"the",
"start",
"of",
"the",
"entry",
"data",
".",
"This",
"method",
"will",
"also",
"close",
"any",
"previous",
"entry",
".",
"The",
"default",
"compressio... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/jar/JarOutputStream.java#L89-L110 |
33,124 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java | TypeDeclarationGenerator.printInstanceVariables | protected void printInstanceVariables() {
Iterable<VariableDeclarationFragment> fields = getInstanceFields();
if (Iterables.isEmpty(fields)) {
newline();
return;
}
// Need direct access to fields possibly from inner classes that are
// promoted to top level classes, so must make all visible fields public.
println(" {");
println(" @public");
indent();
FieldDeclaration lastDeclaration = null;
boolean needsAsterisk = false;
for (VariableDeclarationFragment fragment : fields) {
VariableElement varElement = fragment.getVariableElement();
FieldDeclaration declaration = (FieldDeclaration) fragment.getParent();
if (declaration != lastDeclaration) {
if (lastDeclaration != null) {
println(";");
}
lastDeclaration = declaration;
JavadocGenerator.printDocComment(getBuilder(), declaration.getJavadoc());
printIndent();
if (ElementUtil.isWeakReference(varElement) && !ElementUtil.isVolatile(varElement)) {
// We must add this even without -use-arc because the header may be
// included by a file compiled with ARC.
print("__unsafe_unretained ");
}
String objcType = getDeclarationType(varElement);
needsAsterisk = objcType.endsWith("*");
if (needsAsterisk) {
// Strip pointer from type, as it will be added when appending fragment.
// This is necessary to create "Foo *one, *two;" declarations.
objcType = objcType.substring(0, objcType.length() - 2);
}
print(objcType);
print(' ');
} else {
print(", ");
}
if (needsAsterisk) {
print('*');
}
print(nameTable.getVariableShortName(varElement));
}
println(";");
unindent();
println("}");
} | java | protected void printInstanceVariables() {
Iterable<VariableDeclarationFragment> fields = getInstanceFields();
if (Iterables.isEmpty(fields)) {
newline();
return;
}
// Need direct access to fields possibly from inner classes that are
// promoted to top level classes, so must make all visible fields public.
println(" {");
println(" @public");
indent();
FieldDeclaration lastDeclaration = null;
boolean needsAsterisk = false;
for (VariableDeclarationFragment fragment : fields) {
VariableElement varElement = fragment.getVariableElement();
FieldDeclaration declaration = (FieldDeclaration) fragment.getParent();
if (declaration != lastDeclaration) {
if (lastDeclaration != null) {
println(";");
}
lastDeclaration = declaration;
JavadocGenerator.printDocComment(getBuilder(), declaration.getJavadoc());
printIndent();
if (ElementUtil.isWeakReference(varElement) && !ElementUtil.isVolatile(varElement)) {
// We must add this even without -use-arc because the header may be
// included by a file compiled with ARC.
print("__unsafe_unretained ");
}
String objcType = getDeclarationType(varElement);
needsAsterisk = objcType.endsWith("*");
if (needsAsterisk) {
// Strip pointer from type, as it will be added when appending fragment.
// This is necessary to create "Foo *one, *two;" declarations.
objcType = objcType.substring(0, objcType.length() - 2);
}
print(objcType);
print(' ');
} else {
print(", ");
}
if (needsAsterisk) {
print('*');
}
print(nameTable.getVariableShortName(varElement));
}
println(";");
unindent();
println("}");
} | [
"protected",
"void",
"printInstanceVariables",
"(",
")",
"{",
"Iterable",
"<",
"VariableDeclarationFragment",
">",
"fields",
"=",
"getInstanceFields",
"(",
")",
";",
"if",
"(",
"Iterables",
".",
"isEmpty",
"(",
"fields",
")",
")",
"{",
"newline",
"(",
")",
"... | Prints the list of instance variables in a type. | [
"Prints",
"the",
"list",
"of",
"instance",
"variables",
"in",
"a",
"type",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java#L272-L320 |
33,125 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java | TypeDeclarationGenerator.printDeadClassConstant | protected void printDeadClassConstant(VariableDeclarationFragment fragment) {
VariableElement var = fragment.getVariableElement();
Object value = var.getConstantValue();
assert value != null;
String declType = getDeclarationType(var);
declType += (declType.endsWith("*") ? "" : " ");
String name = nameTable.getVariableShortName(var);
if (ElementUtil.isPrimitiveConstant(var)) {
printf("#define %s_%s %s\n", typeName, name, LiteralGenerator.generate(value));
} else {
println("FOUNDATION_EXPORT "
+ UnicodeUtils.format("%s%s_%s", declType, typeName, name) + ";");
}
} | java | protected void printDeadClassConstant(VariableDeclarationFragment fragment) {
VariableElement var = fragment.getVariableElement();
Object value = var.getConstantValue();
assert value != null;
String declType = getDeclarationType(var);
declType += (declType.endsWith("*") ? "" : " ");
String name = nameTable.getVariableShortName(var);
if (ElementUtil.isPrimitiveConstant(var)) {
printf("#define %s_%s %s\n", typeName, name, LiteralGenerator.generate(value));
} else {
println("FOUNDATION_EXPORT "
+ UnicodeUtils.format("%s%s_%s", declType, typeName, name) + ";");
}
} | [
"protected",
"void",
"printDeadClassConstant",
"(",
"VariableDeclarationFragment",
"fragment",
")",
"{",
"VariableElement",
"var",
"=",
"fragment",
".",
"getVariableElement",
"(",
")",
";",
"Object",
"value",
"=",
"var",
".",
"getConstantValue",
"(",
")",
";",
"as... | Overridden in TypePrivateDeclarationGenerator | [
"Overridden",
"in",
"TypePrivateDeclarationGenerator"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java#L469-L482 |
33,126 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java | TypeDeclarationGenerator.printMethodDeclaration | private void printMethodDeclaration(MethodDeclaration m, boolean isCompanionClass) {
ExecutableElement methodElement = m.getExecutableElement();
TypeElement typeElement = ElementUtil.getDeclaringClass(methodElement);
if (typeElement.getKind().isInterface()) {
// isCompanion and isStatic must be both false (i.e. this prints a non-static method decl
// in @protocol) or must both be true (i.e. this prints a static method decl in the
// companion class' @interface).
if (isCompanionClass != ElementUtil.isStatic(methodElement)) {
return;
}
}
newline();
JavadocGenerator.printDocComment(getBuilder(), m.getJavadoc());
String methodSignature = getMethodSignature(m);
// In order to properly map the method name from the entire signature, we must isolate it from
// associated type and parameter declarations. The method name is guaranteed to be between the
// first closing parenthesis and first colon (for methods with arguments), or the entirety of
// the declaration after the first closing parenthesis (for methods with no arguments).
int identifierStartIndex = methodSignature.indexOf(')') + 1;
int identifierEndIndex =
methodSignature.contains(":") ? methodSignature.indexOf(':') : methodSignature.length();
generatedSourceMappings.addMethodMapping(
m /* methodDeclaration */,
getBuilder().length() + identifierStartIndex /* targetBegin */,
identifierEndIndex - identifierStartIndex /* length */);
print(methodSignature);
String methodName = nameTable.getMethodSelector(methodElement);
if (!m.isConstructor() && NameTable.needsObjcMethodFamilyNoneAttribute(methodName)) {
// Getting around a clang warning.
// clang assumes that methods with names starting with new, alloc or copy
// return objects of the same type as the receiving class, regardless of
// the actual declared return type. This attribute tells clang to not do
// that, please.
// See http://clang.llvm.org/docs/AutomaticReferenceCounting.html
// Sections 5.1 (Explicit method family control)
// and 5.2.2 (Related result types)
print(" OBJC_METHOD_FAMILY_NONE");
}
if (needsDeprecatedAttribute(m.getAnnotations())) {
print(" " + DEPRECATED_ATTRIBUTE);
}
if (m.isUnavailable()) {
print(" NS_UNAVAILABLE");
}
println(";");
} | java | private void printMethodDeclaration(MethodDeclaration m, boolean isCompanionClass) {
ExecutableElement methodElement = m.getExecutableElement();
TypeElement typeElement = ElementUtil.getDeclaringClass(methodElement);
if (typeElement.getKind().isInterface()) {
// isCompanion and isStatic must be both false (i.e. this prints a non-static method decl
// in @protocol) or must both be true (i.e. this prints a static method decl in the
// companion class' @interface).
if (isCompanionClass != ElementUtil.isStatic(methodElement)) {
return;
}
}
newline();
JavadocGenerator.printDocComment(getBuilder(), m.getJavadoc());
String methodSignature = getMethodSignature(m);
// In order to properly map the method name from the entire signature, we must isolate it from
// associated type and parameter declarations. The method name is guaranteed to be between the
// first closing parenthesis and first colon (for methods with arguments), or the entirety of
// the declaration after the first closing parenthesis (for methods with no arguments).
int identifierStartIndex = methodSignature.indexOf(')') + 1;
int identifierEndIndex =
methodSignature.contains(":") ? methodSignature.indexOf(':') : methodSignature.length();
generatedSourceMappings.addMethodMapping(
m /* methodDeclaration */,
getBuilder().length() + identifierStartIndex /* targetBegin */,
identifierEndIndex - identifierStartIndex /* length */);
print(methodSignature);
String methodName = nameTable.getMethodSelector(methodElement);
if (!m.isConstructor() && NameTable.needsObjcMethodFamilyNoneAttribute(methodName)) {
// Getting around a clang warning.
// clang assumes that methods with names starting with new, alloc or copy
// return objects of the same type as the receiving class, regardless of
// the actual declared return type. This attribute tells clang to not do
// that, please.
// See http://clang.llvm.org/docs/AutomaticReferenceCounting.html
// Sections 5.1 (Explicit method family control)
// and 5.2.2 (Related result types)
print(" OBJC_METHOD_FAMILY_NONE");
}
if (needsDeprecatedAttribute(m.getAnnotations())) {
print(" " + DEPRECATED_ATTRIBUTE);
}
if (m.isUnavailable()) {
print(" NS_UNAVAILABLE");
}
println(";");
} | [
"private",
"void",
"printMethodDeclaration",
"(",
"MethodDeclaration",
"m",
",",
"boolean",
"isCompanionClass",
")",
"{",
"ExecutableElement",
"methodElement",
"=",
"m",
".",
"getExecutableElement",
"(",
")",
";",
"TypeElement",
"typeElement",
"=",
"ElementUtil",
".",... | Emit method declaration.
@param m The method.
@param isCompanionClass If true, emit only if m is a static interface method. | [
"Emit",
"method",
"declaration",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java#L556-L608 |
33,127 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java | TypeDeclarationGenerator.nullability | @Override
protected String nullability(Element element) {
if (options.nullability()) {
if (ElementUtil.hasNullableAnnotation(element)) {
return " __nullable";
}
if (ElementUtil.isNonnull(element, parametersNonnullByDefault)) {
return " __nonnull";
}
}
return "";
} | java | @Override
protected String nullability(Element element) {
if (options.nullability()) {
if (ElementUtil.hasNullableAnnotation(element)) {
return " __nullable";
}
if (ElementUtil.isNonnull(element, parametersNonnullByDefault)) {
return " __nonnull";
}
}
return "";
} | [
"@",
"Override",
"protected",
"String",
"nullability",
"(",
"Element",
"element",
")",
"{",
"if",
"(",
"options",
".",
"nullability",
"(",
")",
")",
"{",
"if",
"(",
"ElementUtil",
".",
"hasNullableAnnotation",
"(",
"element",
")",
")",
"{",
"return",
"\" _... | Returns an Objective-C nullability attribute string if there is a matching JSR305 annotation,
or an empty string. | [
"Returns",
"an",
"Objective",
"-",
"C",
"nullability",
"attribute",
"string",
"if",
"there",
"is",
"a",
"matching",
"JSR305",
"annotation",
"or",
"an",
"empty",
"string",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/TypeDeclarationGenerator.java#L726-L737 |
33,128 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java | MappedByteBuffer.mappingOffset | private long mappingOffset() {
int ps = Bits.pageSize();
long offset = address % ps;
return (offset >= 0) ? offset : (ps + offset);
} | java | private long mappingOffset() {
int ps = Bits.pageSize();
long offset = address % ps;
return (offset >= 0) ? offset : (ps + offset);
} | [
"private",
"long",
"mappingOffset",
"(",
")",
"{",
"int",
"ps",
"=",
"Bits",
".",
"pageSize",
"(",
")",
";",
"long",
"offset",
"=",
"address",
"%",
"ps",
";",
"return",
"(",
"offset",
">=",
"0",
")",
"?",
"offset",
":",
"(",
"ps",
"+",
"offset",
... | of the mapping. Computed each time to avoid storing in every direct buffer. | [
"of",
"the",
"mapping",
".",
"Computed",
"each",
"time",
"to",
"avoid",
"storing",
"in",
"every",
"direct",
"buffer",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java#L105-L109 |
33,129 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java | MappedByteBuffer.isLoaded | public final boolean isLoaded() {
checkMapped();
if ((address == 0) || (capacity() == 0))
return true;
long offset = mappingOffset();
long length = mappingLength(offset);
return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length));
} | java | public final boolean isLoaded() {
checkMapped();
if ((address == 0) || (capacity() == 0))
return true;
long offset = mappingOffset();
long length = mappingLength(offset);
return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length));
} | [
"public",
"final",
"boolean",
"isLoaded",
"(",
")",
"{",
"checkMapped",
"(",
")",
";",
"if",
"(",
"(",
"address",
"==",
"0",
")",
"||",
"(",
"capacity",
"(",
")",
"==",
"0",
")",
")",
"return",
"true",
";",
"long",
"offset",
"=",
"mappingOffset",
"... | Tells whether or not this buffer's content is resident in physical
memory.
<p> A return value of <tt>true</tt> implies that it is highly likely
that all of the data in this buffer is resident in physical memory and
may therefore be accessed without incurring any virtual-memory page
faults or I/O operations. A return value of <tt>false</tt> does not
necessarily imply that the buffer's content is not resident in physical
memory.
<p> The returned value is a hint, rather than a guarantee, because the
underlying operating system may have paged out some of the buffer's data
by the time that an invocation of this method returns. </p>
@return <tt>true</tt> if it is likely that this buffer's content
is resident in physical memory | [
"Tells",
"whether",
"or",
"not",
"this",
"buffer",
"s",
"content",
"is",
"resident",
"in",
"physical",
"memory",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java#L137-L144 |
33,130 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java | MappedByteBuffer.load | public final MappedByteBuffer load() {
checkMapped();
if ((address == 0) || (capacity() == 0))
return this;
long offset = mappingOffset();
long length = mappingLength(offset);
load0(mappingAddress(offset), length);
// Read a byte from each page to bring it into memory. A checksum
// is computed as we go along to prevent the compiler from otherwise
// considering the loop as dead code.
Unsafe unsafe = Unsafe.getUnsafe();
int ps = Bits.pageSize();
int count = Bits.pageCount(length);
long a = mappingAddress(offset);
byte x = 0;
for (int i = 0; i < count; i++) {
x ^= unsafe.getByte(a);
a += ps;
}
if (unused != 0)
unused = x;
return this;
} | java | public final MappedByteBuffer load() {
checkMapped();
if ((address == 0) || (capacity() == 0))
return this;
long offset = mappingOffset();
long length = mappingLength(offset);
load0(mappingAddress(offset), length);
// Read a byte from each page to bring it into memory. A checksum
// is computed as we go along to prevent the compiler from otherwise
// considering the loop as dead code.
Unsafe unsafe = Unsafe.getUnsafe();
int ps = Bits.pageSize();
int count = Bits.pageCount(length);
long a = mappingAddress(offset);
byte x = 0;
for (int i = 0; i < count; i++) {
x ^= unsafe.getByte(a);
a += ps;
}
if (unused != 0)
unused = x;
return this;
} | [
"public",
"final",
"MappedByteBuffer",
"load",
"(",
")",
"{",
"checkMapped",
"(",
")",
";",
"if",
"(",
"(",
"address",
"==",
"0",
")",
"||",
"(",
"capacity",
"(",
")",
"==",
"0",
")",
")",
"return",
"this",
";",
"long",
"offset",
"=",
"mappingOffset"... | Loads this buffer's content into physical memory.
<p> This method makes a best effort to ensure that, when it returns,
this buffer's content is resident in physical memory. Invoking this
method may cause some number of page faults and I/O operations to
occur. </p>
@return This buffer | [
"Loads",
"this",
"buffer",
"s",
"content",
"into",
"physical",
"memory",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java#L159-L183 |
33,131 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java | MappedByteBuffer.force | public final MappedByteBuffer force() {
checkMapped();
if ((address != 0) && (capacity() != 0)) {
long offset = mappingOffset();
force0(fd, mappingAddress(offset), mappingLength(offset));
}
return this;
} | java | public final MappedByteBuffer force() {
checkMapped();
if ((address != 0) && (capacity() != 0)) {
long offset = mappingOffset();
force0(fd, mappingAddress(offset), mappingLength(offset));
}
return this;
} | [
"public",
"final",
"MappedByteBuffer",
"force",
"(",
")",
"{",
"checkMapped",
"(",
")",
";",
"if",
"(",
"(",
"address",
"!=",
"0",
")",
"&&",
"(",
"capacity",
"(",
")",
"!=",
"0",
")",
")",
"{",
"long",
"offset",
"=",
"mappingOffset",
"(",
")",
";"... | Forces any changes made to this buffer's content to be written to the
storage device containing the mapped file.
<p> If the file mapped into this buffer resides on a local storage
device then when this method returns it is guaranteed that all changes
made to the buffer since it was created, or since this method was last
invoked, will have been written to that device.
<p> If the file does not reside on a local device then no such guarantee
is made.
<p> If this buffer was not mapped in read/write mode ({@link
java.nio.channels.FileChannel.MapMode#READ_WRITE}) then invoking this
method has no effect. </p>
@return This buffer | [
"Forces",
"any",
"changes",
"made",
"to",
"this",
"buffer",
"s",
"content",
"to",
"be",
"written",
"to",
"the",
"storage",
"device",
"containing",
"the",
"mapped",
"file",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/nio/MappedByteBuffer.java#L203-L210 |
33,132 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java | ListFormatter.getInstance | public static ListFormatter getInstance(Locale locale) {
return getInstance(ULocale.forLocale(locale), Style.STANDARD);
} | java | public static ListFormatter getInstance(Locale locale) {
return getInstance(ULocale.forLocale(locale), Style.STANDARD);
} | [
"public",
"static",
"ListFormatter",
"getInstance",
"(",
"Locale",
"locale",
")",
"{",
"return",
"getInstance",
"(",
"ULocale",
".",
"forLocale",
"(",
"locale",
")",
",",
"Style",
".",
"STANDARD",
")",
";",
"}"
] | Create a list formatter that is appropriate for a locale.
@param locale
the locale in question.
@return ListFormatter | [
"Create",
"a",
"list",
"formatter",
"that",
"is",
"appropriate",
"for",
"a",
"locale",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java#L151-L153 |
33,133 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java | ListFormatter.getInstance | @Deprecated
public static ListFormatter getInstance(ULocale locale, Style style) {
return cache.get(locale, style.getName());
} | java | @Deprecated
public static ListFormatter getInstance(ULocale locale, Style style) {
return cache.get(locale, style.getName());
} | [
"@",
"Deprecated",
"public",
"static",
"ListFormatter",
"getInstance",
"(",
"ULocale",
"locale",
",",
"Style",
"style",
")",
"{",
"return",
"cache",
".",
"get",
"(",
"locale",
",",
"style",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Create a list formatter that is appropriate for a locale and style.
@param locale the locale in question.
@param style the style
@return ListFormatter
@deprecated This API is ICU internal only.
@hide draft / provisional / internal are hidden on Android | [
"Create",
"a",
"list",
"formatter",
"that",
"is",
"appropriate",
"for",
"a",
"locale",
"and",
"style",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java#L164-L167 |
33,134 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java | ListFormatter.format | FormattedListBuilder format(Collection<?> items, int index) {
Iterator<?> it = items.iterator();
int count = items.size();
switch (count) {
case 0:
return new FormattedListBuilder("", false);
case 1:
return new FormattedListBuilder(it.next(), index == 0);
case 2:
return new FormattedListBuilder(it.next(), index == 0).append(two, it.next(), index == 1);
}
FormattedListBuilder builder = new FormattedListBuilder(it.next(), index == 0);
builder.append(start, it.next(), index == 1);
for (int idx = 2; idx < count - 1; ++idx) {
builder.append(middle, it.next(), index == idx);
}
return builder.append(end, it.next(), index == count - 1);
} | java | FormattedListBuilder format(Collection<?> items, int index) {
Iterator<?> it = items.iterator();
int count = items.size();
switch (count) {
case 0:
return new FormattedListBuilder("", false);
case 1:
return new FormattedListBuilder(it.next(), index == 0);
case 2:
return new FormattedListBuilder(it.next(), index == 0).append(two, it.next(), index == 1);
}
FormattedListBuilder builder = new FormattedListBuilder(it.next(), index == 0);
builder.append(start, it.next(), index == 1);
for (int idx = 2; idx < count - 1; ++idx) {
builder.append(middle, it.next(), index == idx);
}
return builder.append(end, it.next(), index == count - 1);
} | [
"FormattedListBuilder",
"format",
"(",
"Collection",
"<",
"?",
">",
"items",
",",
"int",
"index",
")",
"{",
"Iterator",
"<",
"?",
">",
"it",
"=",
"items",
".",
"iterator",
"(",
")",
";",
"int",
"count",
"=",
"items",
".",
"size",
"(",
")",
";",
"sw... | the offset. | [
"the",
"offset",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java#L204-L221 |
33,135 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java | ListFormatter.getPatternForNumItems | public String getPatternForNumItems(int count) {
if (count <= 0) {
throw new IllegalArgumentException("count must be > 0");
}
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < count; i++) {
list.add(String.format("{%d}", i));
}
return format(list);
} | java | public String getPatternForNumItems(int count) {
if (count <= 0) {
throw new IllegalArgumentException("count must be > 0");
}
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < count; i++) {
list.add(String.format("{%d}", i));
}
return format(list);
} | [
"public",
"String",
"getPatternForNumItems",
"(",
"int",
"count",
")",
"{",
"if",
"(",
"count",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"count must be > 0\"",
")",
";",
"}",
"ArrayList",
"<",
"String",
">",
"list",
"=",
"new",... | Returns the pattern to use for a particular item count.
@param count the item count.
@return the pattern with {0}, {1}, {2}, etc. For English,
getPatternForNumItems(3) == "{0}, {1}, and {2}"
@throws IllegalArgumentException when count is 0 or negative. | [
"Returns",
"the",
"pattern",
"to",
"use",
"for",
"a",
"particular",
"item",
"count",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ListFormatter.java#L230-L239 |
33,136 | google/j2objc | tree_shaker/src/main/java/com/google/devtools/treeshaker/UnusedCodeTracker.java | UnusedCodeTracker.markUsedElements | public void markUsedElements(CodeReferenceMap publicRootSet) {
if (publicRootSet == null) {
markUsedElements();
return;
}
//Add all public methods in publicRootClasses to root set
for (String clazz : publicRootSet.getReferencedClasses()) {
ClassReferenceNode classNode = (ClassReferenceNode) elementReferenceMap
.get(ElementReferenceMapper.stitchClassIdentifier(clazz));
assert(classNode != null);
Iterable<ExecutableElement> methods = ElementUtil.getMethods(classNode.classElement);
for (ExecutableElement method : methods) {
if (ElementUtil.isPublic(method)) {
rootSet.add(ElementReferenceMapper.stitchMethodIdentifier(method, env.typeUtil(),
env.elementUtil()));
}
}
}
//Add input root methods to static set
for (Table.Cell<String, String, ImmutableSet<String>> cell : publicRootSet
.getReferencedMethods().cellSet()) {
String clazzName = cell.getRowKey();
String methodName = cell.getColumnKey();
for (String signature : cell.getValue()) {
rootSet.add(ElementReferenceMapper
.stitchMethodIdentifier(clazzName, methodName, signature));
}
}
markUsedElements(staticSet);
markUsedElements(rootSet);
} | java | public void markUsedElements(CodeReferenceMap publicRootSet) {
if (publicRootSet == null) {
markUsedElements();
return;
}
//Add all public methods in publicRootClasses to root set
for (String clazz : publicRootSet.getReferencedClasses()) {
ClassReferenceNode classNode = (ClassReferenceNode) elementReferenceMap
.get(ElementReferenceMapper.stitchClassIdentifier(clazz));
assert(classNode != null);
Iterable<ExecutableElement> methods = ElementUtil.getMethods(classNode.classElement);
for (ExecutableElement method : methods) {
if (ElementUtil.isPublic(method)) {
rootSet.add(ElementReferenceMapper.stitchMethodIdentifier(method, env.typeUtil(),
env.elementUtil()));
}
}
}
//Add input root methods to static set
for (Table.Cell<String, String, ImmutableSet<String>> cell : publicRootSet
.getReferencedMethods().cellSet()) {
String clazzName = cell.getRowKey();
String methodName = cell.getColumnKey();
for (String signature : cell.getValue()) {
rootSet.add(ElementReferenceMapper
.stitchMethodIdentifier(clazzName, methodName, signature));
}
}
markUsedElements(staticSet);
markUsedElements(rootSet);
} | [
"public",
"void",
"markUsedElements",
"(",
"CodeReferenceMap",
"publicRootSet",
")",
"{",
"if",
"(",
"publicRootSet",
"==",
"null",
")",
"{",
"markUsedElements",
"(",
")",
";",
"return",
";",
"}",
"//Add all public methods in publicRootClasses to root set",
"for",
"("... | the isPublic check. | [
"the",
"isPublic",
"check",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/tree_shaker/src/main/java/com/google/devtools/treeshaker/UnusedCodeTracker.java#L111-L143 |
33,137 | google/j2objc | tree_shaker/src/main/java/com/google/devtools/treeshaker/UnusedCodeTracker.java | UnusedCodeTracker.traverseMethod | public void traverseMethod(String methodID) {
MethodReferenceNode node = (MethodReferenceNode) elementReferenceMap.get(methodID);
if (node == null) {
//TODO(malvania): This might never be reached, because we create a node for every method,
// both invoked and declared.
ErrorUtil.warning("Encountered .class method while accessing: " + methodID);
return;
}
if (node.reachable) {
return;
}
node.reachable = true;
markParentClasses(ElementUtil.getDeclaringClass(node.methodElement));
for (String invokedMethodID : node.invokedMethods) {
traverseMethod(invokedMethodID);
}
for (String overrideMethodID : node.overridingMethods) {
traverseMethod(overrideMethodID);
}
} | java | public void traverseMethod(String methodID) {
MethodReferenceNode node = (MethodReferenceNode) elementReferenceMap.get(methodID);
if (node == null) {
//TODO(malvania): This might never be reached, because we create a node for every method,
// both invoked and declared.
ErrorUtil.warning("Encountered .class method while accessing: " + methodID);
return;
}
if (node.reachable) {
return;
}
node.reachable = true;
markParentClasses(ElementUtil.getDeclaringClass(node.methodElement));
for (String invokedMethodID : node.invokedMethods) {
traverseMethod(invokedMethodID);
}
for (String overrideMethodID : node.overridingMethods) {
traverseMethod(overrideMethodID);
}
} | [
"public",
"void",
"traverseMethod",
"(",
"String",
"methodID",
")",
"{",
"MethodReferenceNode",
"node",
"=",
"(",
"MethodReferenceNode",
")",
"elementReferenceMap",
".",
"get",
"(",
"methodID",
")",
";",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"//TODO(malva... | Traverses the method invocation graph created by ElementReferenceMapper, and marks all methods
that are reachable from the inputRootSet. Also covers all methods that possibly override these
called methods.
@param methodID | [
"Traverses",
"the",
"method",
"invocation",
"graph",
"created",
"by",
"ElementReferenceMapper",
"and",
"marks",
"all",
"methods",
"that",
"are",
"reachable",
"from",
"the",
"inputRootSet",
".",
"Also",
"covers",
"all",
"methods",
"that",
"possibly",
"override",
"t... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/tree_shaker/src/main/java/com/google/devtools/treeshaker/UnusedCodeTracker.java#L161-L181 |
33,138 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.init | public final void init(int opmode, Key key) throws InvalidKeyException {
init(opmode, key, JceSecurity.RANDOM);
} | java | public final void init(int opmode, Key key) throws InvalidKeyException {
init(opmode, key, JceSecurity.RANDOM);
} | [
"public",
"final",
"void",
"init",
"(",
"int",
"opmode",
",",
"Key",
"key",
")",
"throws",
"InvalidKeyException",
"{",
"init",
"(",
"opmode",
",",
"key",
",",
"JceSecurity",
".",
"RANDOM",
")",
";",
"}"
] | Initializes this cipher with a key.
<p>The cipher is initialized for one of the following four operations:
encryption, decryption, key wrapping or key unwrapping, depending
on the value of <code>opmode</code>.
<p>If this cipher requires any algorithm parameters that cannot be
derived from the given <code>key</code>, the underlying cipher
implementation is supposed to generate the required parameters itself
(using provider-specific default or random values) if it is being
initialized for encryption or key wrapping, and raise an
<code>InvalidKeyException</code> if it is being
initialized for decryption or key unwrapping.
The generated parameters can be retrieved using
{@link #getParameters() getParameters} or
{@link #getIV() getIV} (if the parameter is an IV).
<p>If this cipher requires algorithm parameters that cannot be
derived from the input parameters, and there are no reasonable
provider-specific default values, initialization will
necessarily fail.
<p>If this cipher (including its underlying feedback or padding scheme)
requires any random bytes (e.g., for parameter generation), it will get
them using the {@link SecureRandom <code>SecureRandom</code>}
implementation of the highest-priority
installed provider as the source of randomness.
(If none of the installed providers supply an implementation of
SecureRandom, a system-provided source of randomness will be used.)
<p>Note that when a Cipher object is initialized, it loses all
previously-acquired state. In other words, initializing a Cipher is
equivalent to creating a new instance of that Cipher and initializing
it.
@param opmode the operation mode of this cipher (this is one of
the following:
<code>ENCRYPT_MODE</code>, <code>DECRYPT_MODE</code>,
<code>WRAP_MODE</code> or <code>UNWRAP_MODE</code>)
@param key the key
@exception InvalidKeyException if the given key is inappropriate for
initializing this cipher, or requires
algorithm parameters that cannot be
determined from the given key, or if the given key has a keysize that
exceeds the maximum allowable keysize (as determined from the
configured jurisdiction policy files). | [
"Initializes",
"this",
"cipher",
"with",
"a",
"key",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L1149-L1151 |
33,139 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.init | public final void init(int opmode, Key key, SecureRandom random)
throws InvalidKeyException
{
initialized = false;
checkOpmode(opmode);
try {
chooseProvider(InitType.KEY, opmode, key, null, null, random);
} catch (InvalidAlgorithmParameterException e) {
// should never occur
throw new InvalidKeyException(e);
}
initialized = true;
this.opmode = opmode;
} | java | public final void init(int opmode, Key key, SecureRandom random)
throws InvalidKeyException
{
initialized = false;
checkOpmode(opmode);
try {
chooseProvider(InitType.KEY, opmode, key, null, null, random);
} catch (InvalidAlgorithmParameterException e) {
// should never occur
throw new InvalidKeyException(e);
}
initialized = true;
this.opmode = opmode;
} | [
"public",
"final",
"void",
"init",
"(",
"int",
"opmode",
",",
"Key",
"key",
",",
"SecureRandom",
"random",
")",
"throws",
"InvalidKeyException",
"{",
"initialized",
"=",
"false",
";",
"checkOpmode",
"(",
"opmode",
")",
";",
"try",
"{",
"chooseProvider",
"(",... | Initializes this cipher with a key and a source of randomness.
<p>The cipher is initialized for one of the following four operations:
encryption, decryption, key wrapping or key unwrapping, depending
on the value of <code>opmode</code>.
<p>If this cipher requires any algorithm parameters that cannot be
derived from the given <code>key</code>, the underlying cipher
implementation is supposed to generate the required parameters itself
(using provider-specific default or random values) if it is being
initialized for encryption or key wrapping, and raise an
<code>InvalidKeyException</code> if it is being
initialized for decryption or key unwrapping.
The generated parameters can be retrieved using
{@link #getParameters() getParameters} or
{@link #getIV() getIV} (if the parameter is an IV).
<p>If this cipher requires algorithm parameters that cannot be
derived from the input parameters, and there are no reasonable
provider-specific default values, initialization will
necessarily fail.
<p>If this cipher (including its underlying feedback or padding scheme)
requires any random bytes (e.g., for parameter generation), it will get
them from <code>random</code>.
<p>Note that when a Cipher object is initialized, it loses all
previously-acquired state. In other words, initializing a Cipher is
equivalent to creating a new instance of that Cipher and initializing
it.
@param opmode the operation mode of this cipher (this is one of the
following:
<code>ENCRYPT_MODE</code>, <code>DECRYPT_MODE</code>,
<code>WRAP_MODE</code> or <code>UNWRAP_MODE</code>)
@param key the encryption key
@param random the source of randomness
@exception InvalidKeyException if the given key is inappropriate for
initializing this cipher, or requires
algorithm parameters that cannot be
determined from the given key, or if the given key has a keysize that
exceeds the maximum allowable keysize (as determined from the
configured jurisdiction policy files). | [
"Initializes",
"this",
"cipher",
"with",
"a",
"key",
"and",
"a",
"source",
"of",
"randomness",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L1199-L1214 |
33,140 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.init | public final void init(int opmode, Key key, AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException
{
initialized = false;
checkOpmode(opmode);
chooseProvider(InitType.ALGORITHM_PARAM_SPEC, opmode, key, params, null, random);
initialized = true;
this.opmode = opmode;
} | java | public final void init(int opmode, Key key, AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException
{
initialized = false;
checkOpmode(opmode);
chooseProvider(InitType.ALGORITHM_PARAM_SPEC, opmode, key, params, null, random);
initialized = true;
this.opmode = opmode;
} | [
"public",
"final",
"void",
"init",
"(",
"int",
"opmode",
",",
"Key",
"key",
",",
"AlgorithmParameterSpec",
"params",
",",
"SecureRandom",
"random",
")",
"throws",
"InvalidKeyException",
",",
"InvalidAlgorithmParameterException",
"{",
"initialized",
"=",
"false",
";"... | Initializes this cipher with a key, a set of algorithm
parameters, and a source of randomness.
<p>The cipher is initialized for one of the following four operations:
encryption, decryption, key wrapping or key unwrapping, depending
on the value of <code>opmode</code>.
<p>If this cipher requires any algorithm parameters and
<code>params</code> is null, the underlying cipher implementation is
supposed to generate the required parameters itself (using
provider-specific default or random values) if it is being
initialized for encryption or key wrapping, and raise an
<code>InvalidAlgorithmParameterException</code> if it is being
initialized for decryption or key unwrapping.
The generated parameters can be retrieved using
{@link #getParameters() getParameters} or
{@link #getIV() getIV} (if the parameter is an IV).
<p>If this cipher requires algorithm parameters that cannot be
derived from the input parameters, and there are no reasonable
provider-specific default values, initialization will
necessarily fail.
<p>If this cipher (including its underlying feedback or padding scheme)
requires any random bytes (e.g., for parameter generation), it will get
them from <code>random</code>.
<p>Note that when a Cipher object is initialized, it loses all
previously-acquired state. In other words, initializing a Cipher is
equivalent to creating a new instance of that Cipher and initializing
it.
@param opmode the operation mode of this cipher (this is one of the
following:
<code>ENCRYPT_MODE</code>, <code>DECRYPT_MODE</code>,
<code>WRAP_MODE</code> or <code>UNWRAP_MODE</code>)
@param key the encryption key
@param params the algorithm parameters
@param random the source of randomness
@exception InvalidKeyException if the given key is inappropriate for
initializing this cipher, or its keysize exceeds the maximum allowable
keysize (as determined from the configured jurisdiction policy files).
@exception InvalidAlgorithmParameterException if the given algorithm
parameters are inappropriate for this cipher,
or this cipher requires
algorithm parameters and <code>params</code> is null, or the given
algorithm parameters imply a cryptographic strength that would exceed
the legal limits (as determined from the configured jurisdiction
policy files). | [
"Initializes",
"this",
"cipher",
"with",
"a",
"key",
"a",
"set",
"of",
"algorithm",
"parameters",
"and",
"a",
"source",
"of",
"randomness",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L1329-L1340 |
33,141 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.init | public final void init(int opmode, Certificate certificate,
SecureRandom random)
throws InvalidKeyException {
initialized = false;
checkOpmode(opmode);
// Check key usage if the certificate is of
// type X.509.
if (certificate instanceof java.security.cert.X509Certificate) {
// Check whether the cert has a key usage extension
// marked as a critical extension.
X509Certificate cert = (X509Certificate) certificate;
Set critSet = cert.getCriticalExtensionOIDs();
if (critSet != null && !critSet.isEmpty()
&& critSet.contains(KEY_USAGE_EXTENSION_OID)) {
boolean[] keyUsageInfo = cert.getKeyUsage();
// keyUsageInfo[2] is for keyEncipherment;
// keyUsageInfo[3] is for dataEncipherment.
if ((keyUsageInfo != null) &&
(((opmode == Cipher.ENCRYPT_MODE) &&
(keyUsageInfo.length > 3) &&
(keyUsageInfo[3] == false)) ||
((opmode == Cipher.WRAP_MODE) &&
(keyUsageInfo.length > 2) &&
(keyUsageInfo[2] == false)))) {
throw new InvalidKeyException("Wrong key usage");
}
}
}
PublicKey publicKey =
(certificate == null ? null : certificate.getPublicKey());
try {
chooseProvider(InitType.KEY, opmode, (Key) publicKey, null, null, random);
} catch (InvalidAlgorithmParameterException e) {
// should never occur
throw new InvalidKeyException(e);
}
initialized = true;
this.opmode = opmode;
} | java | public final void init(int opmode, Certificate certificate,
SecureRandom random)
throws InvalidKeyException {
initialized = false;
checkOpmode(opmode);
// Check key usage if the certificate is of
// type X.509.
if (certificate instanceof java.security.cert.X509Certificate) {
// Check whether the cert has a key usage extension
// marked as a critical extension.
X509Certificate cert = (X509Certificate) certificate;
Set critSet = cert.getCriticalExtensionOIDs();
if (critSet != null && !critSet.isEmpty()
&& critSet.contains(KEY_USAGE_EXTENSION_OID)) {
boolean[] keyUsageInfo = cert.getKeyUsage();
// keyUsageInfo[2] is for keyEncipherment;
// keyUsageInfo[3] is for dataEncipherment.
if ((keyUsageInfo != null) &&
(((opmode == Cipher.ENCRYPT_MODE) &&
(keyUsageInfo.length > 3) &&
(keyUsageInfo[3] == false)) ||
((opmode == Cipher.WRAP_MODE) &&
(keyUsageInfo.length > 2) &&
(keyUsageInfo[2] == false)))) {
throw new InvalidKeyException("Wrong key usage");
}
}
}
PublicKey publicKey =
(certificate == null ? null : certificate.getPublicKey());
try {
chooseProvider(InitType.KEY, opmode, (Key) publicKey, null, null, random);
} catch (InvalidAlgorithmParameterException e) {
// should never occur
throw new InvalidKeyException(e);
}
initialized = true;
this.opmode = opmode;
} | [
"public",
"final",
"void",
"init",
"(",
"int",
"opmode",
",",
"Certificate",
"certificate",
",",
"SecureRandom",
"random",
")",
"throws",
"InvalidKeyException",
"{",
"initialized",
"=",
"false",
";",
"checkOpmode",
"(",
"opmode",
")",
";",
"// Check key usage if t... | Initializes this cipher with the public key from the given certificate
and
a source of randomness.
<p>The cipher is initialized for one of the following four operations:
encryption, decryption, key wrapping
or key unwrapping, depending on
the value of <code>opmode</code>.
<p>If the certificate is of type X.509 and has a <i>key usage</i>
extension field marked as critical, and the value of the <i>key usage</i>
extension field implies that the public key in
the certificate and its corresponding private key are not
supposed to be used for the operation represented by the value of
<code>opmode</code>,
an <code>InvalidKeyException</code>
is thrown.
<p>If this cipher requires any algorithm parameters that cannot be
derived from the public key in the given <code>certificate</code>,
the underlying cipher
implementation is supposed to generate the required parameters itself
(using provider-specific default or random values) if it is being
initialized for encryption or key wrapping, and raise an
<code>InvalidKeyException</code> if it is being
initialized for decryption or key unwrapping.
The generated parameters can be retrieved using
{@link #getParameters() getParameters} or
{@link #getIV() getIV} (if the parameter is an IV).
<p>If this cipher requires algorithm parameters that cannot be
derived from the input parameters, and there are no reasonable
provider-specific default values, initialization will
necessarily fail.
<p>If this cipher (including its underlying feedback or padding scheme)
requires any random bytes (e.g., for parameter generation), it will get
them from <code>random</code>.
<p>Note that when a Cipher object is initialized, it loses all
previously-acquired state. In other words, initializing a Cipher is
equivalent to creating a new instance of that Cipher and initializing
it.
@param opmode the operation mode of this cipher (this is one of the
following:
<code>ENCRYPT_MODE</code>, <code>DECRYPT_MODE</code>,
<code>WRAP_MODE</code> or <code>UNWRAP_MODE</code>)
@param certificate the certificate
@param random the source of randomness
@exception InvalidKeyException if the public key in the given
certificate is inappropriate for initializing this cipher, or this
cipher
requires algorithm parameters that cannot be determined from the
public key in the given certificate, or the keysize of the public key
in the given certificate has a keysize that exceeds the maximum
allowable keysize (as determined by the configured jurisdiction policy
files). | [
"Initializes",
"this",
"cipher",
"with",
"the",
"public",
"key",
"from",
"the",
"given",
"certificate",
"and",
"a",
"source",
"of",
"randomness",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L1595-L1638 |
33,142 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.doFinal | public final int doFinal(byte[] output, int outputOffset)
throws IllegalBlockSizeException, ShortBufferException,
BadPaddingException {
checkCipherState();
// Input sanity check
if ((output == null) || (outputOffset < 0)) {
throw new IllegalArgumentException("Bad arguments");
}
updateProviderIfNeeded();
return spi.engineDoFinal(null, 0, 0, output, outputOffset);
} | java | public final int doFinal(byte[] output, int outputOffset)
throws IllegalBlockSizeException, ShortBufferException,
BadPaddingException {
checkCipherState();
// Input sanity check
if ((output == null) || (outputOffset < 0)) {
throw new IllegalArgumentException("Bad arguments");
}
updateProviderIfNeeded();
return spi.engineDoFinal(null, 0, 0, output, outputOffset);
} | [
"public",
"final",
"int",
"doFinal",
"(",
"byte",
"[",
"]",
"output",
",",
"int",
"outputOffset",
")",
"throws",
"IllegalBlockSizeException",
",",
"ShortBufferException",
",",
"BadPaddingException",
"{",
"checkCipherState",
"(",
")",
";",
"// Input sanity check",
"i... | Finishes a multiple-part encryption or decryption operation, depending
on how this cipher was initialized.
<p>Input data that may have been buffered during a previous
<code>update</code> operation is processed, with padding (if requested)
being applied.
If an AEAD mode such as GCM/CCM is being used, the authentication
tag is appended in the case of encryption, or verified in the
case of decryption.
The result is stored in the <code>output</code> buffer, starting at
<code>outputOffset</code> inclusive.
<p>If the <code>output</code> buffer is too small to hold the result,
a <code>ShortBufferException</code> is thrown. In this case, repeat this
call with a larger output buffer. Use
{@link #getOutputSize(int) getOutputSize} to determine how big
the output buffer should be.
<p>Upon finishing, this method resets this cipher object to the state
it was in when previously initialized via a call to <code>init</code>.
That is, the object is reset and available to encrypt or decrypt
(depending on the operation mode that was specified in the call to
<code>init</code>) more data.
<p>Note: if any exception is thrown, this cipher object may need to
be reset before it can be used again.
@param output the buffer for the result
@param outputOffset the offset in <code>output</code> where the result
is stored
@return the number of bytes stored in <code>output</code>
@exception IllegalStateException if this cipher is in a wrong state
(e.g., has not been initialized)
@exception IllegalBlockSizeException if this cipher is a block cipher,
no padding has been requested (only in encryption mode), and the total
input length of the data processed by this cipher is not a multiple of
block size; or if this encryption algorithm is unable to
process the input data provided.
@exception ShortBufferException if the given output buffer is too small
to hold the result
@exception BadPaddingException if this cipher is in decryption mode,
and (un)padding has been requested, but the decrypted data is not
bounded by the appropriate padding bytes
@exception AEADBadTagException if this cipher is decrypting in an
AEAD mode (such as GCM/CCM), and the received authentication tag
does not match the calculated value | [
"Finishes",
"a",
"multiple",
"-",
"part",
"encryption",
"or",
"decryption",
"operation",
"depending",
"on",
"how",
"this",
"cipher",
"was",
"initialized",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L1999-L2011 |
33,143 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.wrap | public final byte[] wrap(Key key)
throws IllegalBlockSizeException, InvalidKeyException {
if (!(this instanceof NullCipher)) {
if (!initialized) {
throw new IllegalStateException("Cipher not initialized");
}
if (opmode != Cipher.WRAP_MODE) {
throw new IllegalStateException("Cipher not initialized " +
"for wrapping keys");
}
}
updateProviderIfNeeded();
return spi.engineWrap(key);
} | java | public final byte[] wrap(Key key)
throws IllegalBlockSizeException, InvalidKeyException {
if (!(this instanceof NullCipher)) {
if (!initialized) {
throw new IllegalStateException("Cipher not initialized");
}
if (opmode != Cipher.WRAP_MODE) {
throw new IllegalStateException("Cipher not initialized " +
"for wrapping keys");
}
}
updateProviderIfNeeded();
return spi.engineWrap(key);
} | [
"public",
"final",
"byte",
"[",
"]",
"wrap",
"(",
"Key",
"key",
")",
"throws",
"IllegalBlockSizeException",
",",
"InvalidKeyException",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"NullCipher",
")",
")",
"{",
"if",
"(",
"!",
"initialized",
")",
"{",
... | Wrap a key.
@param key the key to be wrapped.
@return the wrapped key.
@exception IllegalStateException if this cipher is in a wrong
state (e.g., has not been initialized).
@exception IllegalBlockSizeException if this cipher is a block
cipher, no padding has been requested, and the length of the
encoding of the key to be wrapped is not a
multiple of the block size.
@exception InvalidKeyException if it is impossible or unsafe to
wrap the key with this cipher (e.g., a hardware protected key is
being passed to a software-only cipher). | [
"Wrap",
"a",
"key",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L2380-L2394 |
33,144 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.unwrap | public final Key unwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {
if (!(this instanceof NullCipher)) {
if (!initialized) {
throw new IllegalStateException("Cipher not initialized");
}
if (opmode != Cipher.UNWRAP_MODE) {
throw new IllegalStateException("Cipher not initialized " +
"for unwrapping keys");
}
}
if ((wrappedKeyType != SECRET_KEY) &&
(wrappedKeyType != PRIVATE_KEY) &&
(wrappedKeyType != PUBLIC_KEY)) {
throw new InvalidParameterException("Invalid key type");
}
updateProviderIfNeeded();
return spi.engineUnwrap(wrappedKey,
wrappedKeyAlgorithm,
wrappedKeyType);
} | java | public final Key unwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {
if (!(this instanceof NullCipher)) {
if (!initialized) {
throw new IllegalStateException("Cipher not initialized");
}
if (opmode != Cipher.UNWRAP_MODE) {
throw new IllegalStateException("Cipher not initialized " +
"for unwrapping keys");
}
}
if ((wrappedKeyType != SECRET_KEY) &&
(wrappedKeyType != PRIVATE_KEY) &&
(wrappedKeyType != PUBLIC_KEY)) {
throw new InvalidParameterException("Invalid key type");
}
updateProviderIfNeeded();
return spi.engineUnwrap(wrappedKey,
wrappedKeyAlgorithm,
wrappedKeyType);
} | [
"public",
"final",
"Key",
"unwrap",
"(",
"byte",
"[",
"]",
"wrappedKey",
",",
"String",
"wrappedKeyAlgorithm",
",",
"int",
"wrappedKeyType",
")",
"throws",
"InvalidKeyException",
",",
"NoSuchAlgorithmException",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"N... | Unwrap a previously wrapped key.
@param wrappedKey the key to be unwrapped.
@param wrappedKeyAlgorithm the algorithm associated with the wrapped
key.
@param wrappedKeyType the type of the wrapped key. This must be one of
<code>SECRET_KEY</code>, <code>PRIVATE_KEY</code>, or
<code>PUBLIC_KEY</code>.
@return the unwrapped key.
@exception IllegalStateException if this cipher is in a wrong state
(e.g., has not been initialized).
@exception NoSuchAlgorithmException if no installed providers
can create keys of type <code>wrappedKeyType</code> for the
<code>wrappedKeyAlgorithm</code>.
@exception InvalidKeyException if <code>wrappedKey</code> does not
represent a wrapped key of type <code>wrappedKeyType</code> for
the <code>wrappedKeyAlgorithm</code>. | [
"Unwrap",
"a",
"previously",
"wrapped",
"key",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L2421-L2445 |
33,145 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.getMaxAllowedParameterSpec | public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(
String transformation) throws NoSuchAlgorithmException {
// Android-changed: Remove references to CryptoPermission and throw early
// if transformation == null or isn't valid.
//
// CryptoPermission cp = getConfiguredPermission(transformation);
// return cp.getAlgorithmParameterSpec();
if (transformation == null) {
throw new NullPointerException("transformation == null");
}
// Throws NoSuchAlgorithmException if necessary.
tokenizeTransformation(transformation);
return null;
} | java | public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(
String transformation) throws NoSuchAlgorithmException {
// Android-changed: Remove references to CryptoPermission and throw early
// if transformation == null or isn't valid.
//
// CryptoPermission cp = getConfiguredPermission(transformation);
// return cp.getAlgorithmParameterSpec();
if (transformation == null) {
throw new NullPointerException("transformation == null");
}
// Throws NoSuchAlgorithmException if necessary.
tokenizeTransformation(transformation);
return null;
} | [
"public",
"static",
"final",
"AlgorithmParameterSpec",
"getMaxAllowedParameterSpec",
"(",
"String",
"transformation",
")",
"throws",
"NoSuchAlgorithmException",
"{",
"// Android-changed: Remove references to CryptoPermission and throw early",
"// if transformation == null or isn't valid.",... | Returns an AlgorithmParameterSpec object which contains
the maximum cipher parameter value according to the
jurisdiction policy file. If JCE unlimited strength jurisdiction
policy files are installed or there is no maximum limit on the
parameters for the specified transformation in the policy file,
null will be returned.
@param transformation the cipher transformation.
@return an AlgorithmParameterSpec which holds the maximum
value or null.
@exception NullPointerException if <code>transformation</code>
is null.
@exception NoSuchAlgorithmException if <code>transformation</code>
is not a valid transformation, i.e. in the form of "algorithm" or
"algorithm/mode/padding".
@since 1.5 | [
"Returns",
"an",
"AlgorithmParameterSpec",
"object",
"which",
"contains",
"the",
"maximum",
"cipher",
"parameter",
"value",
"according",
"to",
"the",
"jurisdiction",
"policy",
"file",
".",
"If",
"JCE",
"unlimited",
"strength",
"jurisdiction",
"policy",
"files",
"are... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L2526-L2539 |
33,146 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java | Cipher.matchAttribute | static boolean matchAttribute(Provider.Service service, String attr, String value) {
if (value == null) {
return true;
}
final String pattern = service.getAttribute(attr);
if (pattern == null) {
return true;
}
final String valueUc = value.toUpperCase(Locale.US);
return valueUc.matches(pattern.toUpperCase(Locale.US));
} | java | static boolean matchAttribute(Provider.Service service, String attr, String value) {
if (value == null) {
return true;
}
final String pattern = service.getAttribute(attr);
if (pattern == null) {
return true;
}
final String valueUc = value.toUpperCase(Locale.US);
return valueUc.matches(pattern.toUpperCase(Locale.US));
} | [
"static",
"boolean",
"matchAttribute",
"(",
"Provider",
".",
"Service",
"service",
",",
"String",
"attr",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"final",
"String",
"pattern",
"=",
"servic... | If the attribute listed exists, check that it matches the regular
expression. | [
"If",
"the",
"attribute",
"listed",
"exists",
"check",
"that",
"it",
"matches",
"the",
"regular",
"expression",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L2685-L2695 |
33,147 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/StringTrieBuilder.java | StringTrieBuilder.registerNode | private final Node registerNode(Node newNode) {
if(state==State.BUILDING_FAST) {
return newNode;
}
// BUILDING_SMALL
Node oldNode=nodes.get(newNode);
if(oldNode!=null) {
return oldNode;
}
// If put() returns a non-null value from an equivalent, previously
// registered node, then get() failed to find that and we will leak newNode.
oldNode=nodes.put(newNode, newNode);
assert(oldNode==null);
return newNode;
} | java | private final Node registerNode(Node newNode) {
if(state==State.BUILDING_FAST) {
return newNode;
}
// BUILDING_SMALL
Node oldNode=nodes.get(newNode);
if(oldNode!=null) {
return oldNode;
}
// If put() returns a non-null value from an equivalent, previously
// registered node, then get() failed to find that and we will leak newNode.
oldNode=nodes.put(newNode, newNode);
assert(oldNode==null);
return newNode;
} | [
"private",
"final",
"Node",
"registerNode",
"(",
"Node",
"newNode",
")",
"{",
"if",
"(",
"state",
"==",
"State",
".",
"BUILDING_FAST",
")",
"{",
"return",
"newNode",
";",
"}",
"// BUILDING_SMALL",
"Node",
"oldNode",
"=",
"nodes",
".",
"get",
"(",
"newNode"... | Makes sure that there is only one unique node registered that is
equivalent to newNode, unless BUILDING_FAST.
@param newNode Input node. The builder takes ownership.
@return newNode if it is the first of its kind, or
an equivalent node if newNode is a duplicate. | [
"Makes",
"sure",
"that",
"there",
"is",
"only",
"one",
"unique",
"node",
"registered",
"that",
"is",
"equivalent",
"to",
"newNode",
"unless",
"BUILDING_FAST",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/StringTrieBuilder.java#L139-L153 |
33,148 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/StringTrieBuilder.java | StringTrieBuilder.registerFinalValue | private final ValueNode registerFinalValue(int value) {
// We always register final values because while ADDING
// we do not know yet whether we will build fast or small.
lookupFinalValueNode.setFinalValue(value);
Node oldNode=nodes.get(lookupFinalValueNode);
if(oldNode!=null) {
return (ValueNode)oldNode;
}
ValueNode newNode=new ValueNode(value);
// If put() returns a non-null value from an equivalent, previously
// registered node, then get() failed to find that and we will leak newNode.
oldNode=nodes.put(newNode, newNode);
assert(oldNode==null);
return newNode;
} | java | private final ValueNode registerFinalValue(int value) {
// We always register final values because while ADDING
// we do not know yet whether we will build fast or small.
lookupFinalValueNode.setFinalValue(value);
Node oldNode=nodes.get(lookupFinalValueNode);
if(oldNode!=null) {
return (ValueNode)oldNode;
}
ValueNode newNode=new ValueNode(value);
// If put() returns a non-null value from an equivalent, previously
// registered node, then get() failed to find that and we will leak newNode.
oldNode=nodes.put(newNode, newNode);
assert(oldNode==null);
return newNode;
} | [
"private",
"final",
"ValueNode",
"registerFinalValue",
"(",
"int",
"value",
")",
"{",
"// We always register final values because while ADDING",
"// we do not know yet whether we will build fast or small.",
"lookupFinalValueNode",
".",
"setFinalValue",
"(",
"value",
")",
";",
"No... | Makes sure that there is only one unique FinalValueNode registered
with this value.
Avoids creating a node if the value is a duplicate.
@param value A final value.
@return A FinalValueNode with the given value. | [
"Makes",
"sure",
"that",
"there",
"is",
"only",
"one",
"unique",
"FinalValueNode",
"registered",
"with",
"this",
"value",
".",
"Avoids",
"creating",
"a",
"node",
"if",
"the",
"value",
"is",
"a",
"duplicate",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/StringTrieBuilder.java#L162-L176 |
33,149 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/ProcessorLRE.java | ProcessorLRE.getStylesheetRoot | protected Stylesheet getStylesheetRoot(StylesheetHandler handler) throws TransformerConfigurationException
{
StylesheetRoot stylesheet;
stylesheet = new StylesheetRoot(handler.getSchema(), handler.getStylesheetProcessor().getErrorListener());
if (handler.getStylesheetProcessor().isSecureProcessing())
stylesheet.setSecureProcessing(true);
return stylesheet;
} | java | protected Stylesheet getStylesheetRoot(StylesheetHandler handler) throws TransformerConfigurationException
{
StylesheetRoot stylesheet;
stylesheet = new StylesheetRoot(handler.getSchema(), handler.getStylesheetProcessor().getErrorListener());
if (handler.getStylesheetProcessor().isSecureProcessing())
stylesheet.setSecureProcessing(true);
return stylesheet;
} | [
"protected",
"Stylesheet",
"getStylesheetRoot",
"(",
"StylesheetHandler",
"handler",
")",
"throws",
"TransformerConfigurationException",
"{",
"StylesheetRoot",
"stylesheet",
";",
"stylesheet",
"=",
"new",
"StylesheetRoot",
"(",
"handler",
".",
"getSchema",
"(",
")",
","... | This method could be over-ridden by a class that extends this class.
@param handler non-null reference to current StylesheetHandler that is constructing the Templates.
@return an object that represents the stylesheet element. | [
"This",
"method",
"could",
"be",
"over",
"-",
"ridden",
"by",
"a",
"class",
"that",
"extends",
"this",
"class",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/ProcessorLRE.java#L319-L327 |
33,150 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java | SignatureGenerator.createTypeSignature | public String createTypeSignature(TypeMirror type) {
StringBuilder sb = new StringBuilder();
genTypeSignature(type, sb);
return sb.toString();
} | java | public String createTypeSignature(TypeMirror type) {
StringBuilder sb = new StringBuilder();
genTypeSignature(type, sb);
return sb.toString();
} | [
"public",
"String",
"createTypeSignature",
"(",
"TypeMirror",
"type",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"genTypeSignature",
"(",
"type",
",",
"sb",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Create a signature for a specified type.
@return the signature of the type. | [
"Create",
"a",
"signature",
"for",
"a",
"specified",
"type",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java#L62-L66 |
33,151 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java | SignatureGenerator.createClassSignature | public String createClassSignature(TypeElement type) {
if (!hasGenericSignature(type)) {
return null;
}
StringBuilder sb = new StringBuilder();
genClassSignature(type, sb);
return sb.toString();
} | java | public String createClassSignature(TypeElement type) {
if (!hasGenericSignature(type)) {
return null;
}
StringBuilder sb = new StringBuilder();
genClassSignature(type, sb);
return sb.toString();
} | [
"public",
"String",
"createClassSignature",
"(",
"TypeElement",
"type",
")",
"{",
"if",
"(",
"!",
"hasGenericSignature",
"(",
"type",
")",
")",
"{",
"return",
"null",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"genClassSigna... | Create a class signature string for a specified type.
@return the signature if class is generic, else null. | [
"Create",
"a",
"class",
"signature",
"string",
"for",
"a",
"specified",
"type",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java#L73-L80 |
33,152 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java | SignatureGenerator.createFieldTypeSignature | public String createFieldTypeSignature(VariableElement variable) {
if (!hasGenericSignature(variable.asType())) {
return null;
}
StringBuilder sb = new StringBuilder();
genTypeSignature(variable.asType(), sb);
return sb.toString();
} | java | public String createFieldTypeSignature(VariableElement variable) {
if (!hasGenericSignature(variable.asType())) {
return null;
}
StringBuilder sb = new StringBuilder();
genTypeSignature(variable.asType(), sb);
return sb.toString();
} | [
"public",
"String",
"createFieldTypeSignature",
"(",
"VariableElement",
"variable",
")",
"{",
"if",
"(",
"!",
"hasGenericSignature",
"(",
"variable",
".",
"asType",
"(",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"Stri... | Create a field signature string for a specified variable.
@return the signature if field type is a type variable, else null. | [
"Create",
"a",
"field",
"signature",
"string",
"for",
"a",
"specified",
"variable",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java#L87-L94 |
33,153 | google/j2objc | translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java | SignatureGenerator.createMethodTypeSignature | public String createMethodTypeSignature(ExecutableElement method) {
if (!hasGenericSignature(method)) {
return null;
}
StringBuilder sb = new StringBuilder();
genMethodTypeSignature(method, sb);
return sb.toString();
} | java | public String createMethodTypeSignature(ExecutableElement method) {
if (!hasGenericSignature(method)) {
return null;
}
StringBuilder sb = new StringBuilder();
genMethodTypeSignature(method, sb);
return sb.toString();
} | [
"public",
"String",
"createMethodTypeSignature",
"(",
"ExecutableElement",
"method",
")",
"{",
"if",
"(",
"!",
"hasGenericSignature",
"(",
"method",
")",
")",
"{",
"return",
"null",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
... | Create a method signature string for a specified method or constructor.
@return the signature if method is generic or use type variables, else null. | [
"Create",
"a",
"method",
"signature",
"string",
"for",
"a",
"specified",
"method",
"or",
"constructor",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/gen/SignatureGenerator.java#L101-L108 |
33,154 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/GetInstance.java | GetInstance.checkSuperClass | public static void checkSuperClass(Service s, Class<?> subClass,
Class<?> superClass) throws NoSuchAlgorithmException {
if (superClass == null) {
return;
}
if (superClass.isAssignableFrom(subClass) == false) {
throw new NoSuchAlgorithmException
("class configured for " + s.getType() + ": "
+ s.getClassName() + " not a " + s.getType());
}
} | java | public static void checkSuperClass(Service s, Class<?> subClass,
Class<?> superClass) throws NoSuchAlgorithmException {
if (superClass == null) {
return;
}
if (superClass.isAssignableFrom(subClass) == false) {
throw new NoSuchAlgorithmException
("class configured for " + s.getType() + ": "
+ s.getClassName() + " not a " + s.getType());
}
} | [
"public",
"static",
"void",
"checkSuperClass",
"(",
"Service",
"s",
",",
"Class",
"<",
"?",
">",
"subClass",
",",
"Class",
"<",
"?",
">",
"superClass",
")",
"throws",
"NoSuchAlgorithmException",
"{",
"if",
"(",
"superClass",
"==",
"null",
")",
"{",
"return... | Check is subClass is a subclass of superClass. If not,
throw a NoSuchAlgorithmException. | [
"Check",
"is",
"subClass",
"is",
"a",
"subclass",
"of",
"superClass",
".",
"If",
"not",
"throw",
"a",
"NoSuchAlgorithmException",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/jca/GetInstance.java#L252-L262 |
33,155 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/SignatureSpi.java | SignatureSpi.engineInitSign | protected void engineInitSign(PrivateKey privateKey,
SecureRandom random)
throws InvalidKeyException {
this.appRandom = random;
engineInitSign(privateKey);
} | java | protected void engineInitSign(PrivateKey privateKey,
SecureRandom random)
throws InvalidKeyException {
this.appRandom = random;
engineInitSign(privateKey);
} | [
"protected",
"void",
"engineInitSign",
"(",
"PrivateKey",
"privateKey",
",",
"SecureRandom",
"random",
")",
"throws",
"InvalidKeyException",
"{",
"this",
".",
"appRandom",
"=",
"random",
";",
"engineInitSign",
"(",
"privateKey",
")",
";",
"}"
] | Initializes this signature object with the specified
private key and source of randomness for signing operations.
<p>This concrete method has been added to this previously-defined
abstract class. (For backwards compatibility, it cannot be abstract.)
@param privateKey the private key of the identity whose signature
will be generated.
@param random the source of randomness
@exception InvalidKeyException if the key is improperly
encoded, parameters are missing, and so on. | [
"Initializes",
"this",
"signature",
"object",
"with",
"the",
"specified",
"private",
"key",
"and",
"source",
"of",
"randomness",
"for",
"signing",
"operations",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/SignatureSpi.java#L100-L105 |
33,156 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/StringTokenizer.java | StringTokenizer.setMaxDelimCodePoint | private void setMaxDelimCodePoint() {
if (delimiters == null) {
maxDelimCodePoint = 0;
return;
}
int m = 0;
int c;
int count = 0;
for (int i = 0; i < delimiters.length(); i += Character.charCount(c)) {
c = delimiters.charAt(i);
if (c >= Character.MIN_HIGH_SURROGATE && c <= Character.MAX_LOW_SURROGATE) {
c = delimiters.codePointAt(i);
hasSurrogates = true;
}
if (m < c)
m = c;
count++;
}
maxDelimCodePoint = m;
if (hasSurrogates) {
delimiterCodePoints = new int[count];
for (int i = 0, j = 0; i < count; i++, j += Character.charCount(c)) {
c = delimiters.codePointAt(j);
delimiterCodePoints[i] = c;
}
}
} | java | private void setMaxDelimCodePoint() {
if (delimiters == null) {
maxDelimCodePoint = 0;
return;
}
int m = 0;
int c;
int count = 0;
for (int i = 0; i < delimiters.length(); i += Character.charCount(c)) {
c = delimiters.charAt(i);
if (c >= Character.MIN_HIGH_SURROGATE && c <= Character.MAX_LOW_SURROGATE) {
c = delimiters.codePointAt(i);
hasSurrogates = true;
}
if (m < c)
m = c;
count++;
}
maxDelimCodePoint = m;
if (hasSurrogates) {
delimiterCodePoints = new int[count];
for (int i = 0, j = 0; i < count; i++, j += Character.charCount(c)) {
c = delimiters.codePointAt(j);
delimiterCodePoints[i] = c;
}
}
} | [
"private",
"void",
"setMaxDelimCodePoint",
"(",
")",
"{",
"if",
"(",
"delimiters",
"==",
"null",
")",
"{",
"maxDelimCodePoint",
"=",
"0",
";",
"return",
";",
"}",
"int",
"m",
"=",
"0",
";",
"int",
"c",
";",
"int",
"count",
"=",
"0",
";",
"for",
"("... | Set maxDelimCodePoint to the highest char in the delimiter set. | [
"Set",
"maxDelimCodePoint",
"to",
"the",
"highest",
"char",
"in",
"the",
"delimiter",
"set",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/StringTokenizer.java#L142-L170 |
33,157 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/StringTokenizer.java | StringTokenizer.skipDelimiters | private int skipDelimiters(int startPos) {
if (delimiters == null)
throw new NullPointerException();
int position = startPos;
while (!retDelims && position < maxPosition) {
if (!hasSurrogates) {
char c = str.charAt(position);
if ((c > maxDelimCodePoint) || (delimiters.indexOf(c) < 0))
break;
position++;
} else {
int c = str.codePointAt(position);
if ((c > maxDelimCodePoint) || !isDelimiter(c)) {
break;
}
position += Character.charCount(c);
}
}
return position;
} | java | private int skipDelimiters(int startPos) {
if (delimiters == null)
throw new NullPointerException();
int position = startPos;
while (!retDelims && position < maxPosition) {
if (!hasSurrogates) {
char c = str.charAt(position);
if ((c > maxDelimCodePoint) || (delimiters.indexOf(c) < 0))
break;
position++;
} else {
int c = str.codePointAt(position);
if ((c > maxDelimCodePoint) || !isDelimiter(c)) {
break;
}
position += Character.charCount(c);
}
}
return position;
} | [
"private",
"int",
"skipDelimiters",
"(",
"int",
"startPos",
")",
"{",
"if",
"(",
"delimiters",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"int",
"position",
"=",
"startPos",
";",
"while",
"(",
"!",
"retDelims",
"&&",
"positio... | Skips delimiters starting from the specified position. If retDelims
is false, returns the index of the first non-delimiter character at or
after startPos. If retDelims is true, startPos is returned. | [
"Skips",
"delimiters",
"starting",
"from",
"the",
"specified",
"position",
".",
"If",
"retDelims",
"is",
"false",
"returns",
"the",
"index",
"of",
"the",
"first",
"non",
"-",
"delimiter",
"character",
"at",
"or",
"after",
"startPos",
".",
"If",
"retDelims",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/StringTokenizer.java#L244-L264 |
33,158 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/StringTokenizer.java | StringTokenizer.scanToken | private int scanToken(int startPos) {
int position = startPos;
while (position < maxPosition) {
if (!hasSurrogates) {
char c = str.charAt(position);
if ((c <= maxDelimCodePoint) && (delimiters.indexOf(c) >= 0))
break;
position++;
} else {
int c = str.codePointAt(position);
if ((c <= maxDelimCodePoint) && isDelimiter(c))
break;
position += Character.charCount(c);
}
}
if (retDelims && (startPos == position)) {
if (!hasSurrogates) {
char c = str.charAt(position);
if ((c <= maxDelimCodePoint) && (delimiters.indexOf(c) >= 0))
position++;
} else {
int c = str.codePointAt(position);
if ((c <= maxDelimCodePoint) && isDelimiter(c))
position += Character.charCount(c);
}
}
return position;
} | java | private int scanToken(int startPos) {
int position = startPos;
while (position < maxPosition) {
if (!hasSurrogates) {
char c = str.charAt(position);
if ((c <= maxDelimCodePoint) && (delimiters.indexOf(c) >= 0))
break;
position++;
} else {
int c = str.codePointAt(position);
if ((c <= maxDelimCodePoint) && isDelimiter(c))
break;
position += Character.charCount(c);
}
}
if (retDelims && (startPos == position)) {
if (!hasSurrogates) {
char c = str.charAt(position);
if ((c <= maxDelimCodePoint) && (delimiters.indexOf(c) >= 0))
position++;
} else {
int c = str.codePointAt(position);
if ((c <= maxDelimCodePoint) && isDelimiter(c))
position += Character.charCount(c);
}
}
return position;
} | [
"private",
"int",
"scanToken",
"(",
"int",
"startPos",
")",
"{",
"int",
"position",
"=",
"startPos",
";",
"while",
"(",
"position",
"<",
"maxPosition",
")",
"{",
"if",
"(",
"!",
"hasSurrogates",
")",
"{",
"char",
"c",
"=",
"str",
".",
"charAt",
"(",
... | Skips ahead from startPos and returns the index of the next delimiter
character encountered, or maxPosition if no such delimiter is found. | [
"Skips",
"ahead",
"from",
"startPos",
"and",
"returns",
"the",
"index",
"of",
"the",
"next",
"delimiter",
"character",
"encountered",
"or",
"maxPosition",
"if",
"no",
"such",
"delimiter",
"is",
"found",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/StringTokenizer.java#L270-L297 |
33,159 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/ReasonFlags.java | ReasonFlags.set | private void set(int position, boolean val) {
// enlarge bitString if necessary
if (position >= bitString.length) {
boolean[] tmp = new boolean[position+1];
System.arraycopy(bitString, 0, tmp, 0, bitString.length);
bitString = tmp;
}
bitString[position] = val;
} | java | private void set(int position, boolean val) {
// enlarge bitString if necessary
if (position >= bitString.length) {
boolean[] tmp = new boolean[position+1];
System.arraycopy(bitString, 0, tmp, 0, bitString.length);
bitString = tmp;
}
bitString[position] = val;
} | [
"private",
"void",
"set",
"(",
"int",
"position",
",",
"boolean",
"val",
")",
"{",
"// enlarge bitString if necessary",
"if",
"(",
"position",
">=",
"bitString",
".",
"length",
")",
"{",
"boolean",
"[",
"]",
"tmp",
"=",
"new",
"boolean",
"[",
"position",
"... | Set the bit at the specified position. | [
"Set",
"the",
"bit",
"at",
"the",
"specified",
"position",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/ReasonFlags.java#L109-L117 |
33,160 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.makeRules | public static void makeRules(String description,
NFRuleSet owner,
NFRule predecessor,
RuleBasedNumberFormat ownersOwner,
List<NFRule> returnList) {
// we know we're making at least one rule, so go ahead and
// new it up and initialize its basevalue and divisor
// (this also strips the rule descriptor, if any, off the
// description string)
NFRule rule1 = new NFRule(ownersOwner, description);
description = rule1.ruleText;
// check the description to see whether there's text enclosed
// in brackets
int brack1 = description.indexOf('[');
int brack2 = brack1 < 0 ? -1 : description.indexOf(']');
// if the description doesn't contain a matched pair of brackets,
// or if it's of a type that doesn't recognize bracketed text,
// then leave the description alone, initialize the rule's
// rule text and substitutions, and return that rule
if (brack2 < 0 || brack1 > brack2
|| rule1.baseValue == PROPER_FRACTION_RULE
|| rule1.baseValue == NEGATIVE_NUMBER_RULE
|| rule1.baseValue == INFINITY_RULE
|| rule1.baseValue == NAN_RULE)
{
rule1.extractSubstitutions(owner, description, predecessor);
}
else {
// if the description does contain a matched pair of brackets,
// then it's really shorthand for two rules (with one exception)
NFRule rule2 = null;
StringBuilder sbuf = new StringBuilder();
// we'll actually only split the rule into two rules if its
// base value is an even multiple of its divisor (or it's one
// of the special rules)
if ((rule1.baseValue > 0
&& rule1.baseValue % (power(rule1.radix, rule1.exponent)) == 0)
|| rule1.baseValue == IMPROPER_FRACTION_RULE
|| rule1.baseValue == MASTER_RULE)
{
// if it passes that test, new up the second rule. If the
// rule set both rules will belong to is a fraction rule
// set, they both have the same base value; otherwise,
// increment the original rule's base value ("rule1" actually
// goes SECOND in the rule set's rule list)
rule2 = new NFRule(ownersOwner, null);
if (rule1.baseValue >= 0) {
rule2.baseValue = rule1.baseValue;
if (!owner.isFractionSet()) {
++rule1.baseValue;
}
}
else if (rule1.baseValue == IMPROPER_FRACTION_RULE) {
// if the description began with "x.x" and contains bracketed
// text, it describes both the improper fraction rule and
// the proper fraction rule
rule2.baseValue = PROPER_FRACTION_RULE;
}
else if (rule1.baseValue == MASTER_RULE) {
// if the description began with "x.0" and contains bracketed
// text, it describes both the master rule and the
// improper fraction rule
rule2.baseValue = rule1.baseValue;
rule1.baseValue = IMPROPER_FRACTION_RULE;
}
// both rules have the same radix and exponent (i.e., the
// same divisor)
rule2.radix = rule1.radix;
rule2.exponent = rule1.exponent;
// rule2's rule text omits the stuff in brackets: initialize
// its rule text and substitutions accordingly
sbuf.append(description.substring(0, brack1));
if (brack2 + 1 < description.length()) {
sbuf.append(description.substring(brack2 + 1));
}
rule2.extractSubstitutions(owner, sbuf.toString(), predecessor);
}
// rule1's text includes the text in the brackets but omits
// the brackets themselves: initialize _its_ rule text and
// substitutions accordingly
sbuf.setLength(0);
sbuf.append(description.substring(0, brack1));
sbuf.append(description.substring(brack1 + 1, brack2));
if (brack2 + 1 < description.length()) {
sbuf.append(description.substring(brack2 + 1));
}
rule1.extractSubstitutions(owner, sbuf.toString(), predecessor);
// if we only have one rule, return it; if we have two, return
// a two-element array containing them (notice that rule2 goes
// BEFORE rule1 in the list: in all cases, rule2 OMITS the
// material in the brackets and rule1 INCLUDES the material
// in the brackets)
if (rule2 != null) {
if (rule2.baseValue >= 0) {
returnList.add(rule2);
}
else {
owner.setNonNumericalRule(rule2);
}
}
}
if (rule1.baseValue >= 0) {
returnList.add(rule1);
}
else {
owner.setNonNumericalRule(rule1);
}
} | java | public static void makeRules(String description,
NFRuleSet owner,
NFRule predecessor,
RuleBasedNumberFormat ownersOwner,
List<NFRule> returnList) {
// we know we're making at least one rule, so go ahead and
// new it up and initialize its basevalue and divisor
// (this also strips the rule descriptor, if any, off the
// description string)
NFRule rule1 = new NFRule(ownersOwner, description);
description = rule1.ruleText;
// check the description to see whether there's text enclosed
// in brackets
int brack1 = description.indexOf('[');
int brack2 = brack1 < 0 ? -1 : description.indexOf(']');
// if the description doesn't contain a matched pair of brackets,
// or if it's of a type that doesn't recognize bracketed text,
// then leave the description alone, initialize the rule's
// rule text and substitutions, and return that rule
if (brack2 < 0 || brack1 > brack2
|| rule1.baseValue == PROPER_FRACTION_RULE
|| rule1.baseValue == NEGATIVE_NUMBER_RULE
|| rule1.baseValue == INFINITY_RULE
|| rule1.baseValue == NAN_RULE)
{
rule1.extractSubstitutions(owner, description, predecessor);
}
else {
// if the description does contain a matched pair of brackets,
// then it's really shorthand for two rules (with one exception)
NFRule rule2 = null;
StringBuilder sbuf = new StringBuilder();
// we'll actually only split the rule into two rules if its
// base value is an even multiple of its divisor (or it's one
// of the special rules)
if ((rule1.baseValue > 0
&& rule1.baseValue % (power(rule1.radix, rule1.exponent)) == 0)
|| rule1.baseValue == IMPROPER_FRACTION_RULE
|| rule1.baseValue == MASTER_RULE)
{
// if it passes that test, new up the second rule. If the
// rule set both rules will belong to is a fraction rule
// set, they both have the same base value; otherwise,
// increment the original rule's base value ("rule1" actually
// goes SECOND in the rule set's rule list)
rule2 = new NFRule(ownersOwner, null);
if (rule1.baseValue >= 0) {
rule2.baseValue = rule1.baseValue;
if (!owner.isFractionSet()) {
++rule1.baseValue;
}
}
else if (rule1.baseValue == IMPROPER_FRACTION_RULE) {
// if the description began with "x.x" and contains bracketed
// text, it describes both the improper fraction rule and
// the proper fraction rule
rule2.baseValue = PROPER_FRACTION_RULE;
}
else if (rule1.baseValue == MASTER_RULE) {
// if the description began with "x.0" and contains bracketed
// text, it describes both the master rule and the
// improper fraction rule
rule2.baseValue = rule1.baseValue;
rule1.baseValue = IMPROPER_FRACTION_RULE;
}
// both rules have the same radix and exponent (i.e., the
// same divisor)
rule2.radix = rule1.radix;
rule2.exponent = rule1.exponent;
// rule2's rule text omits the stuff in brackets: initialize
// its rule text and substitutions accordingly
sbuf.append(description.substring(0, brack1));
if (brack2 + 1 < description.length()) {
sbuf.append(description.substring(brack2 + 1));
}
rule2.extractSubstitutions(owner, sbuf.toString(), predecessor);
}
// rule1's text includes the text in the brackets but omits
// the brackets themselves: initialize _its_ rule text and
// substitutions accordingly
sbuf.setLength(0);
sbuf.append(description.substring(0, brack1));
sbuf.append(description.substring(brack1 + 1, brack2));
if (brack2 + 1 < description.length()) {
sbuf.append(description.substring(brack2 + 1));
}
rule1.extractSubstitutions(owner, sbuf.toString(), predecessor);
// if we only have one rule, return it; if we have two, return
// a two-element array containing them (notice that rule2 goes
// BEFORE rule1 in the list: in all cases, rule2 OMITS the
// material in the brackets and rule1 INCLUDES the material
// in the brackets)
if (rule2 != null) {
if (rule2.baseValue >= 0) {
returnList.add(rule2);
}
else {
owner.setNonNumericalRule(rule2);
}
}
}
if (rule1.baseValue >= 0) {
returnList.add(rule1);
}
else {
owner.setNonNumericalRule(rule1);
}
} | [
"public",
"static",
"void",
"makeRules",
"(",
"String",
"description",
",",
"NFRuleSet",
"owner",
",",
"NFRule",
"predecessor",
",",
"RuleBasedNumberFormat",
"ownersOwner",
",",
"List",
"<",
"NFRule",
">",
"returnList",
")",
"{",
"// we know we're making at least one ... | Creates one or more rules based on the description passed in.
@param description The description of the rule(s).
@param owner The rule set containing the new rule(s).
@param predecessor The rule that precedes the new one(s) in "owner"'s
rule list
@param ownersOwner The RuleBasedNumberFormat that owns the
rule set that owns the new rule(s)
@param returnList One or more instances of NFRule are added and returned here | [
"Creates",
"one",
"or",
"more",
"rules",
"based",
"on",
"the",
"description",
"passed",
"in",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L134-L249 |
33,161 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.extractSubstitutions | private void extractSubstitutions(NFRuleSet owner,
String ruleText,
NFRule predecessor) {
this.ruleText = ruleText;
sub1 = extractSubstitution(owner, predecessor);
if (sub1 == null) {
// Small optimization. There is no need to create a redundant NullSubstitution.
sub2 = null;
}
else {
sub2 = extractSubstitution(owner, predecessor);
}
ruleText = this.ruleText;
int pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = (pluralRuleStart >= 0 ? ruleText.indexOf(")$", pluralRuleStart) : -1);
if (pluralRuleEnd >= 0) {
int endType = ruleText.indexOf(',', pluralRuleStart);
if (endType < 0) {
throw new IllegalArgumentException("Rule \"" + ruleText + "\" does not have a defined type");
}
String type = this.ruleText.substring(pluralRuleStart + 2, endType);
PluralRules.PluralType pluralType;
if ("cardinal".equals(type)) {
pluralType = PluralRules.PluralType.CARDINAL;
}
else if ("ordinal".equals(type)) {
pluralType = PluralRules.PluralType.ORDINAL;
}
else {
throw new IllegalArgumentException(type + " is an unknown type");
}
rulePatternFormat = formatter.createPluralFormat(pluralType,
ruleText.substring(endType + 1, pluralRuleEnd));
}
} | java | private void extractSubstitutions(NFRuleSet owner,
String ruleText,
NFRule predecessor) {
this.ruleText = ruleText;
sub1 = extractSubstitution(owner, predecessor);
if (sub1 == null) {
// Small optimization. There is no need to create a redundant NullSubstitution.
sub2 = null;
}
else {
sub2 = extractSubstitution(owner, predecessor);
}
ruleText = this.ruleText;
int pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = (pluralRuleStart >= 0 ? ruleText.indexOf(")$", pluralRuleStart) : -1);
if (pluralRuleEnd >= 0) {
int endType = ruleText.indexOf(',', pluralRuleStart);
if (endType < 0) {
throw new IllegalArgumentException("Rule \"" + ruleText + "\" does not have a defined type");
}
String type = this.ruleText.substring(pluralRuleStart + 2, endType);
PluralRules.PluralType pluralType;
if ("cardinal".equals(type)) {
pluralType = PluralRules.PluralType.CARDINAL;
}
else if ("ordinal".equals(type)) {
pluralType = PluralRules.PluralType.ORDINAL;
}
else {
throw new IllegalArgumentException(type + " is an unknown type");
}
rulePatternFormat = formatter.createPluralFormat(pluralType,
ruleText.substring(endType + 1, pluralRuleEnd));
}
} | [
"private",
"void",
"extractSubstitutions",
"(",
"NFRuleSet",
"owner",
",",
"String",
"ruleText",
",",
"NFRule",
"predecessor",
")",
"{",
"this",
".",
"ruleText",
"=",
"ruleText",
";",
"sub1",
"=",
"extractSubstitution",
"(",
"owner",
",",
"predecessor",
")",
"... | Searches the rule's rule text for the substitution tokens,
creates the substitutions, and removes the substitution tokens
from the rule's rule text.
@param owner The rule set containing this rule
@param predecessor The rule preceding this one in "owners" rule list
@param ruleText The rule text | [
"Searches",
"the",
"rule",
"s",
"rule",
"text",
"for",
"the",
"substitution",
"tokens",
"creates",
"the",
"substitutions",
"and",
"removes",
"the",
"substitution",
"tokens",
"from",
"the",
"rule",
"s",
"rule",
"text",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L417-L451 |
33,162 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.extractSubstitution | private NFSubstitution extractSubstitution(NFRuleSet owner,
NFRule predecessor) {
NFSubstitution result;
int subStart;
int subEnd;
// search the rule's rule text for the first two characters of
// a substitution token
subStart = indexOfAnyRulePrefix(ruleText);
// if we didn't find one, create a null substitution positioned
// at the end of the rule text
if (subStart == -1) {
return null;
}
// special-case the ">>>" token, since searching for the > at the
// end will actually find the > in the middle
if (ruleText.startsWith(">>>", subStart)) {
subEnd = subStart + 2;
}
else {
// otherwise the substitution token ends with the same character
// it began with
char c = ruleText.charAt(subStart);
subEnd = ruleText.indexOf(c, subStart + 1);
// special case for '<%foo<<'
if (c == '<' && subEnd != -1 && subEnd < ruleText.length() - 1 && ruleText.charAt(subEnd+1) == c) {
// ordinals use "=#,##0==%abbrev=" as their rule. Notice that the '==' in the middle
// occurs because of the juxtaposition of two different rules. The check for '<' is a hack
// to get around this. Having the duplicate at the front would cause problems with
// rules like "<<%" to format, say, percents...
++subEnd;
}
}
// if we don't find the end of the token (i.e., if we're on a single,
// unmatched token character), create a null substitution positioned
// at the end of the rule
if (subEnd == -1) {
return null;
}
// if we get here, we have a real substitution token (or at least
// some text bounded by substitution token characters). Use
// makeSubstitution() to create the right kind of substitution
result = NFSubstitution.makeSubstitution(subStart, this, predecessor, owner,
this.formatter, ruleText.substring(subStart, subEnd + 1));
// remove the substitution from the rule text
ruleText = ruleText.substring(0, subStart) + ruleText.substring(subEnd + 1);
return result;
} | java | private NFSubstitution extractSubstitution(NFRuleSet owner,
NFRule predecessor) {
NFSubstitution result;
int subStart;
int subEnd;
// search the rule's rule text for the first two characters of
// a substitution token
subStart = indexOfAnyRulePrefix(ruleText);
// if we didn't find one, create a null substitution positioned
// at the end of the rule text
if (subStart == -1) {
return null;
}
// special-case the ">>>" token, since searching for the > at the
// end will actually find the > in the middle
if (ruleText.startsWith(">>>", subStart)) {
subEnd = subStart + 2;
}
else {
// otherwise the substitution token ends with the same character
// it began with
char c = ruleText.charAt(subStart);
subEnd = ruleText.indexOf(c, subStart + 1);
// special case for '<%foo<<'
if (c == '<' && subEnd != -1 && subEnd < ruleText.length() - 1 && ruleText.charAt(subEnd+1) == c) {
// ordinals use "=#,##0==%abbrev=" as their rule. Notice that the '==' in the middle
// occurs because of the juxtaposition of two different rules. The check for '<' is a hack
// to get around this. Having the duplicate at the front would cause problems with
// rules like "<<%" to format, say, percents...
++subEnd;
}
}
// if we don't find the end of the token (i.e., if we're on a single,
// unmatched token character), create a null substitution positioned
// at the end of the rule
if (subEnd == -1) {
return null;
}
// if we get here, we have a real substitution token (or at least
// some text bounded by substitution token characters). Use
// makeSubstitution() to create the right kind of substitution
result = NFSubstitution.makeSubstitution(subStart, this, predecessor, owner,
this.formatter, ruleText.substring(subStart, subEnd + 1));
// remove the substitution from the rule text
ruleText = ruleText.substring(0, subStart) + ruleText.substring(subEnd + 1);
return result;
} | [
"private",
"NFSubstitution",
"extractSubstitution",
"(",
"NFRuleSet",
"owner",
",",
"NFRule",
"predecessor",
")",
"{",
"NFSubstitution",
"result",
";",
"int",
"subStart",
";",
"int",
"subEnd",
";",
"// search the rule's rule text for the first two characters of",
"// a subs... | Searches the rule's rule text for the first substitution token,
creates a substitution based on it, and removes the token from
the rule's rule text.
@param owner The rule set containing this rule
@param predecessor The rule preceding this one in the rule set's
rule list
@return The newly-created substitution. This is never null; if
the rule text doesn't contain any substitution tokens, this will
be a NullSubstitution. | [
"Searches",
"the",
"rule",
"s",
"rule",
"text",
"for",
"the",
"first",
"substitution",
"token",
"creates",
"a",
"substitution",
"based",
"on",
"it",
"and",
"removes",
"the",
"token",
"from",
"the",
"rule",
"s",
"rule",
"text",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L464-L516 |
33,163 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.setBaseValue | final void setBaseValue(long newBaseValue) {
// set the base value
baseValue = newBaseValue;
radix = 10;
// if this isn't a special rule, recalculate the radix and exponent
// (the radix always defaults to 10; if it's supposed to be something
// else, it's cleaned up by the caller and the exponent is
// recalculated again-- the only function that does this is
// NFRule.parseRuleDescriptor() )
if (baseValue >= 1) {
exponent = expectedExponent();
// this function gets called on a fully-constructed rule whose
// description didn't specify a base value. This means it
// has substitutions, and some substitutions hold on to copies
// of the rule's divisor. Fix their copies of the divisor.
if (sub1 != null) {
sub1.setDivisor(radix, exponent);
}
if (sub2 != null) {
sub2.setDivisor(radix, exponent);
}
}
else {
// if this is a special rule, its radix and exponent are basically
// ignored. Set them to "safe" default values
exponent = 0;
}
} | java | final void setBaseValue(long newBaseValue) {
// set the base value
baseValue = newBaseValue;
radix = 10;
// if this isn't a special rule, recalculate the radix and exponent
// (the radix always defaults to 10; if it's supposed to be something
// else, it's cleaned up by the caller and the exponent is
// recalculated again-- the only function that does this is
// NFRule.parseRuleDescriptor() )
if (baseValue >= 1) {
exponent = expectedExponent();
// this function gets called on a fully-constructed rule whose
// description didn't specify a base value. This means it
// has substitutions, and some substitutions hold on to copies
// of the rule's divisor. Fix their copies of the divisor.
if (sub1 != null) {
sub1.setDivisor(radix, exponent);
}
if (sub2 != null) {
sub2.setDivisor(radix, exponent);
}
}
else {
// if this is a special rule, its radix and exponent are basically
// ignored. Set them to "safe" default values
exponent = 0;
}
} | [
"final",
"void",
"setBaseValue",
"(",
"long",
"newBaseValue",
")",
"{",
"// set the base value",
"baseValue",
"=",
"newBaseValue",
";",
"radix",
"=",
"10",
";",
"// if this isn't a special rule, recalculate the radix and exponent",
"// (the radix always defaults to 10; if it's su... | Sets the rule's base value, and causes the radix and exponent
to be recalculated. This is used during construction when we
don't know the rule's base value until after it's been
constructed. It should not be used at any other time.
@param newBaseValue The new base value for the rule. | [
"Sets",
"the",
"rule",
"s",
"base",
"value",
"and",
"causes",
"the",
"radix",
"and",
"exponent",
"to",
"be",
"recalculated",
".",
"This",
"is",
"used",
"during",
"construction",
"when",
"we",
"don",
"t",
"know",
"the",
"rule",
"s",
"base",
"value",
"unti... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L525-L554 |
33,164 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.expectedExponent | private short expectedExponent() {
// since the log of 0, or the log base 0 of something, causes an
// error, declare the exponent in these cases to be 0 (we also
// deal with the special-rule identifiers here)
if (radix == 0 || baseValue < 1) {
return 0;
}
// we get rounding error in some cases-- for example, log 1000 / log 10
// gives us 1.9999999996 instead of 2. The extra logic here is to take
// that into account
short tempResult = (short)(Math.log(baseValue) / Math.log(radix));
if (power(radix, (short)(tempResult + 1)) <= baseValue) {
return (short)(tempResult + 1);
} else {
return tempResult;
}
} | java | private short expectedExponent() {
// since the log of 0, or the log base 0 of something, causes an
// error, declare the exponent in these cases to be 0 (we also
// deal with the special-rule identifiers here)
if (radix == 0 || baseValue < 1) {
return 0;
}
// we get rounding error in some cases-- for example, log 1000 / log 10
// gives us 1.9999999996 instead of 2. The extra logic here is to take
// that into account
short tempResult = (short)(Math.log(baseValue) / Math.log(radix));
if (power(radix, (short)(tempResult + 1)) <= baseValue) {
return (short)(tempResult + 1);
} else {
return tempResult;
}
} | [
"private",
"short",
"expectedExponent",
"(",
")",
"{",
"// since the log of 0, or the log base 0 of something, causes an",
"// error, declare the exponent in these cases to be 0 (we also",
"// deal with the special-rule identifiers here)",
"if",
"(",
"radix",
"==",
"0",
"||",
"baseValu... | This calculates the rule's exponent based on its radix and base
value. This will be the highest power the radix can be raised to
and still produce a result less than or equal to the base value. | [
"This",
"calculates",
"the",
"rule",
"s",
"exponent",
"based",
"on",
"its",
"radix",
"and",
"base",
"value",
".",
"This",
"will",
"be",
"the",
"highest",
"power",
"the",
"radix",
"can",
"be",
"raised",
"to",
"and",
"still",
"produce",
"a",
"result",
"les... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L561-L578 |
33,165 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.indexOfAnyRulePrefix | private static int indexOfAnyRulePrefix(String ruleText) {
int result = -1;
if (ruleText.length() > 0) {
int pos;
for (String string : RULE_PREFIXES) {
pos = ruleText.indexOf(string);
if (pos != -1 && (result == -1 || pos < result)) {
result = pos;
}
}
}
return result;
} | java | private static int indexOfAnyRulePrefix(String ruleText) {
int result = -1;
if (ruleText.length() > 0) {
int pos;
for (String string : RULE_PREFIXES) {
pos = ruleText.indexOf(string);
if (pos != -1 && (result == -1 || pos < result)) {
result = pos;
}
}
}
return result;
} | [
"private",
"static",
"int",
"indexOfAnyRulePrefix",
"(",
"String",
"ruleText",
")",
"{",
"int",
"result",
"=",
"-",
"1",
";",
"if",
"(",
"ruleText",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"int",
"pos",
";",
"for",
"(",
"String",
"string",
":",
... | Searches the rule's rule text for any of the specified strings.
@return The index of the first match in the rule's rule text
(i.e., the first substring in the rule's rule text that matches
_any_ of the strings in "strings"). If none of the strings in
"strings" is found in the rule's rule text, returns -1. | [
"Searches",
"the",
"rule",
"s",
"rule",
"text",
"for",
"any",
"of",
"the",
"specified",
"strings",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L593-L605 |
33,166 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.doFormat | public void doFormat(double number, StringBuilder toInsertInto, int pos, int recursionCount) {
// first, insert the rule's rule text into toInsertInto at the
// specified position, then insert the results of the substitutions
// into the right places in toInsertInto
// [again, we have two copies of this routine that do the same thing
// so that we don't sacrifice precision in a long by casting it
// to a double]
int pluralRuleStart = ruleText.length();
int lengthOffset = 0;
if (rulePatternFormat == null) {
toInsertInto.insert(pos, ruleText);
}
else {
pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = ruleText.indexOf(")$", pluralRuleStart);
int initialLength = toInsertInto.length();
if (pluralRuleEnd < ruleText.length() - 1) {
toInsertInto.insert(pos, ruleText.substring(pluralRuleEnd + 2));
}
double pluralVal = number;
if (0 <= pluralVal && pluralVal < 1) {
// We're in a fractional rule, and we have to match the NumeratorSubstitution behavior.
// 2.3 can become 0.2999999999999998 for the fraction due to rounding errors.
pluralVal = Math.round(pluralVal * power(radix, exponent));
}
else {
pluralVal = pluralVal / power(radix, exponent);
}
toInsertInto.insert(pos, rulePatternFormat.format((long)(pluralVal)));
if (pluralRuleStart > 0) {
toInsertInto.insert(pos, ruleText.substring(0, pluralRuleStart));
}
lengthOffset = ruleText.length() - (toInsertInto.length() - initialLength);
}
if (sub2 != null) {
sub2.doSubstitution(number, toInsertInto, pos - (sub2.getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount);
}
if (sub1 != null) {
sub1.doSubstitution(number, toInsertInto, pos - (sub1.getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount);
}
} | java | public void doFormat(double number, StringBuilder toInsertInto, int pos, int recursionCount) {
// first, insert the rule's rule text into toInsertInto at the
// specified position, then insert the results of the substitutions
// into the right places in toInsertInto
// [again, we have two copies of this routine that do the same thing
// so that we don't sacrifice precision in a long by casting it
// to a double]
int pluralRuleStart = ruleText.length();
int lengthOffset = 0;
if (rulePatternFormat == null) {
toInsertInto.insert(pos, ruleText);
}
else {
pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = ruleText.indexOf(")$", pluralRuleStart);
int initialLength = toInsertInto.length();
if (pluralRuleEnd < ruleText.length() - 1) {
toInsertInto.insert(pos, ruleText.substring(pluralRuleEnd + 2));
}
double pluralVal = number;
if (0 <= pluralVal && pluralVal < 1) {
// We're in a fractional rule, and we have to match the NumeratorSubstitution behavior.
// 2.3 can become 0.2999999999999998 for the fraction due to rounding errors.
pluralVal = Math.round(pluralVal * power(radix, exponent));
}
else {
pluralVal = pluralVal / power(radix, exponent);
}
toInsertInto.insert(pos, rulePatternFormat.format((long)(pluralVal)));
if (pluralRuleStart > 0) {
toInsertInto.insert(pos, ruleText.substring(0, pluralRuleStart));
}
lengthOffset = ruleText.length() - (toInsertInto.length() - initialLength);
}
if (sub2 != null) {
sub2.doSubstitution(number, toInsertInto, pos - (sub2.getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount);
}
if (sub1 != null) {
sub1.doSubstitution(number, toInsertInto, pos - (sub1.getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount);
}
} | [
"public",
"void",
"doFormat",
"(",
"double",
"number",
",",
"StringBuilder",
"toInsertInto",
",",
"int",
"pos",
",",
"int",
"recursionCount",
")",
"{",
"// first, insert the rule's rule text into toInsertInto at the",
"// specified position, then insert the results of the substit... | Formats the number, and inserts the resulting text into
toInsertInto.
@param number The number being formatted
@param toInsertInto The string where the resultant text should
be inserted
@param pos The position in toInsertInto where the resultant text
should be inserted | [
"Formats",
"the",
"number",
"and",
"inserts",
"the",
"resulting",
"text",
"into",
"toInsertInto",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L787-L827 |
33,167 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.power | static long power(long base, short exponent) {
if (exponent < 0) {
throw new IllegalArgumentException("Exponent can not be negative");
}
if (base < 0) {
throw new IllegalArgumentException("Base can not be negative");
}
long result = 1;
while (exponent > 0) {
if ((exponent & 1) == 1) {
result *= base;
}
base *= base;
exponent >>= 1;
}
return result;
} | java | static long power(long base, short exponent) {
if (exponent < 0) {
throw new IllegalArgumentException("Exponent can not be negative");
}
if (base < 0) {
throw new IllegalArgumentException("Base can not be negative");
}
long result = 1;
while (exponent > 0) {
if ((exponent & 1) == 1) {
result *= base;
}
base *= base;
exponent >>= 1;
}
return result;
} | [
"static",
"long",
"power",
"(",
"long",
"base",
",",
"short",
"exponent",
")",
"{",
"if",
"(",
"exponent",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Exponent can not be negative\"",
")",
";",
"}",
"if",
"(",
"base",
"<",
"0",
... | This is an equivalent to Math.pow that accurately works on 64-bit numbers
@param base The base
@param exponent The exponent
@return radix ** exponent
@see Math#pow(double, double) | [
"This",
"is",
"an",
"equivalent",
"to",
"Math",
".",
"pow",
"that",
"accurately",
"works",
"on",
"64",
"-",
"bit",
"numbers"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L836-L852 |
33,168 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.doParse | public Number doParse(String text, ParsePosition parsePosition, boolean isFractionRule,
double upperBound) {
// internally we operate on a copy of the string being parsed
// (because we're going to change it) and use our own ParsePosition
ParsePosition pp = new ParsePosition(0);
// check to see whether the text before the first substitution
// matches the text at the beginning of the string being
// parsed. If it does, strip that off the front of workText;
// otherwise, dump out with a mismatch
int sub1Pos = sub1 != null ? sub1.getPos() : ruleText.length();
int sub2Pos = sub2 != null ? sub2.getPos() : ruleText.length();
String workText = stripPrefix(text, ruleText.substring(0, sub1Pos), pp);
int prefixLength = text.length() - workText.length();
if (pp.getIndex() == 0 && sub1Pos != 0) {
// commented out because ParsePosition doesn't have error index in 1.1.x
// parsePosition.setErrorIndex(pp.getErrorIndex());
return ZERO;
}
if (baseValue == INFINITY_RULE) {
// If you match this, don't try to perform any calculations on it.
parsePosition.setIndex(pp.getIndex());
return Double.POSITIVE_INFINITY;
}
if (baseValue == NAN_RULE) {
// If you match this, don't try to perform any calculations on it.
parsePosition.setIndex(pp.getIndex());
return Double.NaN;
}
// this is the fun part. The basic guts of the rule-matching
// logic is matchToDelimiter(), which is called twice. The first
// time it searches the input string for the rule text BETWEEN
// the substitutions and tries to match the intervening text
// in the input string with the first substitution. If that
// succeeds, it then calls it again, this time to look for the
// rule text after the second substitution and to match the
// intervening input text against the second substitution.
//
// For example, say we have a rule that looks like this:
// first << middle >> last;
// and input text that looks like this:
// first one middle two last
// First we use stripPrefix() to match "first " in both places and
// strip it off the front, leaving
// one middle two last
// Then we use matchToDelimiter() to match " middle " and try to
// match "one" against a substitution. If it's successful, we now
// have
// two last
// We use matchToDelimiter() a second time to match " last" and
// try to match "two" against a substitution. If "two" matches
// the substitution, we have a successful parse.
//
// Since it's possible in many cases to find multiple instances
// of each of these pieces of rule text in the input string,
// we need to try all the possible combinations of these
// locations. This prevents us from prematurely declaring a mismatch,
// and makes sure we match as much input text as we can.
int highWaterMark = 0;
double result = 0;
int start = 0;
double tempBaseValue = Math.max(0, baseValue);
do {
// our partial parse result starts out as this rule's base
// value. If it finds a successful match, matchToDelimiter()
// will compose this in some way with what it gets back from
// the substitution, giving us a new partial parse result
pp.setIndex(0);
double partialResult = matchToDelimiter(workText, start, tempBaseValue,
ruleText.substring(sub1Pos, sub2Pos), rulePatternFormat,
pp, sub1, upperBound).doubleValue();
// if we got a successful match (or were trying to match a
// null substitution), pp is now pointing at the first unmatched
// character. Take note of that, and try matchToDelimiter()
// on the input text again
if (pp.getIndex() != 0 || sub1 == null) {
start = pp.getIndex();
String workText2 = workText.substring(pp.getIndex());
ParsePosition pp2 = new ParsePosition(0);
// the second matchToDelimiter() will compose our previous
// partial result with whatever it gets back from its
// substitution if there's a successful match, giving us
// a real result
partialResult = matchToDelimiter(workText2, 0, partialResult,
ruleText.substring(sub2Pos), rulePatternFormat, pp2, sub2,
upperBound).doubleValue();
// if we got a successful match on this second
// matchToDelimiter() call, update the high-water mark
// and result (if necessary)
if (pp2.getIndex() != 0 || sub2 == null) {
if (prefixLength + pp.getIndex() + pp2.getIndex() > highWaterMark) {
highWaterMark = prefixLength + pp.getIndex() + pp2.getIndex();
result = partialResult;
}
}
// commented out because ParsePosition doesn't have error index in 1.1.x
// else {
// int temp = pp2.getErrorIndex() + sub1.getPos() + pp.getIndex();
// if (temp> parsePosition.getErrorIndex()) {
// parsePosition.setErrorIndex(temp);
// }
// }
}
// commented out because ParsePosition doesn't have error index in 1.1.x
// else {
// int temp = sub1.getPos() + pp.getErrorIndex();
// if (temp > parsePosition.getErrorIndex()) {
// parsePosition.setErrorIndex(temp);
// }
// }
// keep trying to match things until the outer matchToDelimiter()
// call fails to make a match (each time, it picks up where it
// left off the previous time)
}
while (sub1Pos != sub2Pos && pp.getIndex() > 0 && pp.getIndex()
< workText.length() && pp.getIndex() != start);
// update the caller's ParsePosition with our high-water mark
// (i.e., it now points at the first character this function
// didn't match-- the ParsePosition is therefore unchanged if
// we didn't match anything)
parsePosition.setIndex(highWaterMark);
// commented out because ParsePosition doesn't have error index in 1.1.x
// if (highWaterMark > 0) {
// parsePosition.setErrorIndex(0);
// }
// this is a hack for one unusual condition: Normally, whether this
// rule belong to a fraction rule set or not is handled by its
// substitutions. But if that rule HAS NO substitutions, then
// we have to account for it here. By definition, if the matching
// rule in a fraction rule set has no substitutions, its numerator
// is 1, and so the result is the reciprocal of its base value.
if (isFractionRule && highWaterMark > 0 && sub1 == null) {
result = 1 / result;
}
// return the result as a Long if possible, or as a Double
if (result == (long)result) {
return Long.valueOf((long)result);
} else {
return new Double(result);
}
} | java | public Number doParse(String text, ParsePosition parsePosition, boolean isFractionRule,
double upperBound) {
// internally we operate on a copy of the string being parsed
// (because we're going to change it) and use our own ParsePosition
ParsePosition pp = new ParsePosition(0);
// check to see whether the text before the first substitution
// matches the text at the beginning of the string being
// parsed. If it does, strip that off the front of workText;
// otherwise, dump out with a mismatch
int sub1Pos = sub1 != null ? sub1.getPos() : ruleText.length();
int sub2Pos = sub2 != null ? sub2.getPos() : ruleText.length();
String workText = stripPrefix(text, ruleText.substring(0, sub1Pos), pp);
int prefixLength = text.length() - workText.length();
if (pp.getIndex() == 0 && sub1Pos != 0) {
// commented out because ParsePosition doesn't have error index in 1.1.x
// parsePosition.setErrorIndex(pp.getErrorIndex());
return ZERO;
}
if (baseValue == INFINITY_RULE) {
// If you match this, don't try to perform any calculations on it.
parsePosition.setIndex(pp.getIndex());
return Double.POSITIVE_INFINITY;
}
if (baseValue == NAN_RULE) {
// If you match this, don't try to perform any calculations on it.
parsePosition.setIndex(pp.getIndex());
return Double.NaN;
}
// this is the fun part. The basic guts of the rule-matching
// logic is matchToDelimiter(), which is called twice. The first
// time it searches the input string for the rule text BETWEEN
// the substitutions and tries to match the intervening text
// in the input string with the first substitution. If that
// succeeds, it then calls it again, this time to look for the
// rule text after the second substitution and to match the
// intervening input text against the second substitution.
//
// For example, say we have a rule that looks like this:
// first << middle >> last;
// and input text that looks like this:
// first one middle two last
// First we use stripPrefix() to match "first " in both places and
// strip it off the front, leaving
// one middle two last
// Then we use matchToDelimiter() to match " middle " and try to
// match "one" against a substitution. If it's successful, we now
// have
// two last
// We use matchToDelimiter() a second time to match " last" and
// try to match "two" against a substitution. If "two" matches
// the substitution, we have a successful parse.
//
// Since it's possible in many cases to find multiple instances
// of each of these pieces of rule text in the input string,
// we need to try all the possible combinations of these
// locations. This prevents us from prematurely declaring a mismatch,
// and makes sure we match as much input text as we can.
int highWaterMark = 0;
double result = 0;
int start = 0;
double tempBaseValue = Math.max(0, baseValue);
do {
// our partial parse result starts out as this rule's base
// value. If it finds a successful match, matchToDelimiter()
// will compose this in some way with what it gets back from
// the substitution, giving us a new partial parse result
pp.setIndex(0);
double partialResult = matchToDelimiter(workText, start, tempBaseValue,
ruleText.substring(sub1Pos, sub2Pos), rulePatternFormat,
pp, sub1, upperBound).doubleValue();
// if we got a successful match (or were trying to match a
// null substitution), pp is now pointing at the first unmatched
// character. Take note of that, and try matchToDelimiter()
// on the input text again
if (pp.getIndex() != 0 || sub1 == null) {
start = pp.getIndex();
String workText2 = workText.substring(pp.getIndex());
ParsePosition pp2 = new ParsePosition(0);
// the second matchToDelimiter() will compose our previous
// partial result with whatever it gets back from its
// substitution if there's a successful match, giving us
// a real result
partialResult = matchToDelimiter(workText2, 0, partialResult,
ruleText.substring(sub2Pos), rulePatternFormat, pp2, sub2,
upperBound).doubleValue();
// if we got a successful match on this second
// matchToDelimiter() call, update the high-water mark
// and result (if necessary)
if (pp2.getIndex() != 0 || sub2 == null) {
if (prefixLength + pp.getIndex() + pp2.getIndex() > highWaterMark) {
highWaterMark = prefixLength + pp.getIndex() + pp2.getIndex();
result = partialResult;
}
}
// commented out because ParsePosition doesn't have error index in 1.1.x
// else {
// int temp = pp2.getErrorIndex() + sub1.getPos() + pp.getIndex();
// if (temp> parsePosition.getErrorIndex()) {
// parsePosition.setErrorIndex(temp);
// }
// }
}
// commented out because ParsePosition doesn't have error index in 1.1.x
// else {
// int temp = sub1.getPos() + pp.getErrorIndex();
// if (temp > parsePosition.getErrorIndex()) {
// parsePosition.setErrorIndex(temp);
// }
// }
// keep trying to match things until the outer matchToDelimiter()
// call fails to make a match (each time, it picks up where it
// left off the previous time)
}
while (sub1Pos != sub2Pos && pp.getIndex() > 0 && pp.getIndex()
< workText.length() && pp.getIndex() != start);
// update the caller's ParsePosition with our high-water mark
// (i.e., it now points at the first character this function
// didn't match-- the ParsePosition is therefore unchanged if
// we didn't match anything)
parsePosition.setIndex(highWaterMark);
// commented out because ParsePosition doesn't have error index in 1.1.x
// if (highWaterMark > 0) {
// parsePosition.setErrorIndex(0);
// }
// this is a hack for one unusual condition: Normally, whether this
// rule belong to a fraction rule set or not is handled by its
// substitutions. But if that rule HAS NO substitutions, then
// we have to account for it here. By definition, if the matching
// rule in a fraction rule set has no substitutions, its numerator
// is 1, and so the result is the reciprocal of its base value.
if (isFractionRule && highWaterMark > 0 && sub1 == null) {
result = 1 / result;
}
// return the result as a Long if possible, or as a Double
if (result == (long)result) {
return Long.valueOf((long)result);
} else {
return new Double(result);
}
} | [
"public",
"Number",
"doParse",
"(",
"String",
"text",
",",
"ParsePosition",
"parsePosition",
",",
"boolean",
"isFractionRule",
",",
"double",
"upperBound",
")",
"{",
"// internally we operate on a copy of the string being parsed",
"// (because we're going to change it) and use ou... | Attempts to parse the string with this rule.
@param text The string being parsed
@param parsePosition On entry, the value is ignored and assumed to
be 0. On exit, this has been updated with the position of the first
character not consumed by matching the text against this rule
(if this rule doesn't match the text at all, the parse position
if left unchanged (presumably at 0) and the function returns
new Long(0)).
@param isFractionRule True if this rule is contained within a
fraction rule set. This is only used if the rule has no
substitutions.
@return If this rule matched the text, this is the rule's base value
combined appropriately with the results of parsing the substitutions.
If nothing matched, this is new Long(0) and the parse position is
left unchanged. The result will be an instance of Long if the
result is an integer and Double otherwise. The result is never null. | [
"Attempts",
"to",
"parse",
"the",
"string",
"with",
"this",
"rule",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L908-L1059 |
33,169 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java | NFRule.allIgnorable | private boolean allIgnorable(String str) {
// if the string is empty, we can just return true
if (str == null || str.length() == 0) {
return true;
}
RbnfLenientScanner scanner = formatter.getLenientScanner();
return scanner != null && scanner.allIgnorable(str);
} | java | private boolean allIgnorable(String str) {
// if the string is empty, we can just return true
if (str == null || str.length() == 0) {
return true;
}
RbnfLenientScanner scanner = formatter.getLenientScanner();
return scanner != null && scanner.allIgnorable(str);
} | [
"private",
"boolean",
"allIgnorable",
"(",
"String",
"str",
")",
"{",
"// if the string is empty, we can just return true",
"if",
"(",
"str",
"==",
"null",
"||",
"str",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"RbnfLenientScann... | Checks to see whether a string consists entirely of ignorable
characters.
@param str The string to test.
@return true if the string is empty of consists entirely of
characters that the number formatter's collator says are
ignorable at the primary-order level. false otherwise. | [
"Checks",
"to",
"see",
"whether",
"a",
"string",
"consists",
"entirely",
"of",
"ignorable",
"characters",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NFRule.java#L1309-L1316 |
33,170 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Trie2.java | Trie2.serializeHeader | protected int serializeHeader(DataOutputStream dos) throws IOException {
// Write the header. It is already set and ready to use, having been
// created when the Trie2 was unserialized or when it was frozen.
int bytesWritten = 0;
dos.writeInt(header.signature);
dos.writeShort(header.options);
dos.writeShort(header.indexLength);
dos.writeShort(header.shiftedDataLength);
dos.writeShort(header.index2NullOffset);
dos.writeShort(header.dataNullOffset);
dos.writeShort(header.shiftedHighStart);
bytesWritten += 16;
// Write the index
int i;
for (i=0; i< header.indexLength; i++) {
dos.writeChar(index[i]);
}
bytesWritten += header.indexLength;
return bytesWritten;
} | java | protected int serializeHeader(DataOutputStream dos) throws IOException {
// Write the header. It is already set and ready to use, having been
// created when the Trie2 was unserialized or when it was frozen.
int bytesWritten = 0;
dos.writeInt(header.signature);
dos.writeShort(header.options);
dos.writeShort(header.indexLength);
dos.writeShort(header.shiftedDataLength);
dos.writeShort(header.index2NullOffset);
dos.writeShort(header.dataNullOffset);
dos.writeShort(header.shiftedHighStart);
bytesWritten += 16;
// Write the index
int i;
for (i=0; i< header.indexLength; i++) {
dos.writeChar(index[i]);
}
bytesWritten += header.indexLength;
return bytesWritten;
} | [
"protected",
"int",
"serializeHeader",
"(",
"DataOutputStream",
"dos",
")",
"throws",
"IOException",
"{",
"// Write the header. It is already set and ready to use, having been",
"// created when the Trie2 was unserialized or when it was frozen.",
"int",
"bytesWritten",
"=",
"0",
";... | Serialize a trie2 Header and Index onto an OutputStream. This is
common code used for both the Trie2_16 and Trie2_32 serialize functions.
@param dos the stream to which the serialized Trie2 data will be written.
@return the number of bytes written. | [
"Serialize",
"a",
"trie2",
"Header",
"and",
"Index",
"onto",
"an",
"OutputStream",
".",
"This",
"is",
"common",
"code",
"used",
"for",
"both",
"the",
"Trie2_16",
"and",
"Trie2_32",
"serialize",
"functions",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Trie2.java#L470-L491 |
33,171 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Trie2.java | Trie2.rangeEnd | int rangeEnd(int start, int limitp, int val) {
int c;
int limit = Math.min(highStart, limitp);
for (c = start+1; c < limit; c++) {
if (get(c) != val) {
break;
}
}
if (c >= highStart) {
c = limitp;
}
return c - 1;
} | java | int rangeEnd(int start, int limitp, int val) {
int c;
int limit = Math.min(highStart, limitp);
for (c = start+1; c < limit; c++) {
if (get(c) != val) {
break;
}
}
if (c >= highStart) {
c = limitp;
}
return c - 1;
} | [
"int",
"rangeEnd",
"(",
"int",
"start",
",",
"int",
"limitp",
",",
"int",
"val",
")",
"{",
"int",
"c",
";",
"int",
"limit",
"=",
"Math",
".",
"min",
"(",
"highStart",
",",
"limitp",
")",
";",
"for",
"(",
"c",
"=",
"start",
"+",
"1",
";",
"c",
... | Find the last character in a contiguous range of characters with the
same Trie2 value as the input character.
@param c The character to begin with.
@return The last contiguous character with the same value. | [
"Find",
"the",
"last",
"character",
"in",
"a",
"contiguous",
"range",
"of",
"characters",
"with",
"the",
"same",
"Trie2",
"value",
"as",
"the",
"input",
"character",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Trie2.java#L1011-L1024 |
33,172 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.add | public final synchronized void add(String name, L listener) {
if (this.map == null) {
this.map = new HashMap<>();
}
L[] array = this.map.get(name);
int size = (array != null)
? array.length
: 0;
L[] clone = newArray(size + 1);
clone[size] = listener;
if (array != null) {
System.arraycopy(array, 0, clone, 0, size);
}
this.map.put(name, clone);
} | java | public final synchronized void add(String name, L listener) {
if (this.map == null) {
this.map = new HashMap<>();
}
L[] array = this.map.get(name);
int size = (array != null)
? array.length
: 0;
L[] clone = newArray(size + 1);
clone[size] = listener;
if (array != null) {
System.arraycopy(array, 0, clone, 0, size);
}
this.map.put(name, clone);
} | [
"public",
"final",
"synchronized",
"void",
"add",
"(",
"String",
"name",
",",
"L",
"listener",
")",
"{",
"if",
"(",
"this",
".",
"map",
"==",
"null",
")",
"{",
"this",
".",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}",
"L",
"[",
"]",
... | Adds a listener to the list of listeners for the specified property.
This listener is called as many times as it was added.
@param name the name of the property to listen on
@param listener the listener to process events | [
"Adds",
"a",
"listener",
"to",
"the",
"list",
"of",
"listeners",
"for",
"the",
"specified",
"property",
".",
"This",
"listener",
"is",
"called",
"as",
"many",
"times",
"as",
"it",
"was",
"added",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L77-L92 |
33,173 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.remove | public final synchronized void remove(String name, L listener) {
if (this.map != null) {
L[] array = this.map.get(name);
if (array != null) {
for (int i = 0; i < array.length; i++) {
if (listener.equals(array[i])) {
int size = array.length - 1;
if (size > 0) {
L[] clone = newArray(size);
System.arraycopy(array, 0, clone, 0, i);
System.arraycopy(array, i + 1, clone, i, size - i);
this.map.put(name, clone);
}
else {
this.map.remove(name);
if (this.map.isEmpty()) {
this.map = null;
}
}
break;
}
}
}
}
} | java | public final synchronized void remove(String name, L listener) {
if (this.map != null) {
L[] array = this.map.get(name);
if (array != null) {
for (int i = 0; i < array.length; i++) {
if (listener.equals(array[i])) {
int size = array.length - 1;
if (size > 0) {
L[] clone = newArray(size);
System.arraycopy(array, 0, clone, 0, i);
System.arraycopy(array, i + 1, clone, i, size - i);
this.map.put(name, clone);
}
else {
this.map.remove(name);
if (this.map.isEmpty()) {
this.map = null;
}
}
break;
}
}
}
}
} | [
"public",
"final",
"synchronized",
"void",
"remove",
"(",
"String",
"name",
",",
"L",
"listener",
")",
"{",
"if",
"(",
"this",
".",
"map",
"!=",
"null",
")",
"{",
"L",
"[",
"]",
"array",
"=",
"this",
".",
"map",
".",
"get",
"(",
"name",
")",
";",... | Removes a listener from the list of listeners for the specified property.
If the listener was added more than once to the same event source,
this listener will be notified one less time after being removed.
@param name the name of the property to listen on
@param listener the listener to process events | [
"Removes",
"a",
"listener",
"from",
"the",
"list",
"of",
"listeners",
"for",
"the",
"specified",
"property",
".",
"If",
"the",
"listener",
"was",
"added",
"more",
"than",
"once",
"to",
"the",
"same",
"event",
"source",
"this",
"listener",
"will",
"be",
"no... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L102-L126 |
33,174 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.get | public final synchronized L[] get(String name) {
return (this.map != null)
? this.map.get(name)
: null;
} | java | public final synchronized L[] get(String name) {
return (this.map != null)
? this.map.get(name)
: null;
} | [
"public",
"final",
"synchronized",
"L",
"[",
"]",
"get",
"(",
"String",
"name",
")",
"{",
"return",
"(",
"this",
".",
"map",
"!=",
"null",
")",
"?",
"this",
".",
"map",
".",
"get",
"(",
"name",
")",
":",
"null",
";",
"}"
] | Returns the list of listeners for the specified property.
@param name the name of the property
@return the corresponding list of listeners | [
"Returns",
"the",
"list",
"of",
"listeners",
"for",
"the",
"specified",
"property",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L134-L138 |
33,175 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.set | public final void set(String name, L[] listeners) {
if (listeners != null) {
if (this.map == null) {
this.map = new HashMap<>();
}
this.map.put(name, listeners);
}
else if (this.map != null) {
this.map.remove(name);
if (this.map.isEmpty()) {
this.map = null;
}
}
} | java | public final void set(String name, L[] listeners) {
if (listeners != null) {
if (this.map == null) {
this.map = new HashMap<>();
}
this.map.put(name, listeners);
}
else if (this.map != null) {
this.map.remove(name);
if (this.map.isEmpty()) {
this.map = null;
}
}
} | [
"public",
"final",
"void",
"set",
"(",
"String",
"name",
",",
"L",
"[",
"]",
"listeners",
")",
"{",
"if",
"(",
"listeners",
"!=",
"null",
")",
"{",
"if",
"(",
"this",
".",
"map",
"==",
"null",
")",
"{",
"this",
".",
"map",
"=",
"new",
"HashMap",
... | Sets new list of listeners for the specified property.
@param name the name of the property
@param listeners new list of listeners | [
"Sets",
"new",
"list",
"of",
"listeners",
"for",
"the",
"specified",
"property",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L146-L159 |
33,176 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.getListeners | public final synchronized L[] getListeners() {
if (this.map == null) {
return newArray(0);
}
List<L> list = new ArrayList<>();
L[] listeners = this.map.get(null);
if (listeners != null) {
for (L listener : listeners) {
list.add(listener);
}
}
for (Entry<String, L[]> entry : this.map.entrySet()) {
String name = entry.getKey();
if (name != null) {
for (L listener : entry.getValue()) {
list.add(newProxy(name, listener));
}
}
}
return list.toArray(newArray(list.size()));
} | java | public final synchronized L[] getListeners() {
if (this.map == null) {
return newArray(0);
}
List<L> list = new ArrayList<>();
L[] listeners = this.map.get(null);
if (listeners != null) {
for (L listener : listeners) {
list.add(listener);
}
}
for (Entry<String, L[]> entry : this.map.entrySet()) {
String name = entry.getKey();
if (name != null) {
for (L listener : entry.getValue()) {
list.add(newProxy(name, listener));
}
}
}
return list.toArray(newArray(list.size()));
} | [
"public",
"final",
"synchronized",
"L",
"[",
"]",
"getListeners",
"(",
")",
"{",
"if",
"(",
"this",
".",
"map",
"==",
"null",
")",
"{",
"return",
"newArray",
"(",
"0",
")",
";",
"}",
"List",
"<",
"L",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"... | Returns all listeners in the map.
@return an array of all listeners | [
"Returns",
"all",
"listeners",
"in",
"the",
"map",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L166-L187 |
33,177 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.getListeners | public final L[] getListeners(String name) {
if (name != null) {
L[] listeners = get(name);
if (listeners != null) {
return listeners.clone();
}
}
return newArray(0);
} | java | public final L[] getListeners(String name) {
if (name != null) {
L[] listeners = get(name);
if (listeners != null) {
return listeners.clone();
}
}
return newArray(0);
} | [
"public",
"final",
"L",
"[",
"]",
"getListeners",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"L",
"[",
"]",
"listeners",
"=",
"get",
"(",
"name",
")",
";",
"if",
"(",
"listeners",
"!=",
"null",
")",
"{",
"return",... | Returns listeners that have been associated with the named property.
@param name the name of the property
@return an array of listeners for the named property | [
"Returns",
"listeners",
"that",
"have",
"been",
"associated",
"with",
"the",
"named",
"property",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L195-L203 |
33,178 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.hasListeners | public final synchronized boolean hasListeners(String name) {
if (this.map == null) {
return false;
}
L[] array = this.map.get(null);
return (array != null) || ((name != null) && (null != this.map.get(name)));
} | java | public final synchronized boolean hasListeners(String name) {
if (this.map == null) {
return false;
}
L[] array = this.map.get(null);
return (array != null) || ((name != null) && (null != this.map.get(name)));
} | [
"public",
"final",
"synchronized",
"boolean",
"hasListeners",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"this",
".",
"map",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"L",
"[",
"]",
"array",
"=",
"this",
".",
"map",
".",
"get",
"(",
"nu... | Indicates whether the map contains
at least one listener to be notified.
@param name the name of the property
@return {@code true} if at least one listener exists or
{@code false} otherwise | [
"Indicates",
"whether",
"the",
"map",
"contains",
"at",
"least",
"one",
"listener",
"to",
"be",
"notified",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L213-L219 |
33,179 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java | ChangeListenerMap.getEntries | public final Set<Entry<String, L[]>> getEntries() {
return (this.map != null)
? this.map.entrySet()
: Collections.<Entry<String, L[]>>emptySet();
} | java | public final Set<Entry<String, L[]>> getEntries() {
return (this.map != null)
? this.map.entrySet()
: Collections.<Entry<String, L[]>>emptySet();
} | [
"public",
"final",
"Set",
"<",
"Entry",
"<",
"String",
",",
"L",
"[",
"]",
">",
">",
"getEntries",
"(",
")",
"{",
"return",
"(",
"this",
".",
"map",
"!=",
"null",
")",
"?",
"this",
".",
"map",
".",
"entrySet",
"(",
")",
":",
"Collections",
".",
... | Returns a set of entries from the map.
Each entry is a pair consisted of the property name
and the corresponding list of listeners.
@return a set of entries from the map | [
"Returns",
"a",
"set",
"of",
"entries",
"from",
"the",
"map",
".",
"Each",
"entry",
"is",
"a",
"pair",
"consisted",
"of",
"the",
"property",
"name",
"and",
"the",
"corresponding",
"list",
"of",
"listeners",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/beans/ChangeListenerMap.java#L228-L232 |
33,180 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/locks/ReentrantLock.java | ReentrantLock.getWaitQueueLength | public int getWaitQueueLength(Condition condition) {
if (condition == null)
throw new NullPointerException();
if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject))
throw new IllegalArgumentException("not owner");
return sync.getWaitQueueLength((AbstractQueuedSynchronizer.ConditionObject)condition);
} | java | public int getWaitQueueLength(Condition condition) {
if (condition == null)
throw new NullPointerException();
if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject))
throw new IllegalArgumentException("not owner");
return sync.getWaitQueueLength((AbstractQueuedSynchronizer.ConditionObject)condition);
} | [
"public",
"int",
"getWaitQueueLength",
"(",
"Condition",
"condition",
")",
"{",
"if",
"(",
"condition",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"if",
"(",
"!",
"(",
"condition",
"instanceof",
"AbstractQueuedSynchronizer",
".",
... | Returns an estimate of the number of threads waiting on the
given condition associated with this lock. Note that because
timeouts and interrupts may occur at any time, the estimate
serves only as an upper bound on the actual number of waiters.
This method is designed for use in monitoring of the system
state, not for synchronization control.
@param condition the condition
@return the estimated number of waiting threads
@throws IllegalMonitorStateException if this lock is not held
@throws IllegalArgumentException if the given condition is
not associated with this lock
@throws NullPointerException if the condition is null | [
"Returns",
"an",
"estimate",
"of",
"the",
"number",
"of",
"threads",
"waiting",
"on",
"the",
"given",
"condition",
"associated",
"with",
"this",
"lock",
".",
"Note",
"that",
"because",
"timeouts",
"and",
"interrupts",
"may",
"occur",
"at",
"any",
"time",
"th... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/locks/ReentrantLock.java#L715-L721 |
33,181 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/locks/ReentrantLock.java | ReentrantLock.getWaitingThreads | protected Collection<Thread> getWaitingThreads(Condition condition) {
if (condition == null)
throw new NullPointerException();
if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject))
throw new IllegalArgumentException("not owner");
return sync.getWaitingThreads((AbstractQueuedSynchronizer.ConditionObject)condition);
} | java | protected Collection<Thread> getWaitingThreads(Condition condition) {
if (condition == null)
throw new NullPointerException();
if (!(condition instanceof AbstractQueuedSynchronizer.ConditionObject))
throw new IllegalArgumentException("not owner");
return sync.getWaitingThreads((AbstractQueuedSynchronizer.ConditionObject)condition);
} | [
"protected",
"Collection",
"<",
"Thread",
">",
"getWaitingThreads",
"(",
"Condition",
"condition",
")",
"{",
"if",
"(",
"condition",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"if",
"(",
"!",
"(",
"condition",
"instanceof",
"Ab... | Returns a collection containing those threads that may be
waiting on the given condition associated with this lock.
Because the actual set of threads may change dynamically while
constructing this result, the returned collection is only a
best-effort estimate. The elements of the returned collection
are in no particular order. This method is designed to
facilitate construction of subclasses that provide more
extensive condition monitoring facilities.
@param condition the condition
@return the collection of threads
@throws IllegalMonitorStateException if this lock is not held
@throws IllegalArgumentException if the given condition is
not associated with this lock
@throws NullPointerException if the condition is null | [
"Returns",
"a",
"collection",
"containing",
"those",
"threads",
"that",
"may",
"be",
"waiting",
"on",
"the",
"given",
"condition",
"associated",
"with",
"this",
"lock",
".",
"Because",
"the",
"actual",
"set",
"of",
"threads",
"may",
"change",
"dynamically",
"w... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/locks/ReentrantLock.java#L740-L746 |
33,182 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SimpleFormatter.java | SimpleFormatter.compileMinMaxArguments | public static SimpleFormatter compileMinMaxArguments(CharSequence pattern, int min, int max) {
StringBuilder sb = new StringBuilder();
String compiledPattern = SimpleFormatterImpl.compileToStringMinMaxArguments(pattern, sb, min, max);
return new SimpleFormatter(compiledPattern);
} | java | public static SimpleFormatter compileMinMaxArguments(CharSequence pattern, int min, int max) {
StringBuilder sb = new StringBuilder();
String compiledPattern = SimpleFormatterImpl.compileToStringMinMaxArguments(pattern, sb, min, max);
return new SimpleFormatter(compiledPattern);
} | [
"public",
"static",
"SimpleFormatter",
"compileMinMaxArguments",
"(",
"CharSequence",
"pattern",
",",
"int",
"min",
",",
"int",
"max",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"compiledPattern",
"=",
"SimpleFormatterIm... | Creates a formatter from the pattern string.
The number of arguments checked against the given limits is the
highest argument number plus one, not the number of occurrences of arguments.
@param pattern The pattern string.
@param min The pattern must have at least this many arguments.
@param max The pattern must have at most this many arguments.
@return The new SimpleFormatter object.
@throws IllegalArgumentException for bad argument syntax and too few or too many arguments.
@hide draft / provisional / internal are hidden on Android | [
"Creates",
"a",
"formatter",
"from",
"the",
"pattern",
"string",
".",
"The",
"number",
"of",
"arguments",
"checked",
"against",
"the",
"given",
"limits",
"is",
"the",
"highest",
"argument",
"number",
"plus",
"one",
"not",
"the",
"number",
"of",
"occurrences",
... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SimpleFormatter.java#L79-L83 |
33,183 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.findValue | public synchronized String findValue(String k) {
if (k == null) {
for (int i = nkeys; --i >= 0;)
if (keys[i] == null)
return values[i];
} else
for (int i = nkeys; --i >= 0;) {
if (k.equalsIgnoreCase(keys[i]))
return values[i];
}
return null;
} | java | public synchronized String findValue(String k) {
if (k == null) {
for (int i = nkeys; --i >= 0;)
if (keys[i] == null)
return values[i];
} else
for (int i = nkeys; --i >= 0;) {
if (k.equalsIgnoreCase(keys[i]))
return values[i];
}
return null;
} | [
"public",
"synchronized",
"String",
"findValue",
"(",
"String",
"k",
")",
"{",
"if",
"(",
"k",
"==",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"nkeys",
";",
"--",
"i",
">=",
"0",
";",
")",
"if",
"(",
"keys",
"[",
"i",
"]",
"==",
"null",
... | Find the value that corresponds to this key.
It finds only the first occurrence of the key.
@param k the key to find.
@return null if not found. | [
"Find",
"the",
"value",
"that",
"corresponds",
"to",
"this",
"key",
".",
"It",
"finds",
"only",
"the",
"first",
"occurrence",
"of",
"the",
"key",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L79-L90 |
33,184 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.getKey | public synchronized int getKey(String k) {
for (int i = nkeys; --i >= 0;)
if ((keys[i] == k) ||
(k != null && k.equalsIgnoreCase(keys[i])))
return i;
return -1;
} | java | public synchronized int getKey(String k) {
for (int i = nkeys; --i >= 0;)
if ((keys[i] == k) ||
(k != null && k.equalsIgnoreCase(keys[i])))
return i;
return -1;
} | [
"public",
"synchronized",
"int",
"getKey",
"(",
"String",
"k",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"nkeys",
";",
"--",
"i",
">=",
"0",
";",
")",
"if",
"(",
"(",
"keys",
"[",
"i",
"]",
"==",
"k",
")",
"||",
"(",
"k",
"!=",
"null",
"&&",
"... | return the location of the key | [
"return",
"the",
"location",
"of",
"the",
"key"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L93-L99 |
33,185 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.filterNTLMResponses | public boolean filterNTLMResponses(String k) {
boolean found = false;
for (int i=0; i<nkeys; i++) {
if (k.equalsIgnoreCase(keys[i])
&& values[i] != null && values[i].length() > 5
&& values[i].regionMatches(true, 0, "NTLM ", 0, 5)) {
found = true;
break;
}
}
if (found) {
int j = 0;
for (int i=0; i<nkeys; i++) {
if (k.equalsIgnoreCase(keys[i]) && (
"Negotiate".equalsIgnoreCase(values[i]) ||
"Kerberos".equalsIgnoreCase(values[i]))) {
continue;
}
if (i != j) {
keys[j] = keys[i];
values[j] = values[i];
}
j++;
}
if (j != nkeys) {
nkeys = j;
return true;
}
}
return false;
} | java | public boolean filterNTLMResponses(String k) {
boolean found = false;
for (int i=0; i<nkeys; i++) {
if (k.equalsIgnoreCase(keys[i])
&& values[i] != null && values[i].length() > 5
&& values[i].regionMatches(true, 0, "NTLM ", 0, 5)) {
found = true;
break;
}
}
if (found) {
int j = 0;
for (int i=0; i<nkeys; i++) {
if (k.equalsIgnoreCase(keys[i]) && (
"Negotiate".equalsIgnoreCase(values[i]) ||
"Kerberos".equalsIgnoreCase(values[i]))) {
continue;
}
if (i != j) {
keys[j] = keys[i];
values[j] = values[i];
}
j++;
}
if (j != nkeys) {
nkeys = j;
return true;
}
}
return false;
} | [
"public",
"boolean",
"filterNTLMResponses",
"(",
"String",
"k",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nkeys",
";",
"i",
"++",
")",
"{",
"if",
"(",
"k",
".",
"equalsIgnoreCase",
"(",
"keys... | Removes bare Negotiate and Kerberos headers when an "NTLM ..."
appears. All Performed on headers with key being k.
@return true if there is a change | [
"Removes",
"bare",
"Negotiate",
"and",
"Kerberos",
"headers",
"when",
"an",
"NTLM",
"...",
"appears",
".",
"All",
"Performed",
"on",
"headers",
"with",
"key",
"being",
"k",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L146-L176 |
33,186 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.print | public synchronized void print(PrintStream p) {
for (int i = 0; i < nkeys; i++)
if (keys[i] != null) {
p.print(keys[i] +
(values[i] != null ? ": "+values[i]: "") + "\r\n");
}
p.print("\r\n");
p.flush();
} | java | public synchronized void print(PrintStream p) {
for (int i = 0; i < nkeys; i++)
if (keys[i] != null) {
p.print(keys[i] +
(values[i] != null ? ": "+values[i]: "") + "\r\n");
}
p.print("\r\n");
p.flush();
} | [
"public",
"synchronized",
"void",
"print",
"(",
"PrintStream",
"p",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nkeys",
";",
"i",
"++",
")",
"if",
"(",
"keys",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"p",
".",
"print",
"(",
"ke... | Prints the key-value pairs represented by this
header. Also prints the RFC required blank line
at the end. Omits pairs with a null key. | [
"Prints",
"the",
"key",
"-",
"value",
"pairs",
"represented",
"by",
"this",
"header",
".",
"Also",
"prints",
"the",
"RFC",
"required",
"blank",
"line",
"at",
"the",
"end",
".",
"Omits",
"pairs",
"with",
"a",
"null",
"key",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L290-L298 |
33,187 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.add | public synchronized void add(String k, String v) {
grow();
keys[nkeys] = k;
values[nkeys] = v;
nkeys++;
} | java | public synchronized void add(String k, String v) {
grow();
keys[nkeys] = k;
values[nkeys] = v;
nkeys++;
} | [
"public",
"synchronized",
"void",
"add",
"(",
"String",
"k",
",",
"String",
"v",
")",
"{",
"grow",
"(",
")",
";",
"keys",
"[",
"nkeys",
"]",
"=",
"k",
";",
"values",
"[",
"nkeys",
"]",
"=",
"v",
";",
"nkeys",
"++",
";",
"}"
] | Adds a key value pair to the end of the
header. Duplicates are allowed | [
"Adds",
"a",
"key",
"value",
"pair",
"to",
"the",
"end",
"of",
"the",
"header",
".",
"Duplicates",
"are",
"allowed"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L302-L307 |
33,188 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.prepend | public synchronized void prepend(String k, String v) {
grow();
for (int i = nkeys; i > 0; i--) {
keys[i] = keys[i-1];
values[i] = values[i-1];
}
keys[0] = k;
values[0] = v;
nkeys++;
} | java | public synchronized void prepend(String k, String v) {
grow();
for (int i = nkeys; i > 0; i--) {
keys[i] = keys[i-1];
values[i] = values[i-1];
}
keys[0] = k;
values[0] = v;
nkeys++;
} | [
"public",
"synchronized",
"void",
"prepend",
"(",
"String",
"k",
",",
"String",
"v",
")",
"{",
"grow",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"nkeys",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"keys",
"[",
"i",
"]",
"=",
"keys",
"[",... | Prepends a key value pair to the beginning of the
header. Duplicates are allowed | [
"Prepends",
"a",
"key",
"value",
"pair",
"to",
"the",
"beginning",
"of",
"the",
"header",
".",
"Duplicates",
"are",
"allowed"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L311-L320 |
33,189 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.remove | public synchronized void remove(String k) {
if(k == null) {
for (int i = 0; i < nkeys; i++) {
while (keys[i] == null && i < nkeys) {
for(int j=i; j<nkeys-1; j++) {
keys[j] = keys[j+1];
values[j] = values[j+1];
}
nkeys--;
}
}
} else {
for (int i = 0; i < nkeys; i++) {
while (k.equalsIgnoreCase(keys[i]) && i < nkeys) {
for(int j=i; j<nkeys-1; j++) {
keys[j] = keys[j+1];
values[j] = values[j+1];
}
nkeys--;
}
}
}
} | java | public synchronized void remove(String k) {
if(k == null) {
for (int i = 0; i < nkeys; i++) {
while (keys[i] == null && i < nkeys) {
for(int j=i; j<nkeys-1; j++) {
keys[j] = keys[j+1];
values[j] = values[j+1];
}
nkeys--;
}
}
} else {
for (int i = 0; i < nkeys; i++) {
while (k.equalsIgnoreCase(keys[i]) && i < nkeys) {
for(int j=i; j<nkeys-1; j++) {
keys[j] = keys[j+1];
values[j] = values[j+1];
}
nkeys--;
}
}
}
} | [
"public",
"synchronized",
"void",
"remove",
"(",
"String",
"k",
")",
"{",
"if",
"(",
"k",
"==",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nkeys",
";",
"i",
"++",
")",
"{",
"while",
"(",
"keys",
"[",
"i",
"]",
"==",
... | Remove the key from the header. If there are multiple values under
the same key, they are all removed.
Nothing is done if the key doesn't exist.
After a remove, the other pairs' order are not changed.
@param k the key to remove | [
"Remove",
"the",
"key",
"from",
"the",
"header",
".",
"If",
"there",
"are",
"multiple",
"values",
"under",
"the",
"same",
"key",
"they",
"are",
"all",
"removed",
".",
"Nothing",
"is",
"done",
"if",
"the",
"key",
"doesn",
"t",
"exist",
".",
"After",
"a"... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L362-L384 |
33,190 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.setIfNotSet | public synchronized void setIfNotSet(String k, String v) {
if (findValue(k) == null) {
add(k, v);
}
} | java | public synchronized void setIfNotSet(String k, String v) {
if (findValue(k) == null) {
add(k, v);
}
} | [
"public",
"synchronized",
"void",
"setIfNotSet",
"(",
"String",
"k",
",",
"String",
"v",
")",
"{",
"if",
"(",
"findValue",
"(",
"k",
")",
"==",
"null",
")",
"{",
"add",
"(",
"k",
",",
"v",
")",
";",
"}",
"}"
] | Set's the value of a key only if there is no
key with that value already. | [
"Set",
"s",
"the",
"value",
"of",
"a",
"key",
"only",
"if",
"there",
"is",
"no",
"key",
"with",
"that",
"value",
"already",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L403-L407 |
33,191 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java | MessageHeader.mergeHeader | public void mergeHeader(InputStream is) throws java.io.IOException {
if (is == null)
return;
char s[] = new char[10];
int firstc = is.read();
while (firstc != '\n' && firstc != '\r' && firstc >= 0) {
int len = 0;
int keyend = -1;
int c;
boolean inKey = firstc > ' ';
s[len++] = (char) firstc;
parseloop:{
while ((c = is.read()) >= 0) {
switch (c) {
case ':':
if (inKey && len > 0)
keyend = len;
inKey = false;
break;
case '\t':
c = ' ';
case ' ':
inKey = false;
break;
case '\r':
case '\n':
firstc = is.read();
if (c == '\r' && firstc == '\n') {
firstc = is.read();
if (firstc == '\r')
firstc = is.read();
}
if (firstc == '\n' || firstc == '\r' || firstc > ' ')
break parseloop;
/* continuation */
c = ' ';
break;
}
if (len >= s.length) {
char ns[] = new char[s.length * 2];
System.arraycopy(s, 0, ns, 0, len);
s = ns;
}
s[len++] = (char) c;
}
firstc = -1;
}
while (len > 0 && s[len - 1] <= ' ')
len--;
String k;
if (keyend <= 0) {
k = null;
keyend = 0;
} else {
k = String.copyValueOf(s, 0, keyend);
if (keyend < len && s[keyend] == ':')
keyend++;
while (keyend < len && s[keyend] <= ' ')
keyend++;
}
String v;
if (keyend >= len)
v = new String();
else
v = String.copyValueOf(s, keyend, len - keyend);
add(k, v);
}
} | java | public void mergeHeader(InputStream is) throws java.io.IOException {
if (is == null)
return;
char s[] = new char[10];
int firstc = is.read();
while (firstc != '\n' && firstc != '\r' && firstc >= 0) {
int len = 0;
int keyend = -1;
int c;
boolean inKey = firstc > ' ';
s[len++] = (char) firstc;
parseloop:{
while ((c = is.read()) >= 0) {
switch (c) {
case ':':
if (inKey && len > 0)
keyend = len;
inKey = false;
break;
case '\t':
c = ' ';
case ' ':
inKey = false;
break;
case '\r':
case '\n':
firstc = is.read();
if (c == '\r' && firstc == '\n') {
firstc = is.read();
if (firstc == '\r')
firstc = is.read();
}
if (firstc == '\n' || firstc == '\r' || firstc > ' ')
break parseloop;
/* continuation */
c = ' ';
break;
}
if (len >= s.length) {
char ns[] = new char[s.length * 2];
System.arraycopy(s, 0, ns, 0, len);
s = ns;
}
s[len++] = (char) c;
}
firstc = -1;
}
while (len > 0 && s[len - 1] <= ' ')
len--;
String k;
if (keyend <= 0) {
k = null;
keyend = 0;
} else {
k = String.copyValueOf(s, 0, keyend);
if (keyend < len && s[keyend] == ':')
keyend++;
while (keyend < len && s[keyend] <= ' ')
keyend++;
}
String v;
if (keyend >= len)
v = new String();
else
v = String.copyValueOf(s, keyend, len - keyend);
add(k, v);
}
} | [
"public",
"void",
"mergeHeader",
"(",
"InputStream",
"is",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"if",
"(",
"is",
"==",
"null",
")",
"return",
";",
"char",
"s",
"[",
"]",
"=",
"new",
"char",
"[",
"10",
"]",
";",
"int",
"firstc"... | Parse and merge a MIME header from an input stream. | [
"Parse",
"and",
"merge",
"a",
"MIME",
"header",
"from",
"an",
"input",
"stream",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/net/www/MessageHeader.java#L440-L507 |
33,192 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/DayPeriodRules.java | DayPeriodRules.getInstance | public static DayPeriodRules getInstance(ULocale locale) {
String localeCode = locale.getName();
if (localeCode.isEmpty()) { localeCode = "root"; }
Integer ruleSetNum = null;
while (ruleSetNum == null) {
ruleSetNum = DATA.localesToRuleSetNumMap.get(localeCode);
if (ruleSetNum == null) {
localeCode = ULocale.getFallback(localeCode);
if (localeCode.isEmpty()) {
// Saves a lookup in the map.
break;
}
} else {
break;
}
}
if (ruleSetNum == null || DATA.rules[ruleSetNum] == null) {
// Data doesn't exist for the locale requested.
return null;
}
return DATA.rules[ruleSetNum];
} | java | public static DayPeriodRules getInstance(ULocale locale) {
String localeCode = locale.getName();
if (localeCode.isEmpty()) { localeCode = "root"; }
Integer ruleSetNum = null;
while (ruleSetNum == null) {
ruleSetNum = DATA.localesToRuleSetNumMap.get(localeCode);
if (ruleSetNum == null) {
localeCode = ULocale.getFallback(localeCode);
if (localeCode.isEmpty()) {
// Saves a lookup in the map.
break;
}
} else {
break;
}
}
if (ruleSetNum == null || DATA.rules[ruleSetNum] == null) {
// Data doesn't exist for the locale requested.
return null;
}
return DATA.rules[ruleSetNum];
} | [
"public",
"static",
"DayPeriodRules",
"getInstance",
"(",
"ULocale",
"locale",
")",
"{",
"String",
"localeCode",
"=",
"locale",
".",
"getName",
"(",
")",
";",
"if",
"(",
"localeCode",
".",
"isEmpty",
"(",
")",
")",
"{",
"localeCode",
"=",
"\"root\"",
";",
... | Get a DayPeriodRules object given a locale.
If data hasn't been loaded, it will be loaded for all locales at once.
@param locale locale for which the DayPeriodRules object is requested.
@return a DayPeriodRules object for `locale`. | [
"Get",
"a",
"DayPeriodRules",
"object",
"given",
"a",
"locale",
".",
"If",
"data",
"hasn",
"t",
"been",
"loaded",
"it",
"will",
"be",
"loaded",
"for",
"all",
"locales",
"at",
"once",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/DayPeriodRules.java#L248-L272 |
33,193 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java | DeflaterOutputStream.write | public void write(byte[] b, int off, int len) throws IOException {
if (def.finished()) {
throw new IOException("write beyond end of stream");
}
if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
if (!def.finished()) {
def.setInput(b, off, len);
while (!def.needsInput()) {
deflate();
}
}
} | java | public void write(byte[] b, int off, int len) throws IOException {
if (def.finished()) {
throw new IOException("write beyond end of stream");
}
if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
if (!def.finished()) {
def.setInput(b, off, len);
while (!def.needsInput()) {
deflate();
}
}
} | [
"public",
"void",
"write",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"if",
"(",
"def",
".",
"finished",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"write beyond end of stream\"",
... | Writes an array of bytes to the compressed output stream. This
method will block until all the bytes are written.
@param b the data to be written
@param off the start offset of the data
@param len the length of the data
@exception IOException if an I/O error has occurred | [
"Writes",
"an",
"array",
"of",
"bytes",
"to",
"the",
"compressed",
"output",
"stream",
".",
"This",
"method",
"will",
"block",
"until",
"all",
"the",
"bytes",
"are",
"written",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java#L200-L215 |
33,194 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java | DeflaterOutputStream.close | public void close() throws IOException {
if (!closed) {
finish();
if (usesDefaultDeflater)
def.end();
out.close();
closed = true;
}
} | java | public void close() throws IOException {
if (!closed) {
finish();
if (usesDefaultDeflater)
def.end();
out.close();
closed = true;
}
} | [
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"closed",
")",
"{",
"finish",
"(",
")",
";",
"if",
"(",
"usesDefaultDeflater",
")",
"def",
".",
"end",
"(",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"closed",
... | Writes remaining compressed data to the output stream and closes the
underlying stream.
@exception IOException if an I/O error has occurred | [
"Writes",
"remaining",
"compressed",
"data",
"to",
"the",
"output",
"stream",
"and",
"closes",
"the",
"underlying",
"stream",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java#L237-L245 |
33,195 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java | DeflaterOutputStream.deflate | protected void deflate() throws IOException {
// Android-changed: output all available compressed data (b/4005091)
int len = 0;
while ((len = def.deflate(buf, 0, buf.length)) > 0) {
out.write(buf, 0, len);
}
} | java | protected void deflate() throws IOException {
// Android-changed: output all available compressed data (b/4005091)
int len = 0;
while ((len = def.deflate(buf, 0, buf.length)) > 0) {
out.write(buf, 0, len);
}
} | [
"protected",
"void",
"deflate",
"(",
")",
"throws",
"IOException",
"{",
"// Android-changed: output all available compressed data (b/4005091)",
"int",
"len",
"=",
"0",
";",
"while",
"(",
"(",
"len",
"=",
"def",
".",
"deflate",
"(",
"buf",
",",
"0",
",",
"buf",
... | Writes next block of compressed data to the output stream.
@throws IOException if an I/O error has occurred | [
"Writes",
"next",
"block",
"of",
"compressed",
"data",
"to",
"the",
"output",
"stream",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java#L251-L257 |
33,196 | google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java | DeflaterOutputStream.flush | public void flush() throws IOException {
if (syncFlush && !def.finished()) {
int len = 0;
while ((len = def.deflate(buf, 0, buf.length, Deflater.SYNC_FLUSH)) > 0)
{
out.write(buf, 0, len);
if (len < buf.length)
break;
}
}
out.flush();
} | java | public void flush() throws IOException {
if (syncFlush && !def.finished()) {
int len = 0;
while ((len = def.deflate(buf, 0, buf.length, Deflater.SYNC_FLUSH)) > 0)
{
out.write(buf, 0, len);
if (len < buf.length)
break;
}
}
out.flush();
} | [
"public",
"void",
"flush",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"syncFlush",
"&&",
"!",
"def",
".",
"finished",
"(",
")",
")",
"{",
"int",
"len",
"=",
"0",
";",
"while",
"(",
"(",
"len",
"=",
"def",
".",
"deflate",
"(",
"buf",
",",
... | Flushes the compressed output stream.
If {@link #DeflaterOutputStream(OutputStream, Deflater, int, boolean)
syncFlush} is {@code true} when this compressed output stream is
constructed, this method first flushes the underlying {@code compressor}
with the flush mode {@link Deflater#SYNC_FLUSH} to force
all pending data to be flushed out to the output stream and then
flushes the output stream. Otherwise this method only flushes the
output stream without flushing the {@code compressor}.
@throws IOException if an I/O error has occurred
@since 1.7 | [
"Flushes",
"the",
"compressed",
"output",
"stream",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/DeflaterOutputStream.java#L274-L285 |
33,197 | google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/objects/XRTreeFrag.java | XRTreeFrag.object | public Object object()
{
if (m_DTMXRTreeFrag.getXPathContext() != null)
return new org.apache.xml.dtm.ref.DTMNodeIterator((DTMIterator)(new org.apache.xpath.NodeSetDTM(m_dtmRoot, m_DTMXRTreeFrag.getXPathContext().getDTMManager())));
else
return super.object();
} | java | public Object object()
{
if (m_DTMXRTreeFrag.getXPathContext() != null)
return new org.apache.xml.dtm.ref.DTMNodeIterator((DTMIterator)(new org.apache.xpath.NodeSetDTM(m_dtmRoot, m_DTMXRTreeFrag.getXPathContext().getDTMManager())));
else
return super.object();
} | [
"public",
"Object",
"object",
"(",
")",
"{",
"if",
"(",
"m_DTMXRTreeFrag",
".",
"getXPathContext",
"(",
")",
"!=",
"null",
")",
"return",
"new",
"org",
".",
"apache",
".",
"xml",
".",
"dtm",
".",
"ref",
".",
"DTMNodeIterator",
"(",
"(",
"DTMIterator",
... | Return a java object that's closest to the representation
that should be handed to an extension.
@return The object that this class wraps | [
"Return",
"a",
"java",
"object",
"that",
"s",
"closest",
"to",
"the",
"representation",
"that",
"should",
"be",
"handed",
"to",
"an",
"extension",
"."
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/objects/XRTreeFrag.java#L81-L87 |
33,198 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java | UCharacterUtility.isNonCharacter | public static boolean isNonCharacter(int ch)
{
if ((ch & NON_CHARACTER_SUFFIX_MIN_3_0_) ==
NON_CHARACTER_SUFFIX_MIN_3_0_) {
return true;
}
return ch >= NON_CHARACTER_MIN_3_1_ && ch <= NON_CHARACTER_MAX_3_1_;
} | java | public static boolean isNonCharacter(int ch)
{
if ((ch & NON_CHARACTER_SUFFIX_MIN_3_0_) ==
NON_CHARACTER_SUFFIX_MIN_3_0_) {
return true;
}
return ch >= NON_CHARACTER_MIN_3_1_ && ch <= NON_CHARACTER_MAX_3_1_;
} | [
"public",
"static",
"boolean",
"isNonCharacter",
"(",
"int",
"ch",
")",
"{",
"if",
"(",
"(",
"ch",
"&",
"NON_CHARACTER_SUFFIX_MIN_3_0_",
")",
"==",
"NON_CHARACTER_SUFFIX_MIN_3_0_",
")",
"{",
"return",
"true",
";",
"}",
"return",
"ch",
">=",
"NON_CHARACTER_MIN_3_... | Determines if codepoint is a non character
@param ch codepoint
@return true if codepoint is a non character false otherwise | [
"Determines",
"if",
"codepoint",
"is",
"a",
"non",
"character"
] | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java#L28-L36 |
33,199 | google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java | UCharacterUtility.getNullTermByteSubString | static int getNullTermByteSubString(StringBuffer str, byte[] array,
int index)
{
byte b = 1;
while (b != 0)
{
b = array[index];
if (b != 0) {
str.append((char)(b & 0x00FF));
}
index ++;
}
return index;
} | java | static int getNullTermByteSubString(StringBuffer str, byte[] array,
int index)
{
byte b = 1;
while (b != 0)
{
b = array[index];
if (b != 0) {
str.append((char)(b & 0x00FF));
}
index ++;
}
return index;
} | [
"static",
"int",
"getNullTermByteSubString",
"(",
"StringBuffer",
"str",
",",
"byte",
"[",
"]",
"array",
",",
"int",
"index",
")",
"{",
"byte",
"b",
"=",
"1",
";",
"while",
"(",
"b",
"!=",
"0",
")",
"{",
"b",
"=",
"array",
"[",
"index",
"]",
";",
... | Retrieves a null terminated substring from an array of bytes.
Substring is a set of non-zero bytes starting from argument start to the
next zero byte. If the first byte is a zero, the next byte will be taken as
the first byte.
@param str stringbuffer to store data in, data will be store with each
byte as a char
@param array byte array
@param index to start substring in byte count
@return the end position of the substring within the character array | [
"Retrieves",
"a",
"null",
"terminated",
"substring",
"from",
"an",
"array",
"of",
"bytes",
".",
"Substring",
"is",
"a",
"set",
"of",
"non",
"-",
"zero",
"bytes",
"starting",
"from",
"argument",
"start",
"to",
"the",
"next",
"zero",
"byte",
".",
"If",
"th... | 471504a735b48d5d4ace51afa1542cc4790a921a | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterUtility.java#L62-L76 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.