code
stringlengths
73
34.1k
label
stringclasses
1 value
public String evaluate(Features features, Set<String> discovered, boolean coerceUndefinedToFalse) { if (feature != null && discovered != null) { discovered.add(feature); } if (feature == null) { return nodeName; } else if (!coerceUndefinedToFalse && !features.contains(feature)) { return null; } else { if (features.isFeature(feature)) { return trueNode.evaluate(features, discovered, coerceUndefinedToFalse); } else { return falseNode.evaluate(features, discovered, coerceUndefinedToFalse); } } }
java
public void replaceWith(HasNode node) { feature = node.feature; nodeName = node.nodeName; trueNode = node.trueNode; falseNode = node.falseNode; }
java
public void replaceWith(String nodeName) { feature = null; this.nodeName = nodeName; trueNode = falseNode = null; }
java
protected String invoke(CommandProvider provider, CommandInterpreterWrapper interpreter) throws Exception { Method method = provider.getClass().getMethod("_aggregator", new Class[]{CommandInterpreter.class}); //$NON-NLS-1$ method.invoke(provider, new Object[]{interpreter}); return interpreter.getOutput(); }
java
public static final void setWriter(String format, TreeWriter writer) { String key = format.toLowerCase(); writers.put(key, writer); if (JSON.equals(key)) { cachedJsonWriter = writer; } }
java
public static <T> Predicate<T> TRUE() { return new Predicate<T>() { public boolean check(T obj) { return true; } }; }
java
public static <T> Predicate<T> FALSE() { return Predicate.<T>NOT(Predicate.<T>TRUE()); }
java
public static <T> Predicate<T> NOT(final Predicate<T> pred) { return new Predicate<T>() { public boolean check(T obj) { return !pred.check(obj); } }; }
java
public static <T> Predicate<T> AND(final Predicate<T> a, final Predicate<T> b) { return new Predicate<T>() { public boolean check(T obj) { return a.check(obj) && b.check(obj); } }; }
java
public static <T> Predicate<T> OR(final Predicate<T> a, final Predicate<T> b) { return new Predicate<T>() { public boolean check(T obj) { return a.check(obj) || b.check(obj); } }; }
java
public void fillVMIndex(TIntIntHashMap index, int p) { for (Node n : scope) { for (VM v : parent.getRunningVMs(n)) { index.put(v.id(), p); } for (VM v : parent.getSleepingVMs(n)) { index.put(v.id(), p); } } for (VM v : ready) { index.put(v.id(), p); } }
java
public Boolean getIncludeStatus() { if (formula.isTrue()) { return Boolean.TRUE; } else if (formula.isFalse()) { return Boolean.FALSE; } return null; }
java
public ModuleDepInfo andWith(ModuleDepInfo other) { if (other == null) { return this; } formula.andWith(other.formula); if (!isPluginNameDeclared && other.isPluginNameDeclared) { pluginName = other.pluginName; isPluginNameDeclared = true; } else if (pluginName == null) { pluginName = other.pluginName; isPluginNameDeclared = other.isPluginNameDeclared; } return this; }
java
public boolean add(ModuleDepInfo other) { Boolean modified = false; if (formula.isTrue()) { // No terms added to a true formula will change the evaluation. return false; } if (other.formula.isTrue()) { // Adding true to this formula makes this formula true. modified = !formula.isTrue(); formula = new BooleanFormula(true); if (modified && other.comment != null && other.commentTermSize < commentTermSize) { comment = other.comment; commentTermSize = other.commentTermSize; } return modified; } // Add the terms modified = formula.addAll(other.formula); // Copy over plugin name if needed if (!isPluginNameDeclared && other.isPluginNameDeclared) { pluginName = other.pluginName; isPluginNameDeclared = true; modified = true; } // And comments... if (other.comment != null && other.commentTermSize < commentTermSize) { comment = other.comment; commentTermSize = other.commentTermSize; } return modified; }
java
public void setMinMaxLength(int[] lengths) { Arrays.sort(lengths); this.minLength = lengths[0]; this.maxLength = lengths[lengths.length - 1]; }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) protected AbstractGenericType<T> create(Type genericType, GenericType<?> genericDefiningType) { return new GenericTypeImpl(genericType, genericDefiningType); }
java
public static <T> void inOrder(T root, BinTreeNavigator<T> binTreeNav, Action<T> action) { for(Iterator<T> it = inOrder(root, binTreeNav); it.hasNext(); ) { T treeVertex = it.next(); action.action(treeVertex); } }
java
private Map<Link, Boolean> getFirstPhysicalPath(Map<Link, Boolean> currentPath, Switch sw, Node dst) { // Iterate through the current switch's links for (Link l : net.getConnectedLinks(sw)) { // Wrong link if (currentPath.containsKey(l)) { continue; } /* * Go through the link and track the direction for full-duplex purpose * From switch to element => false : DownLink * From element to switch => true : UpLink */ currentPath.put(l, !l.getSwitch().equals(sw)); // Check what is after if (l.getElement() instanceof Node) { // Node found, path complete if (l.getElement().equals(dst)) { return currentPath; } } else { // Go to the next switch Map<Link, Boolean> recall = getFirstPhysicalPath( currentPath, l.getSwitch().equals(sw) ? (Switch) l.getElement() : l.getSwitch(), dst); // Return the complete path if found if (!recall.isEmpty()) { return recall; } } // Wrong link, go back currentPath.remove(l); } // No path found through this switch return new LinkedHashMap<>(); }
java
public Bundle getBundle(String symbolicName) { final String sourceMethod = "getBundle"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(FrameworkWiringBundleResolver.class.getName(), sourceMethod, new Object[]{symbolicName}); } Bundle[] candidates = Platform.getBundles(symbolicName, null); if (isTraceLogging) { log.finer("candidate bundles = " + Arrays.toString(candidates)); //$NON-NLS-1$ } if (candidates == null || candidates.length == 0) { if (isTraceLogging) { log.exiting(FrameworkWiringBundleResolver.class.getName(), sourceMethod, null); } return null; } if (candidates.length == 1) { // Only one choice, so return it if (isTraceLogging) { log.exiting(FrameworkWiringBundleResolver.class.getName(), sourceMethod, candidates[0]); } return candidates[0]; } if (fw == null) { if (isTraceLogging) { log.finer("Framework wiring not available. Returning bundle with latest version"); //$NON-NLS-1$ log.exiting(FrameworkWiringBundleResolver.class.getName(), sourceMethod, candidates[0]); } return candidates[0]; } Bundle result = null; // For each candidate bundle, check to see if it's wired, directly or indirectly, to the contributing bundle for (Bundle candidate : candidates) { Collection<Bundle> bundles = fw.getDependencyClosure(Arrays.asList(new Bundle[]{candidate})); for (Bundle bundle : bundles) { if (bundle.equals(contributingBundle)) { // found wired bundle. Return the candidate. result = candidate; break; } } if (result != null) { break; } } if (result == null) { if (isTraceLogging) { log.finer("No wired bundle found amoung candidates. Returning bundle with most recent version."); //$NON-NLS-1$ } result = candidates[0]; } if (isTraceLogging) { log.exiting(FrameworkWiringBundleResolver.class.getName(), sourceMethod, result); } return result; }
java
protected String getSourcesMappingEpilogue() { String root = ""; //$NON-NLS-1$ String contextPath = request.getRequestURI(); if (contextPath != null) { // We may be re-building a layer for a source map request where the layer // has been flushed from the cache. If that's the case, then the context // path will already include the source map path component, so just remove it. if (contextPath.endsWith(ILayer.SOURCEMAP_RESOURCE_PATH)) { contextPath = contextPath.substring(0, contextPath.length()-(ILayer.SOURCEMAP_RESOURCE_PATHCOMP.length()+1)); } // Because we're specifying a relative URL that is relative to the request for the // layer and aggregator paths are assumed to NOT include a trailing '/', then we // need to start the relative path with the last path component of the context // path so that the relative URL will be resolved correctly by the browser. For // more details, see refer to the behavior of URI.resolve(); int idx = contextPath.lastIndexOf("/"); //$NON-NLS-1$ root = contextPath.substring(idx!=-1 ? idx+1 : 0); if (root.length() > 0 && !root.endsWith("/")) { //$NON-NLS-1$ root += "/"; //$NON-NLS-1$ } } StringBuffer sb = new StringBuffer(); sb.append("//# sourceMappingURL=") //$NON-NLS-1$ .append(root) .append(ILayer.SOURCEMAP_RESOURCE_PATHCOMP); String queryString = request.getQueryString(); if (queryString != null) { sb.append("?").append(queryString); //$NON-NLS-1$ } return sb.toString(); }
java
protected List<ModuleBuildFuture> collectFutures(ModuleList moduleList, HttpServletRequest request) throws IOException { final String sourceMethod = "collectFutures"; //$NON-NLS-1$ final boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod, new Object[]{moduleList, request}); } IAggregator aggr = (IAggregator)request.getAttribute(IAggregator.AGGREGATOR_REQATTRNAME); List<ModuleBuildFuture> futures = new ArrayList<ModuleBuildFuture>(); IModuleCache moduleCache = aggr.getCacheManager().getCache().getModules(); // For each source file, add a Future<IModule.ModuleReader> to the list for(ModuleList.ModuleListEntry moduleListEntry : moduleList) { IModule module = moduleListEntry.getModule(); Future<ModuleBuildReader> future = null; try { future = moduleCache.getBuild(request, module); } catch (NotFoundException e) { if (log.isLoggable(Level.FINER)) { log.logp(Level.FINER, sourceClass, sourceMethod, moduleListEntry.getModule().getModuleId() + " not found."); //$NON-NLS-1$ } future = new NotFoundModule(module.getModuleId(), module.getURI()).getBuild(request); if (!moduleListEntry.isServerExpanded()) { // Treat as error. Return error response, or if debug mode, then include // the NotFoundModule in the response. if (options.isDevelopmentMode() || options.isDebugMode()) { // Don't cache responses containing error modules. request.setAttribute(ILayer.NOCACHE_RESPONSE_REQATTRNAME, Boolean.TRUE); } else { // Rethrow the exception to return an error response throw e; } } else { // Not an error if we're doing server-side expansion, but if debug mode // then get the error message from the completed future so that we can output // a console warning in the browser. if (options.isDevelopmentMode() || options.isDebugMode()) { try { nonErrorMessages.add(future.get().getErrorMessage()); } catch (Exception ex) { // Sholdn't ever happen as this is a CompletedFuture throw new RuntimeException(ex); } } if (isTraceLogging) { log.logp(Level.FINER, sourceClass, sourceMethod, "Ignoring exception for server expanded module " + e.getMessage(), e); //$NON-NLS-1$ } // Don't add the future for the error module to the response. continue; } } catch (UnsupportedOperationException ex) { // Missing resource factory or module builder for this resource if (moduleListEntry.isServerExpanded()) { // ignore the error if it's a server expanded module if (isTraceLogging) { log.logp(Level.FINER, sourceClass, sourceMethod, "Ignoring exception for server expanded module " + ex.getMessage(), ex); //$NON-NLS-1$ } continue; } else { // re-throw the exception throw ex; } } futures.add(new ModuleBuildFuture( module, future, moduleListEntry.getSource() )); } if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, futures); } return futures; }
java
protected String notifyLayerListeners(ILayerListener.EventType type, HttpServletRequest request, IModule module) throws IOException { StringBuffer sb = new StringBuffer(); // notify any listeners that the config has been updated List<IServiceReference> refs = null; if(aggr.getPlatformServices() != null){ try { IServiceReference[] ary = aggr.getPlatformServices().getServiceReferences(ILayerListener.class.getName(), "(name="+aggr.getName()+")"); //$NON-NLS-1$ //$NON-NLS-2$ if (ary != null) refs = Arrays.asList(ary); } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } if (refs != null) { if (type == EventType.END_LAYER) { // for END_LAYER, invoke the listeners in reverse order refs = new ArrayList<IServiceReference>(refs); Collections.reverse(refs); } for (IServiceReference ref : refs) { ILayerListener listener = (ILayerListener)aggr.getPlatformServices().getService(ref); try { Set<String> depFeatures = new HashSet<String>(); String str = listener.layerBeginEndNotifier(type, request, type == ILayerListener.EventType.BEGIN_MODULE ? Arrays.asList(new IModule[]{module}) : umLayerListenerModuleList, depFeatures); dependentFeatures.addAll(depFeatures); if (str != null) { sb.append(str); } } finally { aggr.getPlatformServices().ungetService(ref); } } } } return sb.toString(); }
java
public static String getModuleName(URI uri) { String name = uri.getPath(); if (name.endsWith("/")) { //$NON-NLS-1$ name = name.substring(0, name.length()-1); } int idx = name.lastIndexOf("/"); //$NON-NLS-1$ if (idx != -1) { name = name.substring(idx+1); } if (name.endsWith(".js")) { //$NON-NLS-1$ name = name.substring(0, name.length()-3); } return name; }
java
public static String getExtension(String path) { int idx = path.lastIndexOf("/"); //$NON-NLS-1$ String filename = idx == -1 ? path : path.substring(idx+1); idx = filename.lastIndexOf("."); //$NON-NLS-1$ return idx == -1 ? "" : filename.substring(idx+1); //$NON-NLS-1$ }
java
private boolean tryAddModule( IAggregator aggregator, List<String> list, String bundleRoot, IResource bundleRootRes, String locale, String resource, Collection<String> availableLocales) throws IOException { if (availableLocales != null && !availableLocales.contains(locale)) { return false; } boolean result = false; URI uri = bundleRootRes.getURI(); URI testUri = uri.resolve(locale + "/" + resource + ".js"); //$NON-NLS-1$ //$NON-NLS-2$ IResource testResource = aggregator.newResource(testUri); if (availableLocales != null || testResource.exists()) { String mid = bundleRoot+"/"+locale+"/"+resource; //$NON-NLS-1$ //$NON-NLS-2$ list.add(mid); result = true; } return result; }
java
private static <A> ForwardNavigator<RegExp<A>> unionNav() { return new ForwardNavigator<RegExp<A>>() { private Visitor<A,List<RegExp<A>>> unionVis = new Visitor<A,List<RegExp<A>>>() { public List<RegExp<A>> visit(Union<A> ure) { return Arrays.<RegExp<A>>asList(ure.left, ure.right); } public List<RegExp<A>> visit(RegExp<A> re) { return Collections.<RegExp<A>>emptyList(); } }; public List<RegExp<A>> next(RegExp<A> re) { return re.accept(unionVis); } }; }
java
private static <A> ForwardNavigator<RegExp<A>> concatNav() { return new ForwardNavigator<RegExp<A>>() { private Visitor<A,List<RegExp<A>>> concatVis = new Visitor<A,List<RegExp<A>>>() { public List<RegExp<A>> visit(Concat<A> ure) { return Arrays.<RegExp<A>>asList(ure.left, ure.right); } public List<RegExp<A>> visit(RegExp<A> re) { return Collections.<RegExp<A>>emptyList(); } }; public List<RegExp<A>> next(RegExp<A> re) { return re.accept(concatVis); } }; }
java
private Transformer createTransformer(boolean indent) { try { Transformer result = this.transformerFactory.newTransformer(); if (indent) { result.setOutputProperty(OutputKeys.INDENT, "yes"); } return result; } catch (TransformerConfigurationException e) { throw new IllegalStateException("XML Transformer misconfigured!" + " Probably your JVM does not support the required JAXP version!", e); } }
java
public Parameters parameters() { Parameters ps = new DefaultParameters() .setTimeLimit(timeout) .doRepair(repair) .doOptimize(optimize); if (single()) { ps.setVerbosity(verbosity); } if (chunk) { ps.setEnvironmentFactory(mo -> new EnvironmentBuilder().fromChunk().build()); } return ps; }
java
public Stream<LabelledInstance> instances() throws IOException { if (single()) { return Collections.singletonList(instance(new File(instance))).stream(); } @SuppressWarnings("resource") Stream<String> s = Files.lines(Paths.get(instances), StandardCharsets.UTF_8); return s.map(x -> instance(new File(x))); }
java
public File output() throws IOException { File o = new File(output); if (!o.exists() && !o.mkdirs()) { throw new IOException("Unable to create output folder '" + output + "'"); } return o; }
java
public static LabelledInstance instance(File f) { String path = f.getAbsolutePath(); return new LabelledInstance(path, JSON.readInstance(f)); }
java
public static <T1,T2,T3> Function<T1,T3> comp(final Function<T2,T3> func1, final Function<T1,T2> func2) { return new Function<T1,T3>() { public T3 f(T1 x) { return func1.f(func2.f(x)); } }; }
java
public Collection<VM> getAssociatedVGroup(VM u) { for (Collection<VM> vGrp : sets) { if (vGrp.contains(u)) { return vGrp; } } return Collections.emptySet(); }
java
protected Properties loadProps(Properties props) { // try to load the properties file first from the user's home directory File file = getPropsFile(); if (file != null) { // Try to load the file from the user's home directory if (file.exists()) { try { URL url = file.toURI().toURL(); loadFromUrl(props, url); } catch (MalformedURLException ex) { if (log.isLoggable(Level.WARNING)) { log.log(Level.WARNING, ex.getMessage(), ex); } } } } return props; }
java
protected void saveProps(Properties props) throws IOException { if (loadFromPropertiesFile) { // Persist the change to the properties file. File file = getPropsFile(); if (file != null) { FileWriter writer = new FileWriter(file); try { props.store(writer, null); } finally { writer.close(); } } } }
java
protected void updateNotify (long sequence) { IServiceReference[] refs = null; try { if(aggregator != null && aggregator.getPlatformServices() != null){ refs = aggregator.getPlatformServices().getServiceReferences(IOptionsListener.class.getName(),"(name=" + registrationName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ if (refs != null) { for (IServiceReference ref : refs) { IOptionsListener listener = (IOptionsListener)aggregator.getPlatformServices().getService(ref); if (listener != null) { try { listener.optionsUpdated(this, sequence); } catch (Throwable ignore) { } finally { aggregator.getPlatformServices().ungetService(ref); } } } } } } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } }
java
protected void propertiesFileUpdated(Properties updated, long sequence) { Properties newProps = new Properties(getDefaultOptions()); Enumeration<?> propsEnum = updated.propertyNames(); while (propsEnum.hasMoreElements()) { String name = (String)propsEnum.nextElement(); newProps.setProperty(name, updated.getProperty(name)); } setProps(newProps); updateNotify(sequence); }
java
protected void propsFileUpdateNotify(Properties updatedProps, long sequence) { if(aggregator == null || aggregator.getPlatformServices() == null // unit tests? || !loadFromPropertiesFile) return; IPlatformServices platformServices = aggregator.getPlatformServices(); try { IServiceReference[] refs = platformServices.getServiceReferences(OptionsImpl.class.getName(), "(propsFileName=" + getPropsFile().getAbsolutePath().replace("\\", "\\\\") + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ if (refs != null) { for (IServiceReference ref : refs) { String name = ref.getProperty("name"); //$NON-NLS-1$ if (!registrationName.equals(name)) { OptionsImpl impl = (OptionsImpl)platformServices.getService(ref); if (impl != null) { try { impl.propertiesFileUpdated(updatedProps, sequence); } catch (Throwable ignore) {} finally { platformServices.ungetService(ref); } } } } } } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } }
java
protected Properties initDefaultOptions() { Properties defaultValues = new Properties(); defaultValues.putAll(defaults); // See if there's an aggregator.properties in the class loader's root ClassLoader cl = OptionsImpl.class.getClassLoader(); URL url = cl.getResource(getPropsFilename()); if (url != null) { loadFromUrl(defaultValues, url); } // If the bundle defines properties, then load those too if(aggregator != null){ url = aggregator.getPlatformServices().getResource(getPropsFilename()); if (url != null) { loadFromUrl(defaultValues, url); } } Map<String, String> map = new HashMap<String, String>(); for (String name : defaultValues.stringPropertyNames()) { map.put(name, (String)defaultValues.getProperty(name)); } defaultOptionsMap = Collections.unmodifiableMap(map); return defaultValues; }
java
void setFromFractions(final double latFraction, final double lonFraction, final double latFractionDelta, final double lonFractionDelta) { assert (lonFractionDelta >= 0.0); assert (latFractionDelta != 0.0); lonFractionMin = lonFraction; lonFractionMax = lonFraction + lonFractionDelta; if (latFractionDelta < 0) { latFractionMin = latFraction + 1 + latFractionDelta; // y + yDelta can NOT be represented. latFractionMax = latFraction + 1; // y CAN be represented. } else { latFractionMin = latFraction; latFractionMax = latFraction + latFractionDelta; } }
java
@Override public boolean applyAction(Model c) { Mapping map = c.getMapping(); return !map.isOffline(node) && map.addOfflineNode(node); }
java
public static void join(SAXSymbol left, SAXSymbol right) { // System.out.println(" performing the join of " + getPayload(left) + " and " // + getPayload(right)); // check for an OLD digram existence - i.e. left must have a next symbol // if .n exists then we are joining TERMINAL symbols within the string, and must clean-up the // old digram if (left.n != null) { // System.out.println(" " + getPayload(left) // + " use to be in the digram table, cleaning up"); left.deleteDigram(); } // re-link left and right left.n = right; right.p = left; }
java
public void substitute(SAXRule r) { // System.out.println("[sequitur debug] *substitute* " + this.value + " with rule " // + r.asDebugLine()); // clean up this place and the next // here we keep the original position in the input string // r.addIndex(this.originalPosition); this.cleanUp(); this.n.cleanUp(); // link the rule instead of digram SAXNonTerminal nt = new SAXNonTerminal(r); nt.originalPosition = this.originalPosition; this.p.insertAfter(nt); // do p check // // TODO: not getting this if (!p.check()) { p.n.check(); } }
java
public void match(SAXSymbol theDigram, SAXSymbol matchingDigram) { SAXRule rule; SAXSymbol first, second; // System.out.println("[sequitur debug] *match* newDigram [" + newDigram.value + "," // + newDigram.n.value + "], old matching one [" + matchingDigram.value + "," // + matchingDigram.n.value + "]"); // if previous of matching digram is a guard if (matchingDigram.p.isGuard() && matchingDigram.n.n.isGuard()) { // reuse an existing rule rule = ((SAXGuard) matchingDigram.p).r; theDigram.substitute(rule); } else { // well, here we create a new rule because there are two matching digrams rule = new SAXRule(); try { // tie the digram's links together within the new rule // this uses copies of objects, so they do not get cut out of S first = (SAXSymbol) theDigram.clone(); second = (SAXSymbol) theDigram.n.clone(); rule.theGuard.n = first; first.p = rule.theGuard; first.n = second; second.p = first; second.n = rule.theGuard; rule.theGuard.p = second; // System.out.println("[sequitur debug] *newRule...* \n" + rule.getRules()); // put this digram into the hash // this effectively erases the OLD MATCHING digram with the new DIGRAM (symbol is wrapped // into Guard) theDigrams.put(first, first); // substitute the matching (old) digram with this rule in S // System.out.println("[sequitur debug] *newRule...* substitute OLD digram first."); matchingDigram.substitute(rule); // substitute the new digram with this rule in S // System.out.println("[sequitur debug] *newRule...* substitute NEW digram last."); theDigram.substitute(rule); // rule.assignLevel(); // System.out.println(" *** Digrams now: " + makeDigramsTable()); } catch (CloneNotSupportedException c) { c.printStackTrace(); } } // Check for an underused rule. if (rule.first().isNonTerminal() && (((SAXNonTerminal) rule.first()).r.count == 1)) ((SAXNonTerminal) rule.first()).expand(); rule.assignLevel(); }
java
protected static String getPayload(SAXSymbol symbol) { if (symbol.isGuard()) { return "guard of the rule " + ((SAXGuard) symbol).r.ruleIndex; } else if (symbol.isNonTerminal()) { return "nonterminal " + ((SAXNonTerminal) symbol).value; } return "symbol " + symbol.value; }
java
public List<String> getExtraModules() { return extraModules == null ? Collections.<String>emptyList() : Collections.unmodifiableList(extraModules); }
java
public DefaultReconfigurationProblemBuilder setNextVMsStates(Set<VM> ready, Set<VM> running, Set<VM> sleeping, Set<VM> killed) { runs = running; waits = ready; sleep = sleeping; over = killed; return this; }
java
public DefaultReconfigurationProblem build() throws SchedulerException { if (runs == null) { //The others are supposed to be null too as they are set using the same method Mapping map = model.getMapping(); runs = new HashSet<>(); sleep = new HashSet<>(); for (Node n : map.getOnlineNodes()) { runs.addAll(map.getRunningVMs(n)); sleep.addAll(map.getSleepingVMs(n)); } waits = map.getReadyVMs(); over = Collections.emptySet(); } if (manageable == null) { manageable = new HashSet<>(); manageable.addAll(model.getMapping().getSleepingVMs()); manageable.addAll(model.getMapping().getRunningVMs()); manageable.addAll(model.getMapping().getReadyVMs()); } if (ps == null) { ps = new DefaultParameters(); } return new DefaultReconfigurationProblem(model, ps, waits, runs, sleep, over, manageable); }
java
public static String inputStreamToString(InputStream in) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuffer buffer = new StringBuffer(); String line; while ((line = br.readLine()) != null) { buffer.append(line); } return buffer.toString(); }
java
@Override public int compareTo(RepairDigramRecord o) { if (this.freq > o.freq) { return 1; } else if (this.freq < o.freq) { return -1; } return 0; }
java
protected Class<?> getNIOFileResourceClass() { final String method = "getNIOFileResourceClass"; //$NON-NLS-1$ if (tryNIO && nioFileResourceClass == null) { try { nioFileResourceClass = classLoader .loadClass("com.ibm.jaggr.core.impl.resource.NIOFileResource"); //$NON-NLS-1$ } catch (ClassNotFoundException e) { tryNIO = false; // Don't try this again. if (log.isLoggable(Level.WARNING)) { log.logp(Level.WARNING, CLAZZ, method, e.getMessage()); log.logp(Level.WARNING, CLAZZ, method, WARN_MESSAGE); } } catch (UnsupportedClassVersionError e) { tryNIO = false; // Don't try this again. if (log.isLoggable(Level.WARNING)) { log.logp(Level.WARNING, CLAZZ, method, e.getMessage()); log.logp(Level.WARNING, CLAZZ, method, WARN_MESSAGE); } } } return nioFileResourceClass; }
java
protected Constructor<?> getNIOFileResourceConstructor(Class<?>... args) { final String method = "getNIOFileResourceConstructor"; //$NON-NLS-1$ if (tryNIO && nioFileResourceConstructor == null) { try { Class<?> clazz = getNIOFileResourceClass(); if (clazz != null) nioFileResourceConstructor = clazz.getConstructor(args); } catch (NoSuchMethodException e) { tryNIO = false; // Don't try this again. if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } if (log.isLoggable(Level.WARNING)) log.logp(Level.WARNING, CLAZZ, method, WARN_MESSAGE); } catch (SecurityException e) { tryNIO = false; // Don't try this again. if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } if (log.isLoggable(Level.WARNING)) log.logp(Level.WARNING, CLAZZ, method, WARN_MESSAGE); } } return nioFileResourceConstructor; }
java
protected Object getNIOInstance(Constructor<?> constructor, Object... args) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { final String method = "getInstance"; //$NON-NLS-1$ Object ret = null; if (tryNIO) { if (constructor != null) { try { ret = (IResource)constructor.newInstance(args); } catch (NoClassDefFoundError e) { if (log.isLoggable(Level.WARNING)) { log.logp(Level.WARNING, CLAZZ, method, e.getMessage()); log.logp(Level.WARNING, CLAZZ, method, WARN_MESSAGE); } tryNIO = false; } catch (UnsupportedClassVersionError e) { if (log.isLoggable(Level.WARNING)) { log.logp(Level.WARNING, CLAZZ, method, e.getMessage()); log.logp(Level.WARNING, CLAZZ, method, WARN_MESSAGE); } tryNIO = false; } } } return ret; }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) void complete() { if (this.range != null) { AbstractValidatorRange validator = null; if (this.valueType != null) { Class<?> valueClass = this.valueType.getAssignmentClass(); if (this.valueType.isCollection()) { validator = new ValidatorCollectionSize(this.range); } else if (this.valueType.isMap()) { validator = new ValidatorMapSize(this.range); } else if (this.valueType.getComponentType() != null) { validator = new ValidatorArrayLength(this.range); } else if (this.mathUtil.getNumberType(valueClass) != null) { validator = new ValidatorRange<>(this.range); } } if (validator == null) { validator = new ValidatorRangeGeneric<>(this.range); } this.validatorRegistry.add(validator); } }
java
protected void handleNoGetterForSetter(PojoPropertyAccessorOneArg setter, Class<?> targetClass, Object sourceObject, Class<?> sourceClass) { throw new PojoPropertyNotFoundException(sourceClass, setter.getName()); }
java
private void appendConsoleLogging(Node root) { if (logDebug && consoleDebugOutput.size() > 0) { // Emit code to call console.log on the client Node node = root; if (node.getType() == Token.BLOCK) { node = node.getFirstChild(); } if (node.getType() == Token.SCRIPT) { if (source == null) { // This is non-source build. Modify the AST Node firstNode = node.getFirstChild(); for (List<String> entry : consoleDebugOutput) { Node call = new Node(Token.CALL, new Node(Token.GETPROP, Node.newString(Token.NAME, "console"), //$NON-NLS-1$ Node.newString(Token.STRING, "log") //$NON-NLS-1$ ) ); for (String str : entry) { call.addChildToBack(Node.newString(str)); } node.addChildAfter(new Node(Token.EXPR_RESULT, call), firstNode); } } else { // Non-source build. Modify the AST for (List<String> entry : consoleDebugOutput) { StringBuffer sb = new StringBuffer("console.log("); //$NON-NLS-1$ int i = 0; for (String str : entry) { sb.append((i++ == 0 ? "" : ",") + "\"" + StringUtil.escapeForJavaScript(str) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } sb.append(");\n"); //$NON-NLS-1$ source.appendln(sb.toString()); } } } } }
java
public void close() throws IOException { if (dataStream != null) dataStream.close(); byteStream = null; dataStream = null; }
java
protected Collection<String> getRequestedLocales(HttpServletRequest request) { final String sourceMethod = "getRequestedLocales"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod, new Object[]{request.getQueryString()}); } String[] locales; String sLocales = getParameter(request, REQUESTEDLOCALES_REQPARAMS); if (sLocales != null) { locales = sLocales.split(","); //$NON-NLS-1$ } else { locales = new String[0]; } Collection<String> result = Collections.unmodifiableCollection(Arrays.asList(locales)); if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, result); } return result; }
java
protected String getHasConditionsFromRequest(HttpServletRequest request) throws IOException { final String sourceMethod = "getHasConditionsFromRequest"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod, new Object[]{request}); } String ret = null; if (request.getParameter(FEATUREMAPHASH_REQPARAM) != null) { // The cookie called 'has' contains the has conditions if (isTraceLogging) { log.finer("has hash = " + request.getParameter(FEATUREMAPHASH_REQPARAM)); //$NON-NLS-1$ } Cookie[] cookies = request.getCookies(); if (cookies != null) { for (int i = 0; ret == null && i < cookies.length; i++) { Cookie cookie = cookies[i]; if (cookie.getName().equals(FEATUREMAP_REQPARAM) && cookie.getValue() != null) { if (isTraceLogging) { log.finer("has cookie = " + cookie.getValue()); //$NON-NLS-1$ } ret = URLDecoder.decode(cookie.getValue(), "US-ASCII"); //$NON-NLS-1$ break; } } } if (ret == null) { if (log.isLoggable(Level.WARNING)) { StringBuffer url = request.getRequestURL(); if (url != null) { // might be null if using mock request for unit testing url.append("?").append(request.getQueryString()).toString(); //$NON-NLS-1$ log.warning(MessageFormat.format( Messages.AbstractHttpTransport_0, new Object[]{url, request.getHeader("User-Agent")})); //$NON-NLS-1$ } } } } else { ret = request.getParameter(FEATUREMAP_REQPARAM); if (isTraceLogging) { log.finer("reading features from has query arg"); //$NON-NLS-1$ } } if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, ret); } return ret; }
java
protected static String getParameter(HttpServletRequest request, String[] aliases) { final String sourceMethod = "getParameter"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod, new Object[]{request.getQueryString(), Arrays.asList(aliases)}); } Map<String, String[]> params = request.getParameterMap(); String result = null; for (Map.Entry<String, String[]> entry : params.entrySet()) { String name = entry.getKey(); for (String alias : aliases) { if (alias.equalsIgnoreCase(name)) { String[] values = entry.getValue(); result = values[values.length-1]; // return last value in array } } } if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, result); } return result; }
java
protected OptimizationLevel getOptimizationLevelFromRequest(HttpServletRequest request) { final String sourceMethod = "getOptimizationLevelFromRequest"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod, new Object[]{request.getQueryString()}); } // Get the optimization level specified in the request and set the ComilationLevel String optimize = getParameter(request, OPTIMIZATIONLEVEL_REQPARAMS); OptimizationLevel level = OptimizationLevel.SIMPLE; if (optimize != null && !optimize.equals("")) { //$NON-NLS-1$ if (optimize.equalsIgnoreCase("whitespace")) //$NON-NLS-1$ level = OptimizationLevel.WHITESPACE; else if (optimize.equalsIgnoreCase("advanced")) //$NON-NLS-1$ level = OptimizationLevel.ADVANCED; else if (optimize.equalsIgnoreCase("none")) //$NON-NLS-1$ level = OptimizationLevel.NONE; } if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, level); } return level; }
java
protected String getDynamicLoaderExtensionJavaScript(HttpServletRequest request) { final String sourceMethod = "getDynamicLoaderExtensionJavaScript"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod); } StringBuffer sb = new StringBuffer(); for (String contribution : getExtensionContributions()) { sb.append(contribution).append("\r\n"); //$NON-NLS-1$ } String cacheBust = AggregatorUtil.getCacheBust(getAggregator()); if (cacheBust != null && cacheBust.length() > 0) { sb.append("if (!require.combo.cacheBust){require.combo.cacheBust = '") //$NON-NLS-1$ .append(cacheBust).append("';}\r\n"); //$NON-NLS-1$ } contributeBootLayerDeps(sb, request); if (moduleIdListHash != null) { sb.append("require.combo.reg(null, ["); //$NON-NLS-1$ for (int i = 0; i < moduleIdListHash.length; i++) { sb.append(i == 0 ? "" : ", ").append(((int)moduleIdListHash[i])&0xFF); //$NON-NLS-1$ //$NON-NLS-2$ } sb.append("]);\r\n"); //$NON-NLS-1$ } sb.append(clientRegisterSyntheticModules()); if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, sb.toString()); } return sb.toString(); }
java
protected FeatureListResourceFactory newFeatureListResourceFactory(URI resourceUri) { final String methodName = "newFeatureMapJSResourceFactory"; //$NON-NLS-1$ boolean traceLogging = log.isLoggable(Level.FINER); if (traceLogging) { log.entering(sourceClass, methodName, new Object[]{resourceUri}); } FeatureListResourceFactory factory = new FeatureListResourceFactory(resourceUri); if (traceLogging) { log.exiting(sourceClass, methodName); } return factory; }
java
protected String clientRegisterSyntheticModules() { final String methodName = "clientRegisterSyntheticModules"; //$NON-NLS-1$ boolean traceLogging = log.isLoggable(Level.FINER); if (traceLogging) { log.entering(sourceClass, methodName); } StringBuffer sb = new StringBuffer(); Map<String, Integer> map = getModuleIdMap(); if (map != null && getModuleIdRegFunctionName() != null) { Collection<String> names = getSyntheticModuleNames(); if (names != null && names.size() > 0) { // register the text plugin name (combo/text) and name id with the client sb.append(getModuleIdRegFunctionName()).append("([[["); //$NON-NLS-1$ int i = 0; for (String name : names) { if (map.get(name) != null) { sb.append(i++==0 ?"":",").append("\"").append(name).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } } sb.append("]],[["); //$NON-NLS-1$ i = 0; for (String name : names) { Integer id = map.get(name); if (id != null) { sb.append(i++==0?"":",").append(id.intValue()); //$NON-NLS-1$ //$NON-NLS-2$ } } sb.append("]]]);"); //$NON-NLS-1$ } } if (traceLogging) { log.exiting(sourceClass, methodName, sb.toString()); } return sb.toString(); }
java
public static void main(String[] args) { System.out.println(LONG_NAME + " - Release " + RELEASE); System.out.println(); System.out.println(" " + CREDO); System.out.println(); System.out.println("Project maintainer: " + MAINTAINER); System.out.println("Javadoc accessible from the official website on SourceForge:\n\t" + WEBSITE); System.out.println("Submit bug reports / feature requests on the website."); }
java
private static int[] toBoundaries(String str) { int[] res = new int[9]; String[] split = str.split("\\s+"); for (int i = 0; i < 9; i++) { res[i] = Integer.valueOf(split[i]).intValue(); } return res; }
java
public Slice build() throws SchedulerException { if (hoster == null) { hoster = rp.makeHostVariable(lblPrefix, "_hoster"); } if (start == null) { start = rp.getStart(); } if (end == null) { end = rp.getEnd(); } if (duration == null) { duration = makeDuration(); } //UB for the time variables if (!start.isInstantiatedTo(0)) { //enforces start <= end, duration <= end, start + duration == end TaskMonitor.build(start, duration, end); } //start == 0 --> start <= end. duration = end enforced by TaskScheduler return new Slice(vm, start, end, duration, hoster); }
java
private IntVar makeDuration() throws SchedulerException { if (start.isInstantiated() && end.isInstantiated()) { int d = end.getValue() - start.getValue(); return rp.makeDuration(d, d, lblPrefix, "_duration"); } else if (start.isInstantiated()) { if (start.isInstantiatedTo(0)) { return end; } return rp.getModel().intOffsetView(end, -start.getValue()); } int inf = end.getLB() - start.getUB(); if (inf < 0) { inf = 0; } int sup = end.getUB() - start.getLB(); return rp.makeDuration(sup, inf, lblPrefix, "_duration"); }
java
public String generateSourceMap() throws IOException { final String sourceMethod = "generateSourceMap"; //$NON-NLS-1$ final boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod, new Object[]{name}); } String result = null; lineLengths = getLineLengths(); Compiler compiler = new Compiler(); sgen = new SourceMapGeneratorV3(); compiler.initOptions(compiler_options); currentLine = currentChar = 0; Node node = compiler.parse(JSSourceFile.fromCode(name, source)); if (compiler.hasErrors()) { if (log.isLoggable(Level.WARNING)) { JSError[] errors = compiler.getErrors(); for (JSError error : errors) { log.logp(Level.WARNING, sourceClass, sourceMethod, error.toString()); } } } if (node != null) { processNode(node); StringWriter writer = new StringWriter(); sgen.appendTo(writer, name); result = writer.toString(); } sgen = null; lineLengths = null; if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, result); } return result; }
java
private void processNode(Node node) throws IOException { for (Node cursor = node.getFirstChild(); cursor != null; cursor = cursor.getNext()) { int lineno = cursor.getLineno()-1; // adjust for rhino line numbers being 1 based int charno = cursor.getCharno(); if (lineno > currentLine || lineno == currentLine && charno > currentChar) { currentLine = lineno; currentChar = charno; } FilePosition endPosition = getEndPosition(cursor); sgen.addMapping(name, null, new FilePosition(currentLine, currentChar), new FilePosition(currentLine, currentChar), endPosition); if (cursor.hasChildren()) { processNode(cursor); } } }
java
protected void dispatchEvents() { while (true) { Object event = this.eventQueue.poll(); if (event == null) { return; } Collection<Throwable> errors = new LinkedList<>(); dispatchEvent(event, errors); if (!errors.isEmpty()) { handleErrors(errors, event); } } }
java
protected void handleErrors(Collection<Throwable> errors, Object event) { if (this.globalExceptionHandler == null) { for (Throwable error : errors) { LOG.error("Failed to dispatch event {}", event, error); } } else { this.globalExceptionHandler.handleErrors(event, errors.toArray(new Throwable[errors.size()])); } }
java
public BtrpOperand go(BtrPlaceTree parent) { append(token, "Unhandled token " + token.getText() + " (type=" + token.getType() + ")"); return IgnorableOperand.getInstance(); }
java
public IgnorableOperand ignoreError(Exception e) { append(token, e.getMessage()); return IgnorableOperand.getInstance(); }
java
public IgnorableOperand ignoreErrors(ErrorReporter err) { errors.getErrors().addAll(err.getErrors()); return IgnorableOperand.getInstance(); }
java
public IgnorableOperand ignoreError(Token t, String msg) { append(t, msg); return IgnorableOperand.getInstance(); }
java
public void append(Token t, String msg) { errors.append(t.getLine(), t.getCharPositionInLine(), msg); }
java
public T execute() { if (isWindows()) { return onWindows(); } else if (isMac()) { return onMac(); } else if (isUnix()) { return onUnix(); } else if (isSolaris()) { return onSolaris(); } else { throw new IllegalStateException("Invalid operating system " + os); } }
java
public BtrpOperand expand() { String head = getChild(0).getText().substring(0, getChild(0).getText().length() - 1); String tail = getChild(getChildCount() - 1).getText().substring(1); BtrpSet res = new BtrpSet(1, BtrpOperand.Type.STRING); for (int i = 1; i < getChildCount() - 1; i++) { BtrpOperand op = getChild(i).go(this); if (op == IgnorableOperand.getInstance()) { return op; } BtrpSet s = (BtrpSet) op; for (BtrpOperand o : s.getValues()) { //Compose res.getValues().add(new BtrpString(head + o.toString() + tail)); } } return res; }
java
public void add(DepTreeNode child) { if (children == null) { children = new HashMap<String, DepTreeNode>(); } children.put(child.getName(), child); child.setParent(this); }
java
public void overlay(DepTreeNode node) { if (node.defineDependencies != null || node.requireDependencies != null) { setDependencies(node.defineDependencies, node.requireDependencies, node.dependentFeatures, node.lastModified(), node.lastModifiedDep()); } node.uri = uri; if (node.getChildren() == null) { return; } for(Map.Entry<String, DepTreeNode> entry : node.getChildren().entrySet()) { DepTreeNode existing = getChild(entry.getKey()); if (existing == null) { add(entry.getValue()); } else { existing.overlay(entry.getValue()); } } }
java
public DepTreeNode createOrGet(String path, URI uri) { if (path.startsWith("/")) { //$NON-NLS-1$ throw new IllegalArgumentException(path); } if (path.length() == 0) return this; String[] pathComps = path.split("/"); //$NON-NLS-1$ DepTreeNode node = this; int i = 0; for (String comp : pathComps) { DepTreeNode childNode = node.getChild(comp); if (childNode == null) { childNode = new DepTreeNode(comp, i == pathComps.length-1 ? uri : null); node.add(childNode); } node = childNode; i++; } return node; }
java
public void remove(DepTreeNode child) { if (children != null) { DepTreeNode node = children.get(child.getName()); if (node == child) { children.remove(child.getName()); } } child.setParent(null); }
java
public void prune() { if (children != null) { List<String> removeList = new ArrayList<String>(); for (Entry<String, DepTreeNode> entry : children.entrySet()) { DepTreeNode child = entry.getValue(); child.prune(); if ((child.defineDependencies == null && child.requireDependencies == null && child.uri == null) && (child.children == null || child.children.isEmpty())) { removeList.add(entry.getKey()); } } for (String key : removeList) { children.remove(key); } } }
java
public void setDependencies(String[] defineDependencies, String[] requireDependencies, String[] dependentFeatures, long lastModifiedFile, long lastModifiedDep) { this.defineDependencies = defineDependencies; this.requireDependencies = requireDependencies; this.dependentFeatures = dependentFeatures; this.lastModified = lastModifiedFile; this.lastModifiedDep = lastModifiedDep; }
java
private long lastModifiedDepTree(long lm) { long result = (defineDependencies == null && requireDependencies == null) ? lm : Math.max(lm, this.lastModifiedDep); if (children != null) { for (Entry<String, DepTreeNode> entry : this.children.entrySet()) { result = entry.getValue().lastModifiedDepTree(result); } } return result; }
java
void populateDepMap(Map<String, DependencyInfo> depMap) { if (uri != null) { depMap.put(getFullPathName(), new DependencyInfo(defineDependencies, requireDependencies, dependentFeatures, uri)); } if (children != null) { for (Entry<String, DepTreeNode> entry : children.entrySet()) { entry.getValue().populateDepMap(depMap); } } }
java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Call the default implementation to de-serialize our object in.defaultReadObject(); parent = new WeakReference<DepTreeNode>(null); // restore parent reference on all children if (children != null) { for (Entry<String, DepTreeNode> entry : children.entrySet()) { entry.getValue().setParent(this); } } }
java
protected ServiceTracker<IOptions, ?> getOptionsServiceTracker(BundleContext bundleContext) throws InvalidSyntaxException { ServiceTracker<IOptions, ?> tracker = new ServiceTracker<IOptions, Object>( bundleContext, bundleContext.createFilter( "(&(" + Constants.OBJECTCLASS + "=" + IOptions.class.getName() + //$NON-NLS-1$ //$NON-NLS-2$ ")(name=" + getServletBundleName() + "))"), //$NON-NLS-1$ //$NON-NLS-2$ null); tracker.open(); return tracker; }
java
protected ServiceTracker<IExecutors, ?> getExecutorsServiceTracker(BundleContext bundleContext) throws InvalidSyntaxException { ServiceTracker<IExecutors, ?> tracker = new ServiceTracker<IExecutors, Object>( bundleContext, bundleContext.createFilter( "(&(" + Constants.OBJECTCLASS + "=" + IExecutors.class.getName() + //$NON-NLS-1$ //$NON-NLS-2$ ")(name=" + getServletBundleName() + "))"), //$NON-NLS-1$ //$NON-NLS-2$ null); tracker.open(); return tracker; }
java
public String createCacheBundle(String bundleSymbolicName, String bundleFileName) throws IOException { final String sourceMethod = "createCacheBundle"; //$NON-NLS-1$ final boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, sourceMethod, new Object[]{bundleSymbolicName, bundleFileName}); } // Serialize the cache getCacheManager().serializeCache(); // De-serialize the control file to obtain the cache control data File controlFile = new File(getWorkingDirectory(), CacheControl.CONTROL_SERIALIZATION_FILENAME); CacheControl control = null; ObjectInputStream ois = new ObjectInputStream(new FileInputStream(controlFile));; try { control = (CacheControl)ois.readObject(); } catch (Exception ex) { throw new IOException(ex); } finally { IOUtils.closeQuietly(ois); } if (control.getInitStamp() != 0) { return Messages.AggregatorImpl_3; } // create the bundle manifest InputStream is = AggregatorImpl.class.getClassLoader().getResourceAsStream(MANIFEST_TEMPLATE); StringWriter writer = new StringWriter(); CopyUtil.copy(is, writer); String template = writer.toString(); String manifest = MessageFormat.format(template, new Object[]{ Long.toString(new Date().getTime()), getContributingBundle().getHeaders().get("Bundle-Version"), //$NON-NLS-1$ bundleSymbolicName, AggregatorUtil.getCacheBust(this) }); // create the jar File bundleFile = new File(bundleFileName); ZipUtil.Packer packer = new ZipUtil.Packer(); packer.open(bundleFile); try { packer.packEntryFromStream("META-INF/MANIFEST.MF", new ByteArrayInputStream(manifest.getBytes("UTF-8")), new Date().getTime()); //$NON-NLS-1$ //$NON-NLS-2$ packer.packDirectory(getWorkingDirectory(), JAGGR_CACHE_DIRECTORY); } finally { packer.close(); } String result = bundleFile.getCanonicalPath(); if (isTraceLogging) { log.exiting(sourceClass, sourceMethod, result); } return result; }
java
public String processRequestUrl(String requestUrl) throws IOException, ServletException { ConsoleHttpServletRequest req = new ConsoleHttpServletRequest(getServletConfig().getServletContext(), requestUrl); OutputStream nulOutputStream = new OutputStream() { @Override public void write(int b) throws IOException {} }; ConsoleHttpServletResponse resp = new ConsoleHttpServletResponse(nulOutputStream); doGet(req, resp); return Integer.toString(resp.getStatus()); }
java
public void add(VMTransitionBuilder b) { Map<VMState, VMTransitionBuilder> m = vmAMB2.get(b.getDestinationState()); for (VMState src : b.getSourceStates()) { m.put(src, b); } }
java
public boolean remove(VMTransitionBuilder b) { Map<VMState, VMTransitionBuilder> m = vmAMB2.get(b.getDestinationState()); for (VMState src : b.getSourceStates()) { m.remove(src); } return true; }
java
public VMTransitionBuilder getBuilder(VMState srcState, VMState dstState) { Map<VMState, VMTransitionBuilder> dstCompliant = vmAMB2.get(dstState); if (dstCompliant == null) { return null; } return dstCompliant.get(srcState); }
java
public static TransitionFactory newBundle() { TransitionFactory f = new TransitionFactory(); f.add(new BootVM.Builder()); f.add(new ShutdownVM.Builder()); f.add(new SuspendVM.Builder()); f.add(new ResumeVM.Builder()); f.add(new KillVM.Builder()); f.add(new RelocatableVM.Builder()); f.add(new ForgeVM.Builder()); f.add(new StayAwayVM.BuilderReady()); f.add(new StayAwayVM.BuilderSleeping()); f.add(new StayAwayVM.BuilderInit()); f.add(new BootableNode.Builder()); f.add(new ShutdownableNode.Builder()); return f; }
java
public int getMaxBW(Node n1, Node n2) { int max = Integer.MAX_VALUE; for (Link inf : getPath(n1, n2)) { if (inf.getCapacity() < max) { max = inf.getCapacity(); } Switch sw = inf.getSwitch(); if (sw.getCapacity() >= 0 && sw.getCapacity() < max) { //The >= 0 stays for historical reasons max = sw.getCapacity(); } } return max; }
java
protected List<Link> getFirstPhysicalPath(List<Link> currentPath, Switch sw, Node dst) { // Iterate through the current switch's links for (Link l : net.getConnectedLinks(sw)) { // Wrong link if (currentPath.contains(l)) { continue; } // Go through the link currentPath.add(l); // Check what is after if (l.getElement() instanceof Node) { // Node found, path complete if (l.getElement().equals(dst)) { return currentPath; } } else { // Go to the next switch List<Link> recall = getFirstPhysicalPath( currentPath, l.getSwitch().equals(sw) ? (Switch) l.getElement() : l.getSwitch(), dst); // Return the complete path if found if (!recall.isEmpty()) { return recall; } } // Wrong link, go back currentPath.remove(currentPath.size() - 1); } // No path found through this switch return Collections.emptyList(); }
java
private int loadSlack(int dim, int bin) { return p.loads[dim][bin].getUB() - p.loads[dim][bin].getLB(); }
java