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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
11,300
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.classify
|
private void classify() {
// Classify
monitor.taskStarted("Classifying");
monitor.taskBusy();
reasoner = reasoner.classify();
monitor.taskEnded();
monitor.taskStarted("Building taxonomy");
monitor.taskBusy();
taxonomy = reasoner.getClassifiedOntology();
monitor.taskEnded();
}
|
java
|
private void classify() {
// Classify
monitor.taskStarted("Classifying");
monitor.taskBusy();
reasoner = reasoner.classify();
monitor.taskEnded();
monitor.taskStarted("Building taxonomy");
monitor.taskBusy();
taxonomy = reasoner.getClassifiedOntology();
monitor.taskEnded();
}
|
[
"private",
"void",
"classify",
"(",
")",
"{",
"// Classify\r",
"monitor",
".",
"taskStarted",
"(",
"\"Classifying\"",
")",
";",
"monitor",
".",
"taskBusy",
"(",
")",
";",
"reasoner",
"=",
"reasoner",
".",
"classify",
"(",
")",
";",
"monitor",
".",
"taskEnded",
"(",
")",
";",
"monitor",
".",
"taskStarted",
"(",
"\"Building taxonomy\"",
")",
";",
"monitor",
".",
"taskBusy",
"(",
")",
";",
"taxonomy",
"=",
"reasoner",
".",
"getClassifiedOntology",
"(",
")",
";",
"monitor",
".",
"taskEnded",
"(",
")",
";",
"}"
] |
Performs a full classification on the current ontology.
|
[
"Performs",
"a",
"full",
"classification",
"on",
"the",
"current",
"ontology",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L350-L360
|
11,301
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.flush
|
@Override
public void flush() {
if (rawChanges.isEmpty() || !buffering) {
return;
}
// Get the changed axioms
boolean hasRemoveAxiom = false;
List<OWLAxiom> newAxioms = new ArrayList<OWLAxiom>();
for (OWLOntologyChange change : rawChanges) {
OWLAxiom axiom = change.getAxiom();
if(axiom instanceof RemoveAxiom) {
hasRemoveAxiom = true;
break;
}
newAxioms.add(axiom);
}
if(hasRemoveAxiom) {
rawChanges.clear();
classify();
return;
}
// Transform the axioms into the canonical model
Set<Axiom> canAxioms = getAxioms(newAxioms);
// Classify
monitor.taskStarted("Classifying incrementally");
monitor.taskBusy();
reasoner.loadAxioms(canAxioms);
reasoner = reasoner.classify();
monitor.taskEnded();
monitor.taskStarted("Calculating taxonomy incrementally");
monitor.taskBusy();
taxonomy = reasoner.getClassifiedOntology();
monitor.taskEnded();
rawChanges.clear();
}
|
java
|
@Override
public void flush() {
if (rawChanges.isEmpty() || !buffering) {
return;
}
// Get the changed axioms
boolean hasRemoveAxiom = false;
List<OWLAxiom> newAxioms = new ArrayList<OWLAxiom>();
for (OWLOntologyChange change : rawChanges) {
OWLAxiom axiom = change.getAxiom();
if(axiom instanceof RemoveAxiom) {
hasRemoveAxiom = true;
break;
}
newAxioms.add(axiom);
}
if(hasRemoveAxiom) {
rawChanges.clear();
classify();
return;
}
// Transform the axioms into the canonical model
Set<Axiom> canAxioms = getAxioms(newAxioms);
// Classify
monitor.taskStarted("Classifying incrementally");
monitor.taskBusy();
reasoner.loadAxioms(canAxioms);
reasoner = reasoner.classify();
monitor.taskEnded();
monitor.taskStarted("Calculating taxonomy incrementally");
monitor.taskBusy();
taxonomy = reasoner.getClassifiedOntology();
monitor.taskEnded();
rawChanges.clear();
}
|
[
"@",
"Override",
"public",
"void",
"flush",
"(",
")",
"{",
"if",
"(",
"rawChanges",
".",
"isEmpty",
"(",
")",
"||",
"!",
"buffering",
")",
"{",
"return",
";",
"}",
"// Get the changed axioms\r",
"boolean",
"hasRemoveAxiom",
"=",
"false",
";",
"List",
"<",
"OWLAxiom",
">",
"newAxioms",
"=",
"new",
"ArrayList",
"<",
"OWLAxiom",
">",
"(",
")",
";",
"for",
"(",
"OWLOntologyChange",
"change",
":",
"rawChanges",
")",
"{",
"OWLAxiom",
"axiom",
"=",
"change",
".",
"getAxiom",
"(",
")",
";",
"if",
"(",
"axiom",
"instanceof",
"RemoveAxiom",
")",
"{",
"hasRemoveAxiom",
"=",
"true",
";",
"break",
";",
"}",
"newAxioms",
".",
"add",
"(",
"axiom",
")",
";",
"}",
"if",
"(",
"hasRemoveAxiom",
")",
"{",
"rawChanges",
".",
"clear",
"(",
")",
";",
"classify",
"(",
")",
";",
"return",
";",
"}",
"// Transform the axioms into the canonical model\r",
"Set",
"<",
"Axiom",
">",
"canAxioms",
"=",
"getAxioms",
"(",
"newAxioms",
")",
";",
"// Classify\r",
"monitor",
".",
"taskStarted",
"(",
"\"Classifying incrementally\"",
")",
";",
"monitor",
".",
"taskBusy",
"(",
")",
";",
"reasoner",
".",
"loadAxioms",
"(",
"canAxioms",
")",
";",
"reasoner",
"=",
"reasoner",
".",
"classify",
"(",
")",
";",
"monitor",
".",
"taskEnded",
"(",
")",
";",
"monitor",
".",
"taskStarted",
"(",
"\"Calculating taxonomy incrementally\"",
")",
";",
"monitor",
".",
"taskBusy",
"(",
")",
";",
"taxonomy",
"=",
"reasoner",
".",
"getClassifiedOntology",
"(",
")",
";",
"monitor",
".",
"taskEnded",
"(",
")",
";",
"rawChanges",
".",
"clear",
"(",
")",
";",
"}"
] |
Classifies the ontology incrementally if no import changes have occurred.
Flushes any changes stored in the buffer, which causes the reasoner to
take into consideration the changes the current root ontology specified
by the changes. If the reasoner buffering mode is
{@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING}
then this method will have no effect.
|
[
"Classifies",
"the",
"ontology",
"incrementally",
"if",
"no",
"import",
"changes",
"have",
"occurred",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L419-L459
|
11,302
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.isPrecomputed
|
@Override
public boolean isPrecomputed(InferenceType inferenceType) {
if (inferenceType.equals(InferenceType.CLASS_HIERARCHY)) {
return reasoner.isClassified();
} else {
return false;
}
}
|
java
|
@Override
public boolean isPrecomputed(InferenceType inferenceType) {
if (inferenceType.equals(InferenceType.CLASS_HIERARCHY)) {
return reasoner.isClassified();
} else {
return false;
}
}
|
[
"@",
"Override",
"public",
"boolean",
"isPrecomputed",
"(",
"InferenceType",
"inferenceType",
")",
"{",
"if",
"(",
"inferenceType",
".",
"equals",
"(",
"InferenceType",
".",
"CLASS_HIERARCHY",
")",
")",
"{",
"return",
"reasoner",
".",
"isClassified",
"(",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Determines if a specific set of inferences have been precomputed.
@param inferenceType The type of inference to check for.
@return <code>true</code> if the specified type of inferences have been
precomputed, otherwise <code>false</code>.
|
[
"Determines",
"if",
"a",
"specific",
"set",
"of",
"inferences",
"have",
"been",
"precomputed",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L603-L610
|
11,303
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.isSatisfiable
|
@Override
public boolean isSatisfiable(OWLClassExpression classExpression)
throws ReasonerInterruptedException, TimeOutException,
ClassExpressionNotInProfileException, FreshEntitiesException,
InconsistentOntologyException {
if (classExpression.isAnonymous()) {
return false;
} else {
// If the node that contains OWLNothing contains this OWLClass then
// it is not satisfiable
Object id = getId(classExpression.asOWLClass());
au.csiro.ontology.Node bottom = getTaxonomy().getBottomNode();
return !bottom.getEquivalentConcepts().contains(id);
}
}
|
java
|
@Override
public boolean isSatisfiable(OWLClassExpression classExpression)
throws ReasonerInterruptedException, TimeOutException,
ClassExpressionNotInProfileException, FreshEntitiesException,
InconsistentOntologyException {
if (classExpression.isAnonymous()) {
return false;
} else {
// If the node that contains OWLNothing contains this OWLClass then
// it is not satisfiable
Object id = getId(classExpression.asOWLClass());
au.csiro.ontology.Node bottom = getTaxonomy().getBottomNode();
return !bottom.getEquivalentConcepts().contains(id);
}
}
|
[
"@",
"Override",
"public",
"boolean",
"isSatisfiable",
"(",
"OWLClassExpression",
"classExpression",
")",
"throws",
"ReasonerInterruptedException",
",",
"TimeOutException",
",",
"ClassExpressionNotInProfileException",
",",
"FreshEntitiesException",
",",
"InconsistentOntologyException",
"{",
"if",
"(",
"classExpression",
".",
"isAnonymous",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"// If the node that contains OWLNothing contains this OWLClass then\r",
"// it is not satisfiable\r",
"Object",
"id",
"=",
"getId",
"(",
"classExpression",
".",
"asOWLClass",
"(",
")",
")",
";",
"au",
".",
"csiro",
".",
"ontology",
".",
"Node",
"bottom",
"=",
"getTaxonomy",
"(",
")",
".",
"getBottomNode",
"(",
")",
";",
"return",
"!",
"bottom",
".",
"getEquivalentConcepts",
"(",
")",
".",
"contains",
"(",
"id",
")",
";",
"}",
"}"
] |
A convenience method that determines if the specified class expression is
satisfiable with respect to the reasoner axioms.
@param classExpression
The class expression
@return <code>true</code> if classExpression is satisfiable with respect
to the set of axioms, or <code>false</code> if classExpression is
unsatisfiable with respect to the axioms.
@throws InconsistentOntologyException
if the set of reasoner axioms is inconsistent
@throws ClassExpressionNotInProfileException
if <code>classExpression</code> is not within the profile
that is supported by this reasoner.
@throws FreshEntitiesException
if the signature of the classExpression is not contained
within the signature of the set of reasoner axioms.
@throws ReasonerInterruptedException
if the reasoning process was interrupted for any particular
reason (for example if reasoning was cancelled by a client
process)
@throws TimeOutException
if the reasoner timed out during a basic reasoning operation.
See {@link #getTimeOut()}.
|
[
"A",
"convenience",
"method",
"that",
"determines",
"if",
"the",
"specified",
"class",
"expression",
"is",
"satisfiable",
"with",
"respect",
"to",
"the",
"reasoner",
"axioms",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L681-L695
|
11,304
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.getUnsatisfiableClasses
|
@Override
public Node<OWLClass> getUnsatisfiableClasses()
throws ReasonerInterruptedException, TimeOutException,
InconsistentOntologyException {
return nodeToOwlClassNode(getTaxonomy().getBottomNode());
}
|
java
|
@Override
public Node<OWLClass> getUnsatisfiableClasses()
throws ReasonerInterruptedException, TimeOutException,
InconsistentOntologyException {
return nodeToOwlClassNode(getTaxonomy().getBottomNode());
}
|
[
"@",
"Override",
"public",
"Node",
"<",
"OWLClass",
">",
"getUnsatisfiableClasses",
"(",
")",
"throws",
"ReasonerInterruptedException",
",",
"TimeOutException",
",",
"InconsistentOntologyException",
"{",
"return",
"nodeToOwlClassNode",
"(",
"getTaxonomy",
"(",
")",
".",
"getBottomNode",
"(",
")",
")",
";",
"}"
] |
A convenience method that obtains the classes in the signature of the
root ontology that are unsatisfiable.
@return A <code>Node</code> that is the bottom node in the class
hierarchy. This node represents <code>owl:Nothing</code> and
contains <code>owl:Nothing</code> itself plus classes that are
equivalent to <code>owl:Nothing</code>.
@throws ReasonerInterruptedException
if the reasoning process was interrupted for any particular
reason (for example if reasoning was cancelled by a client
process)
@throws TimeOutException
if the reasoner timed out during a basic reasoning operation.
See {@link #getTimeOut()}.
@throws InconsistentOntologyException
if the set of reasoner axioms is inconsistent
|
[
"A",
"convenience",
"method",
"that",
"obtains",
"the",
"classes",
"in",
"the",
"signature",
"of",
"the",
"root",
"ontology",
"that",
"are",
"unsatisfiable",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L716-L721
|
11,305
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.isEntailed
|
@Override
public boolean isEntailed(Set<? extends OWLAxiom> axioms)
throws ReasonerInterruptedException,
UnsupportedEntailmentTypeException, TimeOutException,
AxiomNotInProfileException, FreshEntitiesException,
InconsistentOntologyException {
throw new UnsupportedEntailmentTypeException(axioms.iterator().next());
}
|
java
|
@Override
public boolean isEntailed(Set<? extends OWLAxiom> axioms)
throws ReasonerInterruptedException,
UnsupportedEntailmentTypeException, TimeOutException,
AxiomNotInProfileException, FreshEntitiesException,
InconsistentOntologyException {
throw new UnsupportedEntailmentTypeException(axioms.iterator().next());
}
|
[
"@",
"Override",
"public",
"boolean",
"isEntailed",
"(",
"Set",
"<",
"?",
"extends",
"OWLAxiom",
">",
"axioms",
")",
"throws",
"ReasonerInterruptedException",
",",
"UnsupportedEntailmentTypeException",
",",
"TimeOutException",
",",
"AxiomNotInProfileException",
",",
"FreshEntitiesException",
",",
"InconsistentOntologyException",
"{",
"throw",
"new",
"UnsupportedEntailmentTypeException",
"(",
"axioms",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
")",
";",
"}"
] |
Determines if the specified set of axioms is entailed by the reasoner
axioms.
@param axioms
The set of axioms to be tested
@return <code>true</code> if the set of axioms is entailed by the axioms
in the imports closure of the root ontology, otherwise
<code>false</code>. If the set of reasoner axioms is inconsistent
then <code>true</code>.
@throws FreshEntitiesException
if the signature of the set of axioms is not contained within
the signature of the imports closure of the root ontology and
the undeclared entity policy of this reasoner is set to
{@link FreshEntityPolicy#DISALLOW}.
@throws ReasonerInterruptedException
if the reasoning process was interrupted for any particular
reason (for example if reasoning was cancelled by a client
process)
@throws TimeOutException
if the reasoner timed out during a basic reasoning operation.
See {@link #getTimeOut()}.
@throws UnsupportedEntailmentTypeException
if the reasoner cannot perform a check to see if the
specified axiom is entailed
@throws AxiomNotInProfileException
if <code>axiom</code> is not in the profile that is supported
by this reasoner.
@throws InconsistentOntologyException
if the set of reasoner axioms is inconsistent
@see #isEntailmentCheckingSupported(org.semanticweb.owlapi.model.AxiomType)
|
[
"Determines",
"if",
"the",
"specified",
"set",
"of",
"axioms",
"is",
"entailed",
"by",
"the",
"reasoner",
"axioms",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L796-L803
|
11,306
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.getDataPropertyValues
|
@Override
public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind,
OWLDataProperty pe) throws InconsistentOntologyException,
FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
return Collections.emptySet();
}
|
java
|
@Override
public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind,
OWLDataProperty pe) throws InconsistentOntologyException,
FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
return Collections.emptySet();
}
|
[
"@",
"Override",
"public",
"Set",
"<",
"OWLLiteral",
">",
"getDataPropertyValues",
"(",
"OWLNamedIndividual",
"ind",
",",
"OWLDataProperty",
"pe",
")",
"throws",
"InconsistentOntologyException",
",",
"FreshEntitiesException",
",",
"ReasonerInterruptedException",
",",
"TimeOutException",
"{",
"return",
"Collections",
".",
"emptySet",
"(",
")",
";",
"}"
] |
Gets the data property values for the specified individual and data
property expression. The values are a set of literals. Note that the
results are not guaranteed to be complete for this method. The reasoner
may also return canonical literals or they may be in a form that bears a
resemblance to the syntax of the literals in the root ontology imports
closure.
@param ind
The individual that is the subject of the data property values
@param pe
The data property expression whose values are to be retrieved
for the specified individual
@return A set of <code>OWLLiteral</code>s containing literals such that
for each literal <code>l</code> in the set, the set of reasoner
axioms entails <code>DataPropertyAssertion(pe ind l)</code>.
@throws InconsistentOntologyException
if the imports closure of the root ontology is inconsistent
@throws FreshEntitiesException
if the signature of the individual and property expression is
not contained within the signature of the imports closure of
the root ontology and the undeclared entity policy of this
reasoner is set to {@link FreshEntityPolicy#DISALLOW}.
@throws ReasonerInterruptedException
if the reasoning process was interrupted for any particular
reason (for example if reasoning was cancelled by a client
process)
@throws TimeOutException
if the reasoner timed out during a basic reasoning operation.
See {@link #getTimeOut()}.
@see {@link org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy}
|
[
"Gets",
"the",
"data",
"property",
"values",
"for",
"the",
"specified",
"individual",
"and",
"data",
"property",
"expression",
".",
"The",
"values",
"are",
"a",
"set",
"of",
"literals",
".",
"Note",
"that",
"the",
"results",
"are",
"not",
"guaranteed",
"to",
"be",
"complete",
"for",
"this",
"method",
".",
"The",
"reasoner",
"may",
"also",
"return",
"canonical",
"literals",
"or",
"they",
"may",
"be",
"in",
"a",
"form",
"that",
"bears",
"a",
"resemblance",
"to",
"the",
"syntax",
"of",
"the",
"literals",
"in",
"the",
"root",
"ontology",
"imports",
"closure",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L1942-L1948
|
11,307
|
aehrc/snorocket
|
snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java
|
SnorocketOWLReasoner.getSameIndividuals
|
@Override
public Node<OWLNamedIndividual> getSameIndividuals(OWLNamedIndividual ind)
throws InconsistentOntologyException, FreshEntitiesException,
ReasonerInterruptedException, TimeOutException {
throw new ReasonerInternalException(
"getSameIndividuals not implemented");
}
|
java
|
@Override
public Node<OWLNamedIndividual> getSameIndividuals(OWLNamedIndividual ind)
throws InconsistentOntologyException, FreshEntitiesException,
ReasonerInterruptedException, TimeOutException {
throw new ReasonerInternalException(
"getSameIndividuals not implemented");
}
|
[
"@",
"Override",
"public",
"Node",
"<",
"OWLNamedIndividual",
">",
"getSameIndividuals",
"(",
"OWLNamedIndividual",
"ind",
")",
"throws",
"InconsistentOntologyException",
",",
"FreshEntitiesException",
",",
"ReasonerInterruptedException",
",",
"TimeOutException",
"{",
"throw",
"new",
"ReasonerInternalException",
"(",
"\"getSameIndividuals not implemented\"",
")",
";",
"}"
] |
Gets the individuals that are the same as the specified individual.
@param ind
The individual whose same individuals are to be retrieved.
@return A node containing individuals such that for each individual
<code>j</code> in the node, the root ontology imports closure
entails <code>SameIndividual(j, ind)</code>. Note that the node
will contain <code>j</code>.
@throws InconsistentOntologyException
if the imports closure of the root ontology is inconsistent
@throws FreshEntitiesException
if the signature of the individual is not contained within
the signature of the imports closure of the root ontology and
the undeclared entity policy of this reasoner is set to
{@link FreshEntityPolicy#DISALLOW}.
@throws ReasonerInterruptedException
if the reasoning process was interrupted for any particular
reason (for example if reasoning was cancelled by a client
process)
@throws TimeOutException
if the reasoner timed out during a basic reasoning operation.
See {@link #getTimeOut()}.
|
[
"Gets",
"the",
"individuals",
"that",
"are",
"the",
"same",
"as",
"the",
"specified",
"individual",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-owlapi/src/main/java/au/csiro/snorocket/owlapi/SnorocketOWLReasoner.java#L1975-L1981
|
11,308
|
j-a-w-r/jawr
|
jawr-core/src/main/java/net/jawr/web/util/ReflectionUtils.java
|
ReflectionUtils.methodBelongsTo
|
public static boolean methodBelongsTo(Method m, Method[] methods){
boolean result = false;
for (int i = 0; i < methods.length && !result; i++) {
if(methodEquals (methods [i], m)){
result = true;
}
}
return result;
}
|
java
|
public static boolean methodBelongsTo(Method m, Method[] methods){
boolean result = false;
for (int i = 0; i < methods.length && !result; i++) {
if(methodEquals (methods [i], m)){
result = true;
}
}
return result;
}
|
[
"public",
"static",
"boolean",
"methodBelongsTo",
"(",
"Method",
"m",
",",
"Method",
"[",
"]",
"methods",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"methods",
".",
"length",
"&&",
"!",
"result",
";",
"i",
"++",
")",
"{",
"if",
"(",
"methodEquals",
"(",
"methods",
"[",
"i",
"]",
",",
"m",
")",
")",
"{",
"result",
"=",
"true",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns true if the method is in the method array.
@param m the method
@param methods the method array
@return true if the method is in the method array.
|
[
"Returns",
"true",
"if",
"the",
"method",
"is",
"in",
"the",
"method",
"array",
"."
] |
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
|
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/util/ReflectionUtils.java#L31-L41
|
11,309
|
j-a-w-r/jawr
|
jawr-core/src/main/java/net/jawr/web/util/ReflectionUtils.java
|
ReflectionUtils.methodEquals
|
public static boolean methodEquals( Method method, Method other){
if ((method.getDeclaringClass().equals( other.getDeclaringClass()))
&& (method.getName().equals( other.getName()))) {
if (!method.getReturnType().equals(other.getReturnType()))
return false;
Class<?>[] params1 = method.getParameterTypes();
Class<?>[] params2 = other.getParameterTypes();
if (params1.length == params2.length) {
for (int i = 0; i < params1.length; i++) {
if (params1[i] != params2[i])
return false;
}
return true;
}
}
return false;
}
|
java
|
public static boolean methodEquals( Method method, Method other){
if ((method.getDeclaringClass().equals( other.getDeclaringClass()))
&& (method.getName().equals( other.getName()))) {
if (!method.getReturnType().equals(other.getReturnType()))
return false;
Class<?>[] params1 = method.getParameterTypes();
Class<?>[] params2 = other.getParameterTypes();
if (params1.length == params2.length) {
for (int i = 0; i < params1.length; i++) {
if (params1[i] != params2[i])
return false;
}
return true;
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"methodEquals",
"(",
"Method",
"method",
",",
"Method",
"other",
")",
"{",
"if",
"(",
"(",
"method",
".",
"getDeclaringClass",
"(",
")",
".",
"equals",
"(",
"other",
".",
"getDeclaringClass",
"(",
")",
")",
")",
"&&",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"other",
".",
"getName",
"(",
")",
")",
")",
")",
"{",
"if",
"(",
"!",
"method",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"other",
".",
"getReturnType",
"(",
")",
")",
")",
"return",
"false",
";",
"Class",
"<",
"?",
">",
"[",
"]",
"params1",
"=",
"method",
".",
"getParameterTypes",
"(",
")",
";",
"Class",
"<",
"?",
">",
"[",
"]",
"params2",
"=",
"other",
".",
"getParameterTypes",
"(",
")",
";",
"if",
"(",
"params1",
".",
"length",
"==",
"params2",
".",
"length",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"params1",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"params1",
"[",
"i",
"]",
"!=",
"params2",
"[",
"i",
"]",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if the 2 methods are equals.
@param method the first method
@param other the second method
@return true if the 2 methods are equals
|
[
"Checks",
"if",
"the",
"2",
"methods",
"are",
"equals",
"."
] |
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
|
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/util/ReflectionUtils.java#L50-L68
|
11,310
|
d-michail/jheaps
|
src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java
|
MinMaxBinaryArrayDoubleEndedHeap.fixupMin
|
@SuppressWarnings("unchecked")
private void fixupMin(int k) {
K key = array[k];
int gp = k / 4;
while (gp > 0 && ((Comparable<? super K>) array[gp]).compareTo(key) > 0) {
array[k] = array[gp];
k = gp;
gp = k / 4;
}
array[k] = key;
}
|
java
|
@SuppressWarnings("unchecked")
private void fixupMin(int k) {
K key = array[k];
int gp = k / 4;
while (gp > 0 && ((Comparable<? super K>) array[gp]).compareTo(key) > 0) {
array[k] = array[gp];
k = gp;
gp = k / 4;
}
array[k] = key;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"fixupMin",
"(",
"int",
"k",
")",
"{",
"K",
"key",
"=",
"array",
"[",
"k",
"]",
";",
"int",
"gp",
"=",
"k",
"/",
"4",
";",
"while",
"(",
"gp",
">",
"0",
"&&",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"array",
"[",
"gp",
"]",
")",
".",
"compareTo",
"(",
"key",
")",
">",
"0",
")",
"{",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"gp",
"]",
";",
"k",
"=",
"gp",
";",
"gp",
"=",
"k",
"/",
"4",
";",
"}",
"array",
"[",
"k",
"]",
"=",
"key",
";",
"}"
] |
Upwards fix starting from a particular element at a minimum level
@param k
the index of the starting element
|
[
"Upwards",
"fix",
"starting",
"from",
"a",
"particular",
"element",
"at",
"a",
"minimum",
"level"
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java#L424-L434
|
11,311
|
d-michail/jheaps
|
src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java
|
MinMaxBinaryArrayDoubleEndedHeap.fixupMinWithComparator
|
private void fixupMinWithComparator(int k) {
K key = array[k];
int gp = k / 4;
while (gp > 0 && comparator.compare(array[gp], key) > 0) {
array[k] = array[gp];
k = gp;
gp = k / 4;
}
array[k] = key;
}
|
java
|
private void fixupMinWithComparator(int k) {
K key = array[k];
int gp = k / 4;
while (gp > 0 && comparator.compare(array[gp], key) > 0) {
array[k] = array[gp];
k = gp;
gp = k / 4;
}
array[k] = key;
}
|
[
"private",
"void",
"fixupMinWithComparator",
"(",
"int",
"k",
")",
"{",
"K",
"key",
"=",
"array",
"[",
"k",
"]",
";",
"int",
"gp",
"=",
"k",
"/",
"4",
";",
"while",
"(",
"gp",
">",
"0",
"&&",
"comparator",
".",
"compare",
"(",
"array",
"[",
"gp",
"]",
",",
"key",
")",
">",
"0",
")",
"{",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"gp",
"]",
";",
"k",
"=",
"gp",
";",
"gp",
"=",
"k",
"/",
"4",
";",
"}",
"array",
"[",
"k",
"]",
"=",
"key",
";",
"}"
] |
Upwards fix starting from a particular element at a minimum level.
Performs comparisons using the comparator.
@param k
the index of the starting element
|
[
"Upwards",
"fix",
"starting",
"from",
"a",
"particular",
"element",
"at",
"a",
"minimum",
"level",
".",
"Performs",
"comparisons",
"using",
"the",
"comparator",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java#L443-L452
|
11,312
|
d-michail/jheaps
|
src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java
|
MinMaxBinaryArrayDoubleEndedHeap.fixupMaxWithComparator
|
private void fixupMaxWithComparator(int k) {
K key = array[k];
int gp = k / 4;
while (gp > 0 && comparator.compare(array[gp], key) < 0) {
array[k] = array[gp];
k = gp;
gp = k / 4;
}
array[k] = key;
}
|
java
|
private void fixupMaxWithComparator(int k) {
K key = array[k];
int gp = k / 4;
while (gp > 0 && comparator.compare(array[gp], key) < 0) {
array[k] = array[gp];
k = gp;
gp = k / 4;
}
array[k] = key;
}
|
[
"private",
"void",
"fixupMaxWithComparator",
"(",
"int",
"k",
")",
"{",
"K",
"key",
"=",
"array",
"[",
"k",
"]",
";",
"int",
"gp",
"=",
"k",
"/",
"4",
";",
"while",
"(",
"gp",
">",
"0",
"&&",
"comparator",
".",
"compare",
"(",
"array",
"[",
"gp",
"]",
",",
"key",
")",
"<",
"0",
")",
"{",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"gp",
"]",
";",
"k",
"=",
"gp",
";",
"gp",
"=",
"k",
"/",
"4",
";",
"}",
"array",
"[",
"k",
"]",
"=",
"key",
";",
"}"
] |
Upwards fix starting from a particular element at a maximum level.
Performs comparisons using the comparator.
@param k
the index of the starting element
|
[
"Upwards",
"fix",
"starting",
"from",
"a",
"particular",
"element",
"at",
"a",
"maximum",
"level",
".",
"Performs",
"comparisons",
"using",
"the",
"comparator",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java#L479-L488
|
11,313
|
d-michail/jheaps
|
src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java
|
MinMaxBinaryArrayDoubleEndedHeap.fixdownMin
|
@SuppressWarnings("unchecked")
private void fixdownMin(int k) {
int c = 2 * k;
while (c <= size) {
int m = minChildOrGrandchild(k);
if (m > c + 1) { // grandchild
if (((Comparable<? super K>) array[m]).compareTo(array[k]) >= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (((Comparable<? super K>) array[m]).compareTo(array[m / 2]) > 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (((Comparable<? super K>) array[m]).compareTo(array[k]) < 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
java
|
@SuppressWarnings("unchecked")
private void fixdownMin(int k) {
int c = 2 * k;
while (c <= size) {
int m = minChildOrGrandchild(k);
if (m > c + 1) { // grandchild
if (((Comparable<? super K>) array[m]).compareTo(array[k]) >= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (((Comparable<? super K>) array[m]).compareTo(array[m / 2]) > 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (((Comparable<? super K>) array[m]).compareTo(array[k]) < 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"fixdownMin",
"(",
"int",
"k",
")",
"{",
"int",
"c",
"=",
"2",
"*",
"k",
";",
"while",
"(",
"c",
"<=",
"size",
")",
"{",
"int",
"m",
"=",
"minChildOrGrandchild",
"(",
"k",
")",
";",
"if",
"(",
"m",
">",
"c",
"+",
"1",
")",
"{",
"// grandchild",
"if",
"(",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"array",
"[",
"m",
"]",
")",
".",
"compareTo",
"(",
"array",
"[",
"k",
"]",
")",
">=",
"0",
")",
"{",
"break",
";",
"}",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"if",
"(",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"array",
"[",
"m",
"]",
")",
".",
"compareTo",
"(",
"array",
"[",
"m",
"/",
"2",
"]",
")",
">",
"0",
")",
"{",
"tmp",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"array",
"[",
"m",
"/",
"2",
"]",
";",
"array",
"[",
"m",
"/",
"2",
"]",
"=",
"tmp",
";",
"}",
"// go down",
"k",
"=",
"m",
";",
"c",
"=",
"2",
"*",
"k",
";",
"}",
"else",
"{",
"// child",
"if",
"(",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"array",
"[",
"m",
"]",
")",
".",
"compareTo",
"(",
"array",
"[",
"k",
"]",
")",
"<",
"0",
")",
"{",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"}",
"break",
";",
"}",
"}",
"}"
] |
Downwards fix starting from a particular element at a minimum level.
@param k
the index of the starting element
|
[
"Downwards",
"fix",
"starting",
"from",
"a",
"particular",
"element",
"at",
"a",
"minimum",
"level",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java#L527-L556
|
11,314
|
d-michail/jheaps
|
src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java
|
MinMaxBinaryArrayDoubleEndedHeap.fixdownMinWithComparator
|
private void fixdownMinWithComparator(int k) {
int c = 2 * k;
while (c <= size) {
int m = minChildOrGrandchildWithComparator(k);
if (m > c + 1) { // grandchild
if (comparator.compare(array[m], array[k]) >= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (comparator.compare(array[m], array[m / 2]) > 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (comparator.compare(array[m], array[k]) < 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
java
|
private void fixdownMinWithComparator(int k) {
int c = 2 * k;
while (c <= size) {
int m = minChildOrGrandchildWithComparator(k);
if (m > c + 1) { // grandchild
if (comparator.compare(array[m], array[k]) >= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (comparator.compare(array[m], array[m / 2]) > 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (comparator.compare(array[m], array[k]) < 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
[
"private",
"void",
"fixdownMinWithComparator",
"(",
"int",
"k",
")",
"{",
"int",
"c",
"=",
"2",
"*",
"k",
";",
"while",
"(",
"c",
"<=",
"size",
")",
"{",
"int",
"m",
"=",
"minChildOrGrandchildWithComparator",
"(",
"k",
")",
";",
"if",
"(",
"m",
">",
"c",
"+",
"1",
")",
"{",
"// grandchild",
"if",
"(",
"comparator",
".",
"compare",
"(",
"array",
"[",
"m",
"]",
",",
"array",
"[",
"k",
"]",
")",
">=",
"0",
")",
"{",
"break",
";",
"}",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"if",
"(",
"comparator",
".",
"compare",
"(",
"array",
"[",
"m",
"]",
",",
"array",
"[",
"m",
"/",
"2",
"]",
")",
">",
"0",
")",
"{",
"tmp",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"array",
"[",
"m",
"/",
"2",
"]",
";",
"array",
"[",
"m",
"/",
"2",
"]",
"=",
"tmp",
";",
"}",
"// go down",
"k",
"=",
"m",
";",
"c",
"=",
"2",
"*",
"k",
";",
"}",
"else",
"{",
"// child",
"if",
"(",
"comparator",
".",
"compare",
"(",
"array",
"[",
"m",
"]",
",",
"array",
"[",
"k",
"]",
")",
"<",
"0",
")",
"{",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"}",
"break",
";",
"}",
"}",
"}"
] |
Downwards fix starting from a particular element at a minimum level.
Performs comparisons using the comparator.
@param k
the index of the starting element
|
[
"Downwards",
"fix",
"starting",
"from",
"a",
"particular",
"element",
"at",
"a",
"minimum",
"level",
".",
"Performs",
"comparisons",
"using",
"the",
"comparator",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java#L565-L593
|
11,315
|
d-michail/jheaps
|
src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java
|
MinMaxBinaryArrayDoubleEndedHeap.fixdownMax
|
@SuppressWarnings("unchecked")
private void fixdownMax(int k) {
int c = 2 * k;
while (c <= size) {
int m = maxChildOrGrandchild(k);
if (m > c + 1) { // grandchild
if (((Comparable<? super K>) array[m]).compareTo(array[k]) <= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (((Comparable<? super K>) array[m]).compareTo(array[m / 2]) < 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (((Comparable<? super K>) array[m]).compareTo(array[k]) > 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
java
|
@SuppressWarnings("unchecked")
private void fixdownMax(int k) {
int c = 2 * k;
while (c <= size) {
int m = maxChildOrGrandchild(k);
if (m > c + 1) { // grandchild
if (((Comparable<? super K>) array[m]).compareTo(array[k]) <= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (((Comparable<? super K>) array[m]).compareTo(array[m / 2]) < 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (((Comparable<? super K>) array[m]).compareTo(array[k]) > 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"fixdownMax",
"(",
"int",
"k",
")",
"{",
"int",
"c",
"=",
"2",
"*",
"k",
";",
"while",
"(",
"c",
"<=",
"size",
")",
"{",
"int",
"m",
"=",
"maxChildOrGrandchild",
"(",
"k",
")",
";",
"if",
"(",
"m",
">",
"c",
"+",
"1",
")",
"{",
"// grandchild",
"if",
"(",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"array",
"[",
"m",
"]",
")",
".",
"compareTo",
"(",
"array",
"[",
"k",
"]",
")",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"if",
"(",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"array",
"[",
"m",
"]",
")",
".",
"compareTo",
"(",
"array",
"[",
"m",
"/",
"2",
"]",
")",
"<",
"0",
")",
"{",
"tmp",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"array",
"[",
"m",
"/",
"2",
"]",
";",
"array",
"[",
"m",
"/",
"2",
"]",
"=",
"tmp",
";",
"}",
"// go down",
"k",
"=",
"m",
";",
"c",
"=",
"2",
"*",
"k",
";",
"}",
"else",
"{",
"// child",
"if",
"(",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"array",
"[",
"m",
"]",
")",
".",
"compareTo",
"(",
"array",
"[",
"k",
"]",
")",
">",
"0",
")",
"{",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"}",
"break",
";",
"}",
"}",
"}"
] |
Downwards fix starting from a particular element at a maximum level.
@param k
the index of the starting element
|
[
"Downwards",
"fix",
"starting",
"from",
"a",
"particular",
"element",
"at",
"a",
"maximum",
"level",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java#L601-L630
|
11,316
|
d-michail/jheaps
|
src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java
|
MinMaxBinaryArrayDoubleEndedHeap.fixdownMaxWithComparator
|
private void fixdownMaxWithComparator(int k) {
int c = 2 * k;
while (c <= size) {
int m = maxChildOrGrandchildWithComparator(k);
if (m > c + 1) { // grandchild
if (comparator.compare(array[m], array[k]) <= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (comparator.compare(array[m], array[m / 2]) < 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (comparator.compare(array[m], array[k]) > 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
java
|
private void fixdownMaxWithComparator(int k) {
int c = 2 * k;
while (c <= size) {
int m = maxChildOrGrandchildWithComparator(k);
if (m > c + 1) { // grandchild
if (comparator.compare(array[m], array[k]) <= 0) {
break;
}
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
if (comparator.compare(array[m], array[m / 2]) < 0) {
tmp = array[m];
array[m] = array[m / 2];
array[m / 2] = tmp;
}
// go down
k = m;
c = 2 * k;
} else { // child
if (comparator.compare(array[m], array[k]) > 0) {
K tmp = array[k];
array[k] = array[m];
array[m] = tmp;
}
break;
}
}
}
|
[
"private",
"void",
"fixdownMaxWithComparator",
"(",
"int",
"k",
")",
"{",
"int",
"c",
"=",
"2",
"*",
"k",
";",
"while",
"(",
"c",
"<=",
"size",
")",
"{",
"int",
"m",
"=",
"maxChildOrGrandchildWithComparator",
"(",
"k",
")",
";",
"if",
"(",
"m",
">",
"c",
"+",
"1",
")",
"{",
"// grandchild",
"if",
"(",
"comparator",
".",
"compare",
"(",
"array",
"[",
"m",
"]",
",",
"array",
"[",
"k",
"]",
")",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"if",
"(",
"comparator",
".",
"compare",
"(",
"array",
"[",
"m",
"]",
",",
"array",
"[",
"m",
"/",
"2",
"]",
")",
"<",
"0",
")",
"{",
"tmp",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"array",
"[",
"m",
"/",
"2",
"]",
";",
"array",
"[",
"m",
"/",
"2",
"]",
"=",
"tmp",
";",
"}",
"// go down",
"k",
"=",
"m",
";",
"c",
"=",
"2",
"*",
"k",
";",
"}",
"else",
"{",
"// child",
"if",
"(",
"comparator",
".",
"compare",
"(",
"array",
"[",
"m",
"]",
",",
"array",
"[",
"k",
"]",
")",
">",
"0",
")",
"{",
"K",
"tmp",
"=",
"array",
"[",
"k",
"]",
";",
"array",
"[",
"k",
"]",
"=",
"array",
"[",
"m",
"]",
";",
"array",
"[",
"m",
"]",
"=",
"tmp",
";",
"}",
"break",
";",
"}",
"}",
"}"
] |
Downwards fix starting from a particular element at a maximum level.
Performs comparisons using the comparator.
@param k
the index of the starting element
|
[
"Downwards",
"fix",
"starting",
"from",
"a",
"particular",
"element",
"at",
"a",
"maximum",
"level",
".",
"Performs",
"comparisons",
"using",
"the",
"comparator",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/array/MinMaxBinaryArrayDoubleEndedHeap.java#L639-L667
|
11,317
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/NetworkMonitor.java
|
NetworkMonitor.getCurrentConnectionType
|
public NetworkConnectionType getCurrentConnectionType() {
NetworkInfo activeNetworkInfo = getActiveNetworkInfo();
if (activeNetworkInfo == null || !isInternetAccessAvailable()) {
return NetworkConnectionType.NO_CONNECTION;
}
switch (activeNetworkInfo.getType()) {
case ConnectivityManager.TYPE_WIFI:
return NetworkConnectionType.WIFI;
case ConnectivityManager.TYPE_MOBILE:
return NetworkConnectionType.MOBILE;
case ConnectivityManager.TYPE_WIMAX:
return NetworkConnectionType.WIMAX;
case ConnectivityManager.TYPE_ETHERNET:
return NetworkConnectionType.ETHERNET;
default:
return NetworkConnectionType.NO_CONNECTION;
}
}
|
java
|
public NetworkConnectionType getCurrentConnectionType() {
NetworkInfo activeNetworkInfo = getActiveNetworkInfo();
if (activeNetworkInfo == null || !isInternetAccessAvailable()) {
return NetworkConnectionType.NO_CONNECTION;
}
switch (activeNetworkInfo.getType()) {
case ConnectivityManager.TYPE_WIFI:
return NetworkConnectionType.WIFI;
case ConnectivityManager.TYPE_MOBILE:
return NetworkConnectionType.MOBILE;
case ConnectivityManager.TYPE_WIMAX:
return NetworkConnectionType.WIMAX;
case ConnectivityManager.TYPE_ETHERNET:
return NetworkConnectionType.ETHERNET;
default:
return NetworkConnectionType.NO_CONNECTION;
}
}
|
[
"public",
"NetworkConnectionType",
"getCurrentConnectionType",
"(",
")",
"{",
"NetworkInfo",
"activeNetworkInfo",
"=",
"getActiveNetworkInfo",
"(",
")",
";",
"if",
"(",
"activeNetworkInfo",
"==",
"null",
"||",
"!",
"isInternetAccessAvailable",
"(",
")",
")",
"{",
"return",
"NetworkConnectionType",
".",
"NO_CONNECTION",
";",
"}",
"switch",
"(",
"activeNetworkInfo",
".",
"getType",
"(",
")",
")",
"{",
"case",
"ConnectivityManager",
".",
"TYPE_WIFI",
":",
"return",
"NetworkConnectionType",
".",
"WIFI",
";",
"case",
"ConnectivityManager",
".",
"TYPE_MOBILE",
":",
"return",
"NetworkConnectionType",
".",
"MOBILE",
";",
"case",
"ConnectivityManager",
".",
"TYPE_WIMAX",
":",
"return",
"NetworkConnectionType",
".",
"WIMAX",
";",
"case",
"ConnectivityManager",
".",
"TYPE_ETHERNET",
":",
"return",
"NetworkConnectionType",
".",
"ETHERNET",
";",
"default",
":",
"return",
"NetworkConnectionType",
".",
"NO_CONNECTION",
";",
"}",
"}"
] |
Get the type of network connection that the device is currently using
to connect to the internet.
@return The type of network connection that the device is currently using.
|
[
"Get",
"the",
"type",
"of",
"network",
"connection",
"that",
"the",
"device",
"is",
"currently",
"using",
"to",
"connect",
"to",
"the",
"internet",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/NetworkMonitor.java#L154-L172
|
11,318
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/NetworkMonitor.java
|
NetworkMonitor.getActiveNetworkInfo
|
protected NetworkInfo getActiveNetworkInfo() {
ConnectivityManager connectivityManager
= (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
return connectivityManager.getActiveNetworkInfo();
}
|
java
|
protected NetworkInfo getActiveNetworkInfo() {
ConnectivityManager connectivityManager
= (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
return connectivityManager.getActiveNetworkInfo();
}
|
[
"protected",
"NetworkInfo",
"getActiveNetworkInfo",
"(",
")",
"{",
"ConnectivityManager",
"connectivityManager",
"=",
"(",
"ConnectivityManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"CONNECTIVITY_SERVICE",
")",
";",
"return",
"connectivityManager",
".",
"getActiveNetworkInfo",
"(",
")",
";",
"}"
] |
Retrieves information on the current type of network connection that the device is using
|
[
"Retrieves",
"information",
"on",
"the",
"current",
"type",
"of",
"network",
"connection",
"that",
"the",
"device",
"is",
"using"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/api/NetworkMonitor.java#L194-L198
|
11,319
|
aehrc/snorocket
|
snorocket-examples/src/main/java/au/csiro/snorocket/core/benchmark/Benchmark.java
|
Benchmark.runBechmarkRF1
|
public Stats runBechmarkRF1() {
Stats res = new Stats();
String version = "20110731";
// Classify ontology from stated form
System.out.println("Classifying ontology");
long start = System.currentTimeMillis();
IFactory factory = new CoreFactory();
NormalisedOntology no = new NormalisedOntology(factory);
System.out.println("Importing axioms");
RF1Importer imp = new RF1Importer(
this.getClass().getResourceAsStream(
"/sct1_Concepts_Core_INT_20110731.txt"),
this.getClass().getResourceAsStream(
"/res1_StatedRelationships_Core_INT_20110731.txt"),
version);
Iterator<Ontology> it = imp.getOntologyVersions(new NullProgressMonitor());
Ontology ont = null;
while(it.hasNext()) {
Ontology o = it.next();
if(o.getVersion().equals("snomed")) {
ont = o;
break;
}
}
// We can do this because we know there is only one ontology (RF1 does
// not support multiple versions)
if(ont == null) {
throw new RuntimeException("Could not find version "+version+" in input files");
}
res.setAxiomTransformationTimeMs(System.currentTimeMillis() - start);
start = System.currentTimeMillis();
System.out.println("Loading axioms");
no.loadAxioms(new HashSet<Axiom>((Collection<? extends Axiom>) ont.getStatedAxioms()));
res.setAxiomLoadingTimeMs(System.currentTimeMillis() - start);
start = System.currentTimeMillis();
System.out.println("Running classification");
no.classify();
res.setClassificationTimeMs(System.currentTimeMillis() - start);
start = System.currentTimeMillis();
System.out.println("Computing taxonomy");
no.buildTaxonomy();
res.setTaxonomyBuildingTimeMs(System.currentTimeMillis() - start);
System.out.println("Done");
return res;
}
|
java
|
public Stats runBechmarkRF1() {
Stats res = new Stats();
String version = "20110731";
// Classify ontology from stated form
System.out.println("Classifying ontology");
long start = System.currentTimeMillis();
IFactory factory = new CoreFactory();
NormalisedOntology no = new NormalisedOntology(factory);
System.out.println("Importing axioms");
RF1Importer imp = new RF1Importer(
this.getClass().getResourceAsStream(
"/sct1_Concepts_Core_INT_20110731.txt"),
this.getClass().getResourceAsStream(
"/res1_StatedRelationships_Core_INT_20110731.txt"),
version);
Iterator<Ontology> it = imp.getOntologyVersions(new NullProgressMonitor());
Ontology ont = null;
while(it.hasNext()) {
Ontology o = it.next();
if(o.getVersion().equals("snomed")) {
ont = o;
break;
}
}
// We can do this because we know there is only one ontology (RF1 does
// not support multiple versions)
if(ont == null) {
throw new RuntimeException("Could not find version "+version+" in input files");
}
res.setAxiomTransformationTimeMs(System.currentTimeMillis() - start);
start = System.currentTimeMillis();
System.out.println("Loading axioms");
no.loadAxioms(new HashSet<Axiom>((Collection<? extends Axiom>) ont.getStatedAxioms()));
res.setAxiomLoadingTimeMs(System.currentTimeMillis() - start);
start = System.currentTimeMillis();
System.out.println("Running classification");
no.classify();
res.setClassificationTimeMs(System.currentTimeMillis() - start);
start = System.currentTimeMillis();
System.out.println("Computing taxonomy");
no.buildTaxonomy();
res.setTaxonomyBuildingTimeMs(System.currentTimeMillis() - start);
System.out.println("Done");
return res;
}
|
[
"public",
"Stats",
"runBechmarkRF1",
"(",
")",
"{",
"Stats",
"res",
"=",
"new",
"Stats",
"(",
")",
";",
"String",
"version",
"=",
"\"20110731\"",
";",
"// Classify ontology from stated form\r",
"System",
".",
"out",
".",
"println",
"(",
"\"Classifying ontology\"",
")",
";",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"IFactory",
"factory",
"=",
"new",
"CoreFactory",
"(",
")",
";",
"NormalisedOntology",
"no",
"=",
"new",
"NormalisedOntology",
"(",
"factory",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Importing axioms\"",
")",
";",
"RF1Importer",
"imp",
"=",
"new",
"RF1Importer",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"/sct1_Concepts_Core_INT_20110731.txt\"",
")",
",",
"this",
".",
"getClass",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"/res1_StatedRelationships_Core_INT_20110731.txt\"",
")",
",",
"version",
")",
";",
"Iterator",
"<",
"Ontology",
">",
"it",
"=",
"imp",
".",
"getOntologyVersions",
"(",
"new",
"NullProgressMonitor",
"(",
")",
")",
";",
"Ontology",
"ont",
"=",
"null",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Ontology",
"o",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"o",
".",
"getVersion",
"(",
")",
".",
"equals",
"(",
"\"snomed\"",
")",
")",
"{",
"ont",
"=",
"o",
";",
"break",
";",
"}",
"}",
"// We can do this because we know there is only one ontology (RF1 does\r",
"// not support multiple versions)\r",
"if",
"(",
"ont",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not find version \"",
"+",
"version",
"+",
"\" in input files\"",
")",
";",
"}",
"res",
".",
"setAxiomTransformationTimeMs",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Loading axioms\"",
")",
";",
"no",
".",
"loadAxioms",
"(",
"new",
"HashSet",
"<",
"Axiom",
">",
"(",
"(",
"Collection",
"<",
"?",
"extends",
"Axiom",
">",
")",
"ont",
".",
"getStatedAxioms",
"(",
")",
")",
")",
";",
"res",
".",
"setAxiomLoadingTimeMs",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Running classification\"",
")",
";",
"no",
".",
"classify",
"(",
")",
";",
"res",
".",
"setClassificationTimeMs",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Computing taxonomy\"",
")",
";",
"no",
".",
"buildTaxonomy",
"(",
")",
";",
"res",
".",
"setTaxonomyBuildingTimeMs",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Done\"",
")",
";",
"return",
"res",
";",
"}"
] |
Runs the benchmark using an RF1 file as input.
@param concepts
The concepts file.
@param relationships
The stated relationships file.
|
[
"Runs",
"the",
"benchmark",
"using",
"an",
"RF1",
"file",
"as",
"input",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-examples/src/main/java/au/csiro/snorocket/core/benchmark/Benchmark.java#L49-L100
|
11,320
|
d-michail/jheaps
|
src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java
|
CostlessMeldPairingHeap.delete
|
private void delete(Node<K, V> n) {
if (n != root && n.o_s == null && n.poolIndex == Node.NO_INDEX) {
// no root, no parent and no pool index
throw new IllegalArgumentException("Invalid handle!");
}
// node has a parent
if (n.o_s != null) {
// cut oldest child
Node<K, V> oldestChild = cutOldestChild(n);
if (oldestChild != null) {
linkInPlace(oldestChild, n);
} else {
cutFromParent(n);
}
}
// node has no parent
// cut children
Node<K, V> childrenTree = combine(cutChildren(n));
boolean checkConsolidate = false;
if (childrenTree != null) {
checkConsolidate = true;
addPool(childrenTree, true);
}
size--;
if (n == root) {
root = null;
consolidate();
checkConsolidate = false;
} else if (n.poolIndex != Node.NO_INDEX) {
byte curIndex = n.poolIndex;
decreasePool[curIndex] = decreasePool[decreasePoolSize - 1];
decreasePool[curIndex].poolIndex = curIndex;
decreasePool[decreasePoolSize - 1] = null;
decreasePoolSize--;
n.poolIndex = Node.NO_INDEX;
if (curIndex == decreasePoolMinPos) {
// in decrease pool, and also the minimum
consolidate();
checkConsolidate = false;
} else {
// in decrease pool, and not the minimum
if (decreasePoolMinPos == decreasePoolSize) {
decreasePoolMinPos = curIndex;
}
checkConsolidate = true;
}
}
// if decrease pool has >= ceil(logn) trees, consolidate
if (checkConsolidate) {
double sizeAsDouble = size;
if (decreasePoolSize >= Math.getExponent(sizeAsDouble) + 1) {
consolidate();
}
}
}
|
java
|
private void delete(Node<K, V> n) {
if (n != root && n.o_s == null && n.poolIndex == Node.NO_INDEX) {
// no root, no parent and no pool index
throw new IllegalArgumentException("Invalid handle!");
}
// node has a parent
if (n.o_s != null) {
// cut oldest child
Node<K, V> oldestChild = cutOldestChild(n);
if (oldestChild != null) {
linkInPlace(oldestChild, n);
} else {
cutFromParent(n);
}
}
// node has no parent
// cut children
Node<K, V> childrenTree = combine(cutChildren(n));
boolean checkConsolidate = false;
if (childrenTree != null) {
checkConsolidate = true;
addPool(childrenTree, true);
}
size--;
if (n == root) {
root = null;
consolidate();
checkConsolidate = false;
} else if (n.poolIndex != Node.NO_INDEX) {
byte curIndex = n.poolIndex;
decreasePool[curIndex] = decreasePool[decreasePoolSize - 1];
decreasePool[curIndex].poolIndex = curIndex;
decreasePool[decreasePoolSize - 1] = null;
decreasePoolSize--;
n.poolIndex = Node.NO_INDEX;
if (curIndex == decreasePoolMinPos) {
// in decrease pool, and also the minimum
consolidate();
checkConsolidate = false;
} else {
// in decrease pool, and not the minimum
if (decreasePoolMinPos == decreasePoolSize) {
decreasePoolMinPos = curIndex;
}
checkConsolidate = true;
}
}
// if decrease pool has >= ceil(logn) trees, consolidate
if (checkConsolidate) {
double sizeAsDouble = size;
if (decreasePoolSize >= Math.getExponent(sizeAsDouble) + 1) {
consolidate();
}
}
}
|
[
"private",
"void",
"delete",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"n",
")",
"{",
"if",
"(",
"n",
"!=",
"root",
"&&",
"n",
".",
"o_s",
"==",
"null",
"&&",
"n",
".",
"poolIndex",
"==",
"Node",
".",
"NO_INDEX",
")",
"{",
"// no root, no parent and no pool index",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid handle!\"",
")",
";",
"}",
"// node has a parent",
"if",
"(",
"n",
".",
"o_s",
"!=",
"null",
")",
"{",
"// cut oldest child",
"Node",
"<",
"K",
",",
"V",
">",
"oldestChild",
"=",
"cutOldestChild",
"(",
"n",
")",
";",
"if",
"(",
"oldestChild",
"!=",
"null",
")",
"{",
"linkInPlace",
"(",
"oldestChild",
",",
"n",
")",
";",
"}",
"else",
"{",
"cutFromParent",
"(",
"n",
")",
";",
"}",
"}",
"// node has no parent",
"// cut children",
"Node",
"<",
"K",
",",
"V",
">",
"childrenTree",
"=",
"combine",
"(",
"cutChildren",
"(",
"n",
")",
")",
";",
"boolean",
"checkConsolidate",
"=",
"false",
";",
"if",
"(",
"childrenTree",
"!=",
"null",
")",
"{",
"checkConsolidate",
"=",
"true",
";",
"addPool",
"(",
"childrenTree",
",",
"true",
")",
";",
"}",
"size",
"--",
";",
"if",
"(",
"n",
"==",
"root",
")",
"{",
"root",
"=",
"null",
";",
"consolidate",
"(",
")",
";",
"checkConsolidate",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"n",
".",
"poolIndex",
"!=",
"Node",
".",
"NO_INDEX",
")",
"{",
"byte",
"curIndex",
"=",
"n",
".",
"poolIndex",
";",
"decreasePool",
"[",
"curIndex",
"]",
"=",
"decreasePool",
"[",
"decreasePoolSize",
"-",
"1",
"]",
";",
"decreasePool",
"[",
"curIndex",
"]",
".",
"poolIndex",
"=",
"curIndex",
";",
"decreasePool",
"[",
"decreasePoolSize",
"-",
"1",
"]",
"=",
"null",
";",
"decreasePoolSize",
"--",
";",
"n",
".",
"poolIndex",
"=",
"Node",
".",
"NO_INDEX",
";",
"if",
"(",
"curIndex",
"==",
"decreasePoolMinPos",
")",
"{",
"// in decrease pool, and also the minimum",
"consolidate",
"(",
")",
";",
"checkConsolidate",
"=",
"false",
";",
"}",
"else",
"{",
"// in decrease pool, and not the minimum",
"if",
"(",
"decreasePoolMinPos",
"==",
"decreasePoolSize",
")",
"{",
"decreasePoolMinPos",
"=",
"curIndex",
";",
"}",
"checkConsolidate",
"=",
"true",
";",
"}",
"}",
"// if decrease pool has >= ceil(logn) trees, consolidate",
"if",
"(",
"checkConsolidate",
")",
"{",
"double",
"sizeAsDouble",
"=",
"size",
";",
"if",
"(",
"decreasePoolSize",
">=",
"Math",
".",
"getExponent",
"(",
"sizeAsDouble",
")",
"+",
"1",
")",
"{",
"consolidate",
"(",
")",
";",
"}",
"}",
"}"
] |
Delete a node.
@param n
the node
|
[
"Delete",
"a",
"node",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java#L595-L653
|
11,321
|
d-michail/jheaps
|
src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java
|
CostlessMeldPairingHeap.addPool
|
@SuppressWarnings("unchecked")
private void addPool(Node<K, V> n, boolean updateMinimum) {
decreasePool[decreasePoolSize] = n;
n.poolIndex = decreasePoolSize;
decreasePoolSize++;
if (updateMinimum && decreasePoolSize > 1) {
Node<K, V> poolMin = decreasePool[decreasePoolMinPos];
int c;
if (comparator == null) {
c = ((Comparable<? super K>) n.key).compareTo(poolMin.key);
} else {
c = comparator.compare(n.key, poolMin.key);
}
if (c < 0) {
decreasePoolMinPos = n.poolIndex;
}
}
}
|
java
|
@SuppressWarnings("unchecked")
private void addPool(Node<K, V> n, boolean updateMinimum) {
decreasePool[decreasePoolSize] = n;
n.poolIndex = decreasePoolSize;
decreasePoolSize++;
if (updateMinimum && decreasePoolSize > 1) {
Node<K, V> poolMin = decreasePool[decreasePoolMinPos];
int c;
if (comparator == null) {
c = ((Comparable<? super K>) n.key).compareTo(poolMin.key);
} else {
c = comparator.compare(n.key, poolMin.key);
}
if (c < 0) {
decreasePoolMinPos = n.poolIndex;
}
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"addPool",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"n",
",",
"boolean",
"updateMinimum",
")",
"{",
"decreasePool",
"[",
"decreasePoolSize",
"]",
"=",
"n",
";",
"n",
".",
"poolIndex",
"=",
"decreasePoolSize",
";",
"decreasePoolSize",
"++",
";",
"if",
"(",
"updateMinimum",
"&&",
"decreasePoolSize",
">",
"1",
")",
"{",
"Node",
"<",
"K",
",",
"V",
">",
"poolMin",
"=",
"decreasePool",
"[",
"decreasePoolMinPos",
"]",
";",
"int",
"c",
";",
"if",
"(",
"comparator",
"==",
"null",
")",
"{",
"c",
"=",
"(",
"(",
"Comparable",
"<",
"?",
"super",
"K",
">",
")",
"n",
".",
"key",
")",
".",
"compareTo",
"(",
"poolMin",
".",
"key",
")",
";",
"}",
"else",
"{",
"c",
"=",
"comparator",
".",
"compare",
"(",
"n",
".",
"key",
",",
"poolMin",
".",
"key",
")",
";",
"}",
"if",
"(",
"c",
"<",
"0",
")",
"{",
"decreasePoolMinPos",
"=",
"n",
".",
"poolIndex",
";",
"}",
"}",
"}"
] |
Append to decrease pool.
|
[
"Append",
"to",
"decrease",
"pool",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java#L727-L745
|
11,322
|
d-michail/jheaps
|
src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java
|
CostlessMeldPairingHeap.cutOldestChild
|
private Node<K, V> cutOldestChild(Node<K, V> n) {
Node<K, V> oldestChild = n.o_c;
if (oldestChild != null) {
if (oldestChild.y_s != null) {
oldestChild.y_s.o_s = n;
}
n.o_c = oldestChild.y_s;
oldestChild.y_s = null;
oldestChild.o_s = null;
}
return oldestChild;
}
|
java
|
private Node<K, V> cutOldestChild(Node<K, V> n) {
Node<K, V> oldestChild = n.o_c;
if (oldestChild != null) {
if (oldestChild.y_s != null) {
oldestChild.y_s.o_s = n;
}
n.o_c = oldestChild.y_s;
oldestChild.y_s = null;
oldestChild.o_s = null;
}
return oldestChild;
}
|
[
"private",
"Node",
"<",
"K",
",",
"V",
">",
"cutOldestChild",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"n",
")",
"{",
"Node",
"<",
"K",
",",
"V",
">",
"oldestChild",
"=",
"n",
".",
"o_c",
";",
"if",
"(",
"oldestChild",
"!=",
"null",
")",
"{",
"if",
"(",
"oldestChild",
".",
"y_s",
"!=",
"null",
")",
"{",
"oldestChild",
".",
"y_s",
".",
"o_s",
"=",
"n",
";",
"}",
"n",
".",
"o_c",
"=",
"oldestChild",
".",
"y_s",
";",
"oldestChild",
".",
"y_s",
"=",
"null",
";",
"oldestChild",
".",
"o_s",
"=",
"null",
";",
"}",
"return",
"oldestChild",
";",
"}"
] |
Cut the oldest child of a node.
@param n
the node
@return the oldest child of a node or null
|
[
"Cut",
"the",
"oldest",
"child",
"of",
"a",
"node",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java#L867-L878
|
11,323
|
d-michail/jheaps
|
src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java
|
CostlessMeldPairingHeap.cutFromParent
|
private void cutFromParent(Node<K, V> n) {
if (n.o_s != null) {
if (n.y_s != null) {
n.y_s.o_s = n.o_s;
}
if (n.o_s.o_c == n) { // I am the oldest :(
n.o_s.o_c = n.y_s;
} else { // I have an older sibling!
n.o_s.y_s = n.y_s;
}
n.y_s = null;
n.o_s = null;
}
}
|
java
|
private void cutFromParent(Node<K, V> n) {
if (n.o_s != null) {
if (n.y_s != null) {
n.y_s.o_s = n.o_s;
}
if (n.o_s.o_c == n) { // I am the oldest :(
n.o_s.o_c = n.y_s;
} else { // I have an older sibling!
n.o_s.y_s = n.y_s;
}
n.y_s = null;
n.o_s = null;
}
}
|
[
"private",
"void",
"cutFromParent",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"n",
")",
"{",
"if",
"(",
"n",
".",
"o_s",
"!=",
"null",
")",
"{",
"if",
"(",
"n",
".",
"y_s",
"!=",
"null",
")",
"{",
"n",
".",
"y_s",
".",
"o_s",
"=",
"n",
".",
"o_s",
";",
"}",
"if",
"(",
"n",
".",
"o_s",
".",
"o_c",
"==",
"n",
")",
"{",
"// I am the oldest :(",
"n",
".",
"o_s",
".",
"o_c",
"=",
"n",
".",
"y_s",
";",
"}",
"else",
"{",
"// I have an older sibling!",
"n",
".",
"o_s",
".",
"y_s",
"=",
"n",
".",
"y_s",
";",
"}",
"n",
".",
"y_s",
"=",
"null",
";",
"n",
".",
"o_s",
"=",
"null",
";",
"}",
"}"
] |
Cut a node from its parent.
@param n
the node
|
[
"Cut",
"a",
"node",
"from",
"its",
"parent",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java#L886-L899
|
11,324
|
d-michail/jheaps
|
src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java
|
CostlessMeldPairingHeap.linkInPlace
|
private void linkInPlace(Node<K, V> orphan, Node<K, V> n) {
// link orphan at node's position
orphan.y_s = n.y_s;
if (n.y_s != null) {
n.y_s.o_s = orphan;
}
orphan.o_s = n.o_s;
if (n.o_s != null) {
if (n.o_s.o_c == n) { // node is the oldest :(
n.o_s.o_c = orphan;
} else { // node has an older sibling!
n.o_s.y_s = orphan;
}
}
n.o_s = null;
n.y_s = null;
}
|
java
|
private void linkInPlace(Node<K, V> orphan, Node<K, V> n) {
// link orphan at node's position
orphan.y_s = n.y_s;
if (n.y_s != null) {
n.y_s.o_s = orphan;
}
orphan.o_s = n.o_s;
if (n.o_s != null) {
if (n.o_s.o_c == n) { // node is the oldest :(
n.o_s.o_c = orphan;
} else { // node has an older sibling!
n.o_s.y_s = orphan;
}
}
n.o_s = null;
n.y_s = null;
}
|
[
"private",
"void",
"linkInPlace",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"orphan",
",",
"Node",
"<",
"K",
",",
"V",
">",
"n",
")",
"{",
"// link orphan at node's position",
"orphan",
".",
"y_s",
"=",
"n",
".",
"y_s",
";",
"if",
"(",
"n",
".",
"y_s",
"!=",
"null",
")",
"{",
"n",
".",
"y_s",
".",
"o_s",
"=",
"orphan",
";",
"}",
"orphan",
".",
"o_s",
"=",
"n",
".",
"o_s",
";",
"if",
"(",
"n",
".",
"o_s",
"!=",
"null",
")",
"{",
"if",
"(",
"n",
".",
"o_s",
".",
"o_c",
"==",
"n",
")",
"{",
"// node is the oldest :(",
"n",
".",
"o_s",
".",
"o_c",
"=",
"orphan",
";",
"}",
"else",
"{",
"// node has an older sibling!",
"n",
".",
"o_s",
".",
"y_s",
"=",
"orphan",
";",
"}",
"}",
"n",
".",
"o_s",
"=",
"null",
";",
"n",
".",
"y_s",
"=",
"null",
";",
"}"
] |
Put an orphan node into the position of another node. The other node
becomes an orphan.
@param orphan
the orphan node
@param n
the node which will become an orphan
|
[
"Put",
"an",
"orphan",
"node",
"into",
"the",
"position",
"of",
"another",
"node",
".",
"The",
"other",
"node",
"becomes",
"an",
"orphan",
"."
] |
7146451dd6591c2a8559dc564c9c40428c4a2c10
|
https://github.com/d-michail/jheaps/blob/7146451dd6591c2a8559dc564c9c40428c4a2c10/src/main/java/org/jheaps/tree/CostlessMeldPairingHeap.java#L910-L926
|
11,325
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.createInstance
|
public static synchronized MCAAuthorizationManager createInstance(Context context) {
if (instance == null) {
instance = new MCAAuthorizationManager(context.getApplicationContext());
instance.bluemixRegionSuffix = BMSClient.getInstance().getBluemixRegionSuffix();
instance.tenantId = BMSClient.getInstance().getBluemixAppGUID();
AuthorizationRequest.setup();
}
return instance;
}
|
java
|
public static synchronized MCAAuthorizationManager createInstance(Context context) {
if (instance == null) {
instance = new MCAAuthorizationManager(context.getApplicationContext());
instance.bluemixRegionSuffix = BMSClient.getInstance().getBluemixRegionSuffix();
instance.tenantId = BMSClient.getInstance().getBluemixAppGUID();
AuthorizationRequest.setup();
}
return instance;
}
|
[
"public",
"static",
"synchronized",
"MCAAuthorizationManager",
"createInstance",
"(",
"Context",
"context",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"instance",
"=",
"new",
"MCAAuthorizationManager",
"(",
"context",
".",
"getApplicationContext",
"(",
")",
")",
";",
"instance",
".",
"bluemixRegionSuffix",
"=",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getBluemixRegionSuffix",
"(",
")",
";",
"instance",
".",
"tenantId",
"=",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getBluemixAppGUID",
"(",
")",
";",
"AuthorizationRequest",
".",
"setup",
"(",
")",
";",
"}",
"return",
"instance",
";",
"}"
] |
Init singleton instance with context
@param context Application context
@return The singleton instance
|
[
"Init",
"singleton",
"instance",
"with",
"context"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L82-L92
|
11,326
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.createInstance
|
public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId) {
instance = createInstance(context);
if (null != tenantId) {
instance.tenantId = tenantId;
}
return instance;
}
|
java
|
public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId) {
instance = createInstance(context);
if (null != tenantId) {
instance.tenantId = tenantId;
}
return instance;
}
|
[
"public",
"static",
"synchronized",
"MCAAuthorizationManager",
"createInstance",
"(",
"Context",
"context",
",",
"String",
"tenantId",
")",
"{",
"instance",
"=",
"createInstance",
"(",
"context",
")",
";",
"if",
"(",
"null",
"!=",
"tenantId",
")",
"{",
"instance",
".",
"tenantId",
"=",
"tenantId",
";",
"}",
"return",
"instance",
";",
"}"
] |
Init singleton instance with context and tenantId
@param context Application context
@param tenantId the unique tenant id of the MCA service instance that the application connects to.
@return The singleton instance
|
[
"Init",
"singleton",
"instance",
"with",
"context",
"and",
"tenantId"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L100-L107
|
11,327
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.createInstance
|
public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId, String bluemixRegion) {
instance = createInstance(context, tenantId);
if (null != bluemixRegion) {
instance.bluemixRegionSuffix = bluemixRegion;
}
return instance;
}
|
java
|
public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId, String bluemixRegion) {
instance = createInstance(context, tenantId);
if (null != bluemixRegion) {
instance.bluemixRegionSuffix = bluemixRegion;
}
return instance;
}
|
[
"public",
"static",
"synchronized",
"MCAAuthorizationManager",
"createInstance",
"(",
"Context",
"context",
",",
"String",
"tenantId",
",",
"String",
"bluemixRegion",
")",
"{",
"instance",
"=",
"createInstance",
"(",
"context",
",",
"tenantId",
")",
";",
"if",
"(",
"null",
"!=",
"bluemixRegion",
")",
"{",
"instance",
".",
"bluemixRegionSuffix",
"=",
"bluemixRegion",
";",
"}",
"return",
"instance",
";",
"}"
] |
Init singleton instance with context, tenantId and Bluemix region.
@param context Application context
@param tenantId the unique tenant id of the MCA service instance that the application connects to.
@param bluemixRegion Specifies the Bluemix deployment to use.
@return The singleton instance
|
[
"Init",
"singleton",
"instance",
"with",
"context",
"tenantId",
"and",
"Bluemix",
"region",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L116-L123
|
11,328
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.obtainAuthorization
|
public synchronized void obtainAuthorization(Context context, ResponseListener listener, Object... params) {
authorizationProcessManager.startAuthorizationProcess(context, listener);
}
|
java
|
public synchronized void obtainAuthorization(Context context, ResponseListener listener, Object... params) {
authorizationProcessManager.startAuthorizationProcess(context, listener);
}
|
[
"public",
"synchronized",
"void",
"obtainAuthorization",
"(",
"Context",
"context",
",",
"ResponseListener",
"listener",
",",
"Object",
"...",
"params",
")",
"{",
"authorizationProcessManager",
".",
"startAuthorizationProcess",
"(",
"context",
",",
"listener",
")",
";",
"}"
] |
Invoke process for obtaining authorization header. during this process
@param context Android Activity that will handle the authorization (like facebook or google)
@param listener Response listener
|
[
"Invoke",
"process",
"for",
"obtaining",
"authorization",
"header",
".",
"during",
"this",
"process"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L154-L156
|
11,329
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.clearAuthorizationData
|
public void clearAuthorizationData() {
preferences.accessToken.clear();
preferences.idToken.clear();
preferences.userIdentity.clear();
if (BMSClient.getInstance() != null && BMSClient.getInstance().getCookieManager() != null) {
CookieStore cookieStore = BMSClient.getInstance().getCookieManager().getCookieStore();
if(cookieStore != null) {
for (URI uri : cookieStore.getURIs()) {
for (HttpCookie cookie : cookieStore.get(uri)) {
if (cookie.getName().equals(TAI_COOKIE_NAME)) {
cookieStore.remove(uri, cookie);
}
}
}
}
}
}
|
java
|
public void clearAuthorizationData() {
preferences.accessToken.clear();
preferences.idToken.clear();
preferences.userIdentity.clear();
if (BMSClient.getInstance() != null && BMSClient.getInstance().getCookieManager() != null) {
CookieStore cookieStore = BMSClient.getInstance().getCookieManager().getCookieStore();
if(cookieStore != null) {
for (URI uri : cookieStore.getURIs()) {
for (HttpCookie cookie : cookieStore.get(uri)) {
if (cookie.getName().equals(TAI_COOKIE_NAME)) {
cookieStore.remove(uri, cookie);
}
}
}
}
}
}
|
[
"public",
"void",
"clearAuthorizationData",
"(",
")",
"{",
"preferences",
".",
"accessToken",
".",
"clear",
"(",
")",
";",
"preferences",
".",
"idToken",
".",
"clear",
"(",
")",
";",
"preferences",
".",
"userIdentity",
".",
"clear",
"(",
")",
";",
"if",
"(",
"BMSClient",
".",
"getInstance",
"(",
")",
"!=",
"null",
"&&",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getCookieManager",
"(",
")",
"!=",
"null",
")",
"{",
"CookieStore",
"cookieStore",
"=",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getCookieManager",
"(",
")",
".",
"getCookieStore",
"(",
")",
";",
"if",
"(",
"cookieStore",
"!=",
"null",
")",
"{",
"for",
"(",
"URI",
"uri",
":",
"cookieStore",
".",
"getURIs",
"(",
")",
")",
"{",
"for",
"(",
"HttpCookie",
"cookie",
":",
"cookieStore",
".",
"get",
"(",
"uri",
")",
")",
"{",
"if",
"(",
"cookie",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"TAI_COOKIE_NAME",
")",
")",
"{",
"cookieStore",
".",
"remove",
"(",
"uri",
",",
"cookie",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] |
Clear the local stored authorization data
|
[
"Clear",
"the",
"local",
"stored",
"authorization",
"data"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L190-L206
|
11,330
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.setAuthorizationPersistencePolicy
|
public void setAuthorizationPersistencePolicy(PersistencePolicy policy) {
if (policy == null) {
throw new IllegalArgumentException("The policy argument cannot be null");
}
if (preferences.persistencePolicy.get() != policy) {
preferences.persistencePolicy.set(policy);
preferences.accessToken.updateStateByPolicy();
preferences.idToken.updateStateByPolicy();
}
}
|
java
|
public void setAuthorizationPersistencePolicy(PersistencePolicy policy) {
if (policy == null) {
throw new IllegalArgumentException("The policy argument cannot be null");
}
if (preferences.persistencePolicy.get() != policy) {
preferences.persistencePolicy.set(policy);
preferences.accessToken.updateStateByPolicy();
preferences.idToken.updateStateByPolicy();
}
}
|
[
"public",
"void",
"setAuthorizationPersistencePolicy",
"(",
"PersistencePolicy",
"policy",
")",
"{",
"if",
"(",
"policy",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The policy argument cannot be null\"",
")",
";",
"}",
"if",
"(",
"preferences",
".",
"persistencePolicy",
".",
"get",
"(",
")",
"!=",
"policy",
")",
"{",
"preferences",
".",
"persistencePolicy",
".",
"set",
"(",
"policy",
")",
";",
"preferences",
".",
"accessToken",
".",
"updateStateByPolicy",
"(",
")",
";",
"preferences",
".",
"idToken",
".",
"updateStateByPolicy",
"(",
")",
";",
"}",
"}"
] |
Change the sate of the current authorization persistence policy
@param policy new policy to use
|
[
"Change",
"the",
"sate",
"of",
"the",
"current",
"authorization",
"persistence",
"policy"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L229-L240
|
11,331
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.registerAuthenticationListener
|
public void registerAuthenticationListener(String realm, AuthenticationListener listener) {
if (realm == null || realm.isEmpty()) {
throw new InvalidParameterException("The realm name can't be null or empty.");
}
if (listener == null) {
throw new InvalidParameterException("The authentication listener object can't be null.");
}
ChallengeHandler handler = new ChallengeHandler();
handler.initialize(realm, listener);
challengeHandlers.put(realm, handler);
}
|
java
|
public void registerAuthenticationListener(String realm, AuthenticationListener listener) {
if (realm == null || realm.isEmpty()) {
throw new InvalidParameterException("The realm name can't be null or empty.");
}
if (listener == null) {
throw new InvalidParameterException("The authentication listener object can't be null.");
}
ChallengeHandler handler = new ChallengeHandler();
handler.initialize(realm, listener);
challengeHandlers.put(realm, handler);
}
|
[
"public",
"void",
"registerAuthenticationListener",
"(",
"String",
"realm",
",",
"AuthenticationListener",
"listener",
")",
"{",
"if",
"(",
"realm",
"==",
"null",
"||",
"realm",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidParameterException",
"(",
"\"The realm name can't be null or empty.\"",
")",
";",
"}",
"if",
"(",
"listener",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidParameterException",
"(",
"\"The authentication listener object can't be null.\"",
")",
";",
"}",
"ChallengeHandler",
"handler",
"=",
"new",
"ChallengeHandler",
"(",
")",
";",
"handler",
".",
"initialize",
"(",
"realm",
",",
"listener",
")",
";",
"challengeHandlers",
".",
"put",
"(",
"realm",
",",
"handler",
")",
";",
"}"
] |
Registers authentication listener for specified realm.
@param realm authentication realm.
@param listener authentication listener.
|
[
"Registers",
"authentication",
"listener",
"for",
"specified",
"realm",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L291-L303
|
11,332
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java
|
MCAAuthorizationManager.unregisterAuthenticationListener
|
public void unregisterAuthenticationListener(String realm) {
if (realm != null && !realm.isEmpty()) {
challengeHandlers.remove(realm);
}
}
|
java
|
public void unregisterAuthenticationListener(String realm) {
if (realm != null && !realm.isEmpty()) {
challengeHandlers.remove(realm);
}
}
|
[
"public",
"void",
"unregisterAuthenticationListener",
"(",
"String",
"realm",
")",
"{",
"if",
"(",
"realm",
"!=",
"null",
"&&",
"!",
"realm",
".",
"isEmpty",
"(",
")",
")",
"{",
"challengeHandlers",
".",
"remove",
"(",
"realm",
")",
";",
"}",
"}"
] |
Unregisters authentication listener
@param realm the realm the listener was registered for
|
[
"Unregisters",
"authentication",
"listener"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L310-L314
|
11,333
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationHeaderHelper.java
|
AuthorizationHeaderHelper.addAuthorizationHeader
|
public static void addAuthorizationHeader(URLConnection urlConnection, String header) {
if (header != null) {
urlConnection.setRequestProperty(AUTHORIZATION_HEADER, header);
}
}
|
java
|
public static void addAuthorizationHeader(URLConnection urlConnection, String header) {
if (header != null) {
urlConnection.setRequestProperty(AUTHORIZATION_HEADER, header);
}
}
|
[
"public",
"static",
"void",
"addAuthorizationHeader",
"(",
"URLConnection",
"urlConnection",
",",
"String",
"header",
")",
"{",
"if",
"(",
"header",
"!=",
"null",
")",
"{",
"urlConnection",
".",
"setRequestProperty",
"(",
"AUTHORIZATION_HEADER",
",",
"header",
")",
";",
"}",
"}"
] |
Adds the authorization header to the given URL connection object.
@param urlConnection The URL connection to add the header to.
|
[
"Adds",
"the",
"authorization",
"header",
"to",
"the",
"given",
"URL",
"connection",
"object",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationHeaderHelper.java#L60-L64
|
11,334
|
j-a-w-r/jawr
|
jawr-core/src/main/java/net/jawr/web/taglib/jsf/ImagePathTag.java
|
ImagePathTag.getBinaryResourcesHandler
|
protected BinaryResourcesHandler getBinaryResourcesHandler(FacesContext context) {
// Generate the path for the image element
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) context.getExternalContext()
.getApplicationMap().get(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler == null) {
throw new IllegalStateException(
"You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Binary servlet either failed or never occurred.");
}
return binaryRsHandler;
}
|
java
|
protected BinaryResourcesHandler getBinaryResourcesHandler(FacesContext context) {
// Generate the path for the image element
BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) context.getExternalContext()
.getApplicationMap().get(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
if (binaryRsHandler == null) {
throw new IllegalStateException(
"You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Binary servlet either failed or never occurred.");
}
return binaryRsHandler;
}
|
[
"protected",
"BinaryResourcesHandler",
"getBinaryResourcesHandler",
"(",
"FacesContext",
"context",
")",
"{",
"// Generate the path for the image element",
"BinaryResourcesHandler",
"binaryRsHandler",
"=",
"(",
"BinaryResourcesHandler",
")",
"context",
".",
"getExternalContext",
"(",
")",
".",
"getApplicationMap",
"(",
")",
".",
"get",
"(",
"JawrConstant",
".",
"BINARY_CONTEXT_ATTRIBUTE",
")",
";",
"if",
"(",
"binaryRsHandler",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Binary servlet either failed or never occurred.\"",
")",
";",
"}",
"return",
"binaryRsHandler",
";",
"}"
] |
Returns the image resource handler
@param context
the faces context
@return the image resource handler
|
[
"Returns",
"the",
"image",
"resource",
"handler"
] |
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
|
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/taglib/jsf/ImagePathTag.java#L112-L122
|
11,335
|
dottydingo/hyperion
|
jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java
|
AbstractEntityJpaQueryBuilder.createPredicate
|
protected Predicate createPredicate(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyName,
ComparisonOperator operator, Object argument, PersistenceContext context)
{
logger.debug("Creating criterion: {} {} {}", propertyName, operator, argument);
switch (operator)
{
case EQUAL:
{
if (containWildcard(argument))
{
return createLike(root, query, cb, propertyName, argument, context);
}
else
{
return createEqual(root, query, cb, propertyName, argument, context);
}
}
case NOT_EQUAL:
{
if (containWildcard(argument))
{
return createNotLike(root, query, cb, propertyName, argument, context);
}
else
{
return createNotEqual(root, query, cb, propertyName, argument, context);
}
}
case GREATER_THAN:
return createGreaterThan(root, query, cb, propertyName, argument, context);
case GREATER_EQUAL:
return createGreaterEqual(root, query, cb, propertyName, argument, context);
case LESS_THAN:
return createLessThan(root, query, cb, propertyName, argument, context);
case LESS_EQUAL:
return createLessEqual(root, query, cb, propertyName, argument, context);
case IN:
return createIn(root, query, cb, propertyName, argument, context);
case NOT_IN:
return createNotIn(root, query, cb, propertyName, argument, context);
}
throw new IllegalArgumentException("Unknown operator: " + operator);
}
|
java
|
protected Predicate createPredicate(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyName,
ComparisonOperator operator, Object argument, PersistenceContext context)
{
logger.debug("Creating criterion: {} {} {}", propertyName, operator, argument);
switch (operator)
{
case EQUAL:
{
if (containWildcard(argument))
{
return createLike(root, query, cb, propertyName, argument, context);
}
else
{
return createEqual(root, query, cb, propertyName, argument, context);
}
}
case NOT_EQUAL:
{
if (containWildcard(argument))
{
return createNotLike(root, query, cb, propertyName, argument, context);
}
else
{
return createNotEqual(root, query, cb, propertyName, argument, context);
}
}
case GREATER_THAN:
return createGreaterThan(root, query, cb, propertyName, argument, context);
case GREATER_EQUAL:
return createGreaterEqual(root, query, cb, propertyName, argument, context);
case LESS_THAN:
return createLessThan(root, query, cb, propertyName, argument, context);
case LESS_EQUAL:
return createLessEqual(root, query, cb, propertyName, argument, context);
case IN:
return createIn(root, query, cb, propertyName, argument, context);
case NOT_IN:
return createNotIn(root, query, cb, propertyName, argument, context);
}
throw new IllegalArgumentException("Unknown operator: " + operator);
}
|
[
"protected",
"Predicate",
"createPredicate",
"(",
"Path",
"root",
",",
"CriteriaQuery",
"<",
"?",
">",
"query",
",",
"CriteriaBuilder",
"cb",
",",
"String",
"propertyName",
",",
"ComparisonOperator",
"operator",
",",
"Object",
"argument",
",",
"PersistenceContext",
"context",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Creating criterion: {} {} {}\"",
",",
"propertyName",
",",
"operator",
",",
"argument",
")",
";",
"switch",
"(",
"operator",
")",
"{",
"case",
"EQUAL",
":",
"{",
"if",
"(",
"containWildcard",
"(",
"argument",
")",
")",
"{",
"return",
"createLike",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"}",
"else",
"{",
"return",
"createEqual",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"}",
"}",
"case",
"NOT_EQUAL",
":",
"{",
"if",
"(",
"containWildcard",
"(",
"argument",
")",
")",
"{",
"return",
"createNotLike",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"}",
"else",
"{",
"return",
"createNotEqual",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"}",
"}",
"case",
"GREATER_THAN",
":",
"return",
"createGreaterThan",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"case",
"GREATER_EQUAL",
":",
"return",
"createGreaterEqual",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"case",
"LESS_THAN",
":",
"return",
"createLessThan",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"case",
"LESS_EQUAL",
":",
"return",
"createLessEqual",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"case",
"IN",
":",
"return",
"createIn",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"case",
"NOT_IN",
":",
"return",
"createNotIn",
"(",
"root",
",",
"query",
",",
"cb",
",",
"propertyName",
",",
"argument",
",",
"context",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown operator: \"",
"+",
"operator",
")",
";",
"}"
] |
Delegate creating of a Predicate to an appropriate method according to
operator.
@param root root
@param query query
@param propertyName property name
@param operator comparison operator
@param argument argument
@param context context
@return Predicate
|
[
"Delegate",
"creating",
"of",
"a",
"Predicate",
"to",
"an",
"appropriate",
"method",
"according",
"to",
"operator",
"."
] |
c4d119c90024a88c0335d7d318e9ccdb70149764
|
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java#L43-L86
|
11,336
|
dottydingo/hyperion
|
jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java
|
AbstractEntityJpaQueryBuilder.createEqual
|
protected Predicate createEqual(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyPath,
Object argument, PersistenceContext context)
{
return cb.equal(root.get(propertyPath), argument);
}
|
java
|
protected Predicate createEqual(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyPath,
Object argument, PersistenceContext context)
{
return cb.equal(root.get(propertyPath), argument);
}
|
[
"protected",
"Predicate",
"createEqual",
"(",
"Path",
"root",
",",
"CriteriaQuery",
"<",
"?",
">",
"query",
",",
"CriteriaBuilder",
"cb",
",",
"String",
"propertyPath",
",",
"Object",
"argument",
",",
"PersistenceContext",
"context",
")",
"{",
"return",
"cb",
".",
"equal",
"(",
"root",
".",
"get",
"(",
"propertyPath",
")",
",",
"argument",
")",
";",
"}"
] |
Apply an "equal" constraint to the named property.
@param query
@param propertyPath property name prefixed with an association alias
@param argument value
@param context
@return Predicate
|
[
"Apply",
"an",
"equal",
"constraint",
"to",
"the",
"named",
"property",
"."
] |
c4d119c90024a88c0335d7d318e9ccdb70149764
|
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java#L98-L102
|
11,337
|
dottydingo/hyperion
|
jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java
|
AbstractEntityJpaQueryBuilder.createNotEqual
|
protected Predicate createNotEqual(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyPath, Object argument,
PersistenceContext context)
{
return cb.notEqual(root.get(propertyPath), argument);
}
|
java
|
protected Predicate createNotEqual(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyPath, Object argument,
PersistenceContext context)
{
return cb.notEqual(root.get(propertyPath), argument);
}
|
[
"protected",
"Predicate",
"createNotEqual",
"(",
"Path",
"root",
",",
"CriteriaQuery",
"<",
"?",
">",
"query",
",",
"CriteriaBuilder",
"cb",
",",
"String",
"propertyPath",
",",
"Object",
"argument",
",",
"PersistenceContext",
"context",
")",
"{",
"return",
"cb",
".",
"notEqual",
"(",
"root",
".",
"get",
"(",
"propertyPath",
")",
",",
"argument",
")",
";",
"}"
] |
Apply a "not equal" constraint to the named property.
@param query
@param propertyPath property name prefixed with an association alias
@param argument value
@param context
@return Predicate
|
[
"Apply",
"a",
"not",
"equal",
"constraint",
"to",
"the",
"named",
"property",
"."
] |
c4d119c90024a88c0335d7d318e9ccdb70149764
|
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java#L134-L138
|
11,338
|
dottydingo/hyperion
|
jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java
|
AbstractEntityJpaQueryBuilder.createLessThan
|
protected Predicate createLessThan(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyPath, Object argument,
PersistenceContext context)
{
if(!(argument instanceof Comparable))
throw new BadRequestException(context.getMessageSource().getErrorMessage(
INCOMPATIBLE_QUERY_OPERATION, context.getLocale(), "lt"));
return cb.lessThan(root.get(propertyPath), (Comparable) argument);
}
|
java
|
protected Predicate createLessThan(Path root, CriteriaQuery<?> query, CriteriaBuilder cb, String propertyPath, Object argument,
PersistenceContext context)
{
if(!(argument instanceof Comparable))
throw new BadRequestException(context.getMessageSource().getErrorMessage(
INCOMPATIBLE_QUERY_OPERATION, context.getLocale(), "lt"));
return cb.lessThan(root.get(propertyPath), (Comparable) argument);
}
|
[
"protected",
"Predicate",
"createLessThan",
"(",
"Path",
"root",
",",
"CriteriaQuery",
"<",
"?",
">",
"query",
",",
"CriteriaBuilder",
"cb",
",",
"String",
"propertyPath",
",",
"Object",
"argument",
",",
"PersistenceContext",
"context",
")",
"{",
"if",
"(",
"!",
"(",
"argument",
"instanceof",
"Comparable",
")",
")",
"throw",
"new",
"BadRequestException",
"(",
"context",
".",
"getMessageSource",
"(",
")",
".",
"getErrorMessage",
"(",
"INCOMPATIBLE_QUERY_OPERATION",
",",
"context",
".",
"getLocale",
"(",
")",
",",
"\"lt\"",
")",
")",
";",
"return",
"cb",
".",
"lessThan",
"(",
"root",
".",
"get",
"(",
"propertyPath",
")",
",",
"(",
"Comparable",
")",
"argument",
")",
";",
"}"
] |
Apply a "less than" constraint to the named property.
@param query
@param propertyPath property name prefixed with an association alias
@param argument value
@param context
@return Predicate
|
[
"Apply",
"a",
"less",
"than",
"constraint",
"to",
"the",
"named",
"property",
"."
] |
c4d119c90024a88c0335d7d318e9ccdb70149764
|
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java#L207-L215
|
11,339
|
dottydingo/hyperion
|
jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java
|
AbstractEntityJpaQueryBuilder.containWildcard
|
protected boolean containWildcard(Object value)
{
if (!(value instanceof String))
{
return false;
}
String casted = (String) value;
return casted.contains(LIKE_WILDCARD.toString());
}
|
java
|
protected boolean containWildcard(Object value)
{
if (!(value instanceof String))
{
return false;
}
String casted = (String) value;
return casted.contains(LIKE_WILDCARD.toString());
}
|
[
"protected",
"boolean",
"containWildcard",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"String",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"casted",
"=",
"(",
"String",
")",
"value",
";",
"return",
"casted",
".",
"contains",
"(",
"LIKE_WILDCARD",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Check if given value contains wildcard.
@param value the value
@return Return <tt>true</tt> if argument contains {@link #LIKE_WILDCARD}.
|
[
"Check",
"if",
"given",
"value",
"contains",
"wildcard",
"."
] |
c4d119c90024a88c0335d7d318e9ccdb70149764
|
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/jpa/src/main/java/com/dottydingo/hyperion/jpa/persistence/query/AbstractEntityJpaQueryBuilder.java#L265-L275
|
11,340
|
dottydingo/hyperion
|
api/src/main/java/com/dottydingo/hyperion/api/exception/HyperionException.java
|
HyperionException.getDetailMessage
|
public String getDetailMessage()
{
if(errorDetails == null || errorDetails.isEmpty())
return getMessage();
StringBuilder sb = new StringBuilder(512);
sb.append(getMessage());
sb.append(" [");
for (int i = 0; i < errorDetails.size(); i++)
{
ErrorDetail errorDetail = errorDetails.get(i);
if(i > 0)
sb.append(", ");
sb.append(errorDetail.getMessage());
}
sb.append("]");
return sb.toString();
}
|
java
|
public String getDetailMessage()
{
if(errorDetails == null || errorDetails.isEmpty())
return getMessage();
StringBuilder sb = new StringBuilder(512);
sb.append(getMessage());
sb.append(" [");
for (int i = 0; i < errorDetails.size(); i++)
{
ErrorDetail errorDetail = errorDetails.get(i);
if(i > 0)
sb.append(", ");
sb.append(errorDetail.getMessage());
}
sb.append("]");
return sb.toString();
}
|
[
"public",
"String",
"getDetailMessage",
"(",
")",
"{",
"if",
"(",
"errorDetails",
"==",
"null",
"||",
"errorDetails",
".",
"isEmpty",
"(",
")",
")",
"return",
"getMessage",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"512",
")",
";",
"sb",
".",
"append",
"(",
"getMessage",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" [\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"errorDetails",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"ErrorDetail",
"errorDetail",
"=",
"errorDetails",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"i",
">",
"0",
")",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"sb",
".",
"append",
"(",
"errorDetail",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"]\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Return a detail message. If errorDetails is not empty then the returned message will combine these together,
otherwise the standard exception message is returned.
@return The message
|
[
"Return",
"a",
"detail",
"message",
".",
"If",
"errorDetails",
"is",
"not",
"empty",
"then",
"the",
"returned",
"message",
"will",
"combine",
"these",
"together",
"otherwise",
"the",
"standard",
"exception",
"message",
"is",
"returned",
"."
] |
c4d119c90024a88c0335d7d318e9ccdb70149764
|
https://github.com/dottydingo/hyperion/blob/c4d119c90024a88c0335d7d318e9ccdb70149764/api/src/main/java/com/dottydingo/hyperion/api/exception/HyperionException.java#L125-L144
|
11,341
|
j-a-w-r/jawr
|
jawr-core/src/main/java/net/jawr/web/cache/CacheManagerFactory.java
|
CacheManagerFactory.getCacheManager
|
public static JawrCacheManager getCacheManager(JawrConfig config, String resourceType) {
String cacheMgrAttributeName = CACHE_ATTR_PREFIX + resourceType.toUpperCase() + CACHE_ATTR_SUFFIX;
JawrCacheManager cacheManager = (JawrCacheManager) config.getContext().getAttribute(cacheMgrAttributeName);
if (cacheManager == null) {
String cacheManagerClass = config.getProperty(CACHE_PROPERTY_NAME, BasicCacheManager.class.getName());
cacheManager = (JawrCacheManager) ClassLoaderResourceUtils.buildObjectInstance(cacheManagerClass,
new Object[] { config });
config.getContext().setAttribute(cacheMgrAttributeName, cacheManager);
}
return cacheManager;
}
|
java
|
public static JawrCacheManager getCacheManager(JawrConfig config, String resourceType) {
String cacheMgrAttributeName = CACHE_ATTR_PREFIX + resourceType.toUpperCase() + CACHE_ATTR_SUFFIX;
JawrCacheManager cacheManager = (JawrCacheManager) config.getContext().getAttribute(cacheMgrAttributeName);
if (cacheManager == null) {
String cacheManagerClass = config.getProperty(CACHE_PROPERTY_NAME, BasicCacheManager.class.getName());
cacheManager = (JawrCacheManager) ClassLoaderResourceUtils.buildObjectInstance(cacheManagerClass,
new Object[] { config });
config.getContext().setAttribute(cacheMgrAttributeName, cacheManager);
}
return cacheManager;
}
|
[
"public",
"static",
"JawrCacheManager",
"getCacheManager",
"(",
"JawrConfig",
"config",
",",
"String",
"resourceType",
")",
"{",
"String",
"cacheMgrAttributeName",
"=",
"CACHE_ATTR_PREFIX",
"+",
"resourceType",
".",
"toUpperCase",
"(",
")",
"+",
"CACHE_ATTR_SUFFIX",
";",
"JawrCacheManager",
"cacheManager",
"=",
"(",
"JawrCacheManager",
")",
"config",
".",
"getContext",
"(",
")",
".",
"getAttribute",
"(",
"cacheMgrAttributeName",
")",
";",
"if",
"(",
"cacheManager",
"==",
"null",
")",
"{",
"String",
"cacheManagerClass",
"=",
"config",
".",
"getProperty",
"(",
"CACHE_PROPERTY_NAME",
",",
"BasicCacheManager",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"cacheManager",
"=",
"(",
"JawrCacheManager",
")",
"ClassLoaderResourceUtils",
".",
"buildObjectInstance",
"(",
"cacheManagerClass",
",",
"new",
"Object",
"[",
"]",
"{",
"config",
"}",
")",
";",
"config",
".",
"getContext",
"(",
")",
".",
"setAttribute",
"(",
"cacheMgrAttributeName",
",",
"cacheManager",
")",
";",
"}",
"return",
"cacheManager",
";",
"}"
] |
Retrieves the cache manager for a resource type
@param config
the jawr config
@param resourceType
the resource type
@return the cache manager for a resource type
|
[
"Retrieves",
"the",
"cache",
"manager",
"for",
"a",
"resource",
"type"
] |
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
|
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/cache/CacheManagerFactory.java#L44-L55
|
11,342
|
j-a-w-r/jawr
|
jawr-core/src/main/java/net/jawr/web/cache/CacheManagerFactory.java
|
CacheManagerFactory.resetCacheManager
|
public static synchronized JawrCacheManager resetCacheManager(JawrConfig config, String resourceType) {
String cacheMgrAttributeName = CACHE_ATTR_PREFIX + resourceType.toUpperCase() + CACHE_ATTR_SUFFIX;
JawrCacheManager cacheManager = (JawrCacheManager) config.getContext().getAttribute(cacheMgrAttributeName);
if (cacheManager != null) {
cacheManager.clear();
config.getContext().removeAttribute(cacheMgrAttributeName);
}
return getCacheManager(config, resourceType);
}
|
java
|
public static synchronized JawrCacheManager resetCacheManager(JawrConfig config, String resourceType) {
String cacheMgrAttributeName = CACHE_ATTR_PREFIX + resourceType.toUpperCase() + CACHE_ATTR_SUFFIX;
JawrCacheManager cacheManager = (JawrCacheManager) config.getContext().getAttribute(cacheMgrAttributeName);
if (cacheManager != null) {
cacheManager.clear();
config.getContext().removeAttribute(cacheMgrAttributeName);
}
return getCacheManager(config, resourceType);
}
|
[
"public",
"static",
"synchronized",
"JawrCacheManager",
"resetCacheManager",
"(",
"JawrConfig",
"config",
",",
"String",
"resourceType",
")",
"{",
"String",
"cacheMgrAttributeName",
"=",
"CACHE_ATTR_PREFIX",
"+",
"resourceType",
".",
"toUpperCase",
"(",
")",
"+",
"CACHE_ATTR_SUFFIX",
";",
"JawrCacheManager",
"cacheManager",
"=",
"(",
"JawrCacheManager",
")",
"config",
".",
"getContext",
"(",
")",
".",
"getAttribute",
"(",
"cacheMgrAttributeName",
")",
";",
"if",
"(",
"cacheManager",
"!=",
"null",
")",
"{",
"cacheManager",
".",
"clear",
"(",
")",
";",
"config",
".",
"getContext",
"(",
")",
".",
"removeAttribute",
"(",
"cacheMgrAttributeName",
")",
";",
"}",
"return",
"getCacheManager",
"(",
"config",
",",
"resourceType",
")",
";",
"}"
] |
Resets the cache manager for a resource type
@param config
the jawr config
@param resourceType
the resource type
@return the cache manager for a resource type
|
[
"Resets",
"the",
"cache",
"manager",
"for",
"a",
"resource",
"type"
] |
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
|
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/cache/CacheManagerFactory.java#L66-L76
|
11,343
|
j-a-w-r/jawr
|
jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/AbstractResourceMapper.java
|
AbstractResourceMapper.addBundleToMap
|
protected final void addBundleToMap(String bundleId, String mapping) throws DuplicateBundlePathException {
for (JoinableResourceBundle bundle : currentBundles) {
if (bundleId.equals(bundle.getId()) || this.bundleMapping.containsKey(bundleId)) {
Marker fatal = MarkerFactory.getMarker("FATAL");
LOGGER.error(fatal, "Duplicate bundle id resulted from mapping:" + bundleId);
throw new DuplicateBundlePathException(bundleId);
}
}
bundleMapping.put(bundleId, mapping);
}
|
java
|
protected final void addBundleToMap(String bundleId, String mapping) throws DuplicateBundlePathException {
for (JoinableResourceBundle bundle : currentBundles) {
if (bundleId.equals(bundle.getId()) || this.bundleMapping.containsKey(bundleId)) {
Marker fatal = MarkerFactory.getMarker("FATAL");
LOGGER.error(fatal, "Duplicate bundle id resulted from mapping:" + bundleId);
throw new DuplicateBundlePathException(bundleId);
}
}
bundleMapping.put(bundleId, mapping);
}
|
[
"protected",
"final",
"void",
"addBundleToMap",
"(",
"String",
"bundleId",
",",
"String",
"mapping",
")",
"throws",
"DuplicateBundlePathException",
"{",
"for",
"(",
"JoinableResourceBundle",
"bundle",
":",
"currentBundles",
")",
"{",
"if",
"(",
"bundleId",
".",
"equals",
"(",
"bundle",
".",
"getId",
"(",
")",
")",
"||",
"this",
".",
"bundleMapping",
".",
"containsKey",
"(",
"bundleId",
")",
")",
"{",
"Marker",
"fatal",
"=",
"MarkerFactory",
".",
"getMarker",
"(",
"\"FATAL\"",
")",
";",
"LOGGER",
".",
"error",
"(",
"fatal",
",",
"\"Duplicate bundle id resulted from mapping:\"",
"+",
"bundleId",
")",
";",
"throw",
"new",
"DuplicateBundlePathException",
"(",
"bundleId",
")",
";",
"}",
"}",
"bundleMapping",
".",
"put",
"(",
"bundleId",
",",
"mapping",
")",
";",
"}"
] |
Add a bundle and its mapping to the resulting Map.
@param bundleId
the bundle Id
@param mapping
the mapping
@throws DuplicateBundlePathException
if we try to add a bundle with a name, which already exists.
|
[
"Add",
"a",
"bundle",
"and",
"its",
"mapping",
"to",
"the",
"resulting",
"Map",
"."
] |
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
|
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/AbstractResourceMapper.java#L107-L118
|
11,344
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.loadAxioms
|
public void loadAxioms(final Set<? extends Axiom> inclusions) {
long start = System.currentTimeMillis();
if(log.isInfoEnabled())
log.info("Loading " + inclusions.size() + " axioms");
Set<Inclusion> normInclusions = normalise(inclusions);
if(log.isInfoEnabled()) log.info("Processing " + normInclusions.size() + " normalised axioms");
Statistics.INSTANCE.setTime("normalisation", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
for (Inclusion i : normInclusions) {
addTerm(i.getNormalForm());
}
Statistics.INSTANCE.setTime("indexing", System.currentTimeMillis() - start);
}
|
java
|
public void loadAxioms(final Set<? extends Axiom> inclusions) {
long start = System.currentTimeMillis();
if(log.isInfoEnabled())
log.info("Loading " + inclusions.size() + " axioms");
Set<Inclusion> normInclusions = normalise(inclusions);
if(log.isInfoEnabled()) log.info("Processing " + normInclusions.size() + " normalised axioms");
Statistics.INSTANCE.setTime("normalisation", System.currentTimeMillis() - start);
start = System.currentTimeMillis();
for (Inclusion i : normInclusions) {
addTerm(i.getNormalForm());
}
Statistics.INSTANCE.setTime("indexing", System.currentTimeMillis() - start);
}
|
[
"public",
"void",
"loadAxioms",
"(",
"final",
"Set",
"<",
"?",
"extends",
"Axiom",
">",
"inclusions",
")",
"{",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"log",
".",
"info",
"(",
"\"Loading \"",
"+",
"inclusions",
".",
"size",
"(",
")",
"+",
"\" axioms\"",
")",
";",
"Set",
"<",
"Inclusion",
">",
"normInclusions",
"=",
"normalise",
"(",
"inclusions",
")",
";",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"log",
".",
"info",
"(",
"\"Processing \"",
"+",
"normInclusions",
".",
"size",
"(",
")",
"+",
"\" normalised axioms\"",
")",
";",
"Statistics",
".",
"INSTANCE",
".",
"setTime",
"(",
"\"normalisation\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"for",
"(",
"Inclusion",
"i",
":",
"normInclusions",
")",
"{",
"addTerm",
"(",
"i",
".",
"getNormalForm",
"(",
")",
")",
";",
"}",
"Statistics",
".",
"INSTANCE",
".",
"setTime",
"(",
"\"indexing\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"}"
] |
Normalises and loads a set of axioms.
@param inclusions
|
[
"Normalises",
"and",
"loads",
"a",
"set",
"of",
"axioms",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L377-L390
|
11,345
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.printInternalObject
|
private String printInternalObject(Object o) {
if(o instanceof Conjunction) {
Conjunction con = (Conjunction)o;
StringBuilder sb = new StringBuilder();
AbstractConcept[] cons = con.getConcepts();
if(cons != null && cons.length > 0) {
sb.append(printInternalObject(cons[0]));
for(int i = 1; i < cons.length; i++) {
sb.append(" + ");
sb.append(printInternalObject(cons[i]));
}
}
return sb.toString();
} else if(o instanceof Existential) {
Existential e = (Existential)o;
AbstractConcept c = e.getConcept();
int role = e.getRole();
return factory.lookupRoleId(role)+"."+printInternalObject(c);
} else if(o instanceof Datatype) {
StringBuilder sb = new StringBuilder();
Datatype d = (Datatype)o;
String feature = factory.lookupFeatureId(d.getFeature());
sb.append(feature.toString());
sb.append(".(");
AbstractLiteral literal = d.getLiteral();
sb.append(literal);
sb.append(")");
return sb.toString();
} else if(o instanceof Concept) {
Object obj = factory.lookupConceptId(((Concept)o).hashCode());
if(au.csiro.ontology.model.NamedConcept.TOP.equals(obj)) {
return "TOP";
} else if(au.csiro.ontology.model.NamedConcept.BOTTOM.equals(obj)) {
return "BOTTOM";
} else if(obj instanceof AbstractConcept) {
return "<"+printInternalObject(obj)+">";
} else {
return obj.toString();
}
} else if(o instanceof Comparable<?>) {
return o.toString();
} else {
throw new RuntimeException("Unexpected object with class "+
o.getClass().getName());
}
}
|
java
|
private String printInternalObject(Object o) {
if(o instanceof Conjunction) {
Conjunction con = (Conjunction)o;
StringBuilder sb = new StringBuilder();
AbstractConcept[] cons = con.getConcepts();
if(cons != null && cons.length > 0) {
sb.append(printInternalObject(cons[0]));
for(int i = 1; i < cons.length; i++) {
sb.append(" + ");
sb.append(printInternalObject(cons[i]));
}
}
return sb.toString();
} else if(o instanceof Existential) {
Existential e = (Existential)o;
AbstractConcept c = e.getConcept();
int role = e.getRole();
return factory.lookupRoleId(role)+"."+printInternalObject(c);
} else if(o instanceof Datatype) {
StringBuilder sb = new StringBuilder();
Datatype d = (Datatype)o;
String feature = factory.lookupFeatureId(d.getFeature());
sb.append(feature.toString());
sb.append(".(");
AbstractLiteral literal = d.getLiteral();
sb.append(literal);
sb.append(")");
return sb.toString();
} else if(o instanceof Concept) {
Object obj = factory.lookupConceptId(((Concept)o).hashCode());
if(au.csiro.ontology.model.NamedConcept.TOP.equals(obj)) {
return "TOP";
} else if(au.csiro.ontology.model.NamedConcept.BOTTOM.equals(obj)) {
return "BOTTOM";
} else if(obj instanceof AbstractConcept) {
return "<"+printInternalObject(obj)+">";
} else {
return obj.toString();
}
} else if(o instanceof Comparable<?>) {
return o.toString();
} else {
throw new RuntimeException("Unexpected object with class "+
o.getClass().getName());
}
}
|
[
"private",
"String",
"printInternalObject",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Conjunction",
")",
"{",
"Conjunction",
"con",
"=",
"(",
"Conjunction",
")",
"o",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"AbstractConcept",
"[",
"]",
"cons",
"=",
"con",
".",
"getConcepts",
"(",
")",
";",
"if",
"(",
"cons",
"!=",
"null",
"&&",
"cons",
".",
"length",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"printInternalObject",
"(",
"cons",
"[",
"0",
"]",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"cons",
".",
"length",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"\" + \"",
")",
";",
"sb",
".",
"append",
"(",
"printInternalObject",
"(",
"cons",
"[",
"i",
"]",
")",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Existential",
")",
"{",
"Existential",
"e",
"=",
"(",
"Existential",
")",
"o",
";",
"AbstractConcept",
"c",
"=",
"e",
".",
"getConcept",
"(",
")",
";",
"int",
"role",
"=",
"e",
".",
"getRole",
"(",
")",
";",
"return",
"factory",
".",
"lookupRoleId",
"(",
"role",
")",
"+",
"\".\"",
"+",
"printInternalObject",
"(",
"c",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Datatype",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Datatype",
"d",
"=",
"(",
"Datatype",
")",
"o",
";",
"String",
"feature",
"=",
"factory",
".",
"lookupFeatureId",
"(",
"d",
".",
"getFeature",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"feature",
".",
"toString",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\".(\"",
")",
";",
"AbstractLiteral",
"literal",
"=",
"d",
".",
"getLiteral",
"(",
")",
";",
"sb",
".",
"append",
"(",
"literal",
")",
";",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Concept",
")",
"{",
"Object",
"obj",
"=",
"factory",
".",
"lookupConceptId",
"(",
"(",
"(",
"Concept",
")",
"o",
")",
".",
"hashCode",
"(",
")",
")",
";",
"if",
"(",
"au",
".",
"csiro",
".",
"ontology",
".",
"model",
".",
"NamedConcept",
".",
"TOP",
".",
"equals",
"(",
"obj",
")",
")",
"{",
"return",
"\"TOP\"",
";",
"}",
"else",
"if",
"(",
"au",
".",
"csiro",
".",
"ontology",
".",
"model",
".",
"NamedConcept",
".",
"BOTTOM",
".",
"equals",
"(",
"obj",
")",
")",
"{",
"return",
"\"BOTTOM\"",
";",
"}",
"else",
"if",
"(",
"obj",
"instanceof",
"AbstractConcept",
")",
"{",
"return",
"\"<\"",
"+",
"printInternalObject",
"(",
"obj",
")",
"+",
"\">\"",
";",
"}",
"else",
"{",
"return",
"obj",
".",
"toString",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Comparable",
"<",
"?",
">",
")",
"{",
"return",
"o",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected object with class \"",
"+",
"o",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
Prints an object of the internal model using the string representation
of the corresponding object in the external model.
@param o
@return
|
[
"Prints",
"an",
"object",
"of",
"the",
"internal",
"model",
"using",
"the",
"string",
"representation",
"of",
"the",
"corresponding",
"object",
"in",
"the",
"external",
"model",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L722-L767
|
11,346
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.addTerm
|
protected void addTerm(NormalFormGCI term) {
if (term instanceof NF1a) {
final NF1a nf1 = (NF1a) term;
final int a = nf1.lhsA();
addTerms(ontologyNF1, a, nf1.getQueueEntry());
} else if (term instanceof NF1b) {
final NF1b nf1 = (NF1b) term;
final int a1 = nf1.lhsA1();
final int a2 = nf1.lhsA2();
addTerms(ontologyNF1, a1, nf1.getQueueEntry1());
addTerms(ontologyNF1, a2, nf1.getQueueEntry2());
} else if (term instanceof NF2) {
final NF2 nf2 = (NF2) term;
addTerms(ontologyNF2, nf2);
} else if (term instanceof NF3) {
final NF3 nf3 = (NF3) term;
addTerms(ontologyNF3, nf3);
} else if (term instanceof NF4) {
ontologyNF4.add((NF4) term);
} else if (term instanceof NF5) {
ontologyNF5.add((NF5) term);
} else if (term instanceof NF6) {
reflexiveRoles.add(((NF6) term).getR());
} else if (term instanceof NF7) {
final NF7 nf7 = (NF7) term;
addTerms(ontologyNF7, nf7);
} else if (term instanceof NF8) {
final NF8 nf8 = (NF8) term;
addTerms(ontologyNF8, nf8);
} else {
throw new IllegalArgumentException("Type of " + term
+ " must be one of NF1 through NF8");
}
}
|
java
|
protected void addTerm(NormalFormGCI term) {
if (term instanceof NF1a) {
final NF1a nf1 = (NF1a) term;
final int a = nf1.lhsA();
addTerms(ontologyNF1, a, nf1.getQueueEntry());
} else if (term instanceof NF1b) {
final NF1b nf1 = (NF1b) term;
final int a1 = nf1.lhsA1();
final int a2 = nf1.lhsA2();
addTerms(ontologyNF1, a1, nf1.getQueueEntry1());
addTerms(ontologyNF1, a2, nf1.getQueueEntry2());
} else if (term instanceof NF2) {
final NF2 nf2 = (NF2) term;
addTerms(ontologyNF2, nf2);
} else if (term instanceof NF3) {
final NF3 nf3 = (NF3) term;
addTerms(ontologyNF3, nf3);
} else if (term instanceof NF4) {
ontologyNF4.add((NF4) term);
} else if (term instanceof NF5) {
ontologyNF5.add((NF5) term);
} else if (term instanceof NF6) {
reflexiveRoles.add(((NF6) term).getR());
} else if (term instanceof NF7) {
final NF7 nf7 = (NF7) term;
addTerms(ontologyNF7, nf7);
} else if (term instanceof NF8) {
final NF8 nf8 = (NF8) term;
addTerms(ontologyNF8, nf8);
} else {
throw new IllegalArgumentException("Type of " + term
+ " must be one of NF1 through NF8");
}
}
|
[
"protected",
"void",
"addTerm",
"(",
"NormalFormGCI",
"term",
")",
"{",
"if",
"(",
"term",
"instanceof",
"NF1a",
")",
"{",
"final",
"NF1a",
"nf1",
"=",
"(",
"NF1a",
")",
"term",
";",
"final",
"int",
"a",
"=",
"nf1",
".",
"lhsA",
"(",
")",
";",
"addTerms",
"(",
"ontologyNF1",
",",
"a",
",",
"nf1",
".",
"getQueueEntry",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF1b",
")",
"{",
"final",
"NF1b",
"nf1",
"=",
"(",
"NF1b",
")",
"term",
";",
"final",
"int",
"a1",
"=",
"nf1",
".",
"lhsA1",
"(",
")",
";",
"final",
"int",
"a2",
"=",
"nf1",
".",
"lhsA2",
"(",
")",
";",
"addTerms",
"(",
"ontologyNF1",
",",
"a1",
",",
"nf1",
".",
"getQueueEntry1",
"(",
")",
")",
";",
"addTerms",
"(",
"ontologyNF1",
",",
"a2",
",",
"nf1",
".",
"getQueueEntry2",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF2",
")",
"{",
"final",
"NF2",
"nf2",
"=",
"(",
"NF2",
")",
"term",
";",
"addTerms",
"(",
"ontologyNF2",
",",
"nf2",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF3",
")",
"{",
"final",
"NF3",
"nf3",
"=",
"(",
"NF3",
")",
"term",
";",
"addTerms",
"(",
"ontologyNF3",
",",
"nf3",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF4",
")",
"{",
"ontologyNF4",
".",
"add",
"(",
"(",
"NF4",
")",
"term",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF5",
")",
"{",
"ontologyNF5",
".",
"add",
"(",
"(",
"NF5",
")",
"term",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF6",
")",
"{",
"reflexiveRoles",
".",
"add",
"(",
"(",
"(",
"NF6",
")",
"term",
")",
".",
"getR",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF7",
")",
"{",
"final",
"NF7",
"nf7",
"=",
"(",
"NF7",
")",
"term",
";",
"addTerms",
"(",
"ontologyNF7",
",",
"nf7",
")",
";",
"}",
"else",
"if",
"(",
"term",
"instanceof",
"NF8",
")",
"{",
"final",
"NF8",
"nf8",
"=",
"(",
"NF8",
")",
"term",
";",
"addTerms",
"(",
"ontologyNF8",
",",
"nf8",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Type of \"",
"+",
"term",
"+",
"\" must be one of NF1 through NF8\"",
")",
";",
"}",
"}"
] |
Adds a normalised term to the ontology.
@param term
The normalised term.
|
[
"Adds",
"a",
"normalised",
"term",
"to",
"the",
"ontology",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L775-L808
|
11,347
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.rePrimeNF6
|
private void rePrimeNF6(AxiomSet as, IConceptMap<IConceptSet> subsumptions) {
int size = as.getNf6Axioms().size();
if (size == 0)
return;
IConceptSet deltaNF6 = new SparseConceptSet(size);
for (NF6 nf6 : as.getNf6Axioms()) {
deltaNF6.add(nf6.getR());
}
for (IntIterator it = deltaNF6.iterator(); it.hasNext();) {
int role = it.next();
for (IntIterator it2 = contextIndex.keyIterator(); it2.hasNext();) {
int concept = it2.next();
Context ctx = contextIndex.get(concept);
if (ctx.getSucc().containsRole(role) && !ctx.getSucc().lookupConcept(role).contains(concept)) {
ctx.processExternalEdge(role, concept);
affectedContexts.add(ctx);
ctx.startTracking();
if (ctx.activate()) {
todo.add(ctx);
}
}
}
}
}
|
java
|
private void rePrimeNF6(AxiomSet as, IConceptMap<IConceptSet> subsumptions) {
int size = as.getNf6Axioms().size();
if (size == 0)
return;
IConceptSet deltaNF6 = new SparseConceptSet(size);
for (NF6 nf6 : as.getNf6Axioms()) {
deltaNF6.add(nf6.getR());
}
for (IntIterator it = deltaNF6.iterator(); it.hasNext();) {
int role = it.next();
for (IntIterator it2 = contextIndex.keyIterator(); it2.hasNext();) {
int concept = it2.next();
Context ctx = contextIndex.get(concept);
if (ctx.getSucc().containsRole(role) && !ctx.getSucc().lookupConcept(role).contains(concept)) {
ctx.processExternalEdge(role, concept);
affectedContexts.add(ctx);
ctx.startTracking();
if (ctx.activate()) {
todo.add(ctx);
}
}
}
}
}
|
[
"private",
"void",
"rePrimeNF6",
"(",
"AxiomSet",
"as",
",",
"IConceptMap",
"<",
"IConceptSet",
">",
"subsumptions",
")",
"{",
"int",
"size",
"=",
"as",
".",
"getNf6Axioms",
"(",
")",
".",
"size",
"(",
")",
";",
"if",
"(",
"size",
"==",
"0",
")",
"return",
";",
"IConceptSet",
"deltaNF6",
"=",
"new",
"SparseConceptSet",
"(",
"size",
")",
";",
"for",
"(",
"NF6",
"nf6",
":",
"as",
".",
"getNf6Axioms",
"(",
")",
")",
"{",
"deltaNF6",
".",
"add",
"(",
"nf6",
".",
"getR",
"(",
")",
")",
";",
"}",
"for",
"(",
"IntIterator",
"it",
"=",
"deltaNF6",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"int",
"role",
"=",
"it",
".",
"next",
"(",
")",
";",
"for",
"(",
"IntIterator",
"it2",
"=",
"contextIndex",
".",
"keyIterator",
"(",
")",
";",
"it2",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"int",
"concept",
"=",
"it2",
".",
"next",
"(",
")",
";",
"Context",
"ctx",
"=",
"contextIndex",
".",
"get",
"(",
"concept",
")",
";",
"if",
"(",
"ctx",
".",
"getSucc",
"(",
")",
".",
"containsRole",
"(",
"role",
")",
"&&",
"!",
"ctx",
".",
"getSucc",
"(",
")",
".",
"lookupConcept",
"(",
"role",
")",
".",
"contains",
"(",
"concept",
")",
")",
"{",
"ctx",
".",
"processExternalEdge",
"(",
"role",
",",
"concept",
")",
";",
"affectedContexts",
".",
"add",
"(",
"ctx",
")",
";",
"ctx",
".",
"startTracking",
"(",
")",
";",
"if",
"(",
"ctx",
".",
"activate",
"(",
")",
")",
"{",
"todo",
".",
"add",
"(",
"ctx",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
These are reflexive role axioms. If an axiom of this kind is added, then
an "external edge" must be added to all the contexts that contain that
role and don't contain a successor to themselves.
@param as
@param subsumptions
|
[
"These",
"are",
"reflexive",
"role",
"axioms",
".",
"If",
"an",
"axiom",
"of",
"this",
"kind",
"is",
"added",
"then",
"an",
"external",
"edge",
"must",
"be",
"added",
"to",
"all",
"the",
"contexts",
"that",
"contain",
"that",
"role",
"and",
"don",
"t",
"contain",
"a",
"successor",
"to",
"themselves",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L1306-L1330
|
11,348
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.classify
|
public void classify() {
long start = System.currentTimeMillis();
if(log.isInfoEnabled())
log.info("Classifying with " + numThreads + " threads");
// Create contexts for init concepts in the ontology
int numConcepts = factory.getTotalConcepts();
for (int i = 0; i < numConcepts; i++) {
Context c = new Context(i, this);
contextIndex.put(i, c);
if (c.activate()) {
todo.add(c);
}
if(log.isTraceEnabled()) {
log.trace("Added context " + i);
}
}
if(log.isInfoEnabled())
log.info("Running saturation");
ExecutorService executor = Executors.newFixedThreadPool(numThreads, THREAD_FACTORY);
for (int j = 0; j < numThreads; j++) {
Runnable worker = new Worker(todo);
executor.execute(worker);
}
executor.shutdown();
while (!executor.isTerminated()) {
try {
executor.awaitTermination(100, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
assert (todo.isEmpty());
if (log.isTraceEnabled()) {
log.trace("Processed " + contextIndex.size() + " contexts");
}
hasBeenIncrementallyClassified = false;
Statistics.INSTANCE.setTime("classification",
System.currentTimeMillis() - start);
}
|
java
|
public void classify() {
long start = System.currentTimeMillis();
if(log.isInfoEnabled())
log.info("Classifying with " + numThreads + " threads");
// Create contexts for init concepts in the ontology
int numConcepts = factory.getTotalConcepts();
for (int i = 0; i < numConcepts; i++) {
Context c = new Context(i, this);
contextIndex.put(i, c);
if (c.activate()) {
todo.add(c);
}
if(log.isTraceEnabled()) {
log.trace("Added context " + i);
}
}
if(log.isInfoEnabled())
log.info("Running saturation");
ExecutorService executor = Executors.newFixedThreadPool(numThreads, THREAD_FACTORY);
for (int j = 0; j < numThreads; j++) {
Runnable worker = new Worker(todo);
executor.execute(worker);
}
executor.shutdown();
while (!executor.isTerminated()) {
try {
executor.awaitTermination(100, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
assert (todo.isEmpty());
if (log.isTraceEnabled()) {
log.trace("Processed " + contextIndex.size() + " contexts");
}
hasBeenIncrementallyClassified = false;
Statistics.INSTANCE.setTime("classification",
System.currentTimeMillis() - start);
}
|
[
"public",
"void",
"classify",
"(",
")",
"{",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"log",
".",
"info",
"(",
"\"Classifying with \"",
"+",
"numThreads",
"+",
"\" threads\"",
")",
";",
"// Create contexts for init concepts in the ontology",
"int",
"numConcepts",
"=",
"factory",
".",
"getTotalConcepts",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numConcepts",
";",
"i",
"++",
")",
"{",
"Context",
"c",
"=",
"new",
"Context",
"(",
"i",
",",
"this",
")",
";",
"contextIndex",
".",
"put",
"(",
"i",
",",
"c",
")",
";",
"if",
"(",
"c",
".",
"activate",
"(",
")",
")",
"{",
"todo",
".",
"add",
"(",
"c",
")",
";",
"}",
"if",
"(",
"log",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"log",
".",
"trace",
"(",
"\"Added context \"",
"+",
"i",
")",
";",
"}",
"}",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"log",
".",
"info",
"(",
"\"Running saturation\"",
")",
";",
"ExecutorService",
"executor",
"=",
"Executors",
".",
"newFixedThreadPool",
"(",
"numThreads",
",",
"THREAD_FACTORY",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"numThreads",
";",
"j",
"++",
")",
"{",
"Runnable",
"worker",
"=",
"new",
"Worker",
"(",
"todo",
")",
";",
"executor",
".",
"execute",
"(",
"worker",
")",
";",
"}",
"executor",
".",
"shutdown",
"(",
")",
";",
"while",
"(",
"!",
"executor",
".",
"isTerminated",
"(",
")",
")",
"{",
"try",
"{",
"executor",
".",
"awaitTermination",
"(",
"100",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"assert",
"(",
"todo",
".",
"isEmpty",
"(",
")",
")",
";",
"if",
"(",
"log",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"log",
".",
"trace",
"(",
"\"Processed \"",
"+",
"contextIndex",
".",
"size",
"(",
")",
"+",
"\" contexts\"",
")",
";",
"}",
"hasBeenIncrementallyClassified",
"=",
"false",
";",
"Statistics",
".",
"INSTANCE",
".",
"setTime",
"(",
"\"classification\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"}"
] |
Starts the concurrent classification process.
|
[
"Starts",
"the",
"concurrent",
"classification",
"process",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L1422-L1466
|
11,349
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.getNewSubsumptions
|
public IConceptMap<IConceptSet> getNewSubsumptions() {
IConceptMap<IConceptSet> res = new DenseConceptMap<IConceptSet>(
newContexts.size());
// Collect subsumptions from new contexts
for (Context ctx : newContexts) {
res.put(ctx.getConcept(), ctx.getS());
}
return res;
}
|
java
|
public IConceptMap<IConceptSet> getNewSubsumptions() {
IConceptMap<IConceptSet> res = new DenseConceptMap<IConceptSet>(
newContexts.size());
// Collect subsumptions from new contexts
for (Context ctx : newContexts) {
res.put(ctx.getConcept(), ctx.getS());
}
return res;
}
|
[
"public",
"IConceptMap",
"<",
"IConceptSet",
">",
"getNewSubsumptions",
"(",
")",
"{",
"IConceptMap",
"<",
"IConceptSet",
">",
"res",
"=",
"new",
"DenseConceptMap",
"<",
"IConceptSet",
">",
"(",
"newContexts",
".",
"size",
"(",
")",
")",
";",
"// Collect subsumptions from new contexts",
"for",
"(",
"Context",
"ctx",
":",
"newContexts",
")",
"{",
"res",
".",
"put",
"(",
"ctx",
".",
"getConcept",
"(",
")",
",",
"ctx",
".",
"getS",
"(",
")",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
Returns the subsumptions for the new concepts added in an incremental
classification.
@return
|
[
"Returns",
"the",
"subsumptions",
"for",
"the",
"new",
"concepts",
"added",
"in",
"an",
"incremental",
"classification",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L1486-L1494
|
11,350
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.getAffectedSubsumptions
|
public IConceptMap<IConceptSet> getAffectedSubsumptions() {
int size = 0;
for (Context ctx : affectedContexts) {
if (ctx.hasNewSubsumptions()) {
size++;
}
}
IConceptMap<IConceptSet> res = new DenseConceptMap<IConceptSet>(size);
// Collect subsumptions from affected contexts
for (IntIterator it = contextIndex.keyIterator(); it.hasNext();) {
int key = it.next();
Context ctx = contextIndex.get(key);
if (ctx.hasNewSubsumptions()) {
res.put(key, ctx.getS());
}
}
return res;
}
|
java
|
public IConceptMap<IConceptSet> getAffectedSubsumptions() {
int size = 0;
for (Context ctx : affectedContexts) {
if (ctx.hasNewSubsumptions()) {
size++;
}
}
IConceptMap<IConceptSet> res = new DenseConceptMap<IConceptSet>(size);
// Collect subsumptions from affected contexts
for (IntIterator it = contextIndex.keyIterator(); it.hasNext();) {
int key = it.next();
Context ctx = contextIndex.get(key);
if (ctx.hasNewSubsumptions()) {
res.put(key, ctx.getS());
}
}
return res;
}
|
[
"public",
"IConceptMap",
"<",
"IConceptSet",
">",
"getAffectedSubsumptions",
"(",
")",
"{",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"Context",
"ctx",
":",
"affectedContexts",
")",
"{",
"if",
"(",
"ctx",
".",
"hasNewSubsumptions",
"(",
")",
")",
"{",
"size",
"++",
";",
"}",
"}",
"IConceptMap",
"<",
"IConceptSet",
">",
"res",
"=",
"new",
"DenseConceptMap",
"<",
"IConceptSet",
">",
"(",
"size",
")",
";",
"// Collect subsumptions from affected contexts",
"for",
"(",
"IntIterator",
"it",
"=",
"contextIndex",
".",
"keyIterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"int",
"key",
"=",
"it",
".",
"next",
"(",
")",
";",
"Context",
"ctx",
"=",
"contextIndex",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"ctx",
".",
"hasNewSubsumptions",
"(",
")",
")",
"{",
"res",
".",
"put",
"(",
"key",
",",
"ctx",
".",
"getS",
"(",
")",
")",
";",
"}",
"}",
"return",
"res",
";",
"}"
] |
Returns the subsumptions for the existing concepts that have additional
subsumptions due to the axioms added in an incremental classification.
@return
|
[
"Returns",
"the",
"subsumptions",
"for",
"the",
"existing",
"concepts",
"that",
"have",
"additional",
"subsumptions",
"due",
"to",
"the",
"axioms",
"added",
"in",
"an",
"incremental",
"classification",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L1502-L1520
|
11,351
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.getRelationships
|
public R getRelationships() {
R r = new R(factory.getTotalConcepts(), factory.getTotalRoles());
// Collect subsumptions from context index
for (IntIterator it = contextIndex.keyIterator(); it.hasNext();) {
int key = it.next();
Context ctx = contextIndex.get(key);
int concept = ctx.getConcept();
CR pred = ctx.getPred();
CR succ = ctx.getSucc();
int[] predRoles = pred.getRoles();
for(int i = 0; i < predRoles.length; i++) {
IConceptSet cs = pred.lookupConcept(predRoles[i]);
for(IntIterator it2 = cs.iterator(); it2.hasNext(); ) {
int predC = it2.next();
r.store(predC, predRoles[i], concept);
}
}
int[] succRoles = succ.getRoles();
for(int i = 0; i < succRoles.length; i++) {
IConceptSet cs = succ.lookupConcept(succRoles[i]);
for(IntIterator it2 = cs.iterator(); it2.hasNext(); ) {
int succC = it2.next();
r.store(concept, succRoles[i], succC);
}
}
}
return r;
}
|
java
|
public R getRelationships() {
R r = new R(factory.getTotalConcepts(), factory.getTotalRoles());
// Collect subsumptions from context index
for (IntIterator it = contextIndex.keyIterator(); it.hasNext();) {
int key = it.next();
Context ctx = contextIndex.get(key);
int concept = ctx.getConcept();
CR pred = ctx.getPred();
CR succ = ctx.getSucc();
int[] predRoles = pred.getRoles();
for(int i = 0; i < predRoles.length; i++) {
IConceptSet cs = pred.lookupConcept(predRoles[i]);
for(IntIterator it2 = cs.iterator(); it2.hasNext(); ) {
int predC = it2.next();
r.store(predC, predRoles[i], concept);
}
}
int[] succRoles = succ.getRoles();
for(int i = 0; i < succRoles.length; i++) {
IConceptSet cs = succ.lookupConcept(succRoles[i]);
for(IntIterator it2 = cs.iterator(); it2.hasNext(); ) {
int succC = it2.next();
r.store(concept, succRoles[i], succC);
}
}
}
return r;
}
|
[
"public",
"R",
"getRelationships",
"(",
")",
"{",
"R",
"r",
"=",
"new",
"R",
"(",
"factory",
".",
"getTotalConcepts",
"(",
")",
",",
"factory",
".",
"getTotalRoles",
"(",
")",
")",
";",
"// Collect subsumptions from context index",
"for",
"(",
"IntIterator",
"it",
"=",
"contextIndex",
".",
"keyIterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"int",
"key",
"=",
"it",
".",
"next",
"(",
")",
";",
"Context",
"ctx",
"=",
"contextIndex",
".",
"get",
"(",
"key",
")",
";",
"int",
"concept",
"=",
"ctx",
".",
"getConcept",
"(",
")",
";",
"CR",
"pred",
"=",
"ctx",
".",
"getPred",
"(",
")",
";",
"CR",
"succ",
"=",
"ctx",
".",
"getSucc",
"(",
")",
";",
"int",
"[",
"]",
"predRoles",
"=",
"pred",
".",
"getRoles",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"predRoles",
".",
"length",
";",
"i",
"++",
")",
"{",
"IConceptSet",
"cs",
"=",
"pred",
".",
"lookupConcept",
"(",
"predRoles",
"[",
"i",
"]",
")",
";",
"for",
"(",
"IntIterator",
"it2",
"=",
"cs",
".",
"iterator",
"(",
")",
";",
"it2",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"int",
"predC",
"=",
"it2",
".",
"next",
"(",
")",
";",
"r",
".",
"store",
"(",
"predC",
",",
"predRoles",
"[",
"i",
"]",
",",
"concept",
")",
";",
"}",
"}",
"int",
"[",
"]",
"succRoles",
"=",
"succ",
".",
"getRoles",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"succRoles",
".",
"length",
";",
"i",
"++",
")",
"{",
"IConceptSet",
"cs",
"=",
"succ",
".",
"lookupConcept",
"(",
"succRoles",
"[",
"i",
"]",
")",
";",
"for",
"(",
"IntIterator",
"it2",
"=",
"cs",
".",
"iterator",
"(",
")",
";",
"it2",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"int",
"succC",
"=",
"it2",
".",
"next",
"(",
")",
";",
"r",
".",
"store",
"(",
"concept",
",",
"succRoles",
"[",
"i",
"]",
",",
"succC",
")",
";",
"}",
"}",
"}",
"return",
"r",
";",
"}"
] |
Collects all the information contained in the concurrent R structures in
every context and returns a single R structure with all their content.
@return R
|
[
"Collects",
"all",
"the",
"information",
"contained",
"in",
"the",
"concurrent",
"R",
"structures",
"in",
"every",
"context",
"and",
"returns",
"a",
"single",
"R",
"structure",
"with",
"all",
"their",
"content",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L1528-L1559
|
11,352
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java
|
NormalisedOntology.isChild
|
private boolean isChild(Node cn, Node cn2) {
if (cn == cn2)
return false;
Queue<Node> toProcess = new LinkedList<Node>();
toProcess.addAll(cn.getParents());
while (!toProcess.isEmpty()) {
Node tcn = toProcess.poll();
if (tcn.equals(cn2))
return true;
Set<Node> parents = tcn.getParents();
if (parents != null && !parents.isEmpty())
toProcess.addAll(parents);
}
return false;
}
|
java
|
private boolean isChild(Node cn, Node cn2) {
if (cn == cn2)
return false;
Queue<Node> toProcess = new LinkedList<Node>();
toProcess.addAll(cn.getParents());
while (!toProcess.isEmpty()) {
Node tcn = toProcess.poll();
if (tcn.equals(cn2))
return true;
Set<Node> parents = tcn.getParents();
if (parents != null && !parents.isEmpty())
toProcess.addAll(parents);
}
return false;
}
|
[
"private",
"boolean",
"isChild",
"(",
"Node",
"cn",
",",
"Node",
"cn2",
")",
"{",
"if",
"(",
"cn",
"==",
"cn2",
")",
"return",
"false",
";",
"Queue",
"<",
"Node",
">",
"toProcess",
"=",
"new",
"LinkedList",
"<",
"Node",
">",
"(",
")",
";",
"toProcess",
".",
"addAll",
"(",
"cn",
".",
"getParents",
"(",
")",
")",
";",
"while",
"(",
"!",
"toProcess",
".",
"isEmpty",
"(",
")",
")",
"{",
"Node",
"tcn",
"=",
"toProcess",
".",
"poll",
"(",
")",
";",
"if",
"(",
"tcn",
".",
"equals",
"(",
"cn2",
")",
")",
"return",
"true",
";",
"Set",
"<",
"Node",
">",
"parents",
"=",
"tcn",
".",
"getParents",
"(",
")",
";",
"if",
"(",
"parents",
"!=",
"null",
"&&",
"!",
"parents",
".",
"isEmpty",
"(",
")",
")",
"toProcess",
".",
"addAll",
"(",
"parents",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Indicates if cn is a child of cn2.
@param cn
@param cn2
@return
|
[
"Indicates",
"if",
"cn",
"is",
"a",
"child",
"of",
"cn2",
"."
] |
e33c1e216f8a66d6502e3a14e80876811feedd8b
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/NormalisedOntology.java#L2339-L2356
|
11,353
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java
|
BaseRequest.setHeaders
|
public void setHeaders(Map<String, List<String>> headerMap) {
headers = new Headers.Builder();
for (Map.Entry<String, List<String>> e : headerMap.entrySet()) {
for (String headerValue : e.getValue()) {
addHeader(e.getKey(), headerValue);
}
}
}
|
java
|
public void setHeaders(Map<String, List<String>> headerMap) {
headers = new Headers.Builder();
for (Map.Entry<String, List<String>> e : headerMap.entrySet()) {
for (String headerValue : e.getValue()) {
addHeader(e.getKey(), headerValue);
}
}
}
|
[
"public",
"void",
"setHeaders",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headerMap",
")",
"{",
"headers",
"=",
"new",
"Headers",
".",
"Builder",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"e",
":",
"headerMap",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"String",
"headerValue",
":",
"e",
".",
"getValue",
"(",
")",
")",
"{",
"addHeader",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"headerValue",
")",
";",
"}",
"}",
"}"
] |
Sets headers for this resource request. Overrides all headers previously added.
@param headerMap A multimap containing the header names and corresponding values
|
[
"Sets",
"headers",
"for",
"this",
"resource",
"request",
".",
"Overrides",
"all",
"headers",
"previously",
"added",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java#L296-L304
|
11,354
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java
|
BaseRequest.addAppIDHeader
|
public void addAppIDHeader(Context contextValue) {
BaseAppIdentity appIdDetails = new BaseAppIdentity(contextValue);
headers.add(APPLICATION_BUNDLE_ID, appIdDetails.getId());
}
|
java
|
public void addAppIDHeader(Context contextValue) {
BaseAppIdentity appIdDetails = new BaseAppIdentity(contextValue);
headers.add(APPLICATION_BUNDLE_ID, appIdDetails.getId());
}
|
[
"public",
"void",
"addAppIDHeader",
"(",
"Context",
"contextValue",
")",
"{",
"BaseAppIdentity",
"appIdDetails",
"=",
"new",
"BaseAppIdentity",
"(",
"contextValue",
")",
";",
"headers",
".",
"add",
"(",
"APPLICATION_BUNDLE_ID",
",",
"appIdDetails",
".",
"getId",
"(",
")",
")",
";",
"}"
] |
Adds the App budle ID to this resource request.
@param contextValue context of teh application
|
[
"Adds",
"the",
"App",
"budle",
"ID",
"to",
"this",
"resource",
"request",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java#L321-L324
|
11,355
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java
|
BaseRequest.setTimeout
|
public void setTimeout(int timeout) {
this.timeout = timeout;
httpClient.connectTimeout(timeout, TimeUnit.MILLISECONDS);
httpClient.readTimeout(timeout, TimeUnit.MILLISECONDS);
httpClient.writeTimeout(timeout, TimeUnit.MILLISECONDS);
}
|
java
|
public void setTimeout(int timeout) {
this.timeout = timeout;
httpClient.connectTimeout(timeout, TimeUnit.MILLISECONDS);
httpClient.readTimeout(timeout, TimeUnit.MILLISECONDS);
httpClient.writeTimeout(timeout, TimeUnit.MILLISECONDS);
}
|
[
"public",
"void",
"setTimeout",
"(",
"int",
"timeout",
")",
"{",
"this",
".",
"timeout",
"=",
"timeout",
";",
"httpClient",
".",
"connectTimeout",
"(",
"timeout",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"httpClient",
".",
"readTimeout",
"(",
"timeout",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"httpClient",
".",
"writeTimeout",
"(",
"timeout",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}"
] |
Sets the timeout for this resource request.
@param timeout The timeout for this request procedure
|
[
"Sets",
"the",
"timeout",
"for",
"this",
"resource",
"request",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java#L340-L349
|
11,356
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java
|
BaseRequest.sendOKHttpRequest
|
protected void sendOKHttpRequest(Request request, final Callback callback) {
OkHttpClient client = httpClient.build();
client.newCall(request).enqueue(callback);
}
|
java
|
protected void sendOKHttpRequest(Request request, final Callback callback) {
OkHttpClient client = httpClient.build();
client.newCall(request).enqueue(callback);
}
|
[
"protected",
"void",
"sendOKHttpRequest",
"(",
"Request",
"request",
",",
"final",
"Callback",
"callback",
")",
"{",
"OkHttpClient",
"client",
"=",
"httpClient",
".",
"build",
"(",
")",
";",
"client",
".",
"newCall",
"(",
"request",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] |
Hands off the request to OkHttp
|
[
"Hands",
"off",
"the",
"request",
"to",
"OkHttp"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java#L745-L748
|
11,357
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java
|
BaseRequest.updateProgressListener
|
protected void updateProgressListener(ProgressListener progressListener, Response response) {
InputStream responseStream = response.getResponseByteStream();
int bytesDownloaded = 0;
long totalBytesExpected = response.getContentLength();
// Reading 2 KiB at a time to be consistent with the upload segment size in ProgressRequestBody
final int segmentSize = 2048;
byte[] responseBytes;
if (totalBytesExpected > Integer.MAX_VALUE) {
logger.warn("The response body for " + getUrl() + " is too large to hold in a byte array. Only the first 2 GiB will be available.");
responseBytes = new byte[Integer.MAX_VALUE];
}
else {
responseBytes = new byte[(int)totalBytesExpected];
}
// For every 2 KiB downloaded:
// 1) Call the user's ProgressListener
// 2) Append the downloaded bytes into a byte array
int nextByte;
try {
while ((nextByte = responseStream.read()) != -1) {
if (bytesDownloaded % segmentSize == 0) {
progressListener.onProgress(bytesDownloaded, totalBytesExpected);
}
responseBytes[bytesDownloaded] = (byte)nextByte;
bytesDownloaded += 1;
}
}
catch (IOException e) {
logger.error("IO Exception: " + e.getMessage());
}
// Transfer the downloaded data to the Response object so that the user can later retrieve it
if (response instanceof ResponseImpl) {
((ResponseImpl)response).setResponseBytes(responseBytes);
}
}
|
java
|
protected void updateProgressListener(ProgressListener progressListener, Response response) {
InputStream responseStream = response.getResponseByteStream();
int bytesDownloaded = 0;
long totalBytesExpected = response.getContentLength();
// Reading 2 KiB at a time to be consistent with the upload segment size in ProgressRequestBody
final int segmentSize = 2048;
byte[] responseBytes;
if (totalBytesExpected > Integer.MAX_VALUE) {
logger.warn("The response body for " + getUrl() + " is too large to hold in a byte array. Only the first 2 GiB will be available.");
responseBytes = new byte[Integer.MAX_VALUE];
}
else {
responseBytes = new byte[(int)totalBytesExpected];
}
// For every 2 KiB downloaded:
// 1) Call the user's ProgressListener
// 2) Append the downloaded bytes into a byte array
int nextByte;
try {
while ((nextByte = responseStream.read()) != -1) {
if (bytesDownloaded % segmentSize == 0) {
progressListener.onProgress(bytesDownloaded, totalBytesExpected);
}
responseBytes[bytesDownloaded] = (byte)nextByte;
bytesDownloaded += 1;
}
}
catch (IOException e) {
logger.error("IO Exception: " + e.getMessage());
}
// Transfer the downloaded data to the Response object so that the user can later retrieve it
if (response instanceof ResponseImpl) {
((ResponseImpl)response).setResponseBytes(responseBytes);
}
}
|
[
"protected",
"void",
"updateProgressListener",
"(",
"ProgressListener",
"progressListener",
",",
"Response",
"response",
")",
"{",
"InputStream",
"responseStream",
"=",
"response",
".",
"getResponseByteStream",
"(",
")",
";",
"int",
"bytesDownloaded",
"=",
"0",
";",
"long",
"totalBytesExpected",
"=",
"response",
".",
"getContentLength",
"(",
")",
";",
"// Reading 2 KiB at a time to be consistent with the upload segment size in ProgressRequestBody",
"final",
"int",
"segmentSize",
"=",
"2048",
";",
"byte",
"[",
"]",
"responseBytes",
";",
"if",
"(",
"totalBytesExpected",
">",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"logger",
".",
"warn",
"(",
"\"The response body for \"",
"+",
"getUrl",
"(",
")",
"+",
"\" is too large to hold in a byte array. Only the first 2 GiB will be available.\"",
")",
";",
"responseBytes",
"=",
"new",
"byte",
"[",
"Integer",
".",
"MAX_VALUE",
"]",
";",
"}",
"else",
"{",
"responseBytes",
"=",
"new",
"byte",
"[",
"(",
"int",
")",
"totalBytesExpected",
"]",
";",
"}",
"// For every 2 KiB downloaded:",
"// 1) Call the user's ProgressListener",
"// 2) Append the downloaded bytes into a byte array",
"int",
"nextByte",
";",
"try",
"{",
"while",
"(",
"(",
"nextByte",
"=",
"responseStream",
".",
"read",
"(",
")",
")",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"bytesDownloaded",
"%",
"segmentSize",
"==",
"0",
")",
"{",
"progressListener",
".",
"onProgress",
"(",
"bytesDownloaded",
",",
"totalBytesExpected",
")",
";",
"}",
"responseBytes",
"[",
"bytesDownloaded",
"]",
"=",
"(",
"byte",
")",
"nextByte",
";",
"bytesDownloaded",
"+=",
"1",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"IO Exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"// Transfer the downloaded data to the Response object so that the user can later retrieve it",
"if",
"(",
"response",
"instanceof",
"ResponseImpl",
")",
"{",
"(",
"(",
"ResponseImpl",
")",
"response",
")",
".",
"setResponseBytes",
"(",
"responseBytes",
")",
";",
"}",
"}"
] |
As a download request progresses, periodically call the user's ProgressListener
|
[
"As",
"a",
"download",
"request",
"progresses",
"periodically",
"call",
"the",
"user",
"s",
"ProgressListener"
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/internal/BaseRequest.java#L794-L832
|
11,358
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.initialize
|
public void initialize(Context context, ResponseListener listener) {
this.context = context;
this.listener = (listener != null) ? listener : new ResponseListener() {
final String message = "ResponseListener is not specified. Defaulting to empty listener.";
@Override
public void onSuccess(Response response) {
logger.debug(message);
}
@Override
public void onFailure(Response response, Throwable t, JSONObject extendedInfo) {
logger.debug(message);
}
};
logger.debug("AuthorizationRequestAgent is initialized.");
}
|
java
|
public void initialize(Context context, ResponseListener listener) {
this.context = context;
this.listener = (listener != null) ? listener : new ResponseListener() {
final String message = "ResponseListener is not specified. Defaulting to empty listener.";
@Override
public void onSuccess(Response response) {
logger.debug(message);
}
@Override
public void onFailure(Response response, Throwable t, JSONObject extendedInfo) {
logger.debug(message);
}
};
logger.debug("AuthorizationRequestAgent is initialized.");
}
|
[
"public",
"void",
"initialize",
"(",
"Context",
"context",
",",
"ResponseListener",
"listener",
")",
"{",
"this",
".",
"context",
"=",
"context",
";",
"this",
".",
"listener",
"=",
"(",
"listener",
"!=",
"null",
")",
"?",
"listener",
":",
"new",
"ResponseListener",
"(",
")",
"{",
"final",
"String",
"message",
"=",
"\"ResponseListener is not specified. Defaulting to empty listener.\"",
";",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"Response",
"response",
")",
"{",
"logger",
".",
"debug",
"(",
"message",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onFailure",
"(",
"Response",
"response",
",",
"Throwable",
"t",
",",
"JSONObject",
"extendedInfo",
")",
"{",
"logger",
".",
"debug",
"(",
"message",
")",
";",
"}",
"}",
";",
"logger",
".",
"debug",
"(",
"\"AuthorizationRequestAgent is initialized.\"",
")",
";",
"}"
] |
Initializes the request manager.
@param context Context to be cached and passed to challenge handlers later.
@param listener Response listener. Called when an authorization response has been processed.
|
[
"Initializes",
"the",
"request",
"manager",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L131-L148
|
11,359
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.sendRequest
|
public void sendRequest(String path, RequestOptions options) throws IOException, JSONException {
String rootUrl;
if (path == null) {
throw new IllegalArgumentException("'path' parameter can't be null.");
}
if (path.indexOf(BMSClient.HTTP_SCHEME) == 0 && path.contains(":")) {
// request using full path, split the URL to root and path
URL url = new URL(path);
path = url.getPath();
rootUrl = url.toString().replace(path, "");
} else {
String MCATenantId = MCAAuthorizationManager.getInstance().getTenantId();
if(MCATenantId == null){
MCATenantId = BMSClient.getInstance().getBluemixAppGUID();
}
String bluemixRegionSuffix = MCAAuthorizationManager.getInstance().getBluemixRegionSuffix();
if(bluemixRegionSuffix == null){
bluemixRegionSuffix = BMSClient.getInstance().getBluemixRegionSuffix();
}
// "path" is a relative
String serverHost = BMSClient.getInstance().getDefaultProtocol()
+ "://"
+ AUTH_SERVER_NAME
+ bluemixRegionSuffix;
if (overrideServerHost!=null)
serverHost = overrideServerHost;
rootUrl = serverHost
+ "/"
+ AUTH_SERVER_NAME
+ "/"
+ AUTH_PATH
+ MCATenantId;
}
sendRequestInternal(rootUrl, path, options);
}
|
java
|
public void sendRequest(String path, RequestOptions options) throws IOException, JSONException {
String rootUrl;
if (path == null) {
throw new IllegalArgumentException("'path' parameter can't be null.");
}
if (path.indexOf(BMSClient.HTTP_SCHEME) == 0 && path.contains(":")) {
// request using full path, split the URL to root and path
URL url = new URL(path);
path = url.getPath();
rootUrl = url.toString().replace(path, "");
} else {
String MCATenantId = MCAAuthorizationManager.getInstance().getTenantId();
if(MCATenantId == null){
MCATenantId = BMSClient.getInstance().getBluemixAppGUID();
}
String bluemixRegionSuffix = MCAAuthorizationManager.getInstance().getBluemixRegionSuffix();
if(bluemixRegionSuffix == null){
bluemixRegionSuffix = BMSClient.getInstance().getBluemixRegionSuffix();
}
// "path" is a relative
String serverHost = BMSClient.getInstance().getDefaultProtocol()
+ "://"
+ AUTH_SERVER_NAME
+ bluemixRegionSuffix;
if (overrideServerHost!=null)
serverHost = overrideServerHost;
rootUrl = serverHost
+ "/"
+ AUTH_SERVER_NAME
+ "/"
+ AUTH_PATH
+ MCATenantId;
}
sendRequestInternal(rootUrl, path, options);
}
|
[
"public",
"void",
"sendRequest",
"(",
"String",
"path",
",",
"RequestOptions",
"options",
")",
"throws",
"IOException",
",",
"JSONException",
"{",
"String",
"rootUrl",
";",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"'path' parameter can't be null.\"",
")",
";",
"}",
"if",
"(",
"path",
".",
"indexOf",
"(",
"BMSClient",
".",
"HTTP_SCHEME",
")",
"==",
"0",
"&&",
"path",
".",
"contains",
"(",
"\":\"",
")",
")",
"{",
"// request using full path, split the URL to root and path",
"URL",
"url",
"=",
"new",
"URL",
"(",
"path",
")",
";",
"path",
"=",
"url",
".",
"getPath",
"(",
")",
";",
"rootUrl",
"=",
"url",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"path",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"String",
"MCATenantId",
"=",
"MCAAuthorizationManager",
".",
"getInstance",
"(",
")",
".",
"getTenantId",
"(",
")",
";",
"if",
"(",
"MCATenantId",
"==",
"null",
")",
"{",
"MCATenantId",
"=",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getBluemixAppGUID",
"(",
")",
";",
"}",
"String",
"bluemixRegionSuffix",
"=",
"MCAAuthorizationManager",
".",
"getInstance",
"(",
")",
".",
"getBluemixRegionSuffix",
"(",
")",
";",
"if",
"(",
"bluemixRegionSuffix",
"==",
"null",
")",
"{",
"bluemixRegionSuffix",
"=",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getBluemixRegionSuffix",
"(",
")",
";",
"}",
"// \"path\" is a relative",
"String",
"serverHost",
"=",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getDefaultProtocol",
"(",
")",
"+",
"\"://\"",
"+",
"AUTH_SERVER_NAME",
"+",
"bluemixRegionSuffix",
";",
"if",
"(",
"overrideServerHost",
"!=",
"null",
")",
"serverHost",
"=",
"overrideServerHost",
";",
"rootUrl",
"=",
"serverHost",
"+",
"\"/\"",
"+",
"AUTH_SERVER_NAME",
"+",
"\"/\"",
"+",
"AUTH_PATH",
"+",
"MCATenantId",
";",
"}",
"sendRequestInternal",
"(",
"rootUrl",
",",
"path",
",",
"options",
")",
";",
"}"
] |
Assembles the request path from root and path to authorization endpoint and sends the request.
@param path Path to authorization endpoint
@param options BaseRequest options
@throws IOException
@throws JSONException
|
[
"Assembles",
"the",
"request",
"path",
"from",
"root",
"and",
"path",
"to",
"authorization",
"endpoint",
"and",
"sends",
"the",
"request",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L158-L197
|
11,360
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.sendRequestInternal
|
private void sendRequestInternal(String rootUrl, String path, RequestOptions options) throws IOException, JSONException {
logger.debug("Sending request to root: " + rootUrl + " with path: " + path);
// create default options object with GET request method.
if (options == null) {
options = new RequestOptions();
}
// used to resend request
this.requestPath = Utils.concatenateUrls(rootUrl, path);
this.requestOptions = options;
AuthorizationRequest request = new AuthorizationRequest(this.requestPath, options.requestMethod);
if (options.timeout != 0) {
request.setTimeout(options.timeout);
} else {
request.setTimeout(BMSClient.getInstance().getDefaultTimeout());
}
if (options.headers != null) {
for (Map.Entry<String, String> entry : options.headers.entrySet()) {
request.addHeader(entry.getKey(), entry.getValue());
}
}
if (answers != null) {
// 0 means no spaces in the generated string
String answer = answers.toString(0);
String authorizationHeaderValue = String.format("Bearer %s", answer.replace("\n", ""));
request.addHeader("Authorization", authorizationHeaderValue);
logger.debug("Added authorization header to request: " + authorizationHeaderValue);
}
if (Request.GET.equalsIgnoreCase(options.requestMethod)) {
request.setQueryParameters(options.parameters);
request.send(this);
} else {
request.send(options.parameters, this);
}
}
|
java
|
private void sendRequestInternal(String rootUrl, String path, RequestOptions options) throws IOException, JSONException {
logger.debug("Sending request to root: " + rootUrl + " with path: " + path);
// create default options object with GET request method.
if (options == null) {
options = new RequestOptions();
}
// used to resend request
this.requestPath = Utils.concatenateUrls(rootUrl, path);
this.requestOptions = options;
AuthorizationRequest request = new AuthorizationRequest(this.requestPath, options.requestMethod);
if (options.timeout != 0) {
request.setTimeout(options.timeout);
} else {
request.setTimeout(BMSClient.getInstance().getDefaultTimeout());
}
if (options.headers != null) {
for (Map.Entry<String, String> entry : options.headers.entrySet()) {
request.addHeader(entry.getKey(), entry.getValue());
}
}
if (answers != null) {
// 0 means no spaces in the generated string
String answer = answers.toString(0);
String authorizationHeaderValue = String.format("Bearer %s", answer.replace("\n", ""));
request.addHeader("Authorization", authorizationHeaderValue);
logger.debug("Added authorization header to request: " + authorizationHeaderValue);
}
if (Request.GET.equalsIgnoreCase(options.requestMethod)) {
request.setQueryParameters(options.parameters);
request.send(this);
} else {
request.send(options.parameters, this);
}
}
|
[
"private",
"void",
"sendRequestInternal",
"(",
"String",
"rootUrl",
",",
"String",
"path",
",",
"RequestOptions",
"options",
")",
"throws",
"IOException",
",",
"JSONException",
"{",
"logger",
".",
"debug",
"(",
"\"Sending request to root: \"",
"+",
"rootUrl",
"+",
"\" with path: \"",
"+",
"path",
")",
";",
"// create default options object with GET request method.",
"if",
"(",
"options",
"==",
"null",
")",
"{",
"options",
"=",
"new",
"RequestOptions",
"(",
")",
";",
"}",
"// used to resend request",
"this",
".",
"requestPath",
"=",
"Utils",
".",
"concatenateUrls",
"(",
"rootUrl",
",",
"path",
")",
";",
"this",
".",
"requestOptions",
"=",
"options",
";",
"AuthorizationRequest",
"request",
"=",
"new",
"AuthorizationRequest",
"(",
"this",
".",
"requestPath",
",",
"options",
".",
"requestMethod",
")",
";",
"if",
"(",
"options",
".",
"timeout",
"!=",
"0",
")",
"{",
"request",
".",
"setTimeout",
"(",
"options",
".",
"timeout",
")",
";",
"}",
"else",
"{",
"request",
".",
"setTimeout",
"(",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getDefaultTimeout",
"(",
")",
")",
";",
"}",
"if",
"(",
"options",
".",
"headers",
"!=",
"null",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"options",
".",
"headers",
".",
"entrySet",
"(",
")",
")",
"{",
"request",
".",
"addHeader",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"answers",
"!=",
"null",
")",
"{",
"// 0 means no spaces in the generated string",
"String",
"answer",
"=",
"answers",
".",
"toString",
"(",
"0",
")",
";",
"String",
"authorizationHeaderValue",
"=",
"String",
".",
"format",
"(",
"\"Bearer %s\"",
",",
"answer",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"\"",
")",
")",
";",
"request",
".",
"addHeader",
"(",
"\"Authorization\"",
",",
"authorizationHeaderValue",
")",
";",
"logger",
".",
"debug",
"(",
"\"Added authorization header to request: \"",
"+",
"authorizationHeaderValue",
")",
";",
"}",
"if",
"(",
"Request",
".",
"GET",
".",
"equalsIgnoreCase",
"(",
"options",
".",
"requestMethod",
")",
")",
"{",
"request",
".",
"setQueryParameters",
"(",
"options",
".",
"parameters",
")",
";",
"request",
".",
"send",
"(",
"this",
")",
";",
"}",
"else",
"{",
"request",
".",
"send",
"(",
"options",
".",
"parameters",
",",
"this",
")",
";",
"}",
"}"
] |
Builds an authorization request and sends it. It also caches the request url and request options in
order to be able to re-send the request when authorization challenges have been handled.
@param rootUrl Root of authorization server.
@param path Path to authorization endpoint.
@param options BaseRequest options.
@throws IOException
@throws JSONException
|
[
"Builds",
"an",
"authorization",
"request",
"and",
"sends",
"it",
".",
"It",
"also",
"caches",
"the",
"request",
"url",
"and",
"request",
"options",
"in",
"order",
"to",
"be",
"able",
"to",
"re",
"-",
"send",
"the",
"request",
"when",
"authorization",
"challenges",
"have",
"been",
"handled",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L219-L260
|
11,361
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.setExpectedAnswers
|
private void setExpectedAnswers(ArrayList<String> realms) {
if (answers == null) {
return;
}
for (String realm : realms) {
try {
answers.put(realm, "");
} catch (JSONException t) {
logger.error("setExpectedAnswers failed with exception: " + t.getLocalizedMessage(), t);
}
}
}
|
java
|
private void setExpectedAnswers(ArrayList<String> realms) {
if (answers == null) {
return;
}
for (String realm : realms) {
try {
answers.put(realm, "");
} catch (JSONException t) {
logger.error("setExpectedAnswers failed with exception: " + t.getLocalizedMessage(), t);
}
}
}
|
[
"private",
"void",
"setExpectedAnswers",
"(",
"ArrayList",
"<",
"String",
">",
"realms",
")",
"{",
"if",
"(",
"answers",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"String",
"realm",
":",
"realms",
")",
"{",
"try",
"{",
"answers",
".",
"put",
"(",
"realm",
",",
"\"\"",
")",
";",
"}",
"catch",
"(",
"JSONException",
"t",
")",
"{",
"logger",
".",
"error",
"(",
"\"setExpectedAnswers failed with exception: \"",
"+",
"t",
".",
"getLocalizedMessage",
"(",
")",
",",
"t",
")",
";",
"}",
"}",
"}"
] |
Initializes the collection of expected challenge answers.
@param realms List of realms
|
[
"Initializes",
"the",
"collection",
"of",
"expected",
"challenge",
"answers",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L267-L279
|
11,362
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.removeExpectedAnswer
|
public void removeExpectedAnswer(String realm) {
if (answers != null) {
answers.remove(realm);
}
try {
if (isAnswersFilled()) {
resendRequest();
}
} catch (Throwable t) {
logger.error("removeExpectedAnswer failed with exception: " + t.getLocalizedMessage(), t);
}
}
|
java
|
public void removeExpectedAnswer(String realm) {
if (answers != null) {
answers.remove(realm);
}
try {
if (isAnswersFilled()) {
resendRequest();
}
} catch (Throwable t) {
logger.error("removeExpectedAnswer failed with exception: " + t.getLocalizedMessage(), t);
}
}
|
[
"public",
"void",
"removeExpectedAnswer",
"(",
"String",
"realm",
")",
"{",
"if",
"(",
"answers",
"!=",
"null",
")",
"{",
"answers",
".",
"remove",
"(",
"realm",
")",
";",
"}",
"try",
"{",
"if",
"(",
"isAnswersFilled",
"(",
")",
")",
"{",
"resendRequest",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"logger",
".",
"error",
"(",
"\"removeExpectedAnswer failed with exception: \"",
"+",
"t",
".",
"getLocalizedMessage",
"(",
")",
",",
"t",
")",
";",
"}",
"}"
] |
Removes an expected challenge answer from collection.
@param realm Realm of the answer to remove.
|
[
"Removes",
"an",
"expected",
"challenge",
"answer",
"from",
"collection",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L286-L298
|
11,363
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.submitAnswer
|
public void submitAnswer(JSONObject answer, String realm) {
if (answers == null) {
answers = new JSONObject();
}
try {
answers.put(realm, answer);
if (isAnswersFilled()) {
resendRequest();
}
} catch (Throwable t) {
logger.error("submitAnswer failed with exception: " + t.getLocalizedMessage(), t);
}
}
|
java
|
public void submitAnswer(JSONObject answer, String realm) {
if (answers == null) {
answers = new JSONObject();
}
try {
answers.put(realm, answer);
if (isAnswersFilled()) {
resendRequest();
}
} catch (Throwable t) {
logger.error("submitAnswer failed with exception: " + t.getLocalizedMessage(), t);
}
}
|
[
"public",
"void",
"submitAnswer",
"(",
"JSONObject",
"answer",
",",
"String",
"realm",
")",
"{",
"if",
"(",
"answers",
"==",
"null",
")",
"{",
"answers",
"=",
"new",
"JSONObject",
"(",
")",
";",
"}",
"try",
"{",
"answers",
".",
"put",
"(",
"realm",
",",
"answer",
")",
";",
"if",
"(",
"isAnswersFilled",
"(",
")",
")",
"{",
"resendRequest",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"logger",
".",
"error",
"(",
"\"submitAnswer failed with exception: \"",
"+",
"t",
".",
"getLocalizedMessage",
"(",
")",
",",
"t",
")",
";",
"}",
"}"
] |
Adds an expected challenge answer to collection of answers.
@param answer Answer to add.
@param realm Authentication realm for the answer.
|
[
"Adds",
"an",
"expected",
"challenge",
"answer",
"to",
"collection",
"of",
"answers",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L306-L319
|
11,364
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.isAnswersFilled
|
public boolean isAnswersFilled() throws JSONException {
if (answers == null) {
return true;
}
Iterator<String> it = answers.keys();
while (it.hasNext()) {
String key = it.next();
Object value = answers.get(key);
if ((value instanceof String) && value.equals("")) {
return false;
}
}
return true;
}
|
java
|
public boolean isAnswersFilled() throws JSONException {
if (answers == null) {
return true;
}
Iterator<String> it = answers.keys();
while (it.hasNext()) {
String key = it.next();
Object value = answers.get(key);
if ((value instanceof String) && value.equals("")) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"isAnswersFilled",
"(",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"answers",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"Iterator",
"<",
"String",
">",
"it",
"=",
"answers",
".",
"keys",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"key",
"=",
"it",
".",
"next",
"(",
")",
";",
"Object",
"value",
"=",
"answers",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"(",
"value",
"instanceof",
"String",
")",
"&&",
"value",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Verifies whether all expected challenges have been answered, or not.
@return <code>true</code> if all answers have been submitted, otherwise <code>false</code>.
@throws JSONException
|
[
"Verifies",
"whether",
"all",
"expected",
"challenges",
"have",
"been",
"answered",
"or",
"not",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L327-L343
|
11,365
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.processRedirectResponse
|
private void processRedirectResponse(Response response) throws RuntimeException, JSONException, MalformedURLException {
// a valid redirect response must contain the Location header.
ResponseImpl responseImpl = (ResponseImpl)response;
List<String> locationHeaders = responseImpl.getHeader(LOCATION_HEADER_NAME);
String location = (locationHeaders != null && locationHeaders.size() > 0) ? locationHeaders.get(0) : null;
if (location == null) {
throw new RuntimeException("Redirect response does not contain 'Location' header.");
}
// the redirect location url should contain "wl_result" value in query parameters.
URL url = new URL(location);
String query = url.getQuery();
if (query.contains(WL_RESULT)) {
String result = Utils.getParameterValueFromQuery(query, WL_RESULT);
JSONObject jsonResult = new JSONObject(result);
// process failures if any
JSONObject jsonFailures = jsonResult.optJSONObject(AUTH_FAILURE_VALUE_NAME);
if (jsonFailures != null) {
processFailures(jsonFailures);
listener.onFailure(response, null, null);
return;
}
// process successes if any
JSONObject jsonSuccesses = jsonResult.optJSONObject(AUTH_SUCCESS_VALUE_NAME);
if (jsonSuccesses != null) {
processSuccesses(jsonSuccesses);
}
}
// the rest is handles by the caller
listener.onSuccess(response);
}
|
java
|
private void processRedirectResponse(Response response) throws RuntimeException, JSONException, MalformedURLException {
// a valid redirect response must contain the Location header.
ResponseImpl responseImpl = (ResponseImpl)response;
List<String> locationHeaders = responseImpl.getHeader(LOCATION_HEADER_NAME);
String location = (locationHeaders != null && locationHeaders.size() > 0) ? locationHeaders.get(0) : null;
if (location == null) {
throw new RuntimeException("Redirect response does not contain 'Location' header.");
}
// the redirect location url should contain "wl_result" value in query parameters.
URL url = new URL(location);
String query = url.getQuery();
if (query.contains(WL_RESULT)) {
String result = Utils.getParameterValueFromQuery(query, WL_RESULT);
JSONObject jsonResult = new JSONObject(result);
// process failures if any
JSONObject jsonFailures = jsonResult.optJSONObject(AUTH_FAILURE_VALUE_NAME);
if (jsonFailures != null) {
processFailures(jsonFailures);
listener.onFailure(response, null, null);
return;
}
// process successes if any
JSONObject jsonSuccesses = jsonResult.optJSONObject(AUTH_SUCCESS_VALUE_NAME);
if (jsonSuccesses != null) {
processSuccesses(jsonSuccesses);
}
}
// the rest is handles by the caller
listener.onSuccess(response);
}
|
[
"private",
"void",
"processRedirectResponse",
"(",
"Response",
"response",
")",
"throws",
"RuntimeException",
",",
"JSONException",
",",
"MalformedURLException",
"{",
"// a valid redirect response must contain the Location header.",
"ResponseImpl",
"responseImpl",
"=",
"(",
"ResponseImpl",
")",
"response",
";",
"List",
"<",
"String",
">",
"locationHeaders",
"=",
"responseImpl",
".",
"getHeader",
"(",
"LOCATION_HEADER_NAME",
")",
";",
"String",
"location",
"=",
"(",
"locationHeaders",
"!=",
"null",
"&&",
"locationHeaders",
".",
"size",
"(",
")",
">",
"0",
")",
"?",
"locationHeaders",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"if",
"(",
"location",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Redirect response does not contain 'Location' header.\"",
")",
";",
"}",
"// the redirect location url should contain \"wl_result\" value in query parameters.",
"URL",
"url",
"=",
"new",
"URL",
"(",
"location",
")",
";",
"String",
"query",
"=",
"url",
".",
"getQuery",
"(",
")",
";",
"if",
"(",
"query",
".",
"contains",
"(",
"WL_RESULT",
")",
")",
"{",
"String",
"result",
"=",
"Utils",
".",
"getParameterValueFromQuery",
"(",
"query",
",",
"WL_RESULT",
")",
";",
"JSONObject",
"jsonResult",
"=",
"new",
"JSONObject",
"(",
"result",
")",
";",
"// process failures if any",
"JSONObject",
"jsonFailures",
"=",
"jsonResult",
".",
"optJSONObject",
"(",
"AUTH_FAILURE_VALUE_NAME",
")",
";",
"if",
"(",
"jsonFailures",
"!=",
"null",
")",
"{",
"processFailures",
"(",
"jsonFailures",
")",
";",
"listener",
".",
"onFailure",
"(",
"response",
",",
"null",
",",
"null",
")",
";",
"return",
";",
"}",
"// process successes if any",
"JSONObject",
"jsonSuccesses",
"=",
"jsonResult",
".",
"optJSONObject",
"(",
"AUTH_SUCCESS_VALUE_NAME",
")",
";",
"if",
"(",
"jsonSuccesses",
"!=",
"null",
")",
"{",
"processSuccesses",
"(",
"jsonSuccesses",
")",
";",
"}",
"}",
"// the rest is handles by the caller",
"listener",
".",
"onSuccess",
"(",
"response",
")",
";",
"}"
] |
Processes redirect response from authorization endpoint.
@param response Response from the server.
|
[
"Processes",
"redirect",
"response",
"from",
"authorization",
"endpoint",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L350-L388
|
11,366
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.processResponse
|
private void processResponse(Response response) {
// at this point a server response should contain a secure JSON with challenges
JSONObject jsonResponse = Utils.extractSecureJson(response);
JSONObject jsonChallenges = (jsonResponse == null) ? null : jsonResponse.optJSONObject(CHALLENGES_VALUE_NAME);
if (jsonChallenges != null) {
startHandleChallenges(jsonChallenges, response);
} else {
listener.onSuccess(response);
}
}
|
java
|
private void processResponse(Response response) {
// at this point a server response should contain a secure JSON with challenges
JSONObject jsonResponse = Utils.extractSecureJson(response);
JSONObject jsonChallenges = (jsonResponse == null) ? null : jsonResponse.optJSONObject(CHALLENGES_VALUE_NAME);
if (jsonChallenges != null) {
startHandleChallenges(jsonChallenges, response);
} else {
listener.onSuccess(response);
}
}
|
[
"private",
"void",
"processResponse",
"(",
"Response",
"response",
")",
"{",
"// at this point a server response should contain a secure JSON with challenges",
"JSONObject",
"jsonResponse",
"=",
"Utils",
".",
"extractSecureJson",
"(",
"response",
")",
";",
"JSONObject",
"jsonChallenges",
"=",
"(",
"jsonResponse",
"==",
"null",
")",
"?",
"null",
":",
"jsonResponse",
".",
"optJSONObject",
"(",
"CHALLENGES_VALUE_NAME",
")",
";",
"if",
"(",
"jsonChallenges",
"!=",
"null",
")",
"{",
"startHandleChallenges",
"(",
"jsonChallenges",
",",
"response",
")",
";",
"}",
"else",
"{",
"listener",
".",
"onSuccess",
"(",
"response",
")",
";",
"}",
"}"
] |
Process a response from the server.
@param response Server response.
|
[
"Process",
"a",
"response",
"from",
"the",
"server",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L395-L405
|
11,367
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.startHandleChallenges
|
private void startHandleChallenges(JSONObject jsonChallenges, Response response) {
ArrayList<String> challenges = getRealmsFromJson(jsonChallenges);
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
if (isAuthorizationRequired(response)) {
setExpectedAnswers(challenges);
}
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonChallenges.optJSONObject(realm);
handler.handleChallenge(this, challenge, context);
} else {
throw new RuntimeException("Challenge handler for realm is not found: " + realm);
}
}
}
|
java
|
private void startHandleChallenges(JSONObject jsonChallenges, Response response) {
ArrayList<String> challenges = getRealmsFromJson(jsonChallenges);
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
if (isAuthorizationRequired(response)) {
setExpectedAnswers(challenges);
}
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonChallenges.optJSONObject(realm);
handler.handleChallenge(this, challenge, context);
} else {
throw new RuntimeException("Challenge handler for realm is not found: " + realm);
}
}
}
|
[
"private",
"void",
"startHandleChallenges",
"(",
"JSONObject",
"jsonChallenges",
",",
"Response",
"response",
")",
"{",
"ArrayList",
"<",
"String",
">",
"challenges",
"=",
"getRealmsFromJson",
"(",
"jsonChallenges",
")",
";",
"MCAAuthorizationManager",
"authManager",
"=",
"(",
"MCAAuthorizationManager",
")",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getAuthorizationManager",
"(",
")",
";",
"if",
"(",
"isAuthorizationRequired",
"(",
"response",
")",
")",
"{",
"setExpectedAnswers",
"(",
"challenges",
")",
";",
"}",
"for",
"(",
"String",
"realm",
":",
"challenges",
")",
"{",
"ChallengeHandler",
"handler",
"=",
"authManager",
".",
"getChallengeHandler",
"(",
"realm",
")",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"JSONObject",
"challenge",
"=",
"jsonChallenges",
".",
"optJSONObject",
"(",
"realm",
")",
";",
"handler",
".",
"handleChallenge",
"(",
"this",
",",
"challenge",
",",
"context",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Challenge handler for realm is not found: \"",
"+",
"realm",
")",
";",
"}",
"}",
"}"
] |
Handles authentication challenges.
@param jsonChallenges Collection of challenges.
@param response Server response.
|
[
"Handles",
"authentication",
"challenges",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L413-L431
|
11,368
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.isAuthorizationRequired
|
private boolean isAuthorizationRequired(Response response) {
if (response != null && response.getStatus() == 401) {
ResponseImpl responseImpl = (ResponseImpl)response;
String challengesHeader = responseImpl.getFirstHeader(AUTHENTICATE_HEADER_NAME);
if (AUTHENTICATE_HEADER_VALUE.equalsIgnoreCase(challengesHeader)) {
return true;
}
}
return false;
}
|
java
|
private boolean isAuthorizationRequired(Response response) {
if (response != null && response.getStatus() == 401) {
ResponseImpl responseImpl = (ResponseImpl)response;
String challengesHeader = responseImpl.getFirstHeader(AUTHENTICATE_HEADER_NAME);
if (AUTHENTICATE_HEADER_VALUE.equalsIgnoreCase(challengesHeader)) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"isAuthorizationRequired",
"(",
"Response",
"response",
")",
"{",
"if",
"(",
"response",
"!=",
"null",
"&&",
"response",
".",
"getStatus",
"(",
")",
"==",
"401",
")",
"{",
"ResponseImpl",
"responseImpl",
"=",
"(",
"ResponseImpl",
")",
"response",
";",
"String",
"challengesHeader",
"=",
"responseImpl",
".",
"getFirstHeader",
"(",
"AUTHENTICATE_HEADER_NAME",
")",
";",
"if",
"(",
"AUTHENTICATE_HEADER_VALUE",
".",
"equalsIgnoreCase",
"(",
"challengesHeader",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks server response for MFP 401 error. This kind of response should contain MFP authentication challenges.
@param response Server response.
@return <code>true</code> if the server response contains 401 status code along with MFP challenges.
|
[
"Checks",
"server",
"response",
"for",
"MFP",
"401",
"error",
".",
"This",
"kind",
"of",
"response",
"should",
"contain",
"MFP",
"authentication",
"challenges",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L439-L450
|
11,369
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.processFailures
|
private void processFailures(JSONObject jsonFailures) {
if (jsonFailures == null) {
return;
}
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
ArrayList<String> challenges = getRealmsFromJson(jsonFailures);
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonFailures.optJSONObject(realm);
handler.handleFailure(context, challenge);
} else {
logger.error("Challenge handler for realm is not found: " + realm);
}
}
}
|
java
|
private void processFailures(JSONObject jsonFailures) {
if (jsonFailures == null) {
return;
}
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
ArrayList<String> challenges = getRealmsFromJson(jsonFailures);
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonFailures.optJSONObject(realm);
handler.handleFailure(context, challenge);
} else {
logger.error("Challenge handler for realm is not found: " + realm);
}
}
}
|
[
"private",
"void",
"processFailures",
"(",
"JSONObject",
"jsonFailures",
")",
"{",
"if",
"(",
"jsonFailures",
"==",
"null",
")",
"{",
"return",
";",
"}",
"MCAAuthorizationManager",
"authManager",
"=",
"(",
"MCAAuthorizationManager",
")",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getAuthorizationManager",
"(",
")",
";",
"ArrayList",
"<",
"String",
">",
"challenges",
"=",
"getRealmsFromJson",
"(",
"jsonFailures",
")",
";",
"for",
"(",
"String",
"realm",
":",
"challenges",
")",
"{",
"ChallengeHandler",
"handler",
"=",
"authManager",
".",
"getChallengeHandler",
"(",
"realm",
")",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"JSONObject",
"challenge",
"=",
"jsonFailures",
".",
"optJSONObject",
"(",
"realm",
")",
";",
"handler",
".",
"handleFailure",
"(",
"context",
",",
"challenge",
")",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"Challenge handler for realm is not found: \"",
"+",
"realm",
")",
";",
"}",
"}",
"}"
] |
Processes authentication failures.
@param jsonFailures Collection of authentication failures.
|
[
"Processes",
"authentication",
"failures",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L457-L473
|
11,370
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.processSuccesses
|
private void processSuccesses(JSONObject jsonSuccesses) {
if (jsonSuccesses == null) {
return;
}
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
ArrayList<String> challenges = getRealmsFromJson(jsonSuccesses);
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonSuccesses.optJSONObject(realm);
handler.handleSuccess(context, challenge);
} else {
logger.error("Challenge handler for realm is not found: " + realm);
}
}
}
|
java
|
private void processSuccesses(JSONObject jsonSuccesses) {
if (jsonSuccesses == null) {
return;
}
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
ArrayList<String> challenges = getRealmsFromJson(jsonSuccesses);
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonSuccesses.optJSONObject(realm);
handler.handleSuccess(context, challenge);
} else {
logger.error("Challenge handler for realm is not found: " + realm);
}
}
}
|
[
"private",
"void",
"processSuccesses",
"(",
"JSONObject",
"jsonSuccesses",
")",
"{",
"if",
"(",
"jsonSuccesses",
"==",
"null",
")",
"{",
"return",
";",
"}",
"MCAAuthorizationManager",
"authManager",
"=",
"(",
"MCAAuthorizationManager",
")",
"BMSClient",
".",
"getInstance",
"(",
")",
".",
"getAuthorizationManager",
"(",
")",
";",
"ArrayList",
"<",
"String",
">",
"challenges",
"=",
"getRealmsFromJson",
"(",
"jsonSuccesses",
")",
";",
"for",
"(",
"String",
"realm",
":",
"challenges",
")",
"{",
"ChallengeHandler",
"handler",
"=",
"authManager",
".",
"getChallengeHandler",
"(",
"realm",
")",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"JSONObject",
"challenge",
"=",
"jsonSuccesses",
".",
"optJSONObject",
"(",
"realm",
")",
";",
"handler",
".",
"handleSuccess",
"(",
"context",
",",
"challenge",
")",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"Challenge handler for realm is not found: \"",
"+",
"realm",
")",
";",
"}",
"}",
"}"
] |
Processes authentication successes.
@param jsonSuccesses Collection of authentication successes.
|
[
"Processes",
"authentication",
"successes",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L480-L496
|
11,371
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.requestFailed
|
public void requestFailed(JSONObject info) {
logger.error("BaseRequest failed with info: " + (info == null ? "info is null" : info.toString()));
listener.onFailure(null, null, info);
}
|
java
|
public void requestFailed(JSONObject info) {
logger.error("BaseRequest failed with info: " + (info == null ? "info is null" : info.toString()));
listener.onFailure(null, null, info);
}
|
[
"public",
"void",
"requestFailed",
"(",
"JSONObject",
"info",
")",
"{",
"logger",
".",
"error",
"(",
"\"BaseRequest failed with info: \"",
"+",
"(",
"info",
"==",
"null",
"?",
"\"info is null\"",
":",
"info",
".",
"toString",
"(",
")",
")",
")",
";",
"listener",
".",
"onFailure",
"(",
"null",
",",
"null",
",",
"info",
")",
";",
"}"
] |
Called when a request to authorization server failed.
@param info Extended information about the failure.
|
[
"Called",
"when",
"a",
"request",
"to",
"authorization",
"server",
"failed",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L503-L506
|
11,372
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.getRealmsFromJson
|
private ArrayList<String> getRealmsFromJson(JSONObject jsonChallenges) {
Iterator<String> challengesIterator = jsonChallenges.keys();
ArrayList<String> challenges = new ArrayList<>();
while (challengesIterator.hasNext()) {
challenges.add(challengesIterator.next());
}
return challenges;
}
|
java
|
private ArrayList<String> getRealmsFromJson(JSONObject jsonChallenges) {
Iterator<String> challengesIterator = jsonChallenges.keys();
ArrayList<String> challenges = new ArrayList<>();
while (challengesIterator.hasNext()) {
challenges.add(challengesIterator.next());
}
return challenges;
}
|
[
"private",
"ArrayList",
"<",
"String",
">",
"getRealmsFromJson",
"(",
"JSONObject",
"jsonChallenges",
")",
"{",
"Iterator",
"<",
"String",
">",
"challengesIterator",
"=",
"jsonChallenges",
".",
"keys",
"(",
")",
";",
"ArrayList",
"<",
"String",
">",
"challenges",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"while",
"(",
"challengesIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"challenges",
".",
"add",
"(",
"challengesIterator",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"challenges",
";",
"}"
] |
Iterates a JSON object containing authorization challenges and builds a list of reals.
@param jsonChallenges Collection of challenges.
@return Array with realms.
|
[
"Iterates",
"a",
"JSON",
"object",
"containing",
"authorization",
"challenges",
"and",
"builds",
"a",
"list",
"of",
"reals",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L514-L523
|
11,373
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.onFailure
|
@Override
public void onFailure(Response response, Throwable t, JSONObject extendedInfo) {
if (isAuthorizationRequired(response)) {
processResponseWrapper(response, true);
} else {
listener.onFailure(response, t, extendedInfo);
}
}
|
java
|
@Override
public void onFailure(Response response, Throwable t, JSONObject extendedInfo) {
if (isAuthorizationRequired(response)) {
processResponseWrapper(response, true);
} else {
listener.onFailure(response, t, extendedInfo);
}
}
|
[
"@",
"Override",
"public",
"void",
"onFailure",
"(",
"Response",
"response",
",",
"Throwable",
"t",
",",
"JSONObject",
"extendedInfo",
")",
"{",
"if",
"(",
"isAuthorizationRequired",
"(",
"response",
")",
")",
"{",
"processResponseWrapper",
"(",
"response",
",",
"true",
")",
";",
"}",
"else",
"{",
"listener",
".",
"onFailure",
"(",
"response",
",",
"t",
",",
"extendedInfo",
")",
";",
"}",
"}"
] |
Called when request fails.
@param response Contains detail regarding why the request failed
@param t Exception that could have caused the request to fail. Null if no Exception thrown.
|
[
"Called",
"when",
"request",
"fails",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L541-L548
|
11,374
|
ibm-bluemix-mobile-services/bms-clientsdk-android-core
|
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java
|
AuthorizationRequestManager.processResponseWrapper
|
private void processResponseWrapper(Response response, boolean isFailure) {
try {
ResponseImpl responseImpl = (ResponseImpl)response;
if (isFailure || !responseImpl.isRedirect()) {
processResponse(response);
} else {
processRedirectResponse(response);
}
} catch (Throwable t) {
logger.error("processResponseWrapper caught exception: " + t.getLocalizedMessage());
listener.onFailure(response, t, null);
}
}
|
java
|
private void processResponseWrapper(Response response, boolean isFailure) {
try {
ResponseImpl responseImpl = (ResponseImpl)response;
if (isFailure || !responseImpl.isRedirect()) {
processResponse(response);
} else {
processRedirectResponse(response);
}
} catch (Throwable t) {
logger.error("processResponseWrapper caught exception: " + t.getLocalizedMessage());
listener.onFailure(response, t, null);
}
}
|
[
"private",
"void",
"processResponseWrapper",
"(",
"Response",
"response",
",",
"boolean",
"isFailure",
")",
"{",
"try",
"{",
"ResponseImpl",
"responseImpl",
"=",
"(",
"ResponseImpl",
")",
"response",
";",
"if",
"(",
"isFailure",
"||",
"!",
"responseImpl",
".",
"isRedirect",
"(",
")",
")",
"{",
"processResponse",
"(",
"response",
")",
";",
"}",
"else",
"{",
"processRedirectResponse",
"(",
"response",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"logger",
".",
"error",
"(",
"\"processResponseWrapper caught exception: \"",
"+",
"t",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"listener",
".",
"onFailure",
"(",
"response",
",",
"t",
",",
"null",
")",
";",
"}",
"}"
] |
Called from onSuccess and onFailure. Handles all possible exceptions and notifies the listener
if an exception occurs.
@param response server response
@param isFailure specifies whether this method is called from onSuccess (false) or onFailure (true).
|
[
"Called",
"from",
"onSuccess",
"and",
"onFailure",
".",
"Handles",
"all",
"possible",
"exceptions",
"and",
"notifies",
"the",
"listener",
"if",
"an",
"exception",
"occurs",
"."
] |
8db4f00d0d564792397bfc0e5bd57d52a238b858
|
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/internal/AuthorizationRequestManager.java#L557-L569
|
11,375
|
taimos/RESTUtils
|
src/main/java/de/taimos/restutils/RESTAssert.java
|
RESTAssert.assertNotNull
|
public static void assertNotNull(final Object object, final StatusType status) {
RESTAssert.assertTrue(object != null, status);
}
|
java
|
public static void assertNotNull(final Object object, final StatusType status) {
RESTAssert.assertTrue(object != null, status);
}
|
[
"public",
"static",
"void",
"assertNotNull",
"(",
"final",
"Object",
"object",
",",
"final",
"StatusType",
"status",
")",
"{",
"RESTAssert",
".",
"assertTrue",
"(",
"object",
"!=",
"null",
",",
"status",
")",
";",
"}"
] |
assert that object is not null
@param object the object to check
@param status the status code to throw
@throws WebApplicationException with given status code
|
[
"assert",
"that",
"object",
"is",
"not",
"null"
] |
bdb1bf9a2eb13ede0eec6f071c10cb2698313501
|
https://github.com/taimos/RESTUtils/blob/bdb1bf9a2eb13ede0eec6f071c10cb2698313501/src/main/java/de/taimos/restutils/RESTAssert.java#L160-L162
|
11,376
|
taimos/RESTUtils
|
src/main/java/de/taimos/restutils/RESTAssert.java
|
RESTAssert.assertNotEmpty
|
public static void assertNotEmpty(final String string, final StatusType status) {
RESTAssert.assertNotNull(string, status);
RESTAssert.assertFalse(string.isEmpty(), status);
}
|
java
|
public static void assertNotEmpty(final String string, final StatusType status) {
RESTAssert.assertNotNull(string, status);
RESTAssert.assertFalse(string.isEmpty(), status);
}
|
[
"public",
"static",
"void",
"assertNotEmpty",
"(",
"final",
"String",
"string",
",",
"final",
"StatusType",
"status",
")",
"{",
"RESTAssert",
".",
"assertNotNull",
"(",
"string",
",",
"status",
")",
";",
"RESTAssert",
".",
"assertFalse",
"(",
"string",
".",
"isEmpty",
"(",
")",
",",
"status",
")",
";",
"}"
] |
assert that string is not null nor empty
@param string the string to check
@param status the status code to throw
@throws WebApplicationException with given status code
|
[
"assert",
"that",
"string",
"is",
"not",
"null",
"nor",
"empty"
] |
bdb1bf9a2eb13ede0eec6f071c10cb2698313501
|
https://github.com/taimos/RESTUtils/blob/bdb1bf9a2eb13ede0eec6f071c10cb2698313501/src/main/java/de/taimos/restutils/RESTAssert.java#L181-L184
|
11,377
|
taimos/RESTUtils
|
src/main/java/de/taimos/restutils/RESTAssert.java
|
RESTAssert.assertNotEmpty
|
public static void assertNotEmpty(final Collection<?> collection, final StatusType status) {
RESTAssert.assertNotNull(collection, status);
RESTAssert.assertFalse(collection.isEmpty(), status);
}
|
java
|
public static void assertNotEmpty(final Collection<?> collection, final StatusType status) {
RESTAssert.assertNotNull(collection, status);
RESTAssert.assertFalse(collection.isEmpty(), status);
}
|
[
"public",
"static",
"void",
"assertNotEmpty",
"(",
"final",
"Collection",
"<",
"?",
">",
"collection",
",",
"final",
"StatusType",
"status",
")",
"{",
"RESTAssert",
".",
"assertNotNull",
"(",
"collection",
",",
"status",
")",
";",
"RESTAssert",
".",
"assertFalse",
"(",
"collection",
".",
"isEmpty",
"(",
")",
",",
"status",
")",
";",
"}"
] |
assert that collection is not empty
@param collection the collection to check
@param status the status code to throw
@throws WebApplicationException with given status code
|
[
"assert",
"that",
"collection",
"is",
"not",
"empty"
] |
bdb1bf9a2eb13ede0eec6f071c10cb2698313501
|
https://github.com/taimos/RESTUtils/blob/bdb1bf9a2eb13ede0eec6f071c10cb2698313501/src/main/java/de/taimos/restutils/RESTAssert.java#L203-L206
|
11,378
|
taimos/RESTUtils
|
src/main/java/de/taimos/restutils/RESTAssert.java
|
RESTAssert.assertSingleElement
|
public static void assertSingleElement(final Collection<?> collection, final StatusType status) {
RESTAssert.assertNotNull(collection, status);
RESTAssert.assertTrue(collection.size() == 1, status);
}
|
java
|
public static void assertSingleElement(final Collection<?> collection, final StatusType status) {
RESTAssert.assertNotNull(collection, status);
RESTAssert.assertTrue(collection.size() == 1, status);
}
|
[
"public",
"static",
"void",
"assertSingleElement",
"(",
"final",
"Collection",
"<",
"?",
">",
"collection",
",",
"final",
"StatusType",
"status",
")",
"{",
"RESTAssert",
".",
"assertNotNull",
"(",
"collection",
",",
"status",
")",
";",
"RESTAssert",
".",
"assertTrue",
"(",
"collection",
".",
"size",
"(",
")",
"==",
"1",
",",
"status",
")",
";",
"}"
] |
assert that collection has one element
@param collection the collection to check
@param status the status code to throw
@throws WebApplicationException with given status code
|
[
"assert",
"that",
"collection",
"has",
"one",
"element"
] |
bdb1bf9a2eb13ede0eec6f071c10cb2698313501
|
https://github.com/taimos/RESTUtils/blob/bdb1bf9a2eb13ede0eec6f071c10cb2698313501/src/main/java/de/taimos/restutils/RESTAssert.java#L225-L228
|
11,379
|
j-a-w-r/jawr
|
jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java
|
ClassLoaderResourceUtils.getClass
|
public static Class<?> getClass(String classname) {
Class<?> clazz = null;
try {
clazz = Class.forName(classname);
} catch (Exception e) {
// Try the second approach
}
if (null == clazz) {
Exception classNotFoundEx = null;
try {
clazz = Class.forName(classname, true, new ClassLoaderResourceUtils().getClass().getClassLoader());
} catch (Exception e) {
// Try the third approach
classNotFoundEx = e;
}
if (null == clazz) {
ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
if (null != threadClassLoader) {
try {
clazz = Class.forName(classname, true, threadClassLoader);
} catch (Exception e) {
throw new BundlingProcessException(e.getMessage() + " [The custom class " + classname
+ " could not be instantiated, check wether it is available on the classpath and"
+ " verify that it has a zero-arg constructor].\n" + " The specific error message is: "
+ e.getClass().getName() + ":" + e.getMessage(), e);
}
} else {
throw new BundlingProcessException(classNotFoundEx.getMessage() + " [The custom class " + classname
+ " could not be instantiated, check wether it is available on the classpath and"
+ " verify that it has a zero-arg constructor].\n" + " The specific error message is: "
+ classNotFoundEx.getClass().getName() + ":" + classNotFoundEx.getMessage(),
classNotFoundEx);
}
}
}
return clazz;
}
|
java
|
public static Class<?> getClass(String classname) {
Class<?> clazz = null;
try {
clazz = Class.forName(classname);
} catch (Exception e) {
// Try the second approach
}
if (null == clazz) {
Exception classNotFoundEx = null;
try {
clazz = Class.forName(classname, true, new ClassLoaderResourceUtils().getClass().getClassLoader());
} catch (Exception e) {
// Try the third approach
classNotFoundEx = e;
}
if (null == clazz) {
ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
if (null != threadClassLoader) {
try {
clazz = Class.forName(classname, true, threadClassLoader);
} catch (Exception e) {
throw new BundlingProcessException(e.getMessage() + " [The custom class " + classname
+ " could not be instantiated, check wether it is available on the classpath and"
+ " verify that it has a zero-arg constructor].\n" + " The specific error message is: "
+ e.getClass().getName() + ":" + e.getMessage(), e);
}
} else {
throw new BundlingProcessException(classNotFoundEx.getMessage() + " [The custom class " + classname
+ " could not be instantiated, check wether it is available on the classpath and"
+ " verify that it has a zero-arg constructor].\n" + " The specific error message is: "
+ classNotFoundEx.getClass().getName() + ":" + classNotFoundEx.getMessage(),
classNotFoundEx);
}
}
}
return clazz;
}
|
[
"public",
"static",
"Class",
"<",
"?",
">",
"getClass",
"(",
"String",
"classname",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"null",
";",
"try",
"{",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"classname",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Try the second approach",
"}",
"if",
"(",
"null",
"==",
"clazz",
")",
"{",
"Exception",
"classNotFoundEx",
"=",
"null",
";",
"try",
"{",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"classname",
",",
"true",
",",
"new",
"ClassLoaderResourceUtils",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Try the third approach",
"classNotFoundEx",
"=",
"e",
";",
"}",
"if",
"(",
"null",
"==",
"clazz",
")",
"{",
"ClassLoader",
"threadClassLoader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"threadClassLoader",
")",
"{",
"try",
"{",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"classname",
",",
"true",
",",
"threadClassLoader",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"e",
".",
"getMessage",
"(",
")",
"+",
"\" [The custom class \"",
"+",
"classname",
"+",
"\" could not be instantiated, check wether it is available on the classpath and\"",
"+",
"\" verify that it has a zero-arg constructor].\\n\"",
"+",
"\" The specific error message is: \"",
"+",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\":\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"classNotFoundEx",
".",
"getMessage",
"(",
")",
"+",
"\" [The custom class \"",
"+",
"classname",
"+",
"\" could not be instantiated, check wether it is available on the classpath and\"",
"+",
"\" verify that it has a zero-arg constructor].\\n\"",
"+",
"\" The specific error message is: \"",
"+",
"classNotFoundEx",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\":\"",
"+",
"classNotFoundEx",
".",
"getMessage",
"(",
")",
",",
"classNotFoundEx",
")",
";",
"}",
"}",
"}",
"return",
"clazz",
";",
"}"
] |
Returns the class associated to the class name given in parameter
@param classname
the class name
@return the class
|
[
"Returns",
"the",
"class",
"associated",
"to",
"the",
"class",
"name",
"given",
"in",
"parameter"
] |
1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d
|
https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/ClassLoaderResourceUtils.java#L272-L310
|
11,380
|
telly/groundy
|
library/src/main/java/com/telly/groundy/TaskResult.java
|
TaskResult.add
|
public TaskResult add(String key, SparseArray<? extends Parcelable> value) {
mBundle.putSparseParcelableArray(key, value);
return this;
}
|
java
|
public TaskResult add(String key, SparseArray<? extends Parcelable> value) {
mBundle.putSparseParcelableArray(key, value);
return this;
}
|
[
"public",
"TaskResult",
"add",
"(",
"String",
"key",
",",
"SparseArray",
"<",
"?",
"extends",
"Parcelable",
">",
"value",
")",
"{",
"mBundle",
".",
"putSparseParcelableArray",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Inserts a SparseArray of Parcelable values into the mapping of this Bundle, replacing any
existing value for the given key. Either key or value may be null.
@param key a String, or null
@param value a SparseArray of Parcelable objects, or null
|
[
"Inserts",
"a",
"SparseArray",
"of",
"Parcelable",
"values",
"into",
"the",
"mapping",
"of",
"this",
"Bundle",
"replacing",
"any",
"existing",
"value",
"for",
"the",
"given",
"key",
".",
"Either",
"key",
"or",
"value",
"may",
"be",
"null",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/TaskResult.java#L215-L218
|
11,381
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/statistics/derived/latency/DefaultLatencyHistogramStatistic.java
|
DefaultLatencyHistogramStatistic.tryExpire
|
private void tryExpire(boolean force, LongSupplier time) {
long now = time.getAsLong();
if (force || now >= nextPruning) {
nextPruning = now + pruningDelay;
histogram.expire(now);
}
}
|
java
|
private void tryExpire(boolean force, LongSupplier time) {
long now = time.getAsLong();
if (force || now >= nextPruning) {
nextPruning = now + pruningDelay;
histogram.expire(now);
}
}
|
[
"private",
"void",
"tryExpire",
"(",
"boolean",
"force",
",",
"LongSupplier",
"time",
")",
"{",
"long",
"now",
"=",
"time",
".",
"getAsLong",
"(",
")",
";",
"if",
"(",
"force",
"||",
"now",
">=",
"nextPruning",
")",
"{",
"nextPruning",
"=",
"now",
"+",
"pruningDelay",
";",
"histogram",
".",
"expire",
"(",
"now",
")",
";",
"}",
"}"
] |
Expire the histogram if it is time to expire it, or if force is true AND it is dirty
|
[
"Expire",
"the",
"histogram",
"if",
"it",
"is",
"time",
"to",
"expire",
"it",
"or",
"if",
"force",
"is",
"true",
"AND",
"it",
"is",
"dirty"
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/statistics/derived/latency/DefaultLatencyHistogramStatistic.java#L169-L175
|
11,382
|
telly/groundy
|
library/src/main/java/com/telly/groundy/DeviceStatus.java
|
DeviceStatus.isOnline
|
public static boolean isOnline(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) {
return false;
}
NetworkInfo info = cm.getActiveNetworkInfo();
return info != null && info.isConnectedOrConnecting();
}
|
java
|
public static boolean isOnline(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) {
return false;
}
NetworkInfo info = cm.getActiveNetworkInfo();
return info != null && info.isConnectedOrConnecting();
}
|
[
"public",
"static",
"boolean",
"isOnline",
"(",
"Context",
"context",
")",
"{",
"ConnectivityManager",
"cm",
"=",
"(",
"ConnectivityManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"CONNECTIVITY_SERVICE",
")",
";",
"if",
"(",
"cm",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"NetworkInfo",
"info",
"=",
"cm",
".",
"getActiveNetworkInfo",
"(",
")",
";",
"return",
"info",
"!=",
"null",
"&&",
"info",
".",
"isConnectedOrConnecting",
"(",
")",
";",
"}"
] |
Checks whether there's a network connection.
@param context Context to use
@return true if there's an active network connection, false otherwise
|
[
"Checks",
"whether",
"there",
"s",
"a",
"network",
"connection",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/DeviceStatus.java#L47-L55
|
11,383
|
telly/groundy
|
library/src/main/java/com/telly/groundy/DeviceStatus.java
|
DeviceStatus.isCurrentConnectionWifi
|
public static boolean isCurrentConnectionWifi(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) {
return false;
}
NetworkInfo info = cm.getActiveNetworkInfo();
return info != null && info.getType() == ConnectivityManager.TYPE_WIFI;
}
|
java
|
public static boolean isCurrentConnectionWifi(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) {
return false;
}
NetworkInfo info = cm.getActiveNetworkInfo();
return info != null && info.getType() == ConnectivityManager.TYPE_WIFI;
}
|
[
"public",
"static",
"boolean",
"isCurrentConnectionWifi",
"(",
"Context",
"context",
")",
"{",
"ConnectivityManager",
"cm",
"=",
"(",
"ConnectivityManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"CONNECTIVITY_SERVICE",
")",
";",
"if",
"(",
"cm",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"NetworkInfo",
"info",
"=",
"cm",
".",
"getActiveNetworkInfo",
"(",
")",
";",
"return",
"info",
"!=",
"null",
"&&",
"info",
".",
"getType",
"(",
")",
"==",
"ConnectivityManager",
".",
"TYPE_WIFI",
";",
"}"
] |
Check if current connection is Wi-Fi.
@param context Context to use
@return true if current connection is Wi-Fi false otherwise
|
[
"Check",
"if",
"current",
"connection",
"is",
"Wi",
"-",
"Fi",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/DeviceStatus.java#L63-L71
|
11,384
|
telly/groundy
|
library/src/main/java/com/telly/groundy/DeviceStatus.java
|
DeviceStatus.keepCpuAwake
|
public static void keepCpuAwake(Context context, boolean awake) {
if (cpuWakeLock == null) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm != null) {
cpuWakeLock =
pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG);
cpuWakeLock.setReferenceCounted(true);
}
}
if (cpuWakeLock != null) { //May be null if pm is null
if (awake) {
cpuWakeLock.acquire();
L.d(TAG, "Adquired CPU lock");
} else if (cpuWakeLock.isHeld()) {
cpuWakeLock.release();
L.d(TAG, "Released CPU lock");
}
}
}
|
java
|
public static void keepCpuAwake(Context context, boolean awake) {
if (cpuWakeLock == null) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm != null) {
cpuWakeLock =
pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG);
cpuWakeLock.setReferenceCounted(true);
}
}
if (cpuWakeLock != null) { //May be null if pm is null
if (awake) {
cpuWakeLock.acquire();
L.d(TAG, "Adquired CPU lock");
} else if (cpuWakeLock.isHeld()) {
cpuWakeLock.release();
L.d(TAG, "Released CPU lock");
}
}
}
|
[
"public",
"static",
"void",
"keepCpuAwake",
"(",
"Context",
"context",
",",
"boolean",
"awake",
")",
"{",
"if",
"(",
"cpuWakeLock",
"==",
"null",
")",
"{",
"PowerManager",
"pm",
"=",
"(",
"PowerManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"POWER_SERVICE",
")",
";",
"if",
"(",
"pm",
"!=",
"null",
")",
"{",
"cpuWakeLock",
"=",
"pm",
".",
"newWakeLock",
"(",
"PowerManager",
".",
"PARTIAL_WAKE_LOCK",
"|",
"PowerManager",
".",
"ON_AFTER_RELEASE",
",",
"TAG",
")",
";",
"cpuWakeLock",
".",
"setReferenceCounted",
"(",
"true",
")",
";",
"}",
"}",
"if",
"(",
"cpuWakeLock",
"!=",
"null",
")",
"{",
"//May be null if pm is null",
"if",
"(",
"awake",
")",
"{",
"cpuWakeLock",
".",
"acquire",
"(",
")",
";",
"L",
".",
"d",
"(",
"TAG",
",",
"\"Adquired CPU lock\"",
")",
";",
"}",
"else",
"if",
"(",
"cpuWakeLock",
".",
"isHeld",
"(",
")",
")",
"{",
"cpuWakeLock",
".",
"release",
"(",
")",
";",
"L",
".",
"d",
"(",
"TAG",
",",
"\"Released CPU lock\"",
")",
";",
"}",
"}",
"}"
] |
Register a wake lock to power management in the device.
@param context Context to use
@param awake if true the device cpu will keep awake until false is called back. if true is
passed several times only the first time after a false call will take effect,
also if false is passed and previously the cpu was not turned on (true call)
does nothing.
|
[
"Register",
"a",
"wake",
"lock",
"to",
"power",
"management",
"in",
"the",
"device",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/DeviceStatus.java#L85-L103
|
11,385
|
telly/groundy
|
library/src/main/java/com/telly/groundy/DeviceStatus.java
|
DeviceStatus.keepWiFiOn
|
public static void keepWiFiOn(Context context, boolean on) {
if (wifiLock == null) {
WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wm != null) {
wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
wifiLock.setReferenceCounted(true);
}
}
if (wifiLock != null) { // May be null if wm is null
if (on) {
wifiLock.acquire();
L.d(TAG, "Adquired WiFi lock");
} else if (wifiLock.isHeld()) {
wifiLock.release();
L.d(TAG, "Released WiFi lock");
}
}
}
|
java
|
public static void keepWiFiOn(Context context, boolean on) {
if (wifiLock == null) {
WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wm != null) {
wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
wifiLock.setReferenceCounted(true);
}
}
if (wifiLock != null) { // May be null if wm is null
if (on) {
wifiLock.acquire();
L.d(TAG, "Adquired WiFi lock");
} else if (wifiLock.isHeld()) {
wifiLock.release();
L.d(TAG, "Released WiFi lock");
}
}
}
|
[
"public",
"static",
"void",
"keepWiFiOn",
"(",
"Context",
"context",
",",
"boolean",
"on",
")",
"{",
"if",
"(",
"wifiLock",
"==",
"null",
")",
"{",
"WifiManager",
"wm",
"=",
"(",
"WifiManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"WIFI_SERVICE",
")",
";",
"if",
"(",
"wm",
"!=",
"null",
")",
"{",
"wifiLock",
"=",
"wm",
".",
"createWifiLock",
"(",
"WifiManager",
".",
"WIFI_MODE_FULL",
",",
"TAG",
")",
";",
"wifiLock",
".",
"setReferenceCounted",
"(",
"true",
")",
";",
"}",
"}",
"if",
"(",
"wifiLock",
"!=",
"null",
")",
"{",
"// May be null if wm is null",
"if",
"(",
"on",
")",
"{",
"wifiLock",
".",
"acquire",
"(",
")",
";",
"L",
".",
"d",
"(",
"TAG",
",",
"\"Adquired WiFi lock\"",
")",
";",
"}",
"else",
"if",
"(",
"wifiLock",
".",
"isHeld",
"(",
")",
")",
"{",
"wifiLock",
".",
"release",
"(",
")",
";",
"L",
".",
"d",
"(",
"TAG",
",",
"\"Released WiFi lock\"",
")",
";",
"}",
"}",
"}"
] |
Register a WiFi lock to WiFi management in the device.
@param context Context to use
@param on if true the device WiFi radio will keep awake until false is called back. if
true is passed several times only the first time after a false call will take
effect, also if false is passed and previously the WiFi radio was not turned on
(true call) does nothing.
|
[
"Register",
"a",
"WiFi",
"lock",
"to",
"WiFi",
"management",
"in",
"the",
"device",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/DeviceStatus.java#L117-L134
|
11,386
|
eirbjo/jetty-console
|
jetty-console-core/src/main/java/org/simplericity/jettyconsole/JettyConsoleBootstrapMainClass.java
|
JettyConsoleBootstrapMainClass.createClassLoader
|
private ClassLoader createClassLoader(File warFile, File tempDirectory) {
try {
File condiLibDirectory = new File(tempDirectory, "condi");
condiLibDirectory.mkdirs();
File jettyWebappDirectory = new File(tempDirectory, "webapp");
jettyWebappDirectory.mkdirs();
List<URL> urls = new ArrayList<>();
JarInputStream in = new JarInputStream(new FileInputStream(warFile));
while(true) {
JarEntry entry = in.getNextJarEntry();
if(entry == null) {
break;
}
String name = entry.getName();
String prefix = "META-INF/jettyconsole/lib/";
if(!entry.isDirectory()) {
if( name.startsWith(prefix) ) {
String simpleName = name.substring(name.lastIndexOf("/")+1);
File file = new File(condiLibDirectory, simpleName);
unpackFile(in, file);
urls.add(file.toURI().toURL());
} else if(!name.startsWith("META-INF/jettyconsole")
&& !name.contains("JettyConsoleBootstrapMainClass")) {
File file = new File(jettyWebappDirectory, name);
file.getParentFile().mkdirs();
unpackFile(in, file);
}
}
}
in.close();
return new URLClassLoader(urls.toArray(new URL[urls.size()]), JettyConsoleBootstrapMainClass.class.getClassLoader());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
private ClassLoader createClassLoader(File warFile, File tempDirectory) {
try {
File condiLibDirectory = new File(tempDirectory, "condi");
condiLibDirectory.mkdirs();
File jettyWebappDirectory = new File(tempDirectory, "webapp");
jettyWebappDirectory.mkdirs();
List<URL> urls = new ArrayList<>();
JarInputStream in = new JarInputStream(new FileInputStream(warFile));
while(true) {
JarEntry entry = in.getNextJarEntry();
if(entry == null) {
break;
}
String name = entry.getName();
String prefix = "META-INF/jettyconsole/lib/";
if(!entry.isDirectory()) {
if( name.startsWith(prefix) ) {
String simpleName = name.substring(name.lastIndexOf("/")+1);
File file = new File(condiLibDirectory, simpleName);
unpackFile(in, file);
urls.add(file.toURI().toURL());
} else if(!name.startsWith("META-INF/jettyconsole")
&& !name.contains("JettyConsoleBootstrapMainClass")) {
File file = new File(jettyWebappDirectory, name);
file.getParentFile().mkdirs();
unpackFile(in, file);
}
}
}
in.close();
return new URLClassLoader(urls.toArray(new URL[urls.size()]), JettyConsoleBootstrapMainClass.class.getClassLoader());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"ClassLoader",
"createClassLoader",
"(",
"File",
"warFile",
",",
"File",
"tempDirectory",
")",
"{",
"try",
"{",
"File",
"condiLibDirectory",
"=",
"new",
"File",
"(",
"tempDirectory",
",",
"\"condi\"",
")",
";",
"condiLibDirectory",
".",
"mkdirs",
"(",
")",
";",
"File",
"jettyWebappDirectory",
"=",
"new",
"File",
"(",
"tempDirectory",
",",
"\"webapp\"",
")",
";",
"jettyWebappDirectory",
".",
"mkdirs",
"(",
")",
";",
"List",
"<",
"URL",
">",
"urls",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"JarInputStream",
"in",
"=",
"new",
"JarInputStream",
"(",
"new",
"FileInputStream",
"(",
"warFile",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"JarEntry",
"entry",
"=",
"in",
".",
"getNextJarEntry",
"(",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"break",
";",
"}",
"String",
"name",
"=",
"entry",
".",
"getName",
"(",
")",
";",
"String",
"prefix",
"=",
"\"META-INF/jettyconsole/lib/\"",
";",
"if",
"(",
"!",
"entry",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"name",
".",
"startsWith",
"(",
"prefix",
")",
")",
"{",
"String",
"simpleName",
"=",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"condiLibDirectory",
",",
"simpleName",
")",
";",
"unpackFile",
"(",
"in",
",",
"file",
")",
";",
"urls",
".",
"add",
"(",
"file",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"name",
".",
"startsWith",
"(",
"\"META-INF/jettyconsole\"",
")",
"&&",
"!",
"name",
".",
"contains",
"(",
"\"JettyConsoleBootstrapMainClass\"",
")",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"jettyWebappDirectory",
",",
"name",
")",
";",
"file",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"unpackFile",
"(",
"in",
",",
"file",
")",
";",
"}",
"}",
"}",
"in",
".",
"close",
"(",
")",
";",
"return",
"new",
"URLClassLoader",
"(",
"urls",
".",
"toArray",
"(",
"new",
"URL",
"[",
"urls",
".",
"size",
"(",
")",
"]",
")",
",",
"JettyConsoleBootstrapMainClass",
".",
"class",
".",
"getClassLoader",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Create a URL class loader containing all jar files in the given directory
@param warFile the war file to look for libs dirs in
@return
|
[
"Create",
"a",
"URL",
"class",
"loader",
"containing",
"all",
"jar",
"files",
"in",
"the",
"given",
"directory"
] |
5bd32ecab12837394dd45fd15c51c3934afcd76b
|
https://github.com/eirbjo/jetty-console/blob/5bd32ecab12837394dd45fd15c51c3934afcd76b/jetty-console-core/src/main/java/org/simplericity/jettyconsole/JettyConsoleBootstrapMainClass.java#L247-L287
|
11,387
|
eirbjo/jetty-console
|
jetty-console-core/src/main/java/org/simplericity/jettyconsole/JettyConsoleBootstrapMainClass.java
|
JettyConsoleBootstrapMainClass.getWarLocation
|
private static File getWarLocation() {
URL resource = JettyConsoleBootstrapMainClass.class.getResource("/META-INF/jettyconsole/jettyconsole.properties");
String file = resource.getFile();
file = file.substring("file:".length(), file.indexOf("!"));
try {
file = URLDecoder.decode(file, "utf-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return new File(file);
}
|
java
|
private static File getWarLocation() {
URL resource = JettyConsoleBootstrapMainClass.class.getResource("/META-INF/jettyconsole/jettyconsole.properties");
String file = resource.getFile();
file = file.substring("file:".length(), file.indexOf("!"));
try {
file = URLDecoder.decode(file, "utf-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return new File(file);
}
|
[
"private",
"static",
"File",
"getWarLocation",
"(",
")",
"{",
"URL",
"resource",
"=",
"JettyConsoleBootstrapMainClass",
".",
"class",
".",
"getResource",
"(",
"\"/META-INF/jettyconsole/jettyconsole.properties\"",
")",
";",
"String",
"file",
"=",
"resource",
".",
"getFile",
"(",
")",
";",
"file",
"=",
"file",
".",
"substring",
"(",
"\"file:\"",
".",
"length",
"(",
")",
",",
"file",
".",
"indexOf",
"(",
"\"!\"",
")",
")",
";",
"try",
"{",
"file",
"=",
"URLDecoder",
".",
"decode",
"(",
"file",
",",
"\"utf-8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"new",
"File",
"(",
"file",
")",
";",
"}"
] |
Return a File pointing to the location of the Jar file this Main method is executed from.
|
[
"Return",
"a",
"File",
"pointing",
"to",
"the",
"location",
"of",
"the",
"Jar",
"file",
"this",
"Main",
"method",
"is",
"executed",
"from",
"."
] |
5bd32ecab12837394dd45fd15c51c3934afcd76b
|
https://github.com/eirbjo/jetty-console/blob/5bd32ecab12837394dd45fd15c51c3934afcd76b/jetty-console-core/src/main/java/org/simplericity/jettyconsole/JettyConsoleBootstrapMainClass.java#L303-L313
|
11,388
|
eirbjo/jetty-console
|
jetty-console-core/src/main/java/org/simplericity/jettyconsole/JettyConsoleBootstrapMainClass.java
|
JettyConsoleBootstrapMainClass.unpackFile
|
private static void unpackFile(InputStream in, File file) {
byte[] buffer = new byte[4096];
try {
OutputStream out = new FileOutputStream(file);
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
out.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
private static void unpackFile(InputStream in, File file) {
byte[] buffer = new byte[4096];
try {
OutputStream out = new FileOutputStream(file);
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
out.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"static",
"void",
"unpackFile",
"(",
"InputStream",
"in",
",",
"File",
"file",
")",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"4096",
"]",
";",
"try",
"{",
"OutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"int",
"read",
";",
"while",
"(",
"(",
"read",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"read",
")",
";",
"}",
"out",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Write the contents of an InputStream to a file
@param in the input stream to read
@param file the File to write to
|
[
"Write",
"the",
"contents",
"of",
"an",
"InputStream",
"to",
"a",
"file"
] |
5bd32ecab12837394dd45fd15c51c3934afcd76b
|
https://github.com/eirbjo/jetty-console/blob/5bd32ecab12837394dd45fd15c51c3934afcd76b/jetty-console-core/src/main/java/org/simplericity/jettyconsole/JettyConsoleBootstrapMainClass.java#L319-L332
|
11,389
|
connect-group/thymesheet
|
src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java
|
DOMHelper.getFirstChildElement
|
public static Element getFirstChildElement(Node node) {
if(node instanceof NestableNode) {
return ((NestableNode) node).getFirstElementChild();
}
return null;
}
|
java
|
public static Element getFirstChildElement(Node node) {
if(node instanceof NestableNode) {
return ((NestableNode) node).getFirstElementChild();
}
return null;
}
|
[
"public",
"static",
"Element",
"getFirstChildElement",
"(",
"Node",
"node",
")",
"{",
"if",
"(",
"node",
"instanceof",
"NestableNode",
")",
"{",
"return",
"(",
"(",
"NestableNode",
")",
"node",
")",
".",
"getFirstElementChild",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the first child node that is an element node.
@param node The node whose children should be iterated.
@return The first child element or {@code null}.
|
[
"Get",
"the",
"first",
"child",
"node",
"that",
"is",
"an",
"element",
"node",
"."
] |
b6384e385d3e3b54944d53993bbd396d2668a5a0
|
https://github.com/connect-group/thymesheet/blob/b6384e385d3e3b54944d53993bbd396d2668a5a0/src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java#L42-L49
|
11,390
|
connect-group/thymesheet
|
src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java
|
DOMHelper.getNextSiblingElement
|
public static final Element getNextSiblingElement(Node node) {
List<Node> siblings = node.getParent().getChildren();
Node n = null;
int index = siblings.indexOf(node) + 1;
if(index>0 && index<siblings.size()) {
n = siblings.get(index);
while(!(n instanceof Element) && ++index < siblings.size()) {
n = siblings.get(index);
}
if(index==siblings.size()) {
n = null;
}
}
return (Element) n;
}
|
java
|
public static final Element getNextSiblingElement(Node node) {
List<Node> siblings = node.getParent().getChildren();
Node n = null;
int index = siblings.indexOf(node) + 1;
if(index>0 && index<siblings.size()) {
n = siblings.get(index);
while(!(n instanceof Element) && ++index < siblings.size()) {
n = siblings.get(index);
}
if(index==siblings.size()) {
n = null;
}
}
return (Element) n;
}
|
[
"public",
"static",
"final",
"Element",
"getNextSiblingElement",
"(",
"Node",
"node",
")",
"{",
"List",
"<",
"Node",
">",
"siblings",
"=",
"node",
".",
"getParent",
"(",
")",
".",
"getChildren",
"(",
")",
";",
"Node",
"n",
"=",
"null",
";",
"int",
"index",
"=",
"siblings",
".",
"indexOf",
"(",
"node",
")",
"+",
"1",
";",
"if",
"(",
"index",
">",
"0",
"&&",
"index",
"<",
"siblings",
".",
"size",
"(",
")",
")",
"{",
"n",
"=",
"siblings",
".",
"get",
"(",
"index",
")",
";",
"while",
"(",
"!",
"(",
"n",
"instanceof",
"Element",
")",
"&&",
"++",
"index",
"<",
"siblings",
".",
"size",
"(",
")",
")",
"{",
"n",
"=",
"siblings",
".",
"get",
"(",
"index",
")",
";",
"}",
"if",
"(",
"index",
"==",
"siblings",
".",
"size",
"(",
")",
")",
"{",
"n",
"=",
"null",
";",
"}",
"}",
"return",
"(",
"Element",
")",
"n",
";",
"}"
] |
Get the next sibling element.
@param node The start node.
@return The next sibling element or {@code null}.
|
[
"Get",
"the",
"next",
"sibling",
"element",
"."
] |
b6384e385d3e3b54944d53993bbd396d2668a5a0
|
https://github.com/connect-group/thymesheet/blob/b6384e385d3e3b54944d53993bbd396d2668a5a0/src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java#L57-L75
|
11,391
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/statistics/registry/StatisticRegistry.java
|
StatisticRegistry.registerTable
|
public void registerTable(String fullStatName, Supplier<Table> accessor) {
registerStatistic(fullStatName, table(accessor));
}
|
java
|
public void registerTable(String fullStatName, Supplier<Table> accessor) {
registerStatistic(fullStatName, table(accessor));
}
|
[
"public",
"void",
"registerTable",
"(",
"String",
"fullStatName",
",",
"Supplier",
"<",
"Table",
">",
"accessor",
")",
"{",
"registerStatistic",
"(",
"fullStatName",
",",
"table",
"(",
"accessor",
")",
")",
";",
"}"
] |
Directly register a TABLE stat with its accessors
|
[
"Directly",
"register",
"a",
"TABLE",
"stat",
"with",
"its",
"accessors"
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/statistics/registry/StatisticRegistry.java#L121-L123
|
11,392
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/statistics/registry/StatisticRegistry.java
|
StatisticRegistry.registerGauge
|
public void registerGauge(String fullStatName, Supplier<Number> accessor) {
registerStatistic(fullStatName, gauge(accessor));
}
|
java
|
public void registerGauge(String fullStatName, Supplier<Number> accessor) {
registerStatistic(fullStatName, gauge(accessor));
}
|
[
"public",
"void",
"registerGauge",
"(",
"String",
"fullStatName",
",",
"Supplier",
"<",
"Number",
">",
"accessor",
")",
"{",
"registerStatistic",
"(",
"fullStatName",
",",
"gauge",
"(",
"accessor",
")",
")",
";",
"}"
] |
Directly register a GAUGE stat with its accessor
|
[
"Directly",
"register",
"a",
"GAUGE",
"stat",
"with",
"its",
"accessor"
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/statistics/registry/StatisticRegistry.java#L128-L130
|
11,393
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/statistics/registry/StatisticRegistry.java
|
StatisticRegistry.registerCounter
|
public void registerCounter(String fullStatName, Supplier<Number> accessor) {
registerStatistic(fullStatName, counter(accessor));
}
|
java
|
public void registerCounter(String fullStatName, Supplier<Number> accessor) {
registerStatistic(fullStatName, counter(accessor));
}
|
[
"public",
"void",
"registerCounter",
"(",
"String",
"fullStatName",
",",
"Supplier",
"<",
"Number",
">",
"accessor",
")",
"{",
"registerStatistic",
"(",
"fullStatName",
",",
"counter",
"(",
"accessor",
")",
")",
";",
"}"
] |
Directly register a COUNTER stat with its accessor
|
[
"Directly",
"register",
"a",
"COUNTER",
"stat",
"with",
"its",
"accessor"
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/statistics/registry/StatisticRegistry.java#L135-L137
|
11,394
|
eirbjo/jetty-console
|
jetty-console-creator/src/main/java/org/simplericity/jettyconsole/creator/DefaultCreator.java
|
DefaultCreator.writePathDescriptor
|
private void writePathDescriptor(File consoleDir, Set<String> paths) {
try (PrintWriter writer = new PrintWriter(new FileOutputStream(new File(consoleDir, "jettyconsolepaths.txt")))){
for (String path : paths) {
writer.println(path);
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
|
java
|
private void writePathDescriptor(File consoleDir, Set<String> paths) {
try (PrintWriter writer = new PrintWriter(new FileOutputStream(new File(consoleDir, "jettyconsolepaths.txt")))){
for (String path : paths) {
writer.println(path);
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"void",
"writePathDescriptor",
"(",
"File",
"consoleDir",
",",
"Set",
"<",
"String",
">",
"paths",
")",
"{",
"try",
"(",
"PrintWriter",
"writer",
"=",
"new",
"PrintWriter",
"(",
"new",
"FileOutputStream",
"(",
"new",
"File",
"(",
"consoleDir",
",",
"\"jettyconsolepaths.txt\"",
")",
")",
")",
")",
"{",
"for",
"(",
"String",
"path",
":",
"paths",
")",
"{",
"writer",
".",
"println",
"(",
"path",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Write a txt file with one line for each unpacked class or resource
from dependencies.
|
[
"Write",
"a",
"txt",
"file",
"with",
"one",
"line",
"for",
"each",
"unpacked",
"class",
"or",
"resource",
"from",
"dependencies",
"."
] |
5bd32ecab12837394dd45fd15c51c3934afcd76b
|
https://github.com/eirbjo/jetty-console/blob/5bd32ecab12837394dd45fd15c51c3934afcd76b/jetty-console-creator/src/main/java/org/simplericity/jettyconsole/creator/DefaultCreator.java#L104-L113
|
11,395
|
connect-group/thymesheet
|
src/main/java/com/connect_group/thymesheet/css/selectors/dom/internal/TagChecker.java
|
TagChecker.tagEquals
|
private boolean tagEquals(String tag1, String tag2) {
if (caseSensitive) {
return tag1.equals(tag2);
}
return tag1.equalsIgnoreCase(tag2);
}
|
java
|
private boolean tagEquals(String tag1, String tag2) {
if (caseSensitive) {
return tag1.equals(tag2);
}
return tag1.equalsIgnoreCase(tag2);
}
|
[
"private",
"boolean",
"tagEquals",
"(",
"String",
"tag1",
",",
"String",
"tag2",
")",
"{",
"if",
"(",
"caseSensitive",
")",
"{",
"return",
"tag1",
".",
"equals",
"(",
"tag2",
")",
";",
"}",
"return",
"tag1",
".",
"equalsIgnoreCase",
"(",
"tag2",
")",
";",
"}"
] |
Determine if the two specified tag names are equal.
@param tag1 A tag name.
@param tag2 A tag name.
@return <code>true</code> if the tag names are equal, <code>false</code> otherwise.
|
[
"Determine",
"if",
"the",
"two",
"specified",
"tag",
"names",
"are",
"equal",
"."
] |
b6384e385d3e3b54944d53993bbd396d2668a5a0
|
https://github.com/connect-group/thymesheet/blob/b6384e385d3e3b54944d53993bbd396d2668a5a0/src/main/java/com/connect_group/thymesheet/css/selectors/dom/internal/TagChecker.java#L168-L174
|
11,396
|
telly/groundy
|
library/src/main/java/com/telly/groundy/GroundyService.java
|
GroundyService.onHandleIntent
|
private void onHandleIntent(GroundyTask groundyTask) {
if (groundyTask == null) {
return;
}
boolean requiresWifi = groundyTask.keepWifiOn();
if (requiresWifi) {
mWakeLockHelper.acquire();
}
L.d(TAG, "Executing value: " + groundyTask);
TaskResult taskResult;
try {
taskResult = groundyTask.doInBackground();
} catch (Exception e) {
e.printStackTrace();
taskResult = new Failed();
taskResult.add(Groundy.CRASH_MESSAGE, String.valueOf(e.getMessage()));
}
if (taskResult == null) {
throw new NullPointerException(
"Task " + groundyTask + " returned null from the doInBackground method");
}
if (requiresWifi) {
mWakeLockHelper.release();
}
//Lets try to send back the response
Bundle resultData = taskResult.getResultData();
resultData.putBundle(Groundy.ORIGINAL_PARAMS, groundyTask.getArgs());
resultData.putSerializable(Groundy.TASK_IMPLEMENTATION, groundyTask.getClass());
switch (taskResult.getType()) {
case SUCCESS:
groundyTask.send(OnSuccess.class, resultData);
break;
case FAIL:
groundyTask.send(OnFailure.class, resultData);
break;
case CANCEL:
resultData.putInt(Groundy.CANCEL_REASON, groundyTask.getQuittingReason());
groundyTask.send(OnCancel.class, resultData);
break;
}
}
|
java
|
private void onHandleIntent(GroundyTask groundyTask) {
if (groundyTask == null) {
return;
}
boolean requiresWifi = groundyTask.keepWifiOn();
if (requiresWifi) {
mWakeLockHelper.acquire();
}
L.d(TAG, "Executing value: " + groundyTask);
TaskResult taskResult;
try {
taskResult = groundyTask.doInBackground();
} catch (Exception e) {
e.printStackTrace();
taskResult = new Failed();
taskResult.add(Groundy.CRASH_MESSAGE, String.valueOf(e.getMessage()));
}
if (taskResult == null) {
throw new NullPointerException(
"Task " + groundyTask + " returned null from the doInBackground method");
}
if (requiresWifi) {
mWakeLockHelper.release();
}
//Lets try to send back the response
Bundle resultData = taskResult.getResultData();
resultData.putBundle(Groundy.ORIGINAL_PARAMS, groundyTask.getArgs());
resultData.putSerializable(Groundy.TASK_IMPLEMENTATION, groundyTask.getClass());
switch (taskResult.getType()) {
case SUCCESS:
groundyTask.send(OnSuccess.class, resultData);
break;
case FAIL:
groundyTask.send(OnFailure.class, resultData);
break;
case CANCEL:
resultData.putInt(Groundy.CANCEL_REASON, groundyTask.getQuittingReason());
groundyTask.send(OnCancel.class, resultData);
break;
}
}
|
[
"private",
"void",
"onHandleIntent",
"(",
"GroundyTask",
"groundyTask",
")",
"{",
"if",
"(",
"groundyTask",
"==",
"null",
")",
"{",
"return",
";",
"}",
"boolean",
"requiresWifi",
"=",
"groundyTask",
".",
"keepWifiOn",
"(",
")",
";",
"if",
"(",
"requiresWifi",
")",
"{",
"mWakeLockHelper",
".",
"acquire",
"(",
")",
";",
"}",
"L",
".",
"d",
"(",
"TAG",
",",
"\"Executing value: \"",
"+",
"groundyTask",
")",
";",
"TaskResult",
"taskResult",
";",
"try",
"{",
"taskResult",
"=",
"groundyTask",
".",
"doInBackground",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"taskResult",
"=",
"new",
"Failed",
"(",
")",
";",
"taskResult",
".",
"add",
"(",
"Groundy",
".",
"CRASH_MESSAGE",
",",
"String",
".",
"valueOf",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"taskResult",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Task \"",
"+",
"groundyTask",
"+",
"\" returned null from the doInBackground method\"",
")",
";",
"}",
"if",
"(",
"requiresWifi",
")",
"{",
"mWakeLockHelper",
".",
"release",
"(",
")",
";",
"}",
"//Lets try to send back the response",
"Bundle",
"resultData",
"=",
"taskResult",
".",
"getResultData",
"(",
")",
";",
"resultData",
".",
"putBundle",
"(",
"Groundy",
".",
"ORIGINAL_PARAMS",
",",
"groundyTask",
".",
"getArgs",
"(",
")",
")",
";",
"resultData",
".",
"putSerializable",
"(",
"Groundy",
".",
"TASK_IMPLEMENTATION",
",",
"groundyTask",
".",
"getClass",
"(",
")",
")",
";",
"switch",
"(",
"taskResult",
".",
"getType",
"(",
")",
")",
"{",
"case",
"SUCCESS",
":",
"groundyTask",
".",
"send",
"(",
"OnSuccess",
".",
"class",
",",
"resultData",
")",
";",
"break",
";",
"case",
"FAIL",
":",
"groundyTask",
".",
"send",
"(",
"OnFailure",
".",
"class",
",",
"resultData",
")",
";",
"break",
";",
"case",
"CANCEL",
":",
"resultData",
".",
"putInt",
"(",
"Groundy",
".",
"CANCEL_REASON",
",",
"groundyTask",
".",
"getQuittingReason",
"(",
")",
")",
";",
"groundyTask",
".",
"send",
"(",
"OnCancel",
".",
"class",
",",
"resultData",
")",
";",
"break",
";",
"}",
"}"
] |
This method is invoked on the worker thread with a request to process. Only one Intent is
processed at a time, but the processing happens on a worker thread that runs independently
from other application logic. So, if this code takes a long time, it will hold up other
requests to the same IntentService, but it will not hold up anything else.
@param groundyTask task to execute
|
[
"This",
"method",
"is",
"invoked",
"on",
"the",
"worker",
"thread",
"with",
"a",
"request",
"to",
"process",
".",
"Only",
"one",
"Intent",
"is",
"processed",
"at",
"a",
"time",
"but",
"the",
"processing",
"happens",
"on",
"a",
"worker",
"thread",
"that",
"runs",
"independently",
"from",
"other",
"application",
"logic",
".",
"So",
"if",
"this",
"code",
"takes",
"a",
"long",
"time",
"it",
"will",
"hold",
"up",
"other",
"requests",
"to",
"the",
"same",
"IntentService",
"but",
"it",
"will",
"not",
"hold",
"up",
"anything",
"else",
"."
] |
e90baf9901a8be20b348bd1575d5ad782560cec8
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/GroundyService.java#L342-L389
|
11,397
|
Terracotta-OSS/statistics
|
src/main/java/org/terracotta/statistics/derived/histogram/BarSplittingBiasedHistogram.java
|
BarSplittingBiasedHistogram.expire
|
public void expire(long time) {
long calculatedSize = 0;
Iterator<Bar> it = bars.iterator();
while (it.hasNext()) {
long barSize = it.next().expire(time);
if (barSize == 0) {
it.remove();
}
calculatedSize += barSize;
}
this.size = calculatedSize;
if (bars.isEmpty()) {
bars.add(new Bar(barEpsilon, window));
}
}
|
java
|
public void expire(long time) {
long calculatedSize = 0;
Iterator<Bar> it = bars.iterator();
while (it.hasNext()) {
long barSize = it.next().expire(time);
if (barSize == 0) {
it.remove();
}
calculatedSize += barSize;
}
this.size = calculatedSize;
if (bars.isEmpty()) {
bars.add(new Bar(barEpsilon, window));
}
}
|
[
"public",
"void",
"expire",
"(",
"long",
"time",
")",
"{",
"long",
"calculatedSize",
"=",
"0",
";",
"Iterator",
"<",
"Bar",
">",
"it",
"=",
"bars",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"long",
"barSize",
"=",
"it",
".",
"next",
"(",
")",
".",
"expire",
"(",
"time",
")",
";",
"if",
"(",
"barSize",
"==",
"0",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"calculatedSize",
"+=",
"barSize",
";",
"}",
"this",
".",
"size",
"=",
"calculatedSize",
";",
"if",
"(",
"bars",
".",
"isEmpty",
"(",
")",
")",
"{",
"bars",
".",
"add",
"(",
"new",
"Bar",
"(",
"barEpsilon",
",",
"window",
")",
")",
";",
"}",
"}"
] |
Expire old events from all buckets.
@param time current timestamp
|
[
"Expire",
"old",
"events",
"from",
"all",
"buckets",
"."
] |
d24e4989b8c8dbe4f5210e49c7945d51b6585881
|
https://github.com/Terracotta-OSS/statistics/blob/d24e4989b8c8dbe4f5210e49c7945d51b6585881/src/main/java/org/terracotta/statistics/derived/histogram/BarSplittingBiasedHistogram.java#L163-L177
|
11,398
|
airomem/airomem
|
airomem-core/src/main/java/pl/setblack/airomem/core/kryo/ReferenceResolver.java
|
ReferenceResolver.useReferences
|
@SuppressWarnings("rawtypes")
public boolean useReferences(Class type) {
return !Util.isWrapperClass(type) && !type.equals(String.class) && !type.equals(Date.class) && !type.equals(BigDecimal.class) && !type.equals(BigInteger.class);
}
|
java
|
@SuppressWarnings("rawtypes")
public boolean useReferences(Class type) {
return !Util.isWrapperClass(type) && !type.equals(String.class) && !type.equals(Date.class) && !type.equals(BigDecimal.class) && !type.equals(BigInteger.class);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"boolean",
"useReferences",
"(",
"Class",
"type",
")",
"{",
"return",
"!",
"Util",
".",
"isWrapperClass",
"(",
"type",
")",
"&&",
"!",
"type",
".",
"equals",
"(",
"String",
".",
"class",
")",
"&&",
"!",
"type",
".",
"equals",
"(",
"Date",
".",
"class",
")",
"&&",
"!",
"type",
".",
"equals",
"(",
"BigDecimal",
".",
"class",
")",
"&&",
"!",
"type",
".",
"equals",
"(",
"BigInteger",
".",
"class",
")",
";",
"}"
] |
Returns false for all primitive wrappers.
|
[
"Returns",
"false",
"for",
"all",
"primitive",
"wrappers",
"."
] |
281ce18ff64836fccfb0edab18b8d677f1101a32
|
https://github.com/airomem/airomem/blob/281ce18ff64836fccfb0edab18b8d677f1101a32/airomem-core/src/main/java/pl/setblack/airomem/core/kryo/ReferenceResolver.java#L98-L101
|
11,399
|
phax/ph-ebinterface
|
src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java
|
EbInterfaceWriter.ebInterface30
|
@Nonnull
public static EbInterfaceWriter <Ebi30InvoiceType> ebInterface30 ()
{
final EbInterfaceWriter <Ebi30InvoiceType> ret = EbInterfaceWriter.create (Ebi30InvoiceType.class);
ret.setNamespaceContext (EbInterface30NamespaceContext.getInstance ());
return ret;
}
|
java
|
@Nonnull
public static EbInterfaceWriter <Ebi30InvoiceType> ebInterface30 ()
{
final EbInterfaceWriter <Ebi30InvoiceType> ret = EbInterfaceWriter.create (Ebi30InvoiceType.class);
ret.setNamespaceContext (EbInterface30NamespaceContext.getInstance ());
return ret;
}
|
[
"@",
"Nonnull",
"public",
"static",
"EbInterfaceWriter",
"<",
"Ebi30InvoiceType",
">",
"ebInterface30",
"(",
")",
"{",
"final",
"EbInterfaceWriter",
"<",
"Ebi30InvoiceType",
">",
"ret",
"=",
"EbInterfaceWriter",
".",
"create",
"(",
"Ebi30InvoiceType",
".",
"class",
")",
";",
"ret",
".",
"setNamespaceContext",
"(",
"EbInterface30NamespaceContext",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a writer builder for Ebi30InvoiceType.
@return The builder and never <code>null</code>
|
[
"Create",
"a",
"writer",
"builder",
"for",
"Ebi30InvoiceType",
"."
] |
e3d2381f25c2fdfcc98acff2509bf5f33752d087
|
https://github.com/phax/ph-ebinterface/blob/e3d2381f25c2fdfcc98acff2509bf5f33752d087/src/main/java/com/helger/ebinterface/builder/EbInterfaceWriter.java#L84-L90
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.