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
partition
stringclasses
1 value
cycorp/api-suite
core-api/src/main/java/com/cyc/session/exception/UnsupportedCycOperationException.java
UnsupportedCycOperationException.fromThrowable
public static UnsupportedCycOperationException fromThrowable(String message, Throwable cause) { return (cause instanceof UnsupportedCycOperationException && Objects.equals(message, cause.getMessage())) ? (UnsupportedCycOperationException) cause : new UnsupportedCycOperationException(message, cause); }
java
public static UnsupportedCycOperationException fromThrowable(String message, Throwable cause) { return (cause instanceof UnsupportedCycOperationException && Objects.equals(message, cause.getMessage())) ? (UnsupportedCycOperationException) cause : new UnsupportedCycOperationException(message, cause); }
[ "public", "static", "UnsupportedCycOperationException", "fromThrowable", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "UnsupportedCycOperationException", "&&", "Objects", ".", "equals", "(", "message", ",", "caus...
Converts a Throwable to a UnsupportedCycOperationException with the specified detail message. If the Throwable is a UnsupportedCycOperationException and if the Throwable's message is identical to the one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in a new UnsupportedCycOperationException with the detail message. @param cause the Throwable to convert @param message the specified detail message @return a UnsupportedCycOperationException
[ "Converts", "a", "Throwable", "to", "a", "UnsupportedCycOperationException", "with", "the", "specified", "detail", "message", ".", "If", "the", "Throwable", "is", "a", "UnsupportedCycOperationException", "and", "if", "the", "Throwable", "s", "message", "is", "identi...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/session/exception/UnsupportedCycOperationException.java#L61-L65
train
soarcn/AndroidLifecyle
lifecycle/src/main/java/com/cocosw/lifecycle/LifecycleDispatcher.java
LifecycleDispatcher.unregisterActivityLifecycleCallbacks
public static void unregisterActivityLifecycleCallbacks(Application application, ActivityLifecycleCallbacksCompat callback) { if (PRE_ICS) { preIcsUnregisterActivityLifecycleCallbacks(callback); } else { postIcsUnregisterActivityLifecycleCallbacks(application, callback); } }
java
public static void unregisterActivityLifecycleCallbacks(Application application, ActivityLifecycleCallbacksCompat callback) { if (PRE_ICS) { preIcsUnregisterActivityLifecycleCallbacks(callback); } else { postIcsUnregisterActivityLifecycleCallbacks(application, callback); } }
[ "public", "static", "void", "unregisterActivityLifecycleCallbacks", "(", "Application", "application", ",", "ActivityLifecycleCallbacksCompat", "callback", ")", "{", "if", "(", "PRE_ICS", ")", "{", "preIcsUnregisterActivityLifecycleCallbacks", "(", "callback", ")", ";", "...
Unregisters a previously registered callback. @param application The application with which to unregister the callback. @param callback The callback to unregister.
[ "Unregisters", "a", "previously", "registered", "callback", "." ]
f1e36f1f20871863cc2007aa0fa6c30143dd2091
https://github.com/soarcn/AndroidLifecyle/blob/f1e36f1f20871863cc2007aa0fa6c30143dd2091/lifecycle/src/main/java/com/cocosw/lifecycle/LifecycleDispatcher.java#L65-L71
train
cycorp/api-suite
core-api/src/main/java/com/cyc/session/exception/SessionRuntimeException.java
SessionRuntimeException.fromThrowable
public static SessionRuntimeException fromThrowable(Throwable cause) { return (cause instanceof SessionRuntimeException) ? (SessionRuntimeException) cause : new SessionRuntimeException(cause); }
java
public static SessionRuntimeException fromThrowable(Throwable cause) { return (cause instanceof SessionRuntimeException) ? (SessionRuntimeException) cause : new SessionRuntimeException(cause); }
[ "public", "static", "SessionRuntimeException", "fromThrowable", "(", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "SessionRuntimeException", ")", "?", "(", "SessionRuntimeException", ")", "cause", ":", "new", "SessionRuntimeException", "(", "c...
Converts a Throwable to a SessionRuntimeException. If the Throwable is a SessionRuntimeException, it will be passed through unmodified; otherwise, it will be wrapped in a new SessionRuntimeException. @param cause the Throwable to convert @return a SessionRuntimeException
[ "Converts", "a", "Throwable", "to", "a", "SessionRuntimeException", ".", "If", "the", "Throwable", "is", "a", "SessionRuntimeException", "it", "will", "be", "passed", "through", "unmodified", ";", "otherwise", "it", "will", "be", "wrapped", "in", "a", "new", "...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/session/exception/SessionRuntimeException.java#L49-L53
train
cycorp/api-suite
core-api/src/main/java/com/cyc/session/exception/SessionRuntimeException.java
SessionRuntimeException.fromThrowable
public static SessionRuntimeException fromThrowable(String message, Throwable cause) { return (cause instanceof SessionRuntimeException && Objects.equals(message, cause.getMessage())) ? (SessionRuntimeException) cause : new SessionRuntimeException(message, cause); }
java
public static SessionRuntimeException fromThrowable(String message, Throwable cause) { return (cause instanceof SessionRuntimeException && Objects.equals(message, cause.getMessage())) ? (SessionRuntimeException) cause : new SessionRuntimeException(message, cause); }
[ "public", "static", "SessionRuntimeException", "fromThrowable", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "SessionRuntimeException", "&&", "Objects", ".", "equals", "(", "message", ",", "cause", ".", "getM...
Converts a Throwable to a SessionRuntimeException with the specified detail message. If the Throwable is a SessionRuntimeException and if the Throwable's message is identical to the one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in a new SessionRuntimeException with the detail message. @param cause the Throwable to convert @param message the specified detail message @return a SessionRuntimeException
[ "Converts", "a", "Throwable", "to", "a", "SessionRuntimeException", "with", "the", "specified", "detail", "message", ".", "If", "the", "Throwable", "is", "a", "SessionRuntimeException", "and", "if", "the", "Throwable", "s", "message", "is", "identical", "to", "t...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/session/exception/SessionRuntimeException.java#L66-L70
train
paulhoule/centipede
centipede/src/main/java/com/ontology2/centipede/shell/ResourceAwareObject.java
ResourceAwareObject.stream
protected ByteSource stream(final String resourceId) { return new ByteSource() { @Override public InputStream openStream() throws IOException { return loader.getResource(resourceId).getInputStream(); } }; }
java
protected ByteSource stream(final String resourceId) { return new ByteSource() { @Override public InputStream openStream() throws IOException { return loader.getResource(resourceId).getInputStream(); } }; }
[ "protected", "ByteSource", "stream", "(", "final", "String", "resourceId", ")", "{", "return", "new", "ByteSource", "(", ")", "{", "@", "Override", "public", "InputStream", "openStream", "(", ")", "throws", "IOException", "{", "return", "loader", ".", "getReso...
Wouldn't it be nice if we wrote some tests?
[ "Wouldn", "t", "it", "be", "nice", "if", "we", "wrote", "some", "tests?" ]
83bf94b841685e77f4d57deb8d5c57148eff9c17
https://github.com/paulhoule/centipede/blob/83bf94b841685e77f4d57deb8d5c57148eff9c17/centipede/src/main/java/com/ontology2/centipede/shell/ResourceAwareObject.java#L25-L32
train
cycorp/api-suite
core-api/src/main/java/com/cyc/query/exception/QueryRuntimeException.java
QueryRuntimeException.fromThrowable
public static QueryRuntimeException fromThrowable(Throwable t) { return (t instanceof QueryRuntimeException) ? (QueryRuntimeException) t : new QueryRuntimeException(t); }
java
public static QueryRuntimeException fromThrowable(Throwable t) { return (t instanceof QueryRuntimeException) ? (QueryRuntimeException) t : new QueryRuntimeException(t); }
[ "public", "static", "QueryRuntimeException", "fromThrowable", "(", "Throwable", "t", ")", "{", "return", "(", "t", "instanceof", "QueryRuntimeException", ")", "?", "(", "QueryRuntimeException", ")", "t", ":", "new", "QueryRuntimeException", "(", "t", ")", ";", "...
Converts a Throwable to a QueryRuntimeException. If the Throwable is a QueryRuntimeException, it will be passed through unmodified; otherwise, it will be wrapped in a new QueryRuntimeException. @param t the Throwable to convert @return a QueryRuntimeException
[ "Converts", "a", "Throwable", "to", "a", "QueryRuntimeException", ".", "If", "the", "Throwable", "is", "a", "QueryRuntimeException", "it", "will", "be", "passed", "through", "unmodified", ";", "otherwise", "it", "will", "be", "wrapped", "in", "a", "new", "Quer...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/query/exception/QueryRuntimeException.java#L43-L47
train
cycorp/api-suite
core-api/src/main/java/com/cyc/query/exception/QueryRuntimeException.java
QueryRuntimeException.fromThrowable
public static QueryRuntimeException fromThrowable(String message, Throwable t) { return (t instanceof QueryRuntimeException && Objects.equals(message, t.getMessage())) ? (QueryRuntimeException) t : new QueryRuntimeException(message, t); }
java
public static QueryRuntimeException fromThrowable(String message, Throwable t) { return (t instanceof QueryRuntimeException && Objects.equals(message, t.getMessage())) ? (QueryRuntimeException) t : new QueryRuntimeException(message, t); }
[ "public", "static", "QueryRuntimeException", "fromThrowable", "(", "String", "message", ",", "Throwable", "t", ")", "{", "return", "(", "t", "instanceof", "QueryRuntimeException", "&&", "Objects", ".", "equals", "(", "message", ",", "t", ".", "getMessage", "(", ...
Converts a Throwable to a QueryRuntimeException with the specified detail message. If the Throwable is a QueryRuntimeException and if the Throwable's message is identical to the one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in a new QueryRuntimeException with the detail message. @param t the Throwable to convert @param message the specified detail message @return a QueryRuntimeException
[ "Converts", "a", "Throwable", "to", "a", "QueryRuntimeException", "with", "the", "specified", "detail", "message", ".", "If", "the", "Throwable", "is", "a", "QueryRuntimeException", "and", "if", "the", "Throwable", "s", "message", "is", "identical", "to", "the",...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/query/exception/QueryRuntimeException.java#L60-L64
train
cycorp/api-suite
core-api/src/main/java/com/cyc/query/exception/ProofViewException.java
ProofViewException.fromThrowable
public static ProofViewException fromThrowable(Throwable cause) { return (cause instanceof ProofViewException) ? (ProofViewException) cause : new ProofViewException(cause); }
java
public static ProofViewException fromThrowable(Throwable cause) { return (cause instanceof ProofViewException) ? (ProofViewException) cause : new ProofViewException(cause); }
[ "public", "static", "ProofViewException", "fromThrowable", "(", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "ProofViewException", ")", "?", "(", "ProofViewException", ")", "cause", ":", "new", "ProofViewException", "(", "cause", ")", ";",...
Converts a Throwable to a ProofViewException. If the Throwable is a ProofViewException, it will be passed through unmodified; otherwise, it will be wrapped in a new ProofViewException. @param cause the Throwable to convert @return a ProofViewException
[ "Converts", "a", "Throwable", "to", "a", "ProofViewException", ".", "If", "the", "Throwable", "is", "a", "ProofViewException", "it", "will", "be", "passed", "through", "unmodified", ";", "otherwise", "it", "will", "be", "wrapped", "in", "a", "new", "ProofViewE...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/query/exception/ProofViewException.java#L44-L48
train
cycorp/api-suite
core-api/src/main/java/com/cyc/query/exception/ProofViewException.java
ProofViewException.fromThrowable
public static ProofViewException fromThrowable(String message, Throwable cause) { return (cause instanceof ProofViewException && Objects.equals(message, cause.getMessage())) ? (ProofViewException) cause : new ProofViewException(message, cause); }
java
public static ProofViewException fromThrowable(String message, Throwable cause) { return (cause instanceof ProofViewException && Objects.equals(message, cause.getMessage())) ? (ProofViewException) cause : new ProofViewException(message, cause); }
[ "public", "static", "ProofViewException", "fromThrowable", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "ProofViewException", "&&", "Objects", ".", "equals", "(", "message", ",", "cause", ".", "getMessage", ...
Converts a Throwable to a ProofViewException with the specified detail message. If the Throwable is a ProofViewException and if the Throwable's message is identical to the one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in a new ProofViewException with the detail message. @param cause the Throwable to convert @param message the specified detail message @return a ProofViewException
[ "Converts", "a", "Throwable", "to", "a", "ProofViewException", "with", "the", "specified", "detail", "message", ".", "If", "the", "Throwable", "is", "a", "ProofViewException", "and", "if", "the", "Throwable", "s", "message", "is", "identical", "to", "the", "on...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/query/exception/ProofViewException.java#L61-L65
train
cycorp/api-suite
core-api/src/main/java/com/cyc/kb/exception/KbException.java
KbException.fromThrowable
public static KbException fromThrowable(Throwable cause) { return (cause instanceof KbException) ? (KbException) cause : new KbException(cause); }
java
public static KbException fromThrowable(Throwable cause) { return (cause instanceof KbException) ? (KbException) cause : new KbException(cause); }
[ "public", "static", "KbException", "fromThrowable", "(", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "KbException", ")", "?", "(", "KbException", ")", "cause", ":", "new", "KbException", "(", "cause", ")", ";", "}" ]
Converts a Throwable to a KbException. If the Throwable is a KbException, it will be passed through unmodified; otherwise, it will be wrapped in a new KbException. @param cause the Throwable to convert @return a KbException
[ "Converts", "a", "Throwable", "to", "a", "KbException", ".", "If", "the", "Throwable", "is", "a", "KbException", "it", "will", "be", "passed", "through", "unmodified", ";", "otherwise", "it", "will", "be", "wrapped", "in", "a", "new", "KbException", "." ]
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/kb/exception/KbException.java#L45-L49
train
cycorp/api-suite
core-api/src/main/java/com/cyc/kb/exception/KbException.java
KbException.fromThrowable
public static KbException fromThrowable(String message, Throwable cause) { return (cause instanceof KbException && Objects.equals(message, cause.getMessage())) ? (KbException) cause : new KbException(message, cause); }
java
public static KbException fromThrowable(String message, Throwable cause) { return (cause instanceof KbException && Objects.equals(message, cause.getMessage())) ? (KbException) cause : new KbException(message, cause); }
[ "public", "static", "KbException", "fromThrowable", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "KbException", "&&", "Objects", ".", "equals", "(", "message", ",", "cause", ".", "getMessage", "(", ")", ...
Converts a Throwable to a KbException with the specified detail message. If the Throwable is a KbException and if the Throwable's message is identical to the one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in a new KbException with the detail message. @param cause the Throwable to convert @param message the specified detail message @return a KbException
[ "Converts", "a", "Throwable", "to", "a", "KbException", "with", "the", "specified", "detail", "message", ".", "If", "the", "Throwable", "is", "a", "KbException", "and", "if", "the", "Throwable", "s", "message", "is", "identical", "to", "the", "one", "supplie...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/kb/exception/KbException.java#L62-L66
train
cycorp/api-suite
core-api/src/main/java/com/cyc/kb/exception/DeleteException.java
DeleteException.fromThrowable
public static DeleteException fromThrowable(Throwable cause) { return (cause instanceof DeleteException) ? (DeleteException) cause : new DeleteException(cause); }
java
public static DeleteException fromThrowable(Throwable cause) { return (cause instanceof DeleteException) ? (DeleteException) cause : new DeleteException(cause); }
[ "public", "static", "DeleteException", "fromThrowable", "(", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "DeleteException", ")", "?", "(", "DeleteException", ")", "cause", ":", "new", "DeleteException", "(", "cause", ")", ";", "}" ]
Converts a Throwable to a DeleteException. If the Throwable is a DeleteException, it will be passed through unmodified; otherwise, it will be wrapped in a new DeleteException. @param cause the Throwable to convert @return a DeleteException
[ "Converts", "a", "Throwable", "to", "a", "DeleteException", ".", "If", "the", "Throwable", "is", "a", "DeleteException", "it", "will", "be", "passed", "through", "unmodified", ";", "otherwise", "it", "will", "be", "wrapped", "in", "a", "new", "DeleteException"...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/kb/exception/DeleteException.java#L45-L49
train
cycorp/api-suite
core-api/src/main/java/com/cyc/kb/exception/DeleteException.java
DeleteException.fromThrowable
public static DeleteException fromThrowable(String message, Throwable cause) { return (cause instanceof DeleteException && Objects.equals(message, cause.getMessage())) ? (DeleteException) cause : new DeleteException(message, cause); }
java
public static DeleteException fromThrowable(String message, Throwable cause) { return (cause instanceof DeleteException && Objects.equals(message, cause.getMessage())) ? (DeleteException) cause : new DeleteException(message, cause); }
[ "public", "static", "DeleteException", "fromThrowable", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "return", "(", "cause", "instanceof", "DeleteException", "&&", "Objects", ".", "equals", "(", "message", ",", "cause", ".", "getMessage", "(", ...
Converts a Throwable to a DeleteException with the specified detail message. If the Throwable is a DeleteException and if the Throwable's message is identical to the one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in a new DeleteException with the detail message. @param cause the Throwable to convert @param message the specified detail message @return a DeleteException
[ "Converts", "a", "Throwable", "to", "a", "DeleteException", "with", "the", "specified", "detail", "message", ".", "If", "the", "Throwable", "is", "a", "DeleteException", "and", "if", "the", "Throwable", "s", "message", "is", "identical", "to", "the", "one", ...
1d52affabc4635e3715a059e38741712cbdbf2d5
https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/kb/exception/DeleteException.java#L62-L66
train
m-m-m/util
pojo/src/main/java/net/sf/mmm/util/pojo/descriptor/impl/AbstractPojoIntrospector.java
AbstractPojoIntrospector.initialize
@PostConstruct public void initialize() { if (this.initializationState.setInitializing()) { if (this.visibility == null) { this.visibility = VisibilityModifier.PUBLIC; } this.initializationState.setInitialized(); } }
java
@PostConstruct public void initialize() { if (this.initializationState.setInitializing()) { if (this.visibility == null) { this.visibility = VisibilityModifier.PUBLIC; } this.initializationState.setInitialized(); } }
[ "@", "PostConstruct", "public", "void", "initialize", "(", ")", "{", "if", "(", "this", ".", "initializationState", ".", "setInitializing", "(", ")", ")", "{", "if", "(", "this", ".", "visibility", "==", "null", ")", "{", "this", ".", "visibility", "=", ...
This method initializes this class. It has to be called after construction and injection is completed.
[ "This", "method", "initializes", "this", "class", ".", "It", "has", "to", "be", "called", "after", "construction", "and", "injection", "is", "completed", "." ]
f0e4e084448f8dfc83ca682a9e1618034a094ce6
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/pojo/src/main/java/net/sf/mmm/util/pojo/descriptor/impl/AbstractPojoIntrospector.java#L101-L110
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/readers/ModuleBuildReader.java
ModuleBuildReader.getExtraBuilds
public List<ModuleBuildFuture> getExtraBuilds() { return extraBuilds == null ? Collections.<ModuleBuildFuture>emptyList() : Collections.unmodifiableList(extraBuilds); }
java
public List<ModuleBuildFuture> getExtraBuilds() { return extraBuilds == null ? Collections.<ModuleBuildFuture>emptyList() : Collections.unmodifiableList(extraBuilds); }
[ "public", "List", "<", "ModuleBuildFuture", ">", "getExtraBuilds", "(", ")", "{", "return", "extraBuilds", "==", "null", "?", "Collections", ".", "<", "ModuleBuildFuture", ">", "emptyList", "(", ")", ":", "Collections", ".", "unmodifiableList", "(", "extraBuilds...
Returns the list of additional futures that should be processed along with this build this future @return The list of extra build futures.
[ "Returns", "the", "list", "of", "additional", "futures", "that", "should", "be", "processed", "along", "with", "this", "build", "this", "future" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/readers/ModuleBuildReader.java#L157-L159
train
jMotif/GI
src/main/java/net/seninp/gi/rulepruner/RulePruningAlgorithm.java
RulePruningAlgorithm.getCoverDelta
public double getCoverDelta(GrammarRuleRecord rule) { // counts which uncovered points shall be covered int new_cover = 0; // counts overlaps with previously covered ranges int overlapping_cover = 0; // perform the sum computation for (RuleInterval i : rule.getRuleIntervals()) { int start = i.getStart(); int end = i.getEnd(); for (int j = start; j < end; j++) { if (range[j]) { overlapping_cover++; } else { new_cover++; } } } // if covers nothing, return 0 if (0 == new_cover) { return 0.0; } // if zero overlap, return full weighted cover if (0 == overlapping_cover) { return (double) new_cover / (double) (rule.getExpandedRuleString().length() + rule.getRuleIntervals().size()); } // else divide newly covered points amount by the sum of the rule string length and occurrence // (i.e. encoding size) return ((double) new_cover / (double) (new_cover + overlapping_cover)) / (double) (rule.getExpandedRuleString().length() + rule.getRuleIntervals().size()); }
java
public double getCoverDelta(GrammarRuleRecord rule) { // counts which uncovered points shall be covered int new_cover = 0; // counts overlaps with previously covered ranges int overlapping_cover = 0; // perform the sum computation for (RuleInterval i : rule.getRuleIntervals()) { int start = i.getStart(); int end = i.getEnd(); for (int j = start; j < end; j++) { if (range[j]) { overlapping_cover++; } else { new_cover++; } } } // if covers nothing, return 0 if (0 == new_cover) { return 0.0; } // if zero overlap, return full weighted cover if (0 == overlapping_cover) { return (double) new_cover / (double) (rule.getExpandedRuleString().length() + rule.getRuleIntervals().size()); } // else divide newly covered points amount by the sum of the rule string length and occurrence // (i.e. encoding size) return ((double) new_cover / (double) (new_cover + overlapping_cover)) / (double) (rule.getExpandedRuleString().length() + rule.getRuleIntervals().size()); }
[ "public", "double", "getCoverDelta", "(", "GrammarRuleRecord", "rule", ")", "{", "// counts which uncovered points shall be covered", "int", "new_cover", "=", "0", ";", "// counts overlaps with previously covered ranges", "int", "overlapping_cover", "=", "0", ";", "// perform...
Computes the delta value for the suggested rule candidate. @param rule the grammatical rule candidate. @return the delta value.
[ "Computes", "the", "delta", "value", "for", "the", "suggested", "rule", "candidate", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/rulepruner/RulePruningAlgorithm.java#L88-L125
train
jMotif/GI
src/main/java/net/seninp/gi/rulepruner/RulePruningAlgorithm.java
RulePruningAlgorithm.isCompletelyCoveredBy
private boolean isCompletelyCoveredBy(int[] isCovered, List<RuleInterval> intervals) { for (RuleInterval i : intervals) { for (int j = i.getStart(); j < i.getEnd(); j++) { if (isCovered[j] == 0) { return false; } } } return true; }
java
private boolean isCompletelyCoveredBy(int[] isCovered, List<RuleInterval> intervals) { for (RuleInterval i : intervals) { for (int j = i.getStart(); j < i.getEnd(); j++) { if (isCovered[j] == 0) { return false; } } } return true; }
[ "private", "boolean", "isCompletelyCoveredBy", "(", "int", "[", "]", "isCovered", ",", "List", "<", "RuleInterval", ">", "intervals", ")", "{", "for", "(", "RuleInterval", "i", ":", "intervals", ")", "{", "for", "(", "int", "j", "=", "i", ".", "getStart"...
Checks if the cover is complete. @param isCovered the cover. @param intervals set of rule intervals. @return true if the set complete.
[ "Checks", "if", "the", "cover", "is", "complete", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/rulepruner/RulePruningAlgorithm.java#L207-L216
train
jMotif/GI
src/main/java/net/seninp/gi/sequitur/SAXNonTerminal.java
SAXNonTerminal.expand
public void expand() { join(p, r.first()); join(r.last(), n); // Necessary so that garbage collector // can delete rule and guard. r.theGuard.r = null; r.theGuard = null; }
java
public void expand() { join(p, r.first()); join(r.last(), n); // Necessary so that garbage collector // can delete rule and guard. r.theGuard.r = null; r.theGuard = null; }
[ "public", "void", "expand", "(", ")", "{", "join", "(", "p", ",", "r", ".", "first", "(", ")", ")", ";", "join", "(", "r", ".", "last", "(", ")", ",", "n", ")", ";", "// Necessary so that garbage collector\r", "// can delete rule and guard.\r", "r", ".",...
This symbol is the last reference to its rule. The contents of the rule are substituted in its place.
[ "This", "symbol", "is", "the", "last", "reference", "to", "its", "rule", ".", "The", "contents", "of", "the", "rule", "are", "substituted", "in", "its", "place", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/sequitur/SAXNonTerminal.java#L82-L89
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/util/JSSource.java
JSSource.insert
public void insert(String str, int lineno, int colno) { final String sourceMethod = "insert"; //$NON-NLS-1$ if (isTraceLogging) { log.entering(JSSource.class.getName(), sourceMethod, new Object[]{str, lineno, colno}); } PositionLocator locator = new PositionLocator(lineno, colno); locator.insert(str); if (isTraceLogging) { log.exiting(JSSource.class.getName(), sourceMethod, "String \"" + str + "\" inserted at " + mid + "(" + lineno + "," + colno + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } }
java
public void insert(String str, int lineno, int colno) { final String sourceMethod = "insert"; //$NON-NLS-1$ if (isTraceLogging) { log.entering(JSSource.class.getName(), sourceMethod, new Object[]{str, lineno, colno}); } PositionLocator locator = new PositionLocator(lineno, colno); locator.insert(str); if (isTraceLogging) { log.exiting(JSSource.class.getName(), sourceMethod, "String \"" + str + "\" inserted at " + mid + "(" + lineno + "," + colno + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } }
[ "public", "void", "insert", "(", "String", "str", ",", "int", "lineno", ",", "int", "colno", ")", "{", "final", "String", "sourceMethod", "=", "\"insert\"", ";", "//$NON-NLS-1$\r", "if", "(", "isTraceLogging", ")", "{", "log", ".", "entering", "(", "JSSour...
Inserts the specified string into the source at the specified location @param str the string to insert @param lineno the line number to insert to @param colno the column number to insert to
[ "Inserts", "the", "specified", "string", "into", "the", "source", "at", "the", "specified", "location" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/util/JSSource.java#L85-L95
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/util/JSSource.java
JSSource.appendln
public void appendln(String str) { BufferedReader rdr = new BufferedReader(new StringReader(str)); while (true) { String line = null; try { line = rdr.readLine(); } catch (IOException e) { // shouldn't ever happen since we're using a StringReader throw new RuntimeException(e); } if (line != null) { lines.add(new LineInfo(line)); continue; } break; } }
java
public void appendln(String str) { BufferedReader rdr = new BufferedReader(new StringReader(str)); while (true) { String line = null; try { line = rdr.readLine(); } catch (IOException e) { // shouldn't ever happen since we're using a StringReader throw new RuntimeException(e); } if (line != null) { lines.add(new LineInfo(line)); continue; } break; } }
[ "public", "void", "appendln", "(", "String", "str", ")", "{", "BufferedReader", "rdr", "=", "new", "BufferedReader", "(", "new", "StringReader", "(", "str", ")", ")", ";", "while", "(", "true", ")", "{", "String", "line", "=", "null", ";", "try", "{", ...
Appends the lines in the specified string to the current source. @param str
[ "Appends", "the", "lines", "in", "the", "specified", "string", "to", "the", "current", "source", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/util/JSSource.java#L106-L122
train
m-m-m/util
xml/src/main/java/net/sf/mmm/util/xml/base/jaxb/IdResolverContext.java
IdResolverContext.disposeAndValidate
public void disposeAndValidate() throws ObjectNotFoundException, ComposedException { List<NlsObject> errorList = this.duplicateIdErrors; this.duplicateIdErrors = null; for (Resolver resolver : this.id2callableMap.values()) { if (!resolver.resolved) { errorList.add(this.bundle.errorObjectNotFound(resolver.type, resolver.id)); } } this.id2valueMap = null; this.id2callableMap = null; int errorCount = errorList.size(); if (errorCount > 0) { NlsObject[] errors = errorList.toArray(new NlsObject[errorCount]); throw new ComposedException(errors); } }
java
public void disposeAndValidate() throws ObjectNotFoundException, ComposedException { List<NlsObject> errorList = this.duplicateIdErrors; this.duplicateIdErrors = null; for (Resolver resolver : this.id2callableMap.values()) { if (!resolver.resolved) { errorList.add(this.bundle.errorObjectNotFound(resolver.type, resolver.id)); } } this.id2valueMap = null; this.id2callableMap = null; int errorCount = errorList.size(); if (errorCount > 0) { NlsObject[] errors = errorList.toArray(new NlsObject[errorCount]); throw new ComposedException(errors); } }
[ "public", "void", "disposeAndValidate", "(", ")", "throws", "ObjectNotFoundException", ",", "ComposedException", "{", "List", "<", "NlsObject", ">", "errorList", "=", "this", ".", "duplicateIdErrors", ";", "this", ".", "duplicateIdErrors", "=", "null", ";", "for",...
This method disposes this context and performs a validation that all IDs have been resolved. @throws ObjectNotFoundException if a single ID was NOT resolved. @throws ComposedException if multiple IDs have NOT been resolved.
[ "This", "method", "disposes", "this", "context", "and", "performs", "a", "validation", "that", "all", "IDs", "have", "been", "resolved", "." ]
f0e4e084448f8dfc83ca682a9e1618034a094ce6
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/xml/src/main/java/net/sf/mmm/util/xml/base/jaxb/IdResolverContext.java#L94-L110
train
m-m-m/util
sandbox/src/main/java/net/sf/mmm/util/xml/NamespaceContextImpl.java
NamespaceContextImpl.setNamespace
public void setNamespace(String prefix, String uri) { this.prefix2namespace.put(prefix, uri); this.namespace2prefix.put(uri, prefix); }
java
public void setNamespace(String prefix, String uri) { this.prefix2namespace.put(prefix, uri); this.namespace2prefix.put(uri, prefix); }
[ "public", "void", "setNamespace", "(", "String", "prefix", ",", "String", "uri", ")", "{", "this", ".", "prefix2namespace", ".", "put", "(", "prefix", ",", "uri", ")", ";", "this", ".", "namespace2prefix", ".", "put", "(", "uri", ",", "prefix", ")", ";...
This method is used to declare a namespace in this context. @param prefix is the prefix for the namespace. @param uri is the URI of the namespace.
[ "This", "method", "is", "used", "to", "declare", "a", "namespace", "in", "this", "context", "." ]
f0e4e084448f8dfc83ca682a9e1618034a094ce6
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/sandbox/src/main/java/net/sf/mmm/util/xml/NamespaceContextImpl.java#L89-L93
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/runner/single/InstanceSolverRunner.java
InstanceSolverRunner.build
private ChocoConstraint build(Constraint cstr) throws SchedulerException { ChocoMapper mapper = params.getMapper(); ChocoConstraint cc = mapper.get(cstr); if (cc == null) { throw new SchedulerModelingException(origin, "No implementation mapped to '" + cstr.getClass().getSimpleName() + "'"); } return cc; }
java
private ChocoConstraint build(Constraint cstr) throws SchedulerException { ChocoMapper mapper = params.getMapper(); ChocoConstraint cc = mapper.get(cstr); if (cc == null) { throw new SchedulerModelingException(origin, "No implementation mapped to '" + cstr.getClass().getSimpleName() + "'"); } return cc; }
[ "private", "ChocoConstraint", "build", "(", "Constraint", "cstr", ")", "throws", "SchedulerException", "{", "ChocoMapper", "mapper", "=", "params", ".", "getMapper", "(", ")", ";", "ChocoConstraint", "cc", "=", "mapper", ".", "get", "(", "cstr", ")", ";", "i...
Build a sat constraint @param cstr the model-side constraint @return the solver-side constraint @throws SchedulerException if the process failed
[ "Build", "a", "sat", "constraint" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/runner/single/InstanceSolverRunner.java#L274-L281
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/runner/single/InstanceSolverRunner.java
InstanceSolverRunner.checkNodesExistence
private static void checkNodesExistence(Model mo, Collection<Node> ns) throws SchedulerModelingException { for (Node node : ns) { if (!mo.getMapping().contains(node)) { throw new SchedulerModelingException(mo, "Unknown node '" + node + "'"); } } }
java
private static void checkNodesExistence(Model mo, Collection<Node> ns) throws SchedulerModelingException { for (Node node : ns) { if (!mo.getMapping().contains(node)) { throw new SchedulerModelingException(mo, "Unknown node '" + node + "'"); } } }
[ "private", "static", "void", "checkNodesExistence", "(", "Model", "mo", ",", "Collection", "<", "Node", ">", "ns", ")", "throws", "SchedulerModelingException", "{", "for", "(", "Node", "node", ":", "ns", ")", "{", "if", "(", "!", "mo", ".", "getMapping", ...
Check for the existence of nodes in a model @param mo the model to check @param ns the nodes to check @throws SchedulerModelingException if at least one of the given nodes is not in the RP.
[ "Check", "for", "the", "existence", "of", "nodes", "in", "a", "model" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/runner/single/InstanceSolverRunner.java#L301-L307
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/runner/single/InstanceSolverRunner.java
InstanceSolverRunner.getStatistics
public SingleRunnerStatistics getStatistics() { if (rp != null) { Measures m = rp.getSolver().getMeasures(); stats.setMetrics(new Metrics(m)); stats.setCompleted(m.getSearchState().equals(SearchState.TERMINATED) || m.getSearchState().equals(SearchState.NEW) ); } return stats; }
java
public SingleRunnerStatistics getStatistics() { if (rp != null) { Measures m = rp.getSolver().getMeasures(); stats.setMetrics(new Metrics(m)); stats.setCompleted(m.getSearchState().equals(SearchState.TERMINATED) || m.getSearchState().equals(SearchState.NEW) ); } return stats; }
[ "public", "SingleRunnerStatistics", "getStatistics", "(", ")", "{", "if", "(", "rp", "!=", "null", ")", "{", "Measures", "m", "=", "rp", ".", "getSolver", "(", ")", ".", "getMeasures", "(", ")", ";", "stats", ".", "setMetrics", "(", "new", "Metrics", "...
Get the statistics about the solving process. @return the statistics
[ "Get", "the", "statistics", "about", "the", "solving", "process", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/runner/single/InstanceSolverRunner.java#L314-L323
train
jMotif/GI
src/main/java/net/seninp/gi/clusterrule/DistanceComputation.java
DistanceComputation.calcDistTSAndPattern
protected double calcDistTSAndPattern(double[] ts, double[] pValue) { double INF = 10000000000000000000f; double bestDist = INF; int patternLen = pValue.length; int lastStartP = ts.length - pValue.length + 1; if (lastStartP < 1) return bestDist; Random rand = new Random(); int startP = rand.nextInt((lastStartP - 1 - 0) + 1); double[] slidingWindow = new double[patternLen]; System.arraycopy(ts, startP, slidingWindow, 0, patternLen); bestDist = eculideanDistNorm(pValue, slidingWindow); for (int i = 0; i < lastStartP; i++) { System.arraycopy(ts, i, slidingWindow, 0, patternLen); double tempDist = eculideanDistNormEAbandon(pValue, slidingWindow, bestDist); if (tempDist < bestDist) { bestDist = tempDist; } } return bestDist; }
java
protected double calcDistTSAndPattern(double[] ts, double[] pValue) { double INF = 10000000000000000000f; double bestDist = INF; int patternLen = pValue.length; int lastStartP = ts.length - pValue.length + 1; if (lastStartP < 1) return bestDist; Random rand = new Random(); int startP = rand.nextInt((lastStartP - 1 - 0) + 1); double[] slidingWindow = new double[patternLen]; System.arraycopy(ts, startP, slidingWindow, 0, patternLen); bestDist = eculideanDistNorm(pValue, slidingWindow); for (int i = 0; i < lastStartP; i++) { System.arraycopy(ts, i, slidingWindow, 0, patternLen); double tempDist = eculideanDistNormEAbandon(pValue, slidingWindow, bestDist); if (tempDist < bestDist) { bestDist = tempDist; } } return bestDist; }
[ "protected", "double", "calcDistTSAndPattern", "(", "double", "[", "]", "ts", ",", "double", "[", "]", "pValue", ")", "{", "double", "INF", "=", "10000000000000000000f", ";", "double", "bestDist", "=", "INF", ";", "int", "patternLen", "=", "pValue", ".", "...
Calculating the distance between time series and pattern. @param ts a series of points for time series. @param pValue a series of points for pattern. @return the distance value.
[ "Calculating", "the", "distance", "between", "time", "series", "and", "pattern", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/clusterrule/DistanceComputation.java#L14-L42
train
jMotif/GI
src/main/java/net/seninp/gi/clusterrule/DistanceComputation.java
DistanceComputation.eculideanDistNormEAbandon
protected double eculideanDistNormEAbandon(double[] ts1, double[] ts2, double bsfDist) { double dist = 0; double tsLen = ts1.length; double bsf = Math.pow(tsLen * bsfDist, 2); for (int i = 0; i < ts1.length; i++) { double diff = ts1[i] - ts2[i]; dist += Math.pow(diff, 2); if (dist > bsf) return Double.NaN; } return Math.sqrt(dist) / tsLen; }
java
protected double eculideanDistNormEAbandon(double[] ts1, double[] ts2, double bsfDist) { double dist = 0; double tsLen = ts1.length; double bsf = Math.pow(tsLen * bsfDist, 2); for (int i = 0; i < ts1.length; i++) { double diff = ts1[i] - ts2[i]; dist += Math.pow(diff, 2); if (dist > bsf) return Double.NaN; } return Math.sqrt(dist) / tsLen; }
[ "protected", "double", "eculideanDistNormEAbandon", "(", "double", "[", "]", "ts1", ",", "double", "[", "]", "ts2", ",", "double", "bsfDist", ")", "{", "double", "dist", "=", "0", ";", "double", "tsLen", "=", "ts1", ".", "length", ";", "double", "bsf", ...
Normalized early abandoned Euclidean distance. @param ts1 the first series. @param ts2 the second series. @param bsfDist the distance value (used for early abandon). @return the distance value.
[ "Normalized", "early", "abandoned", "Euclidean", "distance", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/clusterrule/DistanceComputation.java#L52-L67
train
jMotif/GI
src/main/java/net/seninp/gi/clusterrule/DistanceComputation.java
DistanceComputation.eculideanDistNorm
protected double eculideanDistNorm(double[] ts1, double[] ts2) { double dist = 0; double tsLen = ts1.length; for (int i = 0; i < ts1.length; i++) { double diff = ts1[i] - ts2[i]; dist += Math.pow(diff, 2); } return Math.sqrt(dist) / tsLen; }
java
protected double eculideanDistNorm(double[] ts1, double[] ts2) { double dist = 0; double tsLen = ts1.length; for (int i = 0; i < ts1.length; i++) { double diff = ts1[i] - ts2[i]; dist += Math.pow(diff, 2); } return Math.sqrt(dist) / tsLen; }
[ "protected", "double", "eculideanDistNorm", "(", "double", "[", "]", "ts1", ",", "double", "[", "]", "ts2", ")", "{", "double", "dist", "=", "0", ";", "double", "tsLen", "=", "ts1", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", ...
Normalized Euclidean distance. @param ts1 the first series. @param ts2 the second series. @return the distance value.
[ "Normalized", "Euclidean", "distance", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/clusterrule/DistanceComputation.java#L76-L86
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/extensions/AliasedCumulativesFiltering.java
AliasedCumulativesFiltering.toAbsoluteFreeResources
private static void toAbsoluteFreeResources(TIntIntHashMap changes, int[] sortedMoments) { for (int i = 1; i < sortedMoments.length; i++) { int t = sortedMoments[i]; int lastT = sortedMoments[i - 1]; int lastFree = changes.get(lastT); changes.put(t, changes.get(t) + lastFree); } }
java
private static void toAbsoluteFreeResources(TIntIntHashMap changes, int[] sortedMoments) { for (int i = 1; i < sortedMoments.length; i++) { int t = sortedMoments[i]; int lastT = sortedMoments[i - 1]; int lastFree = changes.get(lastT); changes.put(t, changes.get(t) + lastFree); } }
[ "private", "static", "void", "toAbsoluteFreeResources", "(", "TIntIntHashMap", "changes", ",", "int", "[", "]", "sortedMoments", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<", "sortedMoments", ".", "length", ";", "i", "++", ")", "{", "int", ...
Translation for a relatives resources changes to an absolute free resources. @param changes the map that indicates the free CPU variation @param sortedMoments the different moments sorted in ascending order
[ "Translation", "for", "a", "relatives", "resources", "changes", "to", "an", "absolute", "free", "resources", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/extensions/AliasedCumulativesFiltering.java#L176-L184
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/view/CNetwork.java
CNetwork.addLinkConstraints
private void addLinkConstraints(ReconfigurationProblem rp) { // Links limitation List<Task> tasksListUp = new ArrayList<>(); List<Task> tasksListDown = new ArrayList<>(); List<IntVar> heightsListUp = new ArrayList<>(); List<IntVar> heightsListDown = new ArrayList<>(); for (Link l : net.getLinks()) { for (VM vm : rp.getVMs()) { VMTransition a = rp.getVMAction(vm); if (a instanceof RelocatableVM && !a.getDSlice().getHoster().isInstantiatedTo(a.getCSlice().getHoster().getValue())) { Node src = source.getMapping().getVMLocation(vm); Node dst = rp.getNode(a.getDSlice().getHoster().getValue()); List<Link> path = net.getRouting().getPath(src, dst); // Check first if the link is on migration path if (path.contains(l)) { // Get link direction LinkDirection linkDirection = net.getRouting().getLinkDirection(src, dst, l); // UpLink if (linkDirection == LinkDirection.UPLINK) { tasksListUp.add(((RelocatableVM) a).getMigrationTask()); heightsListUp.add(((RelocatableVM) a).getBandwidth()); } // DownLink else { tasksListDown.add(((RelocatableVM) a).getMigrationTask()); heightsListDown.add(((RelocatableVM) a).getBandwidth()); } } } } if (!tasksListUp.isEmpty()) { // Post the cumulative constraint for the current UpLink csp.post(csp.cumulative( tasksListUp.toArray(new Task[tasksListUp.size()]), heightsListUp.toArray(new IntVar[heightsListUp.size()]), csp.intVar(l.getCapacity()), true )); tasksListUp.clear(); heightsListUp.clear(); } if (!tasksListDown.isEmpty()) { // Post the cumulative constraint for the current DownLink csp.post(csp.cumulative( tasksListDown.toArray(new Task[tasksListDown.size()]), heightsListDown.toArray(new IntVar[heightsListDown.size()]), csp.intVar(l.getCapacity()), true )); tasksListDown.clear(); heightsListDown.clear(); } } }
java
private void addLinkConstraints(ReconfigurationProblem rp) { // Links limitation List<Task> tasksListUp = new ArrayList<>(); List<Task> tasksListDown = new ArrayList<>(); List<IntVar> heightsListUp = new ArrayList<>(); List<IntVar> heightsListDown = new ArrayList<>(); for (Link l : net.getLinks()) { for (VM vm : rp.getVMs()) { VMTransition a = rp.getVMAction(vm); if (a instanceof RelocatableVM && !a.getDSlice().getHoster().isInstantiatedTo(a.getCSlice().getHoster().getValue())) { Node src = source.getMapping().getVMLocation(vm); Node dst = rp.getNode(a.getDSlice().getHoster().getValue()); List<Link> path = net.getRouting().getPath(src, dst); // Check first if the link is on migration path if (path.contains(l)) { // Get link direction LinkDirection linkDirection = net.getRouting().getLinkDirection(src, dst, l); // UpLink if (linkDirection == LinkDirection.UPLINK) { tasksListUp.add(((RelocatableVM) a).getMigrationTask()); heightsListUp.add(((RelocatableVM) a).getBandwidth()); } // DownLink else { tasksListDown.add(((RelocatableVM) a).getMigrationTask()); heightsListDown.add(((RelocatableVM) a).getBandwidth()); } } } } if (!tasksListUp.isEmpty()) { // Post the cumulative constraint for the current UpLink csp.post(csp.cumulative( tasksListUp.toArray(new Task[tasksListUp.size()]), heightsListUp.toArray(new IntVar[heightsListUp.size()]), csp.intVar(l.getCapacity()), true )); tasksListUp.clear(); heightsListUp.clear(); } if (!tasksListDown.isEmpty()) { // Post the cumulative constraint for the current DownLink csp.post(csp.cumulative( tasksListDown.toArray(new Task[tasksListDown.size()]), heightsListDown.toArray(new IntVar[heightsListDown.size()]), csp.intVar(l.getCapacity()), true )); tasksListDown.clear(); heightsListDown.clear(); } } }
[ "private", "void", "addLinkConstraints", "(", "ReconfigurationProblem", "rp", ")", "{", "// Links limitation", "List", "<", "Task", ">", "tasksListUp", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "Task", ">", "tasksListDown", "=", "new", "ArrayL...
Add the cumulative constraints for each link. Full-duplex links are considered, two cumulative constraints are defined per link by looking at the migration direction for each link on the migration path. @param rp the reconfiguration problem
[ "Add", "the", "cumulative", "constraints", "for", "each", "link", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/view/CNetwork.java#L189-L253
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/MappingUtils.java
MappingUtils.fill
public static void fill(Mapping src, Mapping dst) { for (Node off : src.getOfflineNodes()) { dst.addOfflineNode(off); } for (VM r : src.getReadyVMs()) { dst.addReadyVM(r); } for (Node on : src.getOnlineNodes()) { dst.addOnlineNode(on); for (VM r : src.getRunningVMs(on)) { dst.addRunningVM(r, on); } for (VM s : src.getSleepingVMs(on)) { dst.addSleepingVM(s, on); } } }
java
public static void fill(Mapping src, Mapping dst) { for (Node off : src.getOfflineNodes()) { dst.addOfflineNode(off); } for (VM r : src.getReadyVMs()) { dst.addReadyVM(r); } for (Node on : src.getOnlineNodes()) { dst.addOnlineNode(on); for (VM r : src.getRunningVMs(on)) { dst.addRunningVM(r, on); } for (VM s : src.getSleepingVMs(on)) { dst.addSleepingVM(s, on); } } }
[ "public", "static", "void", "fill", "(", "Mapping", "src", ",", "Mapping", "dst", ")", "{", "for", "(", "Node", "off", ":", "src", ".", "getOfflineNodes", "(", ")", ")", "{", "dst", ".", "addOfflineNode", "(", "off", ")", ";", "}", "for", "(", "VM"...
Fill a destination mapping with all the elements in a source mapping @param src the mapping to copy @param dst the destination mapping
[ "Fill", "a", "destination", "mapping", "with", "all", "the", "elements", "in", "a", "source", "mapping" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/MappingUtils.java#L42-L59
train
jMotif/GI
src/main/java/net/seninp/gi/repair/RePairRule.java
RePairRule.toRuleString
public String toRuleString() { if (0 == this.ruleNumber) { return this.grammar.r0String; } return this.first.toString() + SPACE + this.second.toString() + SPACE; }
java
public String toRuleString() { if (0 == this.ruleNumber) { return this.grammar.r0String; } return this.first.toString() + SPACE + this.second.toString() + SPACE; }
[ "public", "String", "toRuleString", "(", ")", "{", "if", "(", "0", "==", "this", ".", "ruleNumber", ")", "{", "return", "this", ".", "grammar", ".", "r0String", ";", "}", "return", "this", ".", "first", ".", "toString", "(", ")", "+", "SPACE", "+", ...
Return the prefixed with R rule. @return rule string.
[ "Return", "the", "prefixed", "with", "R", "rule", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/repair/RePairRule.java#L106-L111
train
jMotif/GI
src/main/java/net/seninp/gi/repair/RePairRule.java
RePairRule.getOccurrences
public int[] getOccurrences() { int[] res = new int[this.occurrences.size()]; for (int i = 0; i < this.occurrences.size(); i++) { res[i] = this.occurrences.get(i); } return res; }
java
public int[] getOccurrences() { int[] res = new int[this.occurrences.size()]; for (int i = 0; i < this.occurrences.size(); i++) { res[i] = this.occurrences.get(i); } return res; }
[ "public", "int", "[", "]", "getOccurrences", "(", ")", "{", "int", "[", "]", "res", "=", "new", "int", "[", "this", ".", "occurrences", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "occurrences"...
Gets occurrences. @return all rule's occurrences.
[ "Gets", "occurrences", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/repair/RePairRule.java#L148-L154
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/cachekeygenerator/KeyGenUtil.java
KeyGenUtil.isProvisional
static public boolean isProvisional(Iterable<ICacheKeyGenerator> keyGens) { boolean provisional = false; for (ICacheKeyGenerator keyGen : keyGens) { if (keyGen.isProvisional()) { provisional = true; break; } } return provisional; }
java
static public boolean isProvisional(Iterable<ICacheKeyGenerator> keyGens) { boolean provisional = false; for (ICacheKeyGenerator keyGen : keyGens) { if (keyGen.isProvisional()) { provisional = true; break; } } return provisional; }
[ "static", "public", "boolean", "isProvisional", "(", "Iterable", "<", "ICacheKeyGenerator", ">", "keyGens", ")", "{", "boolean", "provisional", "=", "false", ";", "for", "(", "ICacheKeyGenerator", "keyGen", ":", "keyGens", ")", "{", "if", "(", "keyGen", ".", ...
Return true if any of the cache key generators in the array is a provisional cache key generator. @param keyGens The array @return True if there is a provisional cache key generator in the array
[ "Return", "true", "if", "any", "of", "the", "cache", "key", "generators", "in", "the", "array", "is", "a", "provisional", "cache", "key", "generator", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/cachekeygenerator/KeyGenUtil.java#L39-L48
train
protegeproject/jpaul
src/main/java/jpaul/DataStructs/DSUtil.java
DSUtil.unionColl
public static <E> Collection<E> unionColl(Collection<E> c1, Collection<E> c2) { return new UColl<E>(c1, c2); }
java
public static <E> Collection<E> unionColl(Collection<E> c1, Collection<E> c2) { return new UColl<E>(c1, c2); }
[ "public", "static", "<", "E", ">", "Collection", "<", "E", ">", "unionColl", "(", "Collection", "<", "E", ">", "c1", ",", "Collection", "<", "E", ">", "c2", ")", "{", "return", "new", "UColl", "<", "E", ">", "(", "c1", ",", "c2", ")", ";", "}" ...
Returns the immutable union of two collections.
[ "Returns", "the", "immutable", "union", "of", "two", "collections", "." ]
db579ffb16faaa4b0c577ec82c246f7349427714
https://github.com/protegeproject/jpaul/blob/db579ffb16faaa4b0c577ec82c246f7349427714/src/main/java/jpaul/DataStructs/DSUtil.java#L185-L187
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/transport/RequestedModuleNames.java
RequestedModuleNames.unfoldModulesHelper
protected void unfoldModulesHelper(Object obj, String path, String[] aPrefixes, Map<Integer, String> modules) throws IOException, JSONException { final String sourceMethod = "unfoldModulesHelper"; //$NON-NLS-1$ if (isTraceLogging) { log.entering(RequestedModuleNames.class.getName(), sourceMethod, new Object[]{ obj, path, aPrefixes != null ? Arrays.asList(aPrefixes) : null, modules}); } if (obj instanceof JSONObject) { JSONObject jsonobj = (JSONObject)obj; Iterator<?> it = jsonobj.keySet().iterator(); while (it.hasNext()) { String key = (String)it.next(); String newpath = path + "/" + key; //$NON-NLS-1$ unfoldModulesHelper(jsonobj.get(key), newpath, aPrefixes, modules); } } else if (obj instanceof String){ String[] values = ((String)obj).split("-"); //$NON-NLS-1$ int idx = Integer.parseInt(values[0]); if (modules.get(idx) != null) { throw new BadRequestException(); } modules.put(idx, values.length > 1 ? ((aPrefixes != null ? aPrefixes[Integer.parseInt(values[1])] : values[1]) + "!" + path) : //$NON-NLS-1$ path); } else { throw new BadRequestException(); } if (isTraceLogging) { log.exiting(RequestedModuleNames.class.getName(), sourceMethod, modules); } }
java
protected void unfoldModulesHelper(Object obj, String path, String[] aPrefixes, Map<Integer, String> modules) throws IOException, JSONException { final String sourceMethod = "unfoldModulesHelper"; //$NON-NLS-1$ if (isTraceLogging) { log.entering(RequestedModuleNames.class.getName(), sourceMethod, new Object[]{ obj, path, aPrefixes != null ? Arrays.asList(aPrefixes) : null, modules}); } if (obj instanceof JSONObject) { JSONObject jsonobj = (JSONObject)obj; Iterator<?> it = jsonobj.keySet().iterator(); while (it.hasNext()) { String key = (String)it.next(); String newpath = path + "/" + key; //$NON-NLS-1$ unfoldModulesHelper(jsonobj.get(key), newpath, aPrefixes, modules); } } else if (obj instanceof String){ String[] values = ((String)obj).split("-"); //$NON-NLS-1$ int idx = Integer.parseInt(values[0]); if (modules.get(idx) != null) { throw new BadRequestException(); } modules.put(idx, values.length > 1 ? ((aPrefixes != null ? aPrefixes[Integer.parseInt(values[1])] : values[1]) + "!" + path) : //$NON-NLS-1$ path); } else { throw new BadRequestException(); } if (isTraceLogging) { log.exiting(RequestedModuleNames.class.getName(), sourceMethod, modules); } }
[ "protected", "void", "unfoldModulesHelper", "(", "Object", "obj", ",", "String", "path", ",", "String", "[", "]", "aPrefixes", ",", "Map", "<", "Integer", ",", "String", ">", "modules", ")", "throws", "IOException", ",", "JSONException", "{", "final", "Strin...
Helper routine to unfold folded module names @param obj The folded path list of names, as a string or JSON object @param path The reference path @param aPrefixes Array of loader plugin prefixes @param modules Output - the list of unfolded modlue names as a sparse array implemented using a map with integer keys @throws IOException @throws JSONException
[ "Helper", "routine", "to", "unfold", "folded", "module", "names" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/transport/RequestedModuleNames.java#L529-L562
train
protegeproject/jpaul
src/main/java/jpaul/DataStructs/MapFacts.java
MapFacts.cow
public static <K,V> MapFactory<K,V> cow(MapFactory<K,V> underMapFact) { throw new UnsupportedOperationException("Not implemented yet"); }
java
public static <K,V> MapFactory<K,V> cow(MapFactory<K,V> underMapFact) { throw new UnsupportedOperationException("Not implemented yet"); }
[ "public", "static", "<", "K", ",", "V", ">", "MapFactory", "<", "K", ",", "V", ">", "cow", "(", "MapFactory", "<", "K", ",", "V", ">", "underMapFact", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Not implemented yet\"", ")", ";", "}...
Copy-on-write maps. UNIMPLEMENTED YET.
[ "Copy", "-", "on", "-", "write", "maps", ".", "UNIMPLEMENTED", "YET", "." ]
db579ffb16faaa4b0c577ec82c246f7349427714
https://github.com/protegeproject/jpaul/blob/db579ffb16faaa4b0c577ec82c246f7349427714/src/main/java/jpaul/DataStructs/MapFacts.java#L111-L113
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.sealObject
private void sealObject(ScriptableObject obj) { obj.sealObject(); Object[] ids = obj.getIds(); for (Object id : ids) { Object child = obj.get(id); if (child instanceof ScriptableObject) { sealObject((ScriptableObject)child); } } }
java
private void sealObject(ScriptableObject obj) { obj.sealObject(); Object[] ids = obj.getIds(); for (Object id : ids) { Object child = obj.get(id); if (child instanceof ScriptableObject) { sealObject((ScriptableObject)child); } } }
[ "private", "void", "sealObject", "(", "ScriptableObject", "obj", ")", "{", "obj", ".", "sealObject", "(", ")", ";", "Object", "[", "]", "ids", "=", "obj", ".", "getIds", "(", ")", ";", "for", "(", "Object", "id", ":", "ids", ")", "{", "Object", "ch...
Recursively seals the specified object and all the objects it contains. @param obj the object to seal
[ "Recursively", "seals", "the", "specified", "object", "and", "all", "the", "objects", "it", "contains", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L147-L156
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl._resolve
protected String _resolve( String name, Features features, Set<String> dependentFeatures, boolean resolveAliases, boolean evaluateHasPluginConditionals, int recursionCount, StringBuffer sb) { final String sourceMethod = "_resolve"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(ConfigImpl.class.getName(), sourceMethod, new Object[]{name, features, dependentFeatures, resolveAliases, evaluateHasPluginConditionals, recursionCount, sb}); } String result = name; if (name != null && name.length() != 0) { if (recursionCount >= MAX_RECURSION_COUNT) { throw new IllegalStateException("Excessive recursion in resolver: " + name); //$NON-NLS-1$ } int idx = name.indexOf("!"); //$NON-NLS-1$ if (idx != -1 && HAS_PATTERN.matcher(name.substring(0, idx)).find()) { result = resolveHasPlugin(name.substring(idx+1), features, dependentFeatures, resolveAliases, evaluateHasPluginConditionals, recursionCount+1, sb); result = result.contains("?") ? (name.substring(0, idx+1) + result) : result; //$NON-NLS-1$ } else if (resolveAliases && getAliases() != null) { if (idx != -1) { // non-has plugin // If the module id specifies a plugin, then process each part individually Matcher m = plugins2.matcher(name); StringBuffer sbResult = new StringBuffer(); while (m.find()) { String replacement = _resolve(m.group(0), features, dependentFeatures, true, evaluateHasPluginConditionals, recursionCount+1, sb); m.appendReplacement(sbResult, replacement); } m.appendTail(sbResult); result = sbResult.toString(); } String candidate = resolveAliases(name, features, dependentFeatures, sb); if (candidate != null && candidate.length() > 0 && !candidate.equals(name)) { if (sb != null) { sb.append(", ").append(MessageFormat.format( //$NON-NLS-1$ Messages.ConfigImpl_6, new Object[]{name + " --> " + candidate} //$NON-NLS-1$ )); } result = _resolve(candidate, features, dependentFeatures, true, evaluateHasPluginConditionals, recursionCount+1, sb); } } } if (isTraceLogging) { log.exiting(ConfigImpl.class.getName(), sourceMethod, result); } return result; }
java
protected String _resolve( String name, Features features, Set<String> dependentFeatures, boolean resolveAliases, boolean evaluateHasPluginConditionals, int recursionCount, StringBuffer sb) { final String sourceMethod = "_resolve"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(ConfigImpl.class.getName(), sourceMethod, new Object[]{name, features, dependentFeatures, resolveAliases, evaluateHasPluginConditionals, recursionCount, sb}); } String result = name; if (name != null && name.length() != 0) { if (recursionCount >= MAX_RECURSION_COUNT) { throw new IllegalStateException("Excessive recursion in resolver: " + name); //$NON-NLS-1$ } int idx = name.indexOf("!"); //$NON-NLS-1$ if (idx != -1 && HAS_PATTERN.matcher(name.substring(0, idx)).find()) { result = resolveHasPlugin(name.substring(idx+1), features, dependentFeatures, resolveAliases, evaluateHasPluginConditionals, recursionCount+1, sb); result = result.contains("?") ? (name.substring(0, idx+1) + result) : result; //$NON-NLS-1$ } else if (resolveAliases && getAliases() != null) { if (idx != -1) { // non-has plugin // If the module id specifies a plugin, then process each part individually Matcher m = plugins2.matcher(name); StringBuffer sbResult = new StringBuffer(); while (m.find()) { String replacement = _resolve(m.group(0), features, dependentFeatures, true, evaluateHasPluginConditionals, recursionCount+1, sb); m.appendReplacement(sbResult, replacement); } m.appendTail(sbResult); result = sbResult.toString(); } String candidate = resolveAliases(name, features, dependentFeatures, sb); if (candidate != null && candidate.length() > 0 && !candidate.equals(name)) { if (sb != null) { sb.append(", ").append(MessageFormat.format( //$NON-NLS-1$ Messages.ConfigImpl_6, new Object[]{name + " --> " + candidate} //$NON-NLS-1$ )); } result = _resolve(candidate, features, dependentFeatures, true, evaluateHasPluginConditionals, recursionCount+1, sb); } } } if (isTraceLogging) { log.exiting(ConfigImpl.class.getName(), sourceMethod, result); } return result; }
[ "protected", "String", "_resolve", "(", "String", "name", ",", "Features", "features", ",", "Set", "<", "String", ">", "dependentFeatures", ",", "boolean", "resolveAliases", ",", "boolean", "evaluateHasPluginConditionals", ",", "int", "recursionCount", ",", "StringB...
Resolves a module id by applying alias resolution and has! loader plugin resolution. @param name The module name to map. May specify plugins @param features Features that are defined in the request @param dependentFeatures Output - Set of feature names that the returned value is conditioned on. Used for cache management. @param resolveAliases If true, then module name aliases will be resolved @param evaluateHasPluginConditionals If true, then attempt to evaluate the has plugin conditionals using the features provided in <code>features</code>, potentially eliminating the has! loader plugin from the returned value if all features can be resolved. If false, then the conditionals are retained in the result, although the expression may change if new conditionals are introduced by alias resolution. @param recursionCount Counter used to guard against runaway recursion @param sb If not null, then a reference to a string buffer that can be used by the resolver to indicate debug/diagnostic information about the alias resolution. For example, the resolver may indicate that alias resolution was not performed due to a missing required feature. @return The resolved module id.
[ "Resolves", "a", "module", "id", "by", "applying", "alias", "resolution", "and", "has!", "loader", "plugin", "resolution", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L744-L798
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadConfigUri
protected URI loadConfigUri() throws URISyntaxException, FileNotFoundException { Collection<String> configNames = getAggregator().getInitParams().getValues(InitParams.CONFIG_INITPARAM); if (configNames.size() != 1) { throw new IllegalArgumentException(InitParams.CONFIG_INITPARAM); } String configName = configNames.iterator().next(); return new URI(configName); }
java
protected URI loadConfigUri() throws URISyntaxException, FileNotFoundException { Collection<String> configNames = getAggregator().getInitParams().getValues(InitParams.CONFIG_INITPARAM); if (configNames.size() != 1) { throw new IllegalArgumentException(InitParams.CONFIG_INITPARAM); } String configName = configNames.iterator().next(); return new URI(configName); }
[ "protected", "URI", "loadConfigUri", "(", ")", "throws", "URISyntaxException", ",", "FileNotFoundException", "{", "Collection", "<", "String", ">", "configNames", "=", "getAggregator", "(", ")", ".", "getInitParams", "(", ")", ".", "getValues", "(", "InitParams", ...
Initializes and returns the URI to the server-side config JavaScript @return The config URI @throws URISyntaxException @throws FileNotFoundException
[ "Initializes", "and", "returns", "the", "URI", "to", "the", "server", "-", "side", "config", "JavaScript" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L903-L910
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadBaseURI
protected Location loadBaseURI(Scriptable cfg) throws URISyntaxException { Object baseObj = cfg.get(BASEURL_CONFIGPARAM, cfg); Location result; if (baseObj == Scriptable.NOT_FOUND) { result = new Location(getConfigUri().resolve(".")); //$NON-NLS-1$ } else { Location loc = loadLocation(baseObj, true); Location configLoc = new Location(getConfigUri(), loc.getOverride() != null ? getConfigUri() : null); result = configLoc.resolve(loc); } return result; }
java
protected Location loadBaseURI(Scriptable cfg) throws URISyntaxException { Object baseObj = cfg.get(BASEURL_CONFIGPARAM, cfg); Location result; if (baseObj == Scriptable.NOT_FOUND) { result = new Location(getConfigUri().resolve(".")); //$NON-NLS-1$ } else { Location loc = loadLocation(baseObj, true); Location configLoc = new Location(getConfigUri(), loc.getOverride() != null ? getConfigUri() : null); result = configLoc.resolve(loc); } return result; }
[ "protected", "Location", "loadBaseURI", "(", "Scriptable", "cfg", ")", "throws", "URISyntaxException", "{", "Object", "baseObj", "=", "cfg", ".", "get", "(", "BASEURL_CONFIGPARAM", ",", "cfg", ")", ";", "Location", "result", ";", "if", "(", "baseObj", "==", ...
Initializes and returns the base URI specified by the "baseUrl" property in the server-side config JavaScript @param cfg the parsed config JavaScript @return the base URI @throws URISyntaxException
[ "Initializes", "and", "returns", "the", "base", "URI", "specified", "by", "the", "baseUrl", "property", "in", "the", "server", "-", "side", "config", "JavaScript" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L921-L932
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadConfig
protected Scriptable loadConfig(String configScript) throws IOException { configScript = processConfig(configScript); Context cx = Context.enter(); Scriptable config; try { sharedScope = cx.initStandardObjects(null, true); // set up options object IOptions options = aggregator.getOptions(); if (options != null) { optionsUpdated(options, 1); } // set up init params object InitParams initParams = aggregator.getInitParams(); if (initParams != null) { Scriptable jsInitParams = cx.newObject(sharedScope); Collection<String> names = initParams.getNames(); for (String name : names) { Collection<String> values = initParams.getValues(name); Object value = Context.javaToJS(values.toArray(new String[values.size()]), sharedScope); ScriptableObject.putProperty(jsInitParams, name, value); } ScriptableObject.putProperty(sharedScope, "initParams", jsInitParams); //$NON-NLS-1$ } // set up bundle manifest headers property if ( aggregator.getPlatformServices() != null) { if( aggregator.getPlatformServices().getHeaders() != null){ Dictionary<String, String> headers = (Dictionary<String, String>)( aggregator.getPlatformServices().getHeaders()); Scriptable jsHeaders = cx.newObject(sharedScope); Enumeration<String> keys = headers.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); Object value = Context.javaToJS(headers.get(key), sharedScope); ScriptableObject.putProperty(jsHeaders, key, value); } ScriptableObject.putProperty(sharedScope, "headers", jsHeaders); //$NON-NLS-1$ } } // set up console object Console console = newConsole(); Object jsConsole = Context.javaToJS(console, sharedScope); ScriptableObject.putProperty(sharedScope, "console", jsConsole); //$NON-NLS-1$ GetPropertyFunction getPropertyFn = newGetPropertyFunction(sharedScope, aggregator); ScriptableObject.putProperty(sharedScope, "getProperty", getPropertyFn); //$NON-NLS-1$ // Call the registered scope modifiers callConfigScopeModifiers(sharedScope); cx.evaluateString(sharedScope, "var config = " + //$NON-NLS-1$ aggregator.substituteProps(configScript, new IAggregator.SubstitutionTransformer() { @Override public String transform(String name, String value) { // escape forward slashes for javascript literals return value.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$ } }), getConfigUri().toString(), 1, null); config = (Scriptable)sharedScope.get("config", sharedScope); //$NON-NLS-1$ if (config == Scriptable.NOT_FOUND) { throw new IllegalStateException("config is not defined."); //$NON-NLS-1$ } } finally { Context.exit(); } return config; }
java
protected Scriptable loadConfig(String configScript) throws IOException { configScript = processConfig(configScript); Context cx = Context.enter(); Scriptable config; try { sharedScope = cx.initStandardObjects(null, true); // set up options object IOptions options = aggregator.getOptions(); if (options != null) { optionsUpdated(options, 1); } // set up init params object InitParams initParams = aggregator.getInitParams(); if (initParams != null) { Scriptable jsInitParams = cx.newObject(sharedScope); Collection<String> names = initParams.getNames(); for (String name : names) { Collection<String> values = initParams.getValues(name); Object value = Context.javaToJS(values.toArray(new String[values.size()]), sharedScope); ScriptableObject.putProperty(jsInitParams, name, value); } ScriptableObject.putProperty(sharedScope, "initParams", jsInitParams); //$NON-NLS-1$ } // set up bundle manifest headers property if ( aggregator.getPlatformServices() != null) { if( aggregator.getPlatformServices().getHeaders() != null){ Dictionary<String, String> headers = (Dictionary<String, String>)( aggregator.getPlatformServices().getHeaders()); Scriptable jsHeaders = cx.newObject(sharedScope); Enumeration<String> keys = headers.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); Object value = Context.javaToJS(headers.get(key), sharedScope); ScriptableObject.putProperty(jsHeaders, key, value); } ScriptableObject.putProperty(sharedScope, "headers", jsHeaders); //$NON-NLS-1$ } } // set up console object Console console = newConsole(); Object jsConsole = Context.javaToJS(console, sharedScope); ScriptableObject.putProperty(sharedScope, "console", jsConsole); //$NON-NLS-1$ GetPropertyFunction getPropertyFn = newGetPropertyFunction(sharedScope, aggregator); ScriptableObject.putProperty(sharedScope, "getProperty", getPropertyFn); //$NON-NLS-1$ // Call the registered scope modifiers callConfigScopeModifiers(sharedScope); cx.evaluateString(sharedScope, "var config = " + //$NON-NLS-1$ aggregator.substituteProps(configScript, new IAggregator.SubstitutionTransformer() { @Override public String transform(String name, String value) { // escape forward slashes for javascript literals return value.replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$ } }), getConfigUri().toString(), 1, null); config = (Scriptable)sharedScope.get("config", sharedScope); //$NON-NLS-1$ if (config == Scriptable.NOT_FOUND) { throw new IllegalStateException("config is not defined."); //$NON-NLS-1$ } } finally { Context.exit(); } return config; }
[ "protected", "Scriptable", "loadConfig", "(", "String", "configScript", ")", "throws", "IOException", "{", "configScript", "=", "processConfig", "(", "configScript", ")", ";", "Context", "cx", "=", "Context", ".", "enter", "(", ")", ";", "Scriptable", "config", ...
Loads the config JavaScript and returns the parsed config in a Map @param configScript The javascript config as a text string @return the parsed config in a properties map @throws IOException
[ "Loads", "the", "config", "JavaScript", "and", "returns", "the", "parsed", "config", "in", "a", "Map" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L960-L1026
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadPackages
protected Map<String, IPackage> loadPackages(Scriptable cfg) throws URISyntaxException { Object obj = cfg.get(PACKAGES_CONFIGPARAM, cfg); Map<String, IPackage> packages = new HashMap<String, IPackage>(); if (obj instanceof Scriptable) { for (Object id : ((Scriptable)obj).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object pkg = ((Scriptable)obj).get((Integer)i, (Scriptable)obj); IPackage p = newPackage(pkg); if (!packages.containsKey(p.getName())) { packages.put(p.getName(), p); } } } } return packages; }
java
protected Map<String, IPackage> loadPackages(Scriptable cfg) throws URISyntaxException { Object obj = cfg.get(PACKAGES_CONFIGPARAM, cfg); Map<String, IPackage> packages = new HashMap<String, IPackage>(); if (obj instanceof Scriptable) { for (Object id : ((Scriptable)obj).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object pkg = ((Scriptable)obj).get((Integer)i, (Scriptable)obj); IPackage p = newPackage(pkg); if (!packages.containsKey(p.getName())) { packages.put(p.getName(), p); } } } } return packages; }
[ "protected", "Map", "<", "String", ",", "IPackage", ">", "loadPackages", "(", "Scriptable", "cfg", ")", "throws", "URISyntaxException", "{", "Object", "obj", "=", "cfg", ".", "get", "(", "PACKAGES_CONFIGPARAM", ",", "cfg", ")", ";", "Map", "<", "String", "...
Initializes and returns the map of packages based on the information in the server-side config JavaScript @param cfg The parsed config JavaScript as a properties map @return the package map @throws URISyntaxException
[ "Initializes", "and", "returns", "the", "map", "of", "packages", "based", "on", "the", "information", "in", "the", "server", "-", "side", "config", "JavaScript" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1037-L1053
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadPaths
protected Map<String, Location> loadPaths(Scriptable cfg) throws URISyntaxException { Object pathlocs = cfg.get(PATHS_CONFIGPARAM, cfg); Map<String, Location> paths = new HashMap<String, Location>(); if (pathlocs instanceof Scriptable) { for (Object key : ((Scriptable)pathlocs).getIds()) { String name = toString(key); if (!paths.containsKey(name) && key instanceof String) { Location location = loadLocation(((Scriptable)pathlocs).get(name, (Scriptable)pathlocs), false); paths.put(name, getBase().resolve(location)); } } } return paths; }
java
protected Map<String, Location> loadPaths(Scriptable cfg) throws URISyntaxException { Object pathlocs = cfg.get(PATHS_CONFIGPARAM, cfg); Map<String, Location> paths = new HashMap<String, Location>(); if (pathlocs instanceof Scriptable) { for (Object key : ((Scriptable)pathlocs).getIds()) { String name = toString(key); if (!paths.containsKey(name) && key instanceof String) { Location location = loadLocation(((Scriptable)pathlocs).get(name, (Scriptable)pathlocs), false); paths.put(name, getBase().resolve(location)); } } } return paths; }
[ "protected", "Map", "<", "String", ",", "Location", ">", "loadPaths", "(", "Scriptable", "cfg", ")", "throws", "URISyntaxException", "{", "Object", "pathlocs", "=", "cfg", ".", "get", "(", "PATHS_CONFIGPARAM", ",", "cfg", ")", ";", "Map", "<", "String", ",...
Initializes and returns the map of paths based on the information in the server-side config JavaScript @param cfg The parsed config JavaScript as a properties map @return the map of path-name/path-URI pairs @throws URISyntaxException
[ "Initializes", "and", "returns", "the", "map", "of", "paths", "based", "on", "the", "information", "in", "the", "server", "-", "side", "config", "JavaScript" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1064-L1078
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadAliases
protected List<IAlias> loadAliases(Scriptable cfg) throws IOException { Object aliasList = cfg.get(ALIASES_CONFIGPARAM, cfg); List<IAlias> aliases = new LinkedList<IAlias>(); if (aliasList instanceof Scriptable) { for (Object id : ((Scriptable)aliasList).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object entry = ((Scriptable)aliasList).get((Integer)i, (Scriptable)aliasList); if (entry instanceof Scriptable) { Scriptable vec = (Scriptable)entry; Object pattern = vec.get(0, vec); Object replacement = vec.get(1, vec); if (pattern == Scriptable.NOT_FOUND || replacement == Scriptable.NOT_FOUND) { throw new IllegalArgumentException(toString(entry)); } if (pattern instanceof Scriptable && "RegExp".equals(((Scriptable)pattern).getClassName())) { //$NON-NLS-1$ String regexlit = toString(pattern); String regex = regexlit.substring(1, regexlit.lastIndexOf("/")); //$NON-NLS-1$ String flags = regexlit.substring(regexlit.lastIndexOf("/")+1); //$NON-NLS-1$ int options = 0; if (flags.contains("i")) { //$NON-NLS-1$ options |= Pattern.CASE_INSENSITIVE; } pattern = Pattern.compile(regex, options); } else { pattern = toString(pattern); } if (!(replacement instanceof Scriptable) || !"Function".equals(((Scriptable)replacement).getClassName())) { //$NON-NLS-1$ replacement = toString(replacement); } aliases.add(newAlias(pattern, replacement)); } else { throw new IllegalArgumentException(Context.toString(ALIASES_CONFIGPARAM + "[" + i + "] = " + Context.toString(entry))); //$NON-NLS-1$ //$NON-NLS-2$ } } else { throw new IllegalArgumentException("Unrecognized type for " + ALIASES_CONFIGPARAM + " - " + aliasList.getClass().toString()); //$NON-NLS-1$ //$NON-NLS-2$ } } } return aliases; }
java
protected List<IAlias> loadAliases(Scriptable cfg) throws IOException { Object aliasList = cfg.get(ALIASES_CONFIGPARAM, cfg); List<IAlias> aliases = new LinkedList<IAlias>(); if (aliasList instanceof Scriptable) { for (Object id : ((Scriptable)aliasList).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object entry = ((Scriptable)aliasList).get((Integer)i, (Scriptable)aliasList); if (entry instanceof Scriptable) { Scriptable vec = (Scriptable)entry; Object pattern = vec.get(0, vec); Object replacement = vec.get(1, vec); if (pattern == Scriptable.NOT_FOUND || replacement == Scriptable.NOT_FOUND) { throw new IllegalArgumentException(toString(entry)); } if (pattern instanceof Scriptable && "RegExp".equals(((Scriptable)pattern).getClassName())) { //$NON-NLS-1$ String regexlit = toString(pattern); String regex = regexlit.substring(1, regexlit.lastIndexOf("/")); //$NON-NLS-1$ String flags = regexlit.substring(regexlit.lastIndexOf("/")+1); //$NON-NLS-1$ int options = 0; if (flags.contains("i")) { //$NON-NLS-1$ options |= Pattern.CASE_INSENSITIVE; } pattern = Pattern.compile(regex, options); } else { pattern = toString(pattern); } if (!(replacement instanceof Scriptable) || !"Function".equals(((Scriptable)replacement).getClassName())) { //$NON-NLS-1$ replacement = toString(replacement); } aliases.add(newAlias(pattern, replacement)); } else { throw new IllegalArgumentException(Context.toString(ALIASES_CONFIGPARAM + "[" + i + "] = " + Context.toString(entry))); //$NON-NLS-1$ //$NON-NLS-2$ } } else { throw new IllegalArgumentException("Unrecognized type for " + ALIASES_CONFIGPARAM + " - " + aliasList.getClass().toString()); //$NON-NLS-1$ //$NON-NLS-2$ } } } return aliases; }
[ "protected", "List", "<", "IAlias", ">", "loadAliases", "(", "Scriptable", "cfg", ")", "throws", "IOException", "{", "Object", "aliasList", "=", "cfg", ".", "get", "(", "ALIASES_CONFIGPARAM", ",", "cfg", ")", ";", "List", "<", "IAlias", ">", "aliases", "="...
Initializes and returns the list of aliases defined in the server-side config JavaScript @param cfg The parsed config JavaScript as a properties map @return the list of aliases @throws IOException
[ "Initializes", "and", "returns", "the", "list", "of", "aliases", "defined", "in", "the", "server", "-", "side", "config", "JavaScript" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1089-L1129
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadDeps
protected List<String> loadDeps(Scriptable cfg) { final String methodName = "loadDeps"; //$NON-NLS-1$ Object depsList = cfg.get(DEPS_CONFIGPARAM, cfg); List<String> deps = new LinkedList<String>(); if (depsList instanceof Scriptable) { for (Object id : ((Scriptable)depsList).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object entry = ((Scriptable)depsList).get((Integer)i, (Scriptable)depsList); deps.add(toString(entry)); } } log.logp(Level.WARNING, ConfigImpl.class.getName(), methodName, Messages.ConfigImpl_0); } return deps; }
java
protected List<String> loadDeps(Scriptable cfg) { final String methodName = "loadDeps"; //$NON-NLS-1$ Object depsList = cfg.get(DEPS_CONFIGPARAM, cfg); List<String> deps = new LinkedList<String>(); if (depsList instanceof Scriptable) { for (Object id : ((Scriptable)depsList).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object entry = ((Scriptable)depsList).get((Integer)i, (Scriptable)depsList); deps.add(toString(entry)); } } log.logp(Level.WARNING, ConfigImpl.class.getName(), methodName, Messages.ConfigImpl_0); } return deps; }
[ "protected", "List", "<", "String", ">", "loadDeps", "(", "Scriptable", "cfg", ")", "{", "final", "String", "methodName", "=", "\"loadDeps\"", ";", "//$NON-NLS-1$\r", "Object", "depsList", "=", "cfg", ".", "get", "(", "DEPS_CONFIGPARAM", ",", "cfg", ")", ";"...
Initializes and returns the list of module dependencies specified in the server-side config JavaScript. @param cfg The parsed config JavaScript as a properties map @return the list of module dependencies
[ "Initializes", "and", "returns", "the", "list", "of", "module", "dependencies", "specified", "in", "the", "server", "-", "side", "config", "JavaScript", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1139-L1154
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadExpires
protected int loadExpires(Scriptable cfg) { int expires = 0; Object oExpires = cfg.get(EXPIRES_CONFIGPARAM, cfg); if (oExpires != Scriptable.NOT_FOUND) { try { expires = Integer.parseInt(toString(oExpires)); } catch (NumberFormatException ignore) { throw new IllegalArgumentException(EXPIRES_CONFIGPARAM+"="+oExpires); //$NON-NLS-1$ } } return expires; }
java
protected int loadExpires(Scriptable cfg) { int expires = 0; Object oExpires = cfg.get(EXPIRES_CONFIGPARAM, cfg); if (oExpires != Scriptable.NOT_FOUND) { try { expires = Integer.parseInt(toString(oExpires)); } catch (NumberFormatException ignore) { throw new IllegalArgumentException(EXPIRES_CONFIGPARAM+"="+oExpires); //$NON-NLS-1$ } } return expires; }
[ "protected", "int", "loadExpires", "(", "Scriptable", "cfg", ")", "{", "int", "expires", "=", "0", ";", "Object", "oExpires", "=", "cfg", ".", "get", "(", "EXPIRES_CONFIGPARAM", ",", "cfg", ")", ";", "if", "(", "oExpires", "!=", "Scriptable", ".", "NOT_F...
Initializes and returns the expires time from the server-side config JavaScript @param cfg The parsed config JavaScript as a properties map @return the expires time
[ "Initializes", "and", "returns", "the", "expires", "time", "from", "the", "server", "-", "side", "config", "JavaScript" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1164-L1175
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadDepsIncludeBaseUrl
protected boolean loadDepsIncludeBaseUrl(Scriptable cfg) { boolean result = false; Object value = cfg.get(DEPSINCLUDEBASEURL_CONFIGPARAM, cfg); if (value != Scriptable.NOT_FOUND) { result = TypeUtil.asBoolean(toString(value), false); } return result; }
java
protected boolean loadDepsIncludeBaseUrl(Scriptable cfg) { boolean result = false; Object value = cfg.get(DEPSINCLUDEBASEURL_CONFIGPARAM, cfg); if (value != Scriptable.NOT_FOUND) { result = TypeUtil.asBoolean(toString(value), false); } return result; }
[ "protected", "boolean", "loadDepsIncludeBaseUrl", "(", "Scriptable", "cfg", ")", "{", "boolean", "result", "=", "false", ";", "Object", "value", "=", "cfg", ".", "get", "(", "DEPSINCLUDEBASEURL_CONFIGPARAM", ",", "cfg", ")", ";", "if", "(", "value", "!=", "S...
Initializes and returns the flag indicating if files and directories located under the base directory should be scanned for javascript files when building the module dependency mappings. The default is false. @param cfg The parsed config JavaScript as a properties map @return true if files and folder under the base directory should be scanned
[ "Initializes", "and", "returns", "the", "flag", "indicating", "if", "files", "and", "directories", "located", "under", "the", "base", "directory", "should", "be", "scanned", "for", "javascript", "files", "when", "building", "the", "module", "dependency", "mappings...
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1187-L1194
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadCoerceUndefinedToFalse
protected boolean loadCoerceUndefinedToFalse(Scriptable cfg) { boolean result = false; Object value = cfg.get(COERCEUNDEFINEDTOFALSE_CONFIGPARAM, cfg); if (value != Scriptable.NOT_FOUND) { result = TypeUtil.asBoolean(toString(value), false); } return result; }
java
protected boolean loadCoerceUndefinedToFalse(Scriptable cfg) { boolean result = false; Object value = cfg.get(COERCEUNDEFINEDTOFALSE_CONFIGPARAM, cfg); if (value != Scriptable.NOT_FOUND) { result = TypeUtil.asBoolean(toString(value), false); } return result; }
[ "protected", "boolean", "loadCoerceUndefinedToFalse", "(", "Scriptable", "cfg", ")", "{", "boolean", "result", "=", "false", ";", "Object", "value", "=", "cfg", ".", "get", "(", "COERCEUNDEFINEDTOFALSE_CONFIGPARAM", ",", "cfg", ")", ";", "if", "(", "value", "!...
Initializes and returns the flag indicating if features not specified in the feature set from the request should be treated as false when evaluating has conditionals in javascript code. The default is false. @param cfg The parsed config JavaScript as a properties map @return True if un-specified features should be treated as false.
[ "Initializes", "and", "returns", "the", "flag", "indicating", "if", "features", "not", "specified", "in", "the", "feature", "set", "from", "the", "request", "should", "be", "treated", "as", "false", "when", "evaluating", "has", "conditionals", "in", "javascript"...
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1205-L1212
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.loadPluginDelegators
protected Set<String> loadPluginDelegators(Scriptable cfg, String name) { Set<String> result = null; Object delegators = cfg.get(name, cfg); if (delegators != Scriptable.NOT_FOUND && delegators instanceof Scriptable) { result = new HashSet<String>(); for (Object id : ((Scriptable)delegators).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object entry = ((Scriptable)delegators).get((Integer)i, (Scriptable)delegators); result.add(entry.toString()); } } result = Collections.unmodifiableSet(result); } else { result = Collections.emptySet(); } return result; }
java
protected Set<String> loadPluginDelegators(Scriptable cfg, String name) { Set<String> result = null; Object delegators = cfg.get(name, cfg); if (delegators != Scriptable.NOT_FOUND && delegators instanceof Scriptable) { result = new HashSet<String>(); for (Object id : ((Scriptable)delegators).getIds()) { if (id instanceof Number) { Number i = (Number)id; Object entry = ((Scriptable)delegators).get((Integer)i, (Scriptable)delegators); result.add(entry.toString()); } } result = Collections.unmodifiableSet(result); } else { result = Collections.emptySet(); } return result; }
[ "protected", "Set", "<", "String", ">", "loadPluginDelegators", "(", "Scriptable", "cfg", ",", "String", "name", ")", "{", "Set", "<", "String", ">", "result", "=", "null", ";", "Object", "delegators", "=", "cfg", ".", "get", "(", "name", ",", "cfg", "...
Common routine to load text or js plugin delegators @param cfg the config object as a {@link Scriptable} @param name the name of the plugin delegator selector @return the set of plugin delegators for the selector
[ "Common", "routine", "to", "load", "text", "or", "js", "plugin", "delegators" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1257-L1274
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.callConfigModifiers
protected void callConfigModifiers(Scriptable rawConfig) { if( aggregator.getPlatformServices() != null){ IServiceReference[] refs = null; try { refs = aggregator.getPlatformServices().getServiceReferences(IConfigModifier.class.getName(), "(name="+getAggregator().getName()+")"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } if (refs != null) { for (IServiceReference ref : refs) { IConfigModifier modifier = (IConfigModifier) aggregator.getPlatformServices().getService(ref); if (modifier != null) { try { modifier.modifyConfig(getAggregator(), rawConfig); } catch (Exception e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } finally { aggregator.getPlatformServices().ungetService(ref); } } } } } }
java
protected void callConfigModifiers(Scriptable rawConfig) { if( aggregator.getPlatformServices() != null){ IServiceReference[] refs = null; try { refs = aggregator.getPlatformServices().getServiceReferences(IConfigModifier.class.getName(), "(name="+getAggregator().getName()+")"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } if (refs != null) { for (IServiceReference ref : refs) { IConfigModifier modifier = (IConfigModifier) aggregator.getPlatformServices().getService(ref); if (modifier != null) { try { modifier.modifyConfig(getAggregator(), rawConfig); } catch (Exception e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } finally { aggregator.getPlatformServices().ungetService(ref); } } } } } }
[ "protected", "void", "callConfigModifiers", "(", "Scriptable", "rawConfig", ")", "{", "if", "(", "aggregator", ".", "getPlatformServices", "(", ")", "!=", "null", ")", "{", "IServiceReference", "[", "]", "refs", "=", "null", ";", "try", "{", "refs", "=", "...
Calls the registered config modifiers to give them an opportunity to modify the raw config before config properties are evaluated. @param rawConfig The config object as a {@link Scriptable}.
[ "Calls", "the", "registered", "config", "modifiers", "to", "give", "them", "an", "opportunity", "to", "modify", "the", "raw", "config", "before", "config", "properties", "are", "evaluated", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1366-L1395
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java
ConfigImpl.callConfigScopeModifiers
protected void callConfigScopeModifiers(Scriptable scope) { if( aggregator.getPlatformServices() != null){ IServiceReference[] refs = null; try { refs = aggregator.getPlatformServices().getServiceReferences(IConfigScopeModifier.class.getName(), "(name="+getAggregator().getName()+")"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } if (refs != null) { for (IServiceReference ref : refs) { IConfigScopeModifier adaptor = (IConfigScopeModifier) aggregator.getPlatformServices().getService(ref); if (adaptor != null) { try { adaptor.modifyScope(getAggregator(), scope); } catch (Exception e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } finally { aggregator.getPlatformServices().ungetService(ref); } } } } } }
java
protected void callConfigScopeModifiers(Scriptable scope) { if( aggregator.getPlatformServices() != null){ IServiceReference[] refs = null; try { refs = aggregator.getPlatformServices().getServiceReferences(IConfigScopeModifier.class.getName(), "(name="+getAggregator().getName()+")"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } if (refs != null) { for (IServiceReference ref : refs) { IConfigScopeModifier adaptor = (IConfigScopeModifier) aggregator.getPlatformServices().getService(ref); if (adaptor != null) { try { adaptor.modifyScope(getAggregator(), scope); } catch (Exception e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } finally { aggregator.getPlatformServices().ungetService(ref); } } } } } }
[ "protected", "void", "callConfigScopeModifiers", "(", "Scriptable", "scope", ")", "{", "if", "(", "aggregator", ".", "getPlatformServices", "(", ")", "!=", "null", ")", "{", "IServiceReference", "[", "]", "refs", "=", "null", ";", "try", "{", "refs", "=", ...
Calls the registered config scope modifiers to give them an opportunity to prepare the scope object prior to evaluating the config JavaScript @param scope The object representing the execution scope for the evaluation.
[ "Calls", "the", "registered", "config", "scope", "modifiers", "to", "give", "them", "an", "opportunity", "to", "prepare", "the", "scope", "object", "prior", "to", "evaluating", "the", "config", "JavaScript" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/config/ConfigImpl.java#L1404-L1433
train
smallnest/fastjson-jaxrs-json-provider
src/main/java/com/colobu/fastjson/FastJsonProvider.java
FastJsonProvider.isValidType
protected boolean isValidType(Class<?> type, Annotation[] classAnnotations) { if (type == null) return false; if (annotated) { return checkAnnotation(type); } else if (scanpackages != null) { String classPackage = type.getPackage().getName(); for (String pkg : scanpackages) { if (classPackage.startsWith(pkg)) { if (annotated) { return checkAnnotation(type); } else return true; } } return false; } else if (clazzes != null) { for (Class<?> cls : clazzes) { // must strictly equal. Don't check // inheritance if (cls == type) return true; } return false; } return true; }
java
protected boolean isValidType(Class<?> type, Annotation[] classAnnotations) { if (type == null) return false; if (annotated) { return checkAnnotation(type); } else if (scanpackages != null) { String classPackage = type.getPackage().getName(); for (String pkg : scanpackages) { if (classPackage.startsWith(pkg)) { if (annotated) { return checkAnnotation(type); } else return true; } } return false; } else if (clazzes != null) { for (Class<?> cls : clazzes) { // must strictly equal. Don't check // inheritance if (cls == type) return true; } return false; } return true; }
[ "protected", "boolean", "isValidType", "(", "Class", "<", "?", ">", "type", ",", "Annotation", "[", "]", "classAnnotations", ")", "{", "if", "(", "type", "==", "null", ")", "return", "false", ";", "if", "(", "annotated", ")", "{", "return", "checkAnnotat...
Check whether a class can be serialized or deserialized. It can check based on packages, annotations on entities or explicit classes. @param type class need to check @return true if valid
[ "Check", "whether", "a", "class", "can", "be", "serialized", "or", "deserialized", ".", "It", "can", "check", "based", "on", "packages", "annotations", "on", "entities", "or", "explicit", "classes", "." ]
bbdb2e3d101069bf62c026976ff9d00967671ec0
https://github.com/smallnest/fastjson-jaxrs-json-provider/blob/bbdb2e3d101069bf62c026976ff9d00967671ec0/src/main/java/com/colobu/fastjson/FastJsonProvider.java#L96-L126
train
smallnest/fastjson-jaxrs-json-provider
src/main/java/com/colobu/fastjson/FastJsonProvider.java
FastJsonProvider.writeTo
public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { SerializeFilter filter = null; if(pretty) { if (fastJsonConfig.serializerFeatures == null) fastJsonConfig.serializerFeatures = new SerializerFeature[]{SerializerFeature.PrettyFormat}; else { List<SerializerFeature> serializerFeatures = Arrays.asList(fastJsonConfig.serializerFeatures); serializerFeatures.add(SerializerFeature.PrettyFormat); fastJsonConfig.serializerFeatures = serializerFeatures.toArray(new SerializerFeature[]{}); } } if (fastJsonConfig.serializeFilters != null) filter = fastJsonConfig.serializeFilters.get(type); String jsonStr = toJSONString(t, filter, fastJsonConfig.serializerFeatures); if (jsonStr != null) entityStream.write(jsonStr.getBytes()); }
java
public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { SerializeFilter filter = null; if(pretty) { if (fastJsonConfig.serializerFeatures == null) fastJsonConfig.serializerFeatures = new SerializerFeature[]{SerializerFeature.PrettyFormat}; else { List<SerializerFeature> serializerFeatures = Arrays.asList(fastJsonConfig.serializerFeatures); serializerFeatures.add(SerializerFeature.PrettyFormat); fastJsonConfig.serializerFeatures = serializerFeatures.toArray(new SerializerFeature[]{}); } } if (fastJsonConfig.serializeFilters != null) filter = fastJsonConfig.serializeFilters.get(type); String jsonStr = toJSONString(t, filter, fastJsonConfig.serializerFeatures); if (jsonStr != null) entityStream.write(jsonStr.getBytes()); }
[ "public", "void", "writeTo", "(", "Object", "t", ",", "Class", "<", "?", ">", "type", ",", "Type", "genericType", ",", "Annotation", "[", "]", "annotations", ",", "MediaType", "mediaType", ",", "MultivaluedMap", "<", "String", ",", "Object", ">", "httpHead...
Method that JAX-RS container calls to serialize given value.
[ "Method", "that", "JAX", "-", "RS", "container", "calls", "to", "serialize", "given", "value", "." ]
bbdb2e3d101069bf62c026976ff9d00967671ec0
https://github.com/smallnest/fastjson-jaxrs-json-provider/blob/bbdb2e3d101069bf62c026976ff9d00967671ec0/src/main/java/com/colobu/fastjson/FastJsonProvider.java#L228-L247
train
smallnest/fastjson-jaxrs-json-provider
src/main/java/com/colobu/fastjson/FastJsonProvider.java
FastJsonProvider.readFrom
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { String input = null; try { input = IOUtils.inputStreamToString(entityStream); } catch (Exception e) { } if (input == null) { return null; } if (fastJsonConfig.features == null) return JSON.parseObject(input, type, fastJsonConfig.parserConfig, JSON.DEFAULT_PARSER_FEATURE); else return JSON.parseObject(input, type, fastJsonConfig.parserConfig, JSON.DEFAULT_PARSER_FEATURE, fastJsonConfig.features); }
java
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { String input = null; try { input = IOUtils.inputStreamToString(entityStream); } catch (Exception e) { } if (input == null) { return null; } if (fastJsonConfig.features == null) return JSON.parseObject(input, type, fastJsonConfig.parserConfig, JSON.DEFAULT_PARSER_FEATURE); else return JSON.parseObject(input, type, fastJsonConfig.parserConfig, JSON.DEFAULT_PARSER_FEATURE, fastJsonConfig.features); }
[ "public", "Object", "readFrom", "(", "Class", "<", "Object", ">", "type", ",", "Type", "genericType", ",", "Annotation", "[", "]", "annotations", ",", "MediaType", "mediaType", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "httpHeaders", ",", "In...
Method that JAX-RS container calls to deserialize given value.
[ "Method", "that", "JAX", "-", "RS", "container", "calls", "to", "deserialize", "given", "value", "." ]
bbdb2e3d101069bf62c026976ff9d00967671ec0
https://github.com/smallnest/fastjson-jaxrs-json-provider/blob/bbdb2e3d101069bf62c026976ff9d00967671ec0/src/main/java/com/colobu/fastjson/FastJsonProvider.java#L270-L285
train
jMotif/GI
src/main/java/net/seninp/gi/clusterrule/ClusterRuleFactory.java
ClusterRuleFactory.performPruning
public static ArrayList<SameLengthMotifs> performPruning(double[] ts, GrammarRules grammarRules, double thresholdLength, double thresholdCom, double fractionTopDist) { RuleOrganizer ro = new RuleOrganizer(); ArrayList<SameLengthMotifs> allClassifiedMotifs = ro.classifyMotifs(thresholdLength, grammarRules); allClassifiedMotifs = ro.removeOverlappingInSimiliar(allClassifiedMotifs, grammarRules, ts, thresholdCom); ArrayList<SameLengthMotifs> newAllClassifiedMotifs = ro.refinePatternsByClustering(grammarRules, ts, allClassifiedMotifs, fractionTopDist); return newAllClassifiedMotifs; }
java
public static ArrayList<SameLengthMotifs> performPruning(double[] ts, GrammarRules grammarRules, double thresholdLength, double thresholdCom, double fractionTopDist) { RuleOrganizer ro = new RuleOrganizer(); ArrayList<SameLengthMotifs> allClassifiedMotifs = ro.classifyMotifs(thresholdLength, grammarRules); allClassifiedMotifs = ro.removeOverlappingInSimiliar(allClassifiedMotifs, grammarRules, ts, thresholdCom); ArrayList<SameLengthMotifs> newAllClassifiedMotifs = ro.refinePatternsByClustering(grammarRules, ts, allClassifiedMotifs, fractionTopDist); return newAllClassifiedMotifs; }
[ "public", "static", "ArrayList", "<", "SameLengthMotifs", ">", "performPruning", "(", "double", "[", "]", "ts", ",", "GrammarRules", "grammarRules", ",", "double", "thresholdLength", ",", "double", "thresholdCom", ",", "double", "fractionTopDist", ")", "{", "RuleO...
Performs clustering. @param ts the input time series. @param grammarRules the grammar. @param thresholdLength a parameter. @param thresholdCom another parameter. @param fractionTopDist yet another parameter. @return pruned ruleset.
[ "Performs", "clustering", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/clusterrule/ClusterRuleFactory.java#L21-L36
train
jMotif/GI
src/main/java/net/seninp/gi/clusterrule/ClusterRuleFactory.java
ClusterRuleFactory.getPackedRule
public static ArrayList<PackedRuleRecord> getPackedRule( ArrayList<SameLengthMotifs> newAllClassifiedMotifs) { ArrayList<PackedRuleRecord> arrPackedRuleRecords = new ArrayList<PackedRuleRecord>(); int i = 0; for (SameLengthMotifs subsequencesInClass : newAllClassifiedMotifs) { int classIndex = i; int subsequencesNumber = subsequencesInClass.getSameLenMotifs().size(); int minLength = subsequencesInClass.getMinMotifLen(); int maxLength = subsequencesInClass.getMaxMotifLen(); PackedRuleRecord packedRuleRecord = new PackedRuleRecord(); packedRuleRecord.setClassIndex(classIndex); packedRuleRecord.setSubsequenceNumber(subsequencesNumber); packedRuleRecord.setMinLength(minLength); packedRuleRecord.setMaxLength(maxLength); arrPackedRuleRecords.add(packedRuleRecord); i++; } return arrPackedRuleRecords; }
java
public static ArrayList<PackedRuleRecord> getPackedRule( ArrayList<SameLengthMotifs> newAllClassifiedMotifs) { ArrayList<PackedRuleRecord> arrPackedRuleRecords = new ArrayList<PackedRuleRecord>(); int i = 0; for (SameLengthMotifs subsequencesInClass : newAllClassifiedMotifs) { int classIndex = i; int subsequencesNumber = subsequencesInClass.getSameLenMotifs().size(); int minLength = subsequencesInClass.getMinMotifLen(); int maxLength = subsequencesInClass.getMaxMotifLen(); PackedRuleRecord packedRuleRecord = new PackedRuleRecord(); packedRuleRecord.setClassIndex(classIndex); packedRuleRecord.setSubsequenceNumber(subsequencesNumber); packedRuleRecord.setMinLength(minLength); packedRuleRecord.setMaxLength(maxLength); arrPackedRuleRecords.add(packedRuleRecord); i++; } return arrPackedRuleRecords; }
[ "public", "static", "ArrayList", "<", "PackedRuleRecord", ">", "getPackedRule", "(", "ArrayList", "<", "SameLengthMotifs", ">", "newAllClassifiedMotifs", ")", "{", "ArrayList", "<", "PackedRuleRecord", ">", "arrPackedRuleRecords", "=", "new", "ArrayList", "<", "Packed...
Gets packed rules set. @param newAllClassifiedMotifs a parameter. @return packed rule set.
[ "Gets", "packed", "rules", "set", "." ]
381212dd4f193246a6df82bd46f0d2bcd04a68d6
https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/clusterrule/ClusterRuleFactory.java#L44-L66
train
OpenNTF/JavascriptAggregator
jaggr-service/src/main/java/com/ibm/jaggr/service/util/BundleVersionsHashBase.java
BundleVersionsHashBase.getBundleHeaders
protected Dictionary<?, ?> getBundleHeaders(String bundleName) throws NotFoundException { final String sourceMethod = "getBundleHeaders"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(BundleVersionsHashBase.class.getName(), sourceMethod, new Object[]{bundleName}); } Bundle result = ".".equals(bundleName) ? contributingBundle : bundleResolver.getBundle(bundleName); //$NON-NLS-1$ if (result == null) { throw new NotFoundException("Bundle " + bundleName + " not found."); //$NON-NLS-1$ //$NON-NLS-2$ } if (isTraceLogging) { log.exiting(BundleVersionsHashBase.class.getName(), sourceMethod, result.getHeaders()); } return result.getHeaders(); }
java
protected Dictionary<?, ?> getBundleHeaders(String bundleName) throws NotFoundException { final String sourceMethod = "getBundleHeaders"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(BundleVersionsHashBase.class.getName(), sourceMethod, new Object[]{bundleName}); } Bundle result = ".".equals(bundleName) ? contributingBundle : bundleResolver.getBundle(bundleName); //$NON-NLS-1$ if (result == null) { throw new NotFoundException("Bundle " + bundleName + " not found."); //$NON-NLS-1$ //$NON-NLS-2$ } if (isTraceLogging) { log.exiting(BundleVersionsHashBase.class.getName(), sourceMethod, result.getHeaders()); } return result.getHeaders(); }
[ "protected", "Dictionary", "<", "?", ",", "?", ">", "getBundleHeaders", "(", "String", "bundleName", ")", "throws", "NotFoundException", "{", "final", "String", "sourceMethod", "=", "\"getBundleHeaders\"", ";", "//$NON-NLS-1$\r", "boolean", "isTraceLogging", "=", "l...
Returns the bundle headers for the specified bundle. @param bundleName the bundle name @return the bundle headers for the bundle. @throws NotFoundException if no matching bundle is found.
[ "Returns", "the", "bundle", "headers", "for", "the", "specified", "bundle", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-service/src/main/java/com/ibm/jaggr/service/util/BundleVersionsHashBase.java#L86-L102
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/constraint/DefaultSatConstraintBuilder.java
DefaultSatConstraintBuilder.checkConformance
public boolean checkConformance(BtrPlaceTree t, List<BtrpOperand> ops) { //Arity error if (ops.size() != getParameters().length) { t.ignoreError("'" + pretty(ops) + "' cannot be casted to '" + getSignature() + "'"); return false; } //Type checking for (int i = 0; i < ops.size(); i++) { BtrpOperand o = ops.get(i); ConstraintParam<?> p = params[i]; if (o == IgnorableOperand.getInstance()) { return false; } if (!p.isCompatibleWith(t, o)) { t.ignoreError("'" + pretty(ops) + "' cannot be casted to '" + getSignature() + "'"); return false; } } return true; }
java
public boolean checkConformance(BtrPlaceTree t, List<BtrpOperand> ops) { //Arity error if (ops.size() != getParameters().length) { t.ignoreError("'" + pretty(ops) + "' cannot be casted to '" + getSignature() + "'"); return false; } //Type checking for (int i = 0; i < ops.size(); i++) { BtrpOperand o = ops.get(i); ConstraintParam<?> p = params[i]; if (o == IgnorableOperand.getInstance()) { return false; } if (!p.isCompatibleWith(t, o)) { t.ignoreError("'" + pretty(ops) + "' cannot be casted to '" + getSignature() + "'"); return false; } } return true; }
[ "public", "boolean", "checkConformance", "(", "BtrPlaceTree", "t", ",", "List", "<", "BtrpOperand", ">", "ops", ")", "{", "//Arity error", "if", "(", "ops", ".", "size", "(", ")", "!=", "getParameters", "(", ")", ".", "length", ")", "{", "t", ".", "ign...
Check if the provided parameters match the constraint signature @param t the constraint token @param ops the constraint arguments @return {@code true} iff the arguments match the constraint signature
[ "Check", "if", "the", "provided", "parameters", "match", "the", "constraint", "signature" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/constraint/DefaultSatConstraintBuilder.java#L98-L118
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/ScriptBuilder.java
ScriptBuilder.build
public Script build(File f) throws ScriptBuilderException { int k = f.getAbsolutePath().hashCode(); if (dates.containsKey(k) && dates.get(k) == f.lastModified() && cache.containsKey(f.getPath())) { LOGGER.debug("get '" + f.getName() + "' from the cache"); return cache.get(f.getPath()); } LOGGER.debug(f.getName() + " is built from the file"); dates.put(k, f.lastModified()); String name = f.getName(); try { Script v = build(new ANTLRFileStream(f.getAbsolutePath())); if (!name.equals(v.getlocalName() + Script.EXTENSION)) { throw new ScriptBuilderException("Script '" + v.getlocalName() + "' must be declared in a file named '" + v.getlocalName() + Script.EXTENSION); } cache.put(f.getPath(), v); return v; } catch (IOException e) { throw new ScriptBuilderException(e.getMessage(), e); } }
java
public Script build(File f) throws ScriptBuilderException { int k = f.getAbsolutePath().hashCode(); if (dates.containsKey(k) && dates.get(k) == f.lastModified() && cache.containsKey(f.getPath())) { LOGGER.debug("get '" + f.getName() + "' from the cache"); return cache.get(f.getPath()); } LOGGER.debug(f.getName() + " is built from the file"); dates.put(k, f.lastModified()); String name = f.getName(); try { Script v = build(new ANTLRFileStream(f.getAbsolutePath())); if (!name.equals(v.getlocalName() + Script.EXTENSION)) { throw new ScriptBuilderException("Script '" + v.getlocalName() + "' must be declared in a file named '" + v.getlocalName() + Script.EXTENSION); } cache.put(f.getPath(), v); return v; } catch (IOException e) { throw new ScriptBuilderException(e.getMessage(), e); } }
[ "public", "Script", "build", "(", "File", "f", ")", "throws", "ScriptBuilderException", "{", "int", "k", "=", "f", ".", "getAbsolutePath", "(", ")", ".", "hashCode", "(", ")", ";", "if", "(", "dates", ".", "containsKey", "(", "k", ")", "&&", "dates", ...
Build a script from a file. @param f the file to parse @return the resulting script @throws ScriptBuilderException if an error occurred
[ "Build", "a", "script", "from", "a", "file", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/ScriptBuilder.java#L150-L172
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/ScriptBuilder.java
ScriptBuilder.build
@SuppressWarnings("squid:S1166") //For the UnsupportedOperationException private Script build(CharStream cs) throws ScriptBuilderException { Script v = new Script(); ANTLRBtrplaceSL2Lexer lexer = new ANTLRBtrplaceSL2Lexer(cs); ErrorReporter errorReporter = errBuilder.build(v); lexer.setErrorReporter(errorReporter); CommonTokenStream tokens = new CommonTokenStream(lexer); ANTLRBtrplaceSL2Parser parser = new ANTLRBtrplaceSL2Parser(tokens); parser.setErrorReporter(errorReporter); SymbolsTable t = new SymbolsTable(); parser.setTreeAdaptor(new BtrPlaceTreeAdaptor(v, model, namingServiceNodes, namingServiceVMs, tpls, errorReporter, t, includes, catalog)); try { BtrPlaceTree tree = (BtrPlaceTree) parser.script_decl().getTree(); if (tree != null) { if (tree.token != null) { tree.go(tree); //Single instruction } else { for (int i = 0; i < tree.getChildCount(); i++) { tree.getChild(i).go(tree); } } } } catch (RecognitionException e) { throw new ScriptBuilderException(e.getMessage(), e); } catch (UnsupportedOperationException e) { //We only keep the error message errorReporter.append(0, 0, e.getMessage()); } if (!errorReporter.getErrors().isEmpty()) { throw new ScriptBuilderException(errorReporter); } return v; }
java
@SuppressWarnings("squid:S1166") //For the UnsupportedOperationException private Script build(CharStream cs) throws ScriptBuilderException { Script v = new Script(); ANTLRBtrplaceSL2Lexer lexer = new ANTLRBtrplaceSL2Lexer(cs); ErrorReporter errorReporter = errBuilder.build(v); lexer.setErrorReporter(errorReporter); CommonTokenStream tokens = new CommonTokenStream(lexer); ANTLRBtrplaceSL2Parser parser = new ANTLRBtrplaceSL2Parser(tokens); parser.setErrorReporter(errorReporter); SymbolsTable t = new SymbolsTable(); parser.setTreeAdaptor(new BtrPlaceTreeAdaptor(v, model, namingServiceNodes, namingServiceVMs, tpls, errorReporter, t, includes, catalog)); try { BtrPlaceTree tree = (BtrPlaceTree) parser.script_decl().getTree(); if (tree != null) { if (tree.token != null) { tree.go(tree); //Single instruction } else { for (int i = 0; i < tree.getChildCount(); i++) { tree.getChild(i).go(tree); } } } } catch (RecognitionException e) { throw new ScriptBuilderException(e.getMessage(), e); } catch (UnsupportedOperationException e) { //We only keep the error message errorReporter.append(0, 0, e.getMessage()); } if (!errorReporter.getErrors().isEmpty()) { throw new ScriptBuilderException(errorReporter); } return v; }
[ "@", "SuppressWarnings", "(", "\"squid:S1166\"", ")", "//For the UnsupportedOperationException", "private", "Script", "build", "(", "CharStream", "cs", ")", "throws", "ScriptBuilderException", "{", "Script", "v", "=", "new", "Script", "(", ")", ";", "ANTLRBtrplaceSL2L...
Internal method to check a script from a stream. @param cs the stream to analyze @return the built script @throws ScriptBuilderException in an error occurred while building the script
[ "Internal", "method", "to", "check", "a", "script", "from", "a", "stream", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/ScriptBuilder.java#L192-L232
train
InsightLab/graphast
core/src/main/java/br/ufc/insightlab/graphast/utils/RandomGraphGenerator.java
RandomGraphGenerator.generateRandomMMapGraph
public Graph generateRandomMMapGraph(String graphName, int size, float dens) { Graph graph = null; String dir = "graphs/MMap/" + graphName; SerializationUtils.deleteMMapGraph(dir); graph = new Graph(new MMapGraphStructure(dir)); Random rand = new Random(); for (int i = 0; i < size; i++) graph.addNode(new Node(i)); for (int i = 0; i < size; i++) { for (int j = i+1; j < size; j++) { if (rand.nextFloat() < dens) { int randomCost = Math.abs(rand.nextInt(50)) + 1; Edge e = new Edge(i, j, randomCost); e.setBidirectional(rand.nextBoolean()); graph.addEdge(e); } } } return graph; }
java
public Graph generateRandomMMapGraph(String graphName, int size, float dens) { Graph graph = null; String dir = "graphs/MMap/" + graphName; SerializationUtils.deleteMMapGraph(dir); graph = new Graph(new MMapGraphStructure(dir)); Random rand = new Random(); for (int i = 0; i < size; i++) graph.addNode(new Node(i)); for (int i = 0; i < size; i++) { for (int j = i+1; j < size; j++) { if (rand.nextFloat() < dens) { int randomCost = Math.abs(rand.nextInt(50)) + 1; Edge e = new Edge(i, j, randomCost); e.setBidirectional(rand.nextBoolean()); graph.addEdge(e); } } } return graph; }
[ "public", "Graph", "generateRandomMMapGraph", "(", "String", "graphName", ",", "int", "size", ",", "float", "dens", ")", "{", "Graph", "graph", "=", "null", ";", "String", "dir", "=", "\"graphs/MMap/\"", "+", "graphName", ";", "SerializationUtils", ".", "delet...
Create a new Graph which has the given graphName, size and dens. @param graphName the graph's name. @param size the graph's size. @param dens the graph's dens. @return the graph generated.
[ "Create", "a", "new", "Graph", "which", "has", "the", "given", "graphName", "size", "and", "dens", "." ]
b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24
https://github.com/InsightLab/graphast/blob/b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24/core/src/main/java/br/ufc/insightlab/graphast/utils/RandomGraphGenerator.java#L53-L81
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/constraint/mttr/VMPlacementUtils.java
VMPlacementUtils.makePlacementMap
public static Map<IntVar, VM> makePlacementMap(ReconfigurationProblem rp) { Map<IntVar, VM> m = new HashMap<>(rp.getFutureRunningVMs().size()); for (VM vm : rp.getFutureRunningVMs()) { IntVar v = rp.getVMAction(vm).getDSlice().getHoster(); m.put(v, vm); } return m; }
java
public static Map<IntVar, VM> makePlacementMap(ReconfigurationProblem rp) { Map<IntVar, VM> m = new HashMap<>(rp.getFutureRunningVMs().size()); for (VM vm : rp.getFutureRunningVMs()) { IntVar v = rp.getVMAction(vm).getDSlice().getHoster(); m.put(v, vm); } return m; }
[ "public", "static", "Map", "<", "IntVar", ",", "VM", ">", "makePlacementMap", "(", "ReconfigurationProblem", "rp", ")", "{", "Map", "<", "IntVar", ",", "VM", ">", "m", "=", "new", "HashMap", "<>", "(", "rp", ".", "getFutureRunningVMs", "(", ")", ".", "...
Map a map where keys are the placement variable of the future-running VMs and values are the VM identifier. @param rp the problem @return the resulting map.
[ "Map", "a", "map", "where", "keys", "are", "the", "placement", "variable", "of", "the", "future", "-", "running", "VMs", "and", "values", "are", "the", "VM", "identifier", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/constraint/mttr/VMPlacementUtils.java#L47-L54
train
m-m-m/util
contenttype/src/main/java/net/sf/mmm/util/contenttype/base/format/Segment.java
Segment.validate
public final void validate(StringBuilder source) { int length = source.length(); source.append('/'); source.append(getSourceIdentifier()); doValidate(source); // reset source for recursive invocation... source.setLength(length); }
java
public final void validate(StringBuilder source) { int length = source.length(); source.append('/'); source.append(getSourceIdentifier()); doValidate(source); // reset source for recursive invocation... source.setLength(length); }
[ "public", "final", "void", "validate", "(", "StringBuilder", "source", ")", "{", "int", "length", "=", "source", ".", "length", "(", ")", ";", "source", ".", "append", "(", "'", "'", ")", ";", "source", ".", "append", "(", "getSourceIdentifier", "(", "...
This method validates this segment recursively to ensure the correctness of the configured format. @param source describes the source of the validation.
[ "This", "method", "validates", "this", "segment", "recursively", "to", "ensure", "the", "correctness", "of", "the", "configured", "format", "." ]
f0e4e084448f8dfc83ca682a9e1618034a094ce6
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/contenttype/src/main/java/net/sf/mmm/util/contenttype/base/format/Segment.java#L99-L107
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/ShareableResource.java
ShareableResource.setConsumption
public ShareableResource setConsumption(VM vm, int val) { if (val < 0) { throw new IllegalArgumentException(String.format("The '%s' consumption of VM '%s' must be >= 0", rcId, vm)); } vmsConsumption.put(vm, val); return this; }
java
public ShareableResource setConsumption(VM vm, int val) { if (val < 0) { throw new IllegalArgumentException(String.format("The '%s' consumption of VM '%s' must be >= 0", rcId, vm)); } vmsConsumption.put(vm, val); return this; }
[ "public", "ShareableResource", "setConsumption", "(", "VM", "vm", ",", "int", "val", ")", "{", "if", "(", "val", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"The '%s' consumption of VM '%s' must be >= 0\"", ...
Set the resource consumption of a VM. @param vm the VM @param val the value to set @return the current resource
[ "Set", "the", "resource", "consumption", "of", "a", "VM", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/ShareableResource.java#L150-L156
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/ShareableResource.java
ShareableResource.setConsumption
public ShareableResource setConsumption(int val, VM... vms) { Stream.of(vms).forEach(v -> setConsumption(v, val)); return this; }
java
public ShareableResource setConsumption(int val, VM... vms) { Stream.of(vms).forEach(v -> setConsumption(v, val)); return this; }
[ "public", "ShareableResource", "setConsumption", "(", "int", "val", ",", "VM", "...", "vms", ")", "{", "Stream", ".", "of", "(", "vms", ")", ".", "forEach", "(", "v", "->", "setConsumption", "(", "v", ",", "val", ")", ")", ";", "return", "this", ";",...
Set the resource consumption of VMs. @param val the value to set @param vms the VMs @return the current resource
[ "Set", "the", "resource", "consumption", "of", "VMs", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/ShareableResource.java#L165-L168
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/ShareableResource.java
ShareableResource.setCapacity
public ShareableResource setCapacity(Node n, int val) { if (val < 0) { throw new IllegalArgumentException(String.format("The '%s' capacity of node '%s' must be >= 0", rcId, n)); } nodesCapacity.put(n, val); return this; }
java
public ShareableResource setCapacity(Node n, int val) { if (val < 0) { throw new IllegalArgumentException(String.format("The '%s' capacity of node '%s' must be >= 0", rcId, n)); } nodesCapacity.put(n, val); return this; }
[ "public", "ShareableResource", "setCapacity", "(", "Node", "n", ",", "int", "val", ")", "{", "if", "(", "val", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"The '%s' capacity of node '%s' must be >= 0\"", "...
Set the resource consumption of a node. @param n the node @param val the value to set @return the current resource
[ "Set", "the", "resource", "consumption", "of", "a", "node", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/ShareableResource.java#L177-L183
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/ShareableResource.java
ShareableResource.setCapacity
public ShareableResource setCapacity(int val, Node... nodes) { Stream.of(nodes).forEach(n -> this.setCapacity(n, val)); return this; }
java
public ShareableResource setCapacity(int val, Node... nodes) { Stream.of(nodes).forEach(n -> this.setCapacity(n, val)); return this; }
[ "public", "ShareableResource", "setCapacity", "(", "int", "val", ",", "Node", "...", "nodes", ")", "{", "Stream", ".", "of", "(", "nodes", ")", ".", "forEach", "(", "n", "->", "this", ".", "setCapacity", "(", "n", ",", "val", ")", ")", ";", "return",...
Set the resource consumption of nodes. @param val the value to set @param nodes the nodes @return the current resource
[ "Set", "the", "resource", "consumption", "of", "nodes", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/ShareableResource.java#L192-L195
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/ShareableResource.java
ShareableResource.sumConsumptions
public int sumConsumptions(Collection<VM> ids, boolean undef) { int s = 0; for (VM u: ids) { if (consumptionDefined(u) || undef) { s += vmsConsumption.get(u); } } return s; }
java
public int sumConsumptions(Collection<VM> ids, boolean undef) { int s = 0; for (VM u: ids) { if (consumptionDefined(u) || undef) { s += vmsConsumption.get(u); } } return s; }
[ "public", "int", "sumConsumptions", "(", "Collection", "<", "VM", ">", "ids", ",", "boolean", "undef", ")", "{", "int", "s", "=", "0", ";", "for", "(", "VM", "u", ":", "ids", ")", "{", "if", "(", "consumptionDefined", "(", "u", ")", "||", "undef", ...
Get the cumulative VMs consumption. @param ids the VMs. @param undef {@code true} to include the undefined elements using the default value @return the value
[ "Get", "the", "cumulative", "VMs", "consumption", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/ShareableResource.java#L367-L375
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/ShareableResource.java
ShareableResource.sumCapacities
public int sumCapacities(Collection<Node> ids, boolean undef) { int s = 0; for (Node u: ids) { if (capacityDefined(u) || undef) { s += nodesCapacity.get(u); } } return s; }
java
public int sumCapacities(Collection<Node> ids, boolean undef) { int s = 0; for (Node u: ids) { if (capacityDefined(u) || undef) { s += nodesCapacity.get(u); } } return s; }
[ "public", "int", "sumCapacities", "(", "Collection", "<", "Node", ">", "ids", ",", "boolean", "undef", ")", "{", "int", "s", "=", "0", ";", "for", "(", "Node", "u", ":", "ids", ")", "{", "if", "(", "capacityDefined", "(", "u", ")", "||", "undef", ...
Get the cumulative nodes capacity. @param ids the nodes. @param undef {@code true} to include the undefined elements using the default value @return the value
[ "Get", "the", "cumulative", "nodes", "capacity", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/ShareableResource.java#L384-L392
train
btrplace/scheduler
api/src/main/java/org/btrplace/model/view/ShareableResource.java
ShareableResource.get
public static ShareableResource get(Model mo, String id) { return (ShareableResource) mo.getView(VIEW_ID_BASE + id); }
java
public static ShareableResource get(Model mo, String id) { return (ShareableResource) mo.getView(VIEW_ID_BASE + id); }
[ "public", "static", "ShareableResource", "get", "(", "Model", "mo", ",", "String", "id", ")", "{", "return", "(", "ShareableResource", ")", "mo", ".", "getView", "(", "VIEW_ID_BASE", "+", "id", ")", ";", "}" ]
Get the view associated to a model if exists @param mo the model to look at @return the view if attached. {@code null} otherwise
[ "Get", "the", "view", "associated", "to", "a", "model", "if", "exists" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/api/src/main/java/org/btrplace/model/view/ShareableResource.java#L400-L402
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.getlocalName
public String getlocalName() { if (fqn.contains(".")) { return this.fqn.substring(fqn.lastIndexOf('.') + 1, this.fqn.length()); } return fqn; }
java
public String getlocalName() { if (fqn.contains(".")) { return this.fqn.substring(fqn.lastIndexOf('.') + 1, this.fqn.length()); } return fqn; }
[ "public", "String", "getlocalName", "(", ")", "{", "if", "(", "fqn", ".", "contains", "(", "\".\"", ")", ")", "{", "return", "this", ".", "fqn", ".", "substring", "(", "fqn", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ",", "this", ".", "fq...
Get the local name of the script. @return a non-empty String
[ "Get", "the", "local", "name", "of", "the", "script", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L108-L113
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.add
public boolean add(Collection<BtrpElement> elems) { boolean ret = false; for (BtrpElement el : elems) { ret |= add(el); } return ret; }
java
public boolean add(Collection<BtrpElement> elems) { boolean ret = false; for (BtrpElement el : elems) { ret |= add(el); } return ret; }
[ "public", "boolean", "add", "(", "Collection", "<", "BtrpElement", ">", "elems", ")", "{", "boolean", "ret", "=", "false", ";", "for", "(", "BtrpElement", "el", ":", "elems", ")", "{", "ret", "|=", "add", "(", "el", ")", ";", "}", "return", "ret", ...
Add a collection of nodes or elements. @param elems the elements to add @return {@code true} iff at least one element has been added
[ "Add", "a", "collection", "of", "nodes", "or", "elements", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L168-L174
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.add
public boolean add(BtrpElement el) { switch (el.type()) { case VM: if (!this.vms.add((VM) el.getElement())) { return false; } break; case NODE: if (!this.nodes.add((Node) el.getElement())) { return false; } break; default: return false; } return true; }
java
public boolean add(BtrpElement el) { switch (el.type()) { case VM: if (!this.vms.add((VM) el.getElement())) { return false; } break; case NODE: if (!this.nodes.add((Node) el.getElement())) { return false; } break; default: return false; } return true; }
[ "public", "boolean", "add", "(", "BtrpElement", "el", ")", "{", "switch", "(", "el", ".", "type", "(", ")", ")", "{", "case", "VM", ":", "if", "(", "!", "this", ".", "vms", ".", "add", "(", "(", "VM", ")", "el", ".", "getElement", "(", ")", "...
Add a VM or a node to the script. @param el the element to add @return {@code true} if the was was added
[ "Add", "a", "VM", "or", "a", "node", "to", "the", "script", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L182-L199
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.getImportables
public List<BtrpOperand> getImportables(String ns) { List<BtrpOperand> importable = new ArrayList<>(); for (String symbol : getExported()) { if (canImport(symbol, ns)) { importable.add(getImportable(symbol, ns)); } } return importable; }
java
public List<BtrpOperand> getImportables(String ns) { List<BtrpOperand> importable = new ArrayList<>(); for (String symbol : getExported()) { if (canImport(symbol, ns)) { importable.add(getImportable(symbol, ns)); } } return importable; }
[ "public", "List", "<", "BtrpOperand", ">", "getImportables", "(", "String", "ns", ")", "{", "List", "<", "BtrpOperand", ">", "importable", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "symbol", ":", "getExported", "(", ")", ")", ...
Get all the operand a given script can import @param ns the script namespace @return a list of importable operand, may be empty
[ "Get", "all", "the", "operand", "a", "given", "script", "can", "import" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L207-L215
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.getImportable
public BtrpOperand getImportable(String label, String namespace) { if (canImport(label, namespace)) { return exported.get(label); } return null; }
java
public BtrpOperand getImportable(String label, String namespace) { if (canImport(label, namespace)) { return exported.get(label); } return null; }
[ "public", "BtrpOperand", "getImportable", "(", "String", "label", ",", "String", "namespace", ")", "{", "if", "(", "canImport", "(", "label", ",", "namespace", ")", ")", "{", "return", "exported", ".", "get", "(", "label", ")", ";", "}", "return", "null"...
Get the exported operand from its label. @param label the operand label @param namespace the namespace of the script that ask for this operand. @return the operand if exists or {@code null}
[ "Get", "the", "exported", "operand", "from", "its", "label", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L224-L229
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.canImport
public boolean canImport(String label, String namespace) { if (!exported.containsKey(label)) { return false; } Set<String> scopes = exportScopes.get(label); for (String scope : scopes) { if (scope.equals(namespace)) { return true; } else if (scope.endsWith("*") && namespace.startsWith(scope.substring(0, scope.length() - 1))) { return true; } } return false; }
java
public boolean canImport(String label, String namespace) { if (!exported.containsKey(label)) { return false; } Set<String> scopes = exportScopes.get(label); for (String scope : scopes) { if (scope.equals(namespace)) { return true; } else if (scope.endsWith("*") && namespace.startsWith(scope.substring(0, scope.length() - 1))) { return true; } } return false; }
[ "public", "boolean", "canImport", "(", "String", "label", ",", "String", "namespace", ")", "{", "if", "(", "!", "exported", ".", "containsKey", "(", "label", ")", ")", "{", "return", "false", ";", "}", "Set", "<", "String", ">", "scopes", "=", "exportS...
Indicates whether a namespace can import an exported variable or not. To be imported, the label must point to an exported variable, with no import restrictions or with a given namespace compatible with the restrictions. @param label the label to import @param namespace the namespace of the script asking for the variable @return {@code true} if the variable can be imported. {@code false} otherwise}
[ "Indicates", "whether", "a", "namespace", "can", "import", "an", "exported", "variable", "or", "not", ".", "To", "be", "imported", "the", "label", "must", "point", "to", "an", "exported", "variable", "with", "no", "import", "restrictions", "or", "with", "a",...
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L252-L265
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.fullyQualifiedSymbolName
public String fullyQualifiedSymbolName(String name) { if (name.equals(SymbolsTable.ME)) { return "$".concat(id()); } else if (name.startsWith("$")) { return "$" + id() + '.' + name.substring(1); } return id() + '.' + name; }
java
public String fullyQualifiedSymbolName(String name) { if (name.equals(SymbolsTable.ME)) { return "$".concat(id()); } else if (name.startsWith("$")) { return "$" + id() + '.' + name.substring(1); } return id() + '.' + name; }
[ "public", "String", "fullyQualifiedSymbolName", "(", "String", "name", ")", "{", "if", "(", "name", ".", "equals", "(", "SymbolsTable", ".", "ME", ")", ")", "{", "return", "\"$\"", ".", "concat", "(", "id", "(", ")", ")", ";", "}", "else", "if", "(",...
Get the fully qualified name of a symbol. @param name the symbol name @return the fully qualified symbol name.
[ "Get", "the", "fully", "qualified", "name", "of", "a", "symbol", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L287-L294
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/Script.java
Script.prettyDependencies
public String prettyDependencies() { StringBuilder b = new StringBuilder(); b.append(id()).append('\n'); for (Iterator<Script> ite = dependencies.iterator(); ite.hasNext(); ) { Script n = ite.next(); prettyDependencies(b, !ite.hasNext(), 0, n); } return b.toString(); }
java
public String prettyDependencies() { StringBuilder b = new StringBuilder(); b.append(id()).append('\n'); for (Iterator<Script> ite = dependencies.iterator(); ite.hasNext(); ) { Script n = ite.next(); prettyDependencies(b, !ite.hasNext(), 0, n); } return b.toString(); }
[ "public", "String", "prettyDependencies", "(", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "b", ".", "append", "(", "id", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "for", "(", "Iterator", "<", "Script", ...
Textual representation for the dependencies. @return a String containing the dependency tree.
[ "Textual", "representation", "for", "the", "dependencies", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/Script.java#L334-L342
train
InsightLab/graphast
core/src/main/java/br/ufc/insightlab/graphast/model/Graph.java
Graph.addNode
public void addNode(Node n) { try { structure.addNode(n); for (NodeListener listener : nodeListeners) listener.onInsert(n); } catch (DuplicatedNodeException e) { duplicatedNodesCounter++; } }
java
public void addNode(Node n) { try { structure.addNode(n); for (NodeListener listener : nodeListeners) listener.onInsert(n); } catch (DuplicatedNodeException e) { duplicatedNodesCounter++; } }
[ "public", "void", "addNode", "(", "Node", "n", ")", "{", "try", "{", "structure", ".", "addNode", "(", "n", ")", ";", "for", "(", "NodeListener", "listener", ":", "nodeListeners", ")", "listener", ".", "onInsert", "(", "n", ")", ";", "}", "catch", "(...
Adds a new node to the graph, given the Node object. If a node already exists with an id equal to the given node, a DuplicatedNodeException is thrown. @param n the new node to be added to the graph.
[ "Adds", "a", "new", "node", "to", "the", "graph", "given", "the", "Node", "object", ".", "If", "a", "node", "already", "exists", "with", "an", "id", "equal", "to", "the", "given", "node", "a", "DuplicatedNodeException", "is", "thrown", "." ]
b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24
https://github.com/InsightLab/graphast/blob/b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24/core/src/main/java/br/ufc/insightlab/graphast/model/Graph.java#L109-L117
train
InsightLab/graphast
core/src/main/java/br/ufc/insightlab/graphast/model/Graph.java
Graph.addEdge
public void addEdge(Edge e) { structure.addEdge(e); for (EdgeListener listener : edgeListeners) listener.onInsert(e); }
java
public void addEdge(Edge e) { structure.addEdge(e); for (EdgeListener listener : edgeListeners) listener.onInsert(e); }
[ "public", "void", "addEdge", "(", "Edge", "e", ")", "{", "structure", ".", "addEdge", "(", "e", ")", ";", "for", "(", "EdgeListener", "listener", ":", "edgeListeners", ")", "listener", ".", "onInsert", "(", ")", ";", "}" ]
Adds a new edge to this graph, given a new Edge object. It uses the GraphStructure attribute's addEdge method to add the new edge to this graph. If one of the node ids of the given Edge object does not exists in this graph, a NodeNotFoundException is thrown. Otherwise, the edge is successfully added to this graph. @param e the new edge to be added to the graph.
[ "Adds", "a", "new", "edge", "to", "this", "graph", "given", "a", "new", "Edge", "object", ".", "It", "uses", "the", "GraphStructure", "attribute", "s", "addEdge", "method", "to", "add", "the", "new", "edge", "to", "this", "graph", ".", "If", "one", "of...
b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24
https://github.com/InsightLab/graphast/blob/b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24/core/src/main/java/br/ufc/insightlab/graphast/model/Graph.java#L149-L153
train
InsightLab/graphast
core/src/main/java/br/ufc/insightlab/graphast/model/Graph.java
Graph.getNeighborhoodIterator
public Iterator<Long> getNeighborhoodIterator(final long id) { return new Iterator<Long>() { Iterator<Edge> iter = structure.getExistingOutEdgesIterator(id); @Override public boolean hasNext() { return iter.hasNext(); } @Override public Long next() { Edge e = iter.next(); return e.getFromNodeId() == id ? e.getToNodeId() : e.getFromNodeId(); } }; }
java
public Iterator<Long> getNeighborhoodIterator(final long id) { return new Iterator<Long>() { Iterator<Edge> iter = structure.getExistingOutEdgesIterator(id); @Override public boolean hasNext() { return iter.hasNext(); } @Override public Long next() { Edge e = iter.next(); return e.getFromNodeId() == id ? e.getToNodeId() : e.getFromNodeId(); } }; }
[ "public", "Iterator", "<", "Long", ">", "getNeighborhoodIterator", "(", "final", "long", "id", ")", "{", "return", "new", "Iterator", "<", "Long", ">", "(", ")", "{", "Iterator", "<", "Edge", ">", "iter", "=", "structure", ".", "getExistingOutEdgesIterator",...
Gets the neighborhood from a node represented by a given id. If the graph has any Node object with the given id, this function returns an Iterator object representing all the neighboring Node objects to the given node. The neighboring nodes are given according to the outgoing edges of the Node object of the graph that has the given id. @param id the id of a Node object in the graph. @return the neighborhood of the node with the given id, if this node exists in the graph. This neighborhood is represented by an Iterator object of a list of ids of nodes to which the node given in the function points to.
[ "Gets", "the", "neighborhood", "from", "a", "node", "represented", "by", "a", "given", "id", ".", "If", "the", "graph", "has", "any", "Node", "object", "with", "the", "given", "id", "this", "function", "returns", "an", "Iterator", "object", "representing", ...
b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24
https://github.com/InsightLab/graphast/blob/b81d10c1ea8378e1fb9fcb545dd75d5e6308fd24/core/src/main/java/br/ufc/insightlab/graphast/model/Graph.java#L322-L340
train
btrplace/scheduler
json/src/main/java/org/btrplace/json/model/AttributesConverter.java
AttributesConverter.toJSON
public static JSONObject toJSON(Attributes attributes) { JSONObject res = new JSONObject(); JSONObject vms = new JSONObject(); JSONObject nodes = new JSONObject(); for (Element e : attributes.getDefined()) { JSONObject el = new JSONObject(); for (String k : attributes.getKeys(e)) { el.put(k, attributes.get(e, k)); } if (e instanceof VM) { vms.put(Integer.toString(e.id()), el); } else { nodes.put(Integer.toString(e.id()), el); } } res.put("vms", vms); res.put("nodes", nodes); return res; }
java
public static JSONObject toJSON(Attributes attributes) { JSONObject res = new JSONObject(); JSONObject vms = new JSONObject(); JSONObject nodes = new JSONObject(); for (Element e : attributes.getDefined()) { JSONObject el = new JSONObject(); for (String k : attributes.getKeys(e)) { el.put(k, attributes.get(e, k)); } if (e instanceof VM) { vms.put(Integer.toString(e.id()), el); } else { nodes.put(Integer.toString(e.id()), el); } } res.put("vms", vms); res.put("nodes", nodes); return res; }
[ "public", "static", "JSONObject", "toJSON", "(", "Attributes", "attributes", ")", "{", "JSONObject", "res", "=", "new", "JSONObject", "(", ")", ";", "JSONObject", "vms", "=", "new", "JSONObject", "(", ")", ";", "JSONObject", "nodes", "=", "new", "JSONObject"...
Serialise attributes. @param attributes the attributes @return the resulting encoded attributes
[ "Serialise", "attributes", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/json/src/main/java/org/btrplace/json/model/AttributesConverter.java#L104-L122
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java
KnapsackDecorator.fullKnapsack
private void fullKnapsack() throws ContradictionException { for (int bin = 0; bin < prop.nbBins; bin++) { for (int d = 0; d < prop.nbDims; d++) { knapsack(bin, d); } } }
java
private void fullKnapsack() throws ContradictionException { for (int bin = 0; bin < prop.nbBins; bin++) { for (int d = 0; d < prop.nbDims; d++) { knapsack(bin, d); } } }
[ "private", "void", "fullKnapsack", "(", ")", "throws", "ContradictionException", "{", "for", "(", "int", "bin", "=", "0", ";", "bin", "<", "prop", ".", "nbBins", ";", "bin", "++", ")", "{", "for", "(", "int", "d", "=", "0", ";", "d", "<", "prop", ...
Propagate a knapsack on every node and every dimension. @throws ContradictionException
[ "Propagate", "a", "knapsack", "on", "every", "node", "and", "every", "dimension", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java#L71-L77
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java
KnapsackDecorator.postInitialize
public void postInitialize() throws ContradictionException { final int[] biggest = new int[prop.nbDims]; for (int i = 0; i < prop.bins.length; i++) { for (int d = 0; d < prop.nbDims; d++) { biggest[d] = Math.max(biggest[d], prop.iSizes[d][i]); } if (!prop.bins[i].isInstantiated()) { final DisposableValueIterator it = prop.bins[i].getValueIterator(true); try { while (it.hasNext()) { candidate.get(it.next()).set(i); } } finally { it.dispose(); } } } for (int b = 0; b < prop.nbBins; b++) { for (int d = 0; d < prop.nbDims; d++) { dynBiggest[d][b] = prop.getVars()[0].getEnvironment().makeInt(biggest[d]); } } fullKnapsack(); }
java
public void postInitialize() throws ContradictionException { final int[] biggest = new int[prop.nbDims]; for (int i = 0; i < prop.bins.length; i++) { for (int d = 0; d < prop.nbDims; d++) { biggest[d] = Math.max(biggest[d], prop.iSizes[d][i]); } if (!prop.bins[i].isInstantiated()) { final DisposableValueIterator it = prop.bins[i].getValueIterator(true); try { while (it.hasNext()) { candidate.get(it.next()).set(i); } } finally { it.dispose(); } } } for (int b = 0; b < prop.nbBins; b++) { for (int d = 0; d < prop.nbDims; d++) { dynBiggest[d][b] = prop.getVars()[0].getEnvironment().makeInt(biggest[d]); } } fullKnapsack(); }
[ "public", "void", "postInitialize", "(", ")", "throws", "ContradictionException", "{", "final", "int", "[", "]", "biggest", "=", "new", "int", "[", "prop", ".", "nbDims", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "prop", ".", "bins",...
initialize the lists of candidates.
[ "initialize", "the", "lists", "of", "candidates", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java#L82-L108
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java
KnapsackDecorator.postRemoveItem
@SuppressWarnings("squid:S3346") public void postRemoveItem(int item, int bin) { assert candidate.get(bin).get(item); candidate.get(bin).clear(item); }
java
@SuppressWarnings("squid:S3346") public void postRemoveItem(int item, int bin) { assert candidate.get(bin).get(item); candidate.get(bin).clear(item); }
[ "@", "SuppressWarnings", "(", "\"squid:S3346\"", ")", "public", "void", "postRemoveItem", "(", "int", "item", ",", "int", "bin", ")", "{", "assert", "candidate", ".", "get", "(", "bin", ")", ".", "get", "(", "item", ")", ";", "candidate", ".", "get", "...
update the candidate list of a bin when an item is removed @param item the removed item @param bin the bin
[ "update", "the", "candidate", "list", "of", "a", "bin", "when", "an", "item", "is", "removed" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java#L148-L152
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java
KnapsackDecorator.knapsack
private void knapsack(int bin, int d) throws ContradictionException { final int maxLoad = prop.loads[d][bin].getUB(); final int free = maxLoad - prop.assignedLoad[d][bin].get(); if (free >= dynBiggest[d][bin].get()) { // fail fast. The remaining space > the biggest item. return; } if (free > 0) { // The bin is not full and some items exceeds the remaining space. We // get rid of them // In parallel, we set the new biggest candidate item for that // (bin,dimension) int newMax = -1; for (int i = candidate.get(bin).nextSetBit(0); i >= 0; i = candidate.get(bin).nextSetBit(i + 1)) { if (prop.iSizes[d][i] > free) { if (prop.bins[i].removeValue(bin, prop)) { prop.removeItem(i, bin); if (prop.bins[i].isInstantiated()) { prop.assignItem(i, prop.bins[i].getValue()); } } } else { // The item is still a candidate, we just update the biggest value. newMax = Math.max(newMax, prop.iSizes[d][i]); } } dynBiggest[d][bin].set(newMax); } }
java
private void knapsack(int bin, int d) throws ContradictionException { final int maxLoad = prop.loads[d][bin].getUB(); final int free = maxLoad - prop.assignedLoad[d][bin].get(); if (free >= dynBiggest[d][bin].get()) { // fail fast. The remaining space > the biggest item. return; } if (free > 0) { // The bin is not full and some items exceeds the remaining space. We // get rid of them // In parallel, we set the new biggest candidate item for that // (bin,dimension) int newMax = -1; for (int i = candidate.get(bin).nextSetBit(0); i >= 0; i = candidate.get(bin).nextSetBit(i + 1)) { if (prop.iSizes[d][i] > free) { if (prop.bins[i].removeValue(bin, prop)) { prop.removeItem(i, bin); if (prop.bins[i].isInstantiated()) { prop.assignItem(i, prop.bins[i].getValue()); } } } else { // The item is still a candidate, we just update the biggest value. newMax = Math.max(newMax, prop.iSizes[d][i]); } } dynBiggest[d][bin].set(newMax); } }
[ "private", "void", "knapsack", "(", "int", "bin", ",", "int", "d", ")", "throws", "ContradictionException", "{", "final", "int", "maxLoad", "=", "prop", ".", "loads", "[", "d", "]", "[", "bin", "]", ".", "getUB", "(", ")", ";", "final", "int", "free"...
Propagate a knapsack on a given dimension and bin. If the usage of an item exceeds the bin free capacity, it is filtered out. @param bin the bin @param d the dimension @throws ContradictionException
[ "Propagate", "a", "knapsack", "on", "a", "given", "dimension", "and", "bin", ".", "If", "the", "usage", "of", "an", "item", "exceeds", "the", "bin", "free", "capacity", "it", "is", "filtered", "out", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/extensions/pack/KnapsackDecorator.java#L195-L226
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/runner/Metrics.java
Metrics.add
public void add(Metrics m) { timeCount += m.timeCount; readingTimeCount += m.readingTimeCount; nodes += m.nodes; backtracks += m.backtracks; fails += m.fails; restarts += m.restarts; }
java
public void add(Metrics m) { timeCount += m.timeCount; readingTimeCount += m.readingTimeCount; nodes += m.nodes; backtracks += m.backtracks; fails += m.fails; restarts += m.restarts; }
[ "public", "void", "add", "(", "Metrics", "m", ")", "{", "timeCount", "+=", "m", ".", "timeCount", ";", "readingTimeCount", "+=", "m", ".", "readingTimeCount", ";", "nodes", "+=", "m", ".", "nodes", ";", "backtracks", "+=", "m", ".", "backtracks", ";", ...
Add metrics. All the metrics are aggregated to the current instance @param m the metrics to add
[ "Add", "metrics", ".", "All", "the", "metrics", "are", "aggregated", "to", "the", "current", "instance" ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/runner/Metrics.java#L97-L104
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/layer/LayerImpl.java
LayerImpl.generateCacheKey
protected String generateCacheKey(HttpServletRequest request, Map<String, ICacheKeyGenerator> cacheKeyGenerators) throws IOException { String cacheKey = null; if (cacheKeyGenerators != null) { // First, decompose any composite cache key generators into their // constituent cache key generators so that we can combine them // more effectively. Use TreeMap to get predictable ordering of // keys. Map<String, ICacheKeyGenerator> gens = new TreeMap<String, ICacheKeyGenerator>(); for (ICacheKeyGenerator gen : cacheKeyGenerators.values()) { List<ICacheKeyGenerator> constituentGens = gen.getCacheKeyGenerators(request); addCacheKeyGenerators(gens, constituentGens == null ? Arrays.asList(new ICacheKeyGenerator[]{gen}) : constituentGens); } cacheKey = KeyGenUtil.generateKey( request, gens.values()); } return cacheKey; }
java
protected String generateCacheKey(HttpServletRequest request, Map<String, ICacheKeyGenerator> cacheKeyGenerators) throws IOException { String cacheKey = null; if (cacheKeyGenerators != null) { // First, decompose any composite cache key generators into their // constituent cache key generators so that we can combine them // more effectively. Use TreeMap to get predictable ordering of // keys. Map<String, ICacheKeyGenerator> gens = new TreeMap<String, ICacheKeyGenerator>(); for (ICacheKeyGenerator gen : cacheKeyGenerators.values()) { List<ICacheKeyGenerator> constituentGens = gen.getCacheKeyGenerators(request); addCacheKeyGenerators(gens, constituentGens == null ? Arrays.asList(new ICacheKeyGenerator[]{gen}) : constituentGens); } cacheKey = KeyGenUtil.generateKey( request, gens.values()); } return cacheKey; }
[ "protected", "String", "generateCacheKey", "(", "HttpServletRequest", "request", ",", "Map", "<", "String", ",", "ICacheKeyGenerator", ">", "cacheKeyGenerators", ")", "throws", "IOException", "{", "String", "cacheKey", "=", "null", ";", "if", "(", "cacheKeyGenerator...
Generates a cache key for the layer. @param request the request object @param cacheKeyGenerators map of cache key generator class names to instance objects @return the cache key @throws IOException
[ "Generates", "a", "cache", "key", "for", "the", "layer", "." ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/layer/LayerImpl.java#L654-L674
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/layer/LayerImpl.java
LayerImpl.readObject
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Call the default implementation to de-serialize our object in.defaultReadObject(); // init transients _validateLastModified = new AtomicBoolean(true); _cacheKeyGenMutex = new Semaphore(1); _isReportCacheInfo = false; }
java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Call the default implementation to de-serialize our object in.defaultReadObject(); // init transients _validateLastModified = new AtomicBoolean(true); _cacheKeyGenMutex = new Semaphore(1); _isReportCacheInfo = false; }
[ "private", "void", "readObject", "(", "ObjectInputStream", "in", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "// Call the default implementation to de-serialize our object\r", "in", ".", "defaultReadObject", "(", ")", ";", "// init transients\r", "_valid...
De-serialize this object from an ObjectInputStream @param in The ObjectInputStream @throws IOException @throws ClassNotFoundException
[ "De", "-", "serialize", "this", "object", "from", "an", "ObjectInputStream" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/layer/LayerImpl.java#L763-L770
train
OpenNTF/JavascriptAggregator
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/layer/LayerImpl.java
LayerImpl.getLastModified
protected long getLastModified(IAggregator aggregator, ModuleList modules) { long result = 0L; for (ModuleList.ModuleListEntry entry : modules) { IResource resource = entry.getModule().getResource(aggregator); long lastMod = resource.lastModified(); result = Math.max(result, lastMod); } return result; }
java
protected long getLastModified(IAggregator aggregator, ModuleList modules) { long result = 0L; for (ModuleList.ModuleListEntry entry : modules) { IResource resource = entry.getModule().getResource(aggregator); long lastMod = resource.lastModified(); result = Math.max(result, lastMod); } return result; }
[ "protected", "long", "getLastModified", "(", "IAggregator", "aggregator", ",", "ModuleList", "modules", ")", "{", "long", "result", "=", "0L", ";", "for", "(", "ModuleList", ".", "ModuleListEntry", "entry", ":", "modules", ")", "{", "IResource", "resource", "=...
Returns the newest last modified time of the files in the list @param aggregator @param modules The list of ModuleFile objects @return The newest last modified time of all the files in the list
[ "Returns", "the", "newest", "last", "modified", "time", "of", "the", "files", "in", "the", "list" ]
9f47a96d778251638b1df9a368462176216d5b29
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/layer/LayerImpl.java#L1031-L1039
train
nikolavp/approval
approval-core/src/main/java/com/github/approval/Approvals.java
Approvals.verify
public static void verify(short value, Path path) { Approval.of(short.class) .withReporter(reporter) .build() .verify(value, path); }
java
public static void verify(short value, Path path) { Approval.of(short.class) .withReporter(reporter) .build() .verify(value, path); }
[ "public", "static", "void", "verify", "(", "short", "value", ",", "Path", "path", ")", "{", "Approval", ".", "of", "(", "short", ".", "class", ")", ".", "withReporter", "(", "reporter", ")", ".", "build", "(", ")", ".", "verify", "(", "value", ",", ...
An overload for verifying a single short value. This will call the approval object with proper reporter and use the path for verification. @param value the short that needs to be verified @param path the path in which to store the approval file
[ "An", "overload", "for", "verifying", "a", "single", "short", "value", ".", "This", "will", "call", "the", "approval", "object", "with", "proper", "reporter", "and", "use", "the", "path", "for", "verification", "." ]
5e32ecc3bc7f631e94a7049894fdd99a3aa5b1b8
https://github.com/nikolavp/approval/blob/5e32ecc3bc7f631e94a7049894fdd99a3aa5b1b8/approval-core/src/main/java/com/github/approval/Approvals.java#L182-L187
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/element/DefaultBtrpOperand.java
DefaultBtrpOperand.prettyType
public static String prettyType(BtrpOperand o) { if (o == IgnorableOperand.getInstance()) { return "??"; } return prettyType(o.degree(), o.type()); }
java
public static String prettyType(BtrpOperand o) { if (o == IgnorableOperand.getInstance()) { return "??"; } return prettyType(o.degree(), o.type()); }
[ "public", "static", "String", "prettyType", "(", "BtrpOperand", "o", ")", "{", "if", "(", "o", "==", "IgnorableOperand", ".", "getInstance", "(", ")", ")", "{", "return", "\"??\"", ";", "}", "return", "prettyType", "(", "o", ".", "degree", "(", ")", ",...
Generate a pretty type for an operand. @param o the operand @return a string that describes the operand type.
[ "Generate", "a", "pretty", "type", "for", "an", "operand", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/element/DefaultBtrpOperand.java#L113-L118
train
btrplace/scheduler
btrpsl/src/main/java/org/btrplace/btrpsl/element/DefaultBtrpOperand.java
DefaultBtrpOperand.prettyType
public static String prettyType(int degree, Type t) { StringBuilder b = new StringBuilder(); for (int i = degree; i > 0; i--) { b.append("set<"); } b.append(t.toString().toLowerCase()); for (int i = 0; i < degree; i++) { b.append(">"); } return b.toString(); }
java
public static String prettyType(int degree, Type t) { StringBuilder b = new StringBuilder(); for (int i = degree; i > 0; i--) { b.append("set<"); } b.append(t.toString().toLowerCase()); for (int i = 0; i < degree; i++) { b.append(">"); } return b.toString(); }
[ "public", "static", "String", "prettyType", "(", "int", "degree", ",", "Type", "t", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "degree", ";", "i", ">", "0", ";", "i", "--", ")", "{", "...
Pretty textual representation of a given element type. @param degree 0 for a literal, 1 for a set, 2 for a set of sets, ... @param t the literal @return a String
[ "Pretty", "textual", "representation", "of", "a", "given", "element", "type", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/btrpsl/src/main/java/org/btrplace/btrpsl/element/DefaultBtrpOperand.java#L127-L137
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/view/DefaultCumulatives.java
DefaultCumulatives.addDim
@Override public void addDim(List<IntVar> c, int[] cUse, IntVar[] dUse) { capacities.add(c); cUsages.add(cUse); dUsages.add(dUse); }
java
@Override public void addDim(List<IntVar> c, int[] cUse, IntVar[] dUse) { capacities.add(c); cUsages.add(cUse); dUsages.add(dUse); }
[ "@", "Override", "public", "void", "addDim", "(", "List", "<", "IntVar", ">", "c", ",", "int", "[", "]", "cUse", ",", "IntVar", "[", "]", "dUse", ")", "{", "capacities", ".", "add", "(", "c", ")", ";", "cUsages", ".", "add", "(", "cUse", ")", "...
Add a dimension. @param c the resource capacity of each of the nodes @param cUse the resource usage of each of the cSlices @param dUse the resource usage of each of the dSlices
[ "Add", "a", "dimension", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/view/DefaultCumulatives.java#L62-L67
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/view/DefaultCumulatives.java
DefaultCumulatives.beforeSolve
@Override @SuppressWarnings("squid:S3346") public boolean beforeSolve(ReconfigurationProblem rp) { super.beforeSolve(rp); if (rp.getSourceModel().getMapping().getNbNodes() == 0 || capacities.isEmpty()) { return true; } int nbDims = capacities.size(); int nbRes = capacities.get(0).size(); //We get the UB of the node capacity and the LB for the VM usage. int[][] capas = new int[nbRes][nbDims]; int d = 0; for (List<IntVar> capaDim : capacities) { assert capaDim.size() == nbRes; for (int j = 0; j < capaDim.size(); j++) { capas[j][d] = capaDim.get(j).getUB(); } d++; } assert cUsages.size() == nbDims; int nbCHosts = cUsages.get(0).length; int[][] cUses = new int[nbCHosts][nbDims]; d = 0; for (int[] cUseDim : cUsages) { assert cUseDim.length == nbCHosts; for (int i = 0; i < nbCHosts; i++) { cUses[i][d] = cUseDim[i]; } d++; } assert dUsages.size() == nbDims; int nbDHosts = dUsages.get(0).length; int[][] dUses = new int[nbDHosts][nbDims]; d = 0; for (IntVar[] dUseDim : dUsages) { assert dUseDim.length == nbDHosts; for (int j = 0; j < nbDHosts; j++) { dUses[j][d] = dUseDim[j].getLB(); } d++; } symmetryBreakingForStayingVMs(rp); IntVar[] earlyStarts = rp.getNodeActions().stream().map(NodeTransition::getHostingStart).toArray(IntVar[]::new); IntVar[] lastEnd = rp.getNodeActions().stream().map(NodeTransition::getHostingEnd).toArray(IntVar[]::new); rp.getModel().post( new TaskScheduler(earlyStarts, lastEnd, capas, cHosts, cUses, cEnds, dHosts, dUses, dStarts, associations) ); return true; }
java
@Override @SuppressWarnings("squid:S3346") public boolean beforeSolve(ReconfigurationProblem rp) { super.beforeSolve(rp); if (rp.getSourceModel().getMapping().getNbNodes() == 0 || capacities.isEmpty()) { return true; } int nbDims = capacities.size(); int nbRes = capacities.get(0).size(); //We get the UB of the node capacity and the LB for the VM usage. int[][] capas = new int[nbRes][nbDims]; int d = 0; for (List<IntVar> capaDim : capacities) { assert capaDim.size() == nbRes; for (int j = 0; j < capaDim.size(); j++) { capas[j][d] = capaDim.get(j).getUB(); } d++; } assert cUsages.size() == nbDims; int nbCHosts = cUsages.get(0).length; int[][] cUses = new int[nbCHosts][nbDims]; d = 0; for (int[] cUseDim : cUsages) { assert cUseDim.length == nbCHosts; for (int i = 0; i < nbCHosts; i++) { cUses[i][d] = cUseDim[i]; } d++; } assert dUsages.size() == nbDims; int nbDHosts = dUsages.get(0).length; int[][] dUses = new int[nbDHosts][nbDims]; d = 0; for (IntVar[] dUseDim : dUsages) { assert dUseDim.length == nbDHosts; for (int j = 0; j < nbDHosts; j++) { dUses[j][d] = dUseDim[j].getLB(); } d++; } symmetryBreakingForStayingVMs(rp); IntVar[] earlyStarts = rp.getNodeActions().stream().map(NodeTransition::getHostingStart).toArray(IntVar[]::new); IntVar[] lastEnd = rp.getNodeActions().stream().map(NodeTransition::getHostingEnd).toArray(IntVar[]::new); rp.getModel().post( new TaskScheduler(earlyStarts, lastEnd, capas, cHosts, cUses, cEnds, dHosts, dUses, dStarts, associations) ); return true; }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"squid:S3346\"", ")", "public", "boolean", "beforeSolve", "(", "ReconfigurationProblem", "rp", ")", "{", "super", ".", "beforeSolve", "(", "rp", ")", ";", "if", "(", "rp", ".", "getSourceModel", "(", ")", ".",...
Build the constraint. @return the resulting constraint
[ "Build", "the", "constraint", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/view/DefaultCumulatives.java#L74-L131
train
btrplace/scheduler
choco/src/main/java/org/btrplace/scheduler/choco/view/DefaultCumulatives.java
DefaultCumulatives.symmetryBreakingForStayingVMs
private boolean symmetryBreakingForStayingVMs(ReconfigurationProblem rp) { for (VM vm : rp.getFutureRunningVMs()) { VMTransition a = rp.getVMAction(vm); Slice dSlice = a.getDSlice(); Slice cSlice = a.getCSlice(); if (dSlice != null && cSlice != null) { BoolVar stay = ((KeepRunningVM) a).isStaying(); Boolean ret = strictlyDecreasingOrUnchanged(vm); if (Boolean.TRUE.equals(ret) && !zeroDuration(rp, stay, cSlice)) { return false; //Else, the resource usage is decreasing, so // we set the cSlice duration to 0 to directly reduces the resource allocation } else if (Boolean.FALSE.equals(ret) && !zeroDuration(rp, stay, dSlice)) { //If the resource usage will be increasing //Then the duration of the dSlice can be set to 0 //(the allocation will be performed at the end of the reconfiguration process) return false; } } } return true; }
java
private boolean symmetryBreakingForStayingVMs(ReconfigurationProblem rp) { for (VM vm : rp.getFutureRunningVMs()) { VMTransition a = rp.getVMAction(vm); Slice dSlice = a.getDSlice(); Slice cSlice = a.getCSlice(); if (dSlice != null && cSlice != null) { BoolVar stay = ((KeepRunningVM) a).isStaying(); Boolean ret = strictlyDecreasingOrUnchanged(vm); if (Boolean.TRUE.equals(ret) && !zeroDuration(rp, stay, cSlice)) { return false; //Else, the resource usage is decreasing, so // we set the cSlice duration to 0 to directly reduces the resource allocation } else if (Boolean.FALSE.equals(ret) && !zeroDuration(rp, stay, dSlice)) { //If the resource usage will be increasing //Then the duration of the dSlice can be set to 0 //(the allocation will be performed at the end of the reconfiguration process) return false; } } } return true; }
[ "private", "boolean", "symmetryBreakingForStayingVMs", "(", "ReconfigurationProblem", "rp", ")", "{", "for", "(", "VM", "vm", ":", "rp", ".", "getFutureRunningVMs", "(", ")", ")", "{", "VMTransition", "a", "=", "rp", ".", "getVMAction", "(", "vm", ")", ";", ...
Symmetry breaking for VMs that stay running, on the same node. @return {@code true} iff the symmetry breaking does not lead to a problem without solutions
[ "Symmetry", "breaking", "for", "VMs", "that", "stay", "running", "on", "the", "same", "node", "." ]
611063aad0b47a016e57ebf36fa4dfdf24de09e8
https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/view/DefaultCumulatives.java#L165-L187
train
berkesa/datatree
src/main/java/io/datatree/Tree.java
Tree.getPath
protected StringBuilder getPath(StringBuilder path, int startIndex, boolean addPoint) { boolean simple = true; if (key != null) { if (addPoint && path.length() > 0) { path.insert(0, '.'); } if (key instanceof Integer) { path.insert(0, ']'); if (startIndex == 0) { path.insert(0, key); } else { path.insert(0, startIndex + (int) key); } path.insert(0, '['); simple = false; } else { path.insert(0, key); } } if (parent != null) { parent.getPath(path, startIndex, simple); } return path; }
java
protected StringBuilder getPath(StringBuilder path, int startIndex, boolean addPoint) { boolean simple = true; if (key != null) { if (addPoint && path.length() > 0) { path.insert(0, '.'); } if (key instanceof Integer) { path.insert(0, ']'); if (startIndex == 0) { path.insert(0, key); } else { path.insert(0, startIndex + (int) key); } path.insert(0, '['); simple = false; } else { path.insert(0, key); } } if (parent != null) { parent.getPath(path, startIndex, simple); } return path; }
[ "protected", "StringBuilder", "getPath", "(", "StringBuilder", "path", ",", "int", "startIndex", ",", "boolean", "addPoint", ")", "{", "boolean", "simple", "=", "true", ";", "if", "(", "key", "!=", "null", ")", "{", "if", "(", "addPoint", "&&", "path", "...
Recursive path-builder method. @param path path builder @param startIndex first index within array (startIndex = 0 -&gt; zero based array-indexing) @param addPoint a point is insertable into the path @return path of this node
[ "Recursive", "path", "-", "builder", "method", "." ]
79aea9b45c7b46ab28af0a09310bc01c421c6b3a
https://github.com/berkesa/datatree/blob/79aea9b45c7b46ab28af0a09310bc01c421c6b3a/src/main/java/io/datatree/Tree.java#L402-L425
train
berkesa/datatree
src/main/java/io/datatree/Tree.java
Tree.setType
public Tree setType(Class<?> type) { if (value == null || value.getClass() == type) { return this; } value = DataConverterRegistry.convert(type, value); if (parent != null && key != null) { if (key instanceof String) { parent.putObjectInternal((String) key, value, false); } else { parent.remove((int) key); parent.insertObjectInternal((int) key, value); } } return this; }
java
public Tree setType(Class<?> type) { if (value == null || value.getClass() == type) { return this; } value = DataConverterRegistry.convert(type, value); if (parent != null && key != null) { if (key instanceof String) { parent.putObjectInternal((String) key, value, false); } else { parent.remove((int) key); parent.insertObjectInternal((int) key, value); } } return this; }
[ "public", "Tree", "setType", "(", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "value", "==", "null", "||", "value", ".", "getClass", "(", ")", "==", "type", ")", "{", "return", "this", ";", "}", "value", "=", "DataConverterRegistry", ".", ...
Sets this node's type and converts the value into the specified type. @param type new type @return this node
[ "Sets", "this", "node", "s", "type", "and", "converts", "the", "value", "into", "the", "specified", "type", "." ]
79aea9b45c7b46ab28af0a09310bc01c421c6b3a
https://github.com/berkesa/datatree/blob/79aea9b45c7b46ab28af0a09310bc01c421c6b3a/src/main/java/io/datatree/Tree.java#L446-L460
train
berkesa/datatree
src/main/java/io/datatree/Tree.java
Tree.insert
public Tree insert(int index, byte[] value, boolean asBase64String) { if (asBase64String) { return insertObjectInternal(index, BASE64.encode(value)); } return insertObjectInternal(index, value); }
java
public Tree insert(int index, byte[] value, boolean asBase64String) { if (asBase64String) { return insertObjectInternal(index, BASE64.encode(value)); } return insertObjectInternal(index, value); }
[ "public", "Tree", "insert", "(", "int", "index", ",", "byte", "[", "]", "value", ",", "boolean", "asBase64String", ")", "{", "if", "(", "asBase64String", ")", "{", "return", "insertObjectInternal", "(", "index", ",", "BASE64", ".", "encode", "(", "value", ...
Inserts the specified byte array at the specified position in this List. @param index index at which the specified element is to be inserted @param value array value to be inserted @param asBase64String store byte array as BASE64 String @return this node @throws IndexOutOfBoundsException if the index is out of range
[ "Inserts", "the", "specified", "byte", "array", "at", "the", "specified", "position", "in", "this", "List", "." ]
79aea9b45c7b46ab28af0a09310bc01c421c6b3a
https://github.com/berkesa/datatree/blob/79aea9b45c7b46ab28af0a09310bc01c421c6b3a/src/main/java/io/datatree/Tree.java#L1485-L1490
train