code stringlengths 73 34.1k | label stringclasses 1 value |
|---|---|
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 void unregisterActivityLifecycleCallbacks(Application application, ActivityLifecycleCallbacksCompat callback) {
if (PRE_ICS) {
preIcsUnregisterActivityLifecycleCallbacks(callback);
} else {
postIcsUnregisterActivityLifecycleCallbacks(application, callback);
}
} | java |
public static SessionRuntimeException fromThrowable(Throwable cause) {
return (cause instanceof SessionRuntimeException)
? (SessionRuntimeException) cause
: new SessionRuntimeException(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);
} | java |
protected ByteSource stream(final String resourceId) {
return new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return loader.getResource(resourceId).getInputStream();
}
};
} | java |
public static QueryRuntimeException fromThrowable(Throwable t) {
return (t instanceof QueryRuntimeException)
? (QueryRuntimeException) t
: new QueryRuntimeException(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);
} | java |
public static ProofViewException fromThrowable(Throwable cause) {
return (cause instanceof ProofViewException)
? (ProofViewException) cause
: new ProofViewException(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);
} | java |
public static KbException fromThrowable(Throwable cause) {
return (cause instanceof KbException)
? (KbException) cause
: new KbException(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);
} | java |
public static DeleteException fromThrowable(Throwable cause) {
return (cause instanceof DeleteException)
? (DeleteException) cause
: new DeleteException(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);
} | java |
@PostConstruct
public void initialize() {
if (this.initializationState.setInitializing()) {
if (this.visibility == null) {
this.visibility = VisibilityModifier.PUBLIC;
}
this.initializationState.setInitialized();
}
} | java |
public List<ModuleBuildFuture> getExtraBuilds() {
return extraBuilds == null ? Collections.<ModuleBuildFuture>emptyList() : Collections.unmodifiableList(extraBuilds);
} | 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());
} | 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;
} | 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;
} | 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$
}
} | 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;
}
} | 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);
}
} | java |
public void setNamespace(String prefix, String uri) {
this.prefix2namespace.put(prefix, uri);
this.namespace2prefix.put(uri, prefix);
} | 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;
} | 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 + "'");
}
}
} | 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;
} | 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;
} | 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;
} | 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;
} | 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);
}
} | 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();
}
}
} | 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);
}
}
} | java |
public String toRuleString() {
if (0 == this.ruleNumber) {
return this.grammar.r0String;
}
return this.first.toString() + SPACE + this.second.toString() + SPACE;
} | 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;
} | java |
static public boolean isProvisional(Iterable<ICacheKeyGenerator> keyGens) {
boolean provisional = false;
for (ICacheKeyGenerator keyGen : keyGens) {
if (keyGen.isProvisional()) {
provisional = true;
break;
}
}
return provisional;
} | java |
public static <E> Collection<E> unionColl(Collection<E> c1, Collection<E> c2) {
return new UColl<E>(c1, c2);
} | 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);
}
} | java |
public static <K,V> MapFactory<K,V> cow(MapFactory<K,V> underMapFact) {
throw new UnsupportedOperationException("Not implemented yet");
} | 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);
}
}
} | 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;
} | 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);
} | 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;
} | 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;
} | 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;
} | 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;
} | 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;
} | 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;
} | 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;
} | 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;
} | 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;
} | 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;
} | 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);
}
}
}
}
}
} | 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);
}
}
}
}
}
} | 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;
} | 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());
} | 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);
} | 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;
} | 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;
} | 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();
} | 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;
} | 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);
}
} | 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;
} | 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;
} | 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;
} | 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);
} | 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;
} | java |
public ShareableResource setConsumption(int val, VM... vms) {
Stream.of(vms).forEach(v -> setConsumption(v, 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;
} | java |
public ShareableResource setCapacity(int val, Node... nodes) {
Stream.of(nodes).forEach(n -> this.setCapacity(n, val));
return this;
} | 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;
} | 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;
} | java |
public static ShareableResource get(Model mo, String id) {
return (ShareableResource) mo.getView(VIEW_ID_BASE + id);
} | java |
public String getlocalName() {
if (fqn.contains(".")) {
return this.fqn.substring(fqn.lastIndexOf('.') + 1, this.fqn.length());
}
return fqn;
} | java |
public boolean add(Collection<BtrpElement> elems) {
boolean ret = false;
for (BtrpElement el : elems) {
ret |= add(el);
}
return ret;
} | 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;
} | 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;
} | java |
public BtrpOperand getImportable(String label, String namespace) {
if (canImport(label, namespace)) {
return exported.get(label);
}
return null;
} | 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;
} | 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;
} | 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();
} | java |
public void addNode(Node n) {
try {
structure.addNode(n);
for (NodeListener listener : nodeListeners)
listener.onInsert(n);
} catch (DuplicatedNodeException e) {
duplicatedNodesCounter++;
}
} | java |
public void addEdge(Edge e) {
structure.addEdge(e);
for (EdgeListener listener : edgeListeners)
listener.onInsert(e);
} | 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();
}
};
} | 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;
} | 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);
}
}
} | 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();
} | java |
@SuppressWarnings("squid:S3346")
public void postRemoveItem(int item, int bin) {
assert candidate.get(bin).get(item);
candidate.get(bin).clear(item);
} | 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);
}
} | java |
public void add(Metrics m) {
timeCount += m.timeCount;
readingTimeCount += m.readingTimeCount;
nodes += m.nodes;
backtracks += m.backtracks;
fails += m.fails;
restarts += m.restarts;
} | 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;
} | 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;
} | 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;
} | java |
public static void verify(short value, Path path) {
Approval.of(short.class)
.withReporter(reporter)
.build()
.verify(value, path);
} | java |
public static String prettyType(BtrpOperand o) {
if (o == IgnorableOperand.getInstance()) {
return "??";
}
return prettyType(o.degree(), o.type());
} | 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();
} | java |
@Override
public void addDim(List<IntVar> c, int[] cUse, IntVar[] dUse) {
capacities.add(c);
cUsages.add(cUse);
dUsages.add(dUse);
} | 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;
} | 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;
} | 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;
} | 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;
} | java |
public Tree insert(int index, byte[] value, boolean asBase64String) {
if (asBase64String) {
return insertObjectInternal(index, BASE64.encode(value));
}
return insertObjectInternal(index, value);
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.