_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q16900
HelpUtil.createViewer
train
private static IHelpViewer createViewer(Page page) { IHelpViewer viewer; if (getViewerMode(page) == HelpViewerMode.POPUP) { viewer = new HelpViewerProxy(page); } else { BaseComponent root = PageUtil.createPage(VIEWER_URL, page).get(0); viewer = (IHelpViewer) root.getAttribute("controller"); } page.setAttribute(VIEWER_ATTRIB, viewer); return viewer; }
java
{ "resource": "" }
q16901
HelpUtil.removeViewer
train
protected static void removeViewer(Page page, boolean close) { IHelpViewer viewer = (IHelpViewer) page.removeAttribute(VIEWER_ATTRIB); if (viewer != null && close) { viewer.close(); } }
java
{ "resource": "" }
q16902
HelpUtil.removeViewer
train
protected static void removeViewer(Page page, IHelpViewer viewer, boolean close) { if (viewer != null && viewer == page.getAttribute(VIEWER_ATTRIB)) { removeViewer(page, close); } }
java
{ "resource": "" }
q16903
HelpUtil.getUrl
train
public static String getUrl(String path) { if (path == null) { return path; } ServletContext sc = ExecutionContext.getSession().getServletContext(); if (path.startsWith("jar:")) { int i = path.indexOf("!"); path = i < 0 ? path : path.substring(++i); } path = sc.getContextPath() + path; return path; }
java
{ "resource": "" }
q16904
HelpUtil.show
train
public static void show(String module, String topic, String label) { getViewer(true).show(module, topic, label); }
java
{ "resource": "" }
q16905
HelpUtil.showCSH
train
public static void showCSH(BaseComponent component) { while (component != null) { HelpContext target = (HelpContext) component.getAttribute(CSH_TARGET); if (target != null) { HelpUtil.show(target); break; } component = component.getParent(); } }
java
{ "resource": "" }
q16906
HelpUtil.associateCSH
train
public static void associateCSH(BaseUIComponent component, HelpContext helpContext, BaseUIComponent commandTarget) { if (component != null) { component.setAttribute(CSH_TARGET, helpContext); CommandUtil.associateCommand("help", component, commandTarget); } }
java
{ "resource": "" }
q16907
HelpUtil.dissociateCSH
train
public static void dissociateCSH(BaseUIComponent component) { if (component != null && component.hasAttribute(CSH_TARGET)) { CommandUtil.dissociateCommand("help", component); component.removeAttribute(CSH_TARGET); } }
java
{ "resource": "" }
q16908
DoubleArrays.subtract
train
public static void subtract(double[] array1, double[] array2) { assert (array1.length == array2.length); for (int i=0; i<array1.length; i++) { array1[i] -= array2[i]; } }
java
{ "resource": "" }
q16909
DoubleArrays.multiply
train
public static void multiply(double[] array1, double[] array2) { assert (array1.length == array2.length); for (int i=0; i<array1.length; i++) { array1[i] *= array2[i]; } }
java
{ "resource": "" }
q16910
DoubleArrays.divide
train
public static void divide(double[] array1, double[] array2) { assert (array1.length == array2.length); for (int i=0; i<array1.length; i++) { array1[i] /= array2[i]; } }
java
{ "resource": "" }
q16911
DoubleArrays.indexOf
train
public static int indexOf(double[] array, double val) { for (int i=0; i<array.length; i++) { if (array[i] == val) { return i; } } return -1; }
java
{ "resource": "" }
q16912
DoubleArrays.lastIndexOf
train
public static int lastIndexOf(double[] array, double val) { for (int i=array.length-1; i >= 0; i--) { if (array[i] == val) { return i; } } return -1; }
java
{ "resource": "" }
q16913
GuiceUtils.getPropertyProvider
train
public static Provider<String> getPropertyProvider(Binder binder, String propertyName) { return binder.getProvider(getPropertyKey(propertyName)); }
java
{ "resource": "" }
q16914
GuiceUtils.bindDefault
train
public static Provider<String> bindDefault(Binder binder, String propertyName, String defaultValue) { Key<String> propertyKey = getPropertyKey(propertyName); OptionalBinder<String> optionalBinder = OptionalBinder. newOptionalBinder(binder, propertyKey); optionalBinder.setDefault().toInstance(defaultValue); return binder.getProvider(propertyKey); }
java
{ "resource": "" }
q16915
Collectors.toList
train
public static <T> Collector<T, List<T>> toList() { return new Collector<T, List<T>>() { @Override public List<T> collect(Stream<? extends T> stream) { return Lists.newArrayList(stream.iterator()); } }; }
java
{ "resource": "" }
q16916
Collectors.toSet
train
public static <T> Collector<T, Set<T>> toSet() { return new Collector<T, Set<T>>() { @Override public Set<T> collect(Stream<? extends T> stream) { return Sets.newHashSet(stream.iterator()); } }; }
java
{ "resource": "" }
q16917
ViewTransform.transform
train
@Override public void transform(InputStream inputStream, OutputStream outputStream) throws Exception { try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, CS_WIN1252))) { String line; String closingTag = null; Stack<String> stack = new Stack<>(); String id = null; String url = null; String label = null; while ((line = reader.readLine()) != null) { line = line.trim(); int i = line.indexOf('>', 1); int j = line.indexOf(' ', 1); int end = i == -1 ? j : j == -1 ? i : i < j ? i : j; int token = ArrayUtils.indexOf(TOKENS, end < 1 ? "" : line.substring(1, end).toLowerCase()); if (stack.isEmpty() && token != 0) { continue; } switch (token) { case 0: // <ul> if (closingTag != null) { write(outputStream, ">", true, 0); closingTag = "</topic>"; } stack.push(closingTag); closingTag = null; break; case 1: // </ul> write(outputStream, closingTag, true, 0); closingTag = stack.pop(); writeClosingTag(outputStream, closingTag, stack.size()); closingTag = null; break; case 2: // <li> writeClosingTag(outputStream, closingTag, 0); write(outputStream, "<topic", false, stack.size()); closingTag = " />"; break; case 3: // <param> String name = extractAttribute("name", line); String value = extractAttribute("value", line); if ("name".equalsIgnoreCase(name)) { if (label == null) { label = value; } else { id = value; } } else if ("local".equalsIgnoreCase(name)) { url = value; } break; case 4: // </object> writeAttribute(outputStream, "id", id); writeAttribute(outputStream, "label", label); writeAttribute(outputStream, "url", url); id = label = url = null; break; } } } }
java
{ "resource": "" }
q16918
ScopeContainer.registerDestructionCallback
train
@Override public void registerDestructionCallback(String name, Runnable callback) { synchronized (this) { destructionCallbacks.put(name, callback); } }
java
{ "resource": "" }
q16919
ScopeContainer.destroy
train
public void destroy() { for (Entry<String, Runnable> entry : destructionCallbacks.entrySet()) { try { entry.getValue().run(); } catch (Throwable t) { log.error("Error during destruction callback for bean " + entry.getKey(), t); } } beans.clear(); destructionCallbacks.clear(); }
java
{ "resource": "" }
q16920
LabelPropertySource.getProperty
train
@Override public String getProperty(String name) { return name.startsWith(LABEL_PREFIX) ? StrUtil.getLabel(name.substring(LABEL_PREFIX.length())) : null; }
java
{ "resource": "" }
q16921
RRPerformanceSiteV1_0Generator.setAddress
train
private void setAddress(Address address, RolodexContract rolodex) { if (rolodex != null) { address.setStreet1(rolodex.getAddressLine1()); address.setStreet2(rolodex.getAddressLine2()); address.setCity(checkNull(rolodex.getCity())); address.setCounty(rolodex.getCounty()); address.setState(rolodex.getState()); address.setZipCode(rolodex.getPostalCode()); if (rolodex.getCountryCode() != null) { CountryCodeType.Enum country = CountryCodeType.Enum.forString(rolodex.getCountryCode()); address.setCountry(country); } }else { address.setStreet1(""); address.setCity(""); } }
java
{ "resource": "" }
q16922
ChmSource.buildEntryList
train
private Set<ChmEntry> buildEntryList() throws TikaException { Set<ChmEntry> entries = new TreeSet<>(); for (DirectoryListingEntry entry : chmExtractor.getChmDirList().getDirectoryListingEntryList()) { String name = entry.getName(); if (name.startsWith("/") && !name.equals("/") && !name.startsWith("/$")) { entries.add(new ChmEntry(entry)); } } return entries; }
java
{ "resource": "" }
q16923
ChmSource.findEntry
train
private ChmEntry findEntry(String file) { for (ChmEntry entry : entries) { if (file.equals(entry.getSourcePath())) { return entry; } } return null; }
java
{ "resource": "" }
q16924
PropertyEditorBase.hasChanged
train
public boolean hasChanged() { Object currentValue = getValue(); return value == null || currentValue == null ? value != currentValue : !value.equals(currentValue); }
java
{ "resource": "" }
q16925
PropertyEditorBase.init
train
protected void init(Object target, PropertyInfo propInfo, PropertyGrid propGrid) { this.target = target; this.propInfo = propInfo; this.propGrid = propGrid; this.index = propGrid.getEditorCount(); wireController(); }
java
{ "resource": "" }
q16926
PropertyEditorBase.commit
train
public boolean commit() { try { setWrongValueMessage(null); propInfo.setPropertyValue(target, getValue()); updateValue(); return true; } catch (Exception e) { setWrongValueException(e); return false; } }
java
{ "resource": "" }
q16927
PropertyEditorBase.revert
train
public boolean revert() { try { setWrongValueMessage(null); setValue(propInfo.getPropertyValue(target)); updateValue(); return true; } catch (Exception e) { setWrongValueException(e); return false; } }
java
{ "resource": "" }
q16928
MarkovGenerator.nextParagraphs
train
public List<String> nextParagraphs() { return nextParagraphs(Math.min(Math.max(4 + (int) (random.nextGaussian() * 3d), 1), 8)); }
java
{ "resource": "" }
q16929
MarkovGenerator.nextParagraphs
train
public List<String> nextParagraphs(int num) { List<String> paragraphs = new ArrayList<String>(num); for(int i = 0; i < num; i++) { paragraphs.add(nextParagraph()); } return paragraphs; }
java
{ "resource": "" }
q16930
MarkovGenerator.nextParagraph
train
public String nextParagraph(int totalSentences) { StringBuilder out = new StringBuilder(); List<String> lastWords = new ArrayList<String>(); lastWords.add(null); lastWords.add(null); int numSentences = 0; boolean inSentence = false; boolean inQuote = false; while(numSentences < totalSentences) { List<String> words = pairTable.get(lastWords); if(words == null) { // no hit for the digram, try just the last word words = singleWordTable.get(lastWords.get(1)); } if(words == null) { // hit end of paragraph pair, nothing directly following. start again words = pairTable.get(Arrays.<String>asList(null, null)); } String nextWord = words.get(random.nextInt(words.size())); if(nextWord.length() == 1 && sentenceEndChars.indexOf(nextWord.charAt(0)) != -1) { out.append(nextWord); if(inQuote) { out.append('"'); } numSentences++; inSentence = false; inQuote = false; lastWords.remove(0); lastWords.add(null); // look up } else { if(!inSentence) { // start a new sentence if(out.length() > 0) { out.append(" "); } inSentence = true; } else { // need a word separator out.append(" "); } out.append(nextWord); if(nextWord.indexOf('"') != -1) { inQuote = true; } } lastWords.remove(0); lastWords.add(nextWord); } return out.toString(); }
java
{ "resource": "" }
q16931
CommonSF424BaseGenerator.getEOStateReview
train
public Map<String, String> getEOStateReview(ProposalDevelopmentDocumentContract pdDoc) { Map<String, String> stateReview = new HashMap<>(); List<? extends AnswerHeaderContract> answerHeaders = propDevQuestionAnswerService.getQuestionnaireAnswerHeaders(pdDoc.getDevelopmentProposal().getProposalNumber()); if (!answerHeaders.isEmpty()) { for (AnswerContract answers : answerHeaders.get(0).getAnswers()) { Integer questionSeqId = getQuestionAnswerService().findQuestionById(answers.getQuestionId()).getQuestionSeqId(); if (questionSeqId != null && questionSeqId.equals(PROPOSAL_YNQ_QUESTION_129)) { stateReview.putIfAbsent(YNQ_ANSWER, answers.getAnswer()); } if (questionSeqId != null && questionSeqId.equals(PROPOSAL_YNQ_QUESTION_130)) { stateReview.putIfAbsent(YNQ_REVIEW_DATE, answers.getAnswer()); } if (questionSeqId != null && questionSeqId.equals(PROPOSAL_YNQ_QUESTION_131)) { stateReview.putIfAbsent(YNQ_STATE_REVIEW_DATA, answers.getAnswer()); } } } // If question is not answered or question is inactive if (stateReview.size() == 0) { stateReview.put(YNQ_ANSWER, YNQ_NOT_REVIEWED); stateReview.put(YNQ_REVIEW_DATE, null); } return stateReview; }
java
{ "resource": "" }
q16932
CommonSF424BaseGenerator.getDivisionName
train
public String getDivisionName(ProposalDevelopmentDocumentContract pdDoc) { String divisionName = null; if (pdDoc != null && pdDoc.getDevelopmentProposal().getOwnedByUnit() != null) { UnitContract ownedByUnit = pdDoc.getDevelopmentProposal().getOwnedByUnit(); // traverse through the parent units till the top level unit while (ownedByUnit.getParentUnit() != null) { ownedByUnit = ownedByUnit.getParentUnit(); } divisionName = ownedByUnit.getUnitName(); if (divisionName.length() > DIVISION_NAME_MAX_LENGTH) { divisionName = divisionName.substring(0, DIVISION_NAME_MAX_LENGTH); } } return divisionName; }
java
{ "resource": "" }
q16933
AbstractProcessor.registerTransform
train
public void registerTransform(String pattern, AbstractTransform transform) { transforms.add(new Transform(new WildcardFileFilter(pattern.split("\\,")), transform)); }
java
{ "resource": "" }
q16934
AbstractProcessor.replaceURLs
train
public String replaceURLs(String line) { StringBuffer sb = new StringBuffer(); Matcher matcher = URL_PATTERN.matcher(line); String newPath = "web/" + getResourceBase() + "/"; while (matcher.find()) { char dlm = line.charAt(matcher.start() - 1); int i = line.indexOf(dlm, matcher.end()); String url = i > 0 ? line.substring(matcher.start(), i) : null; if (url == null || (!mojo.isExcluded(url) && getTransform(url) != null)) { matcher.appendReplacement(sb, newPath); } } matcher.appendTail(sb); return sb.toString(); }
java
{ "resource": "" }
q16935
AbstractProcessor.transform
train
protected boolean transform(IResource resource) throws Exception { String name = StringUtils.trimToEmpty(resource.getSourcePath()); if (resource.isDirectory() || mojo.isExcluded(name)) { return false; } AbstractTransform transform = getTransform(name); String targetPath = transform == null ? null : transform.getTargetPath(resource); if (targetPath != null) { File out = mojo.newStagingFile(relocateResource(targetPath), resource.getTime()); try (OutputStream outputStream = new FileOutputStream(out);) { transform.transform(resource, outputStream); return true; } } return false; }
java
{ "resource": "" }
q16936
AbstractProcessor.getTransform
train
private AbstractTransform getTransform(String fileName) { File file = new File(fileName); for (Transform transform : transforms) { if (transform.filter.accept(file)) { return transform.transform; } } return null; }
java
{ "resource": "" }
q16937
StringUtils.substringBefore
train
public static String substringBefore(final String str, final String separator) { if (Strings.isNullOrEmpty(str)) { return str; } final int pos = str.indexOf(separator); if (pos == -1) { return str; } return str.substring(0, pos); }
java
{ "resource": "" }
q16938
ActionRegistry.getRegisteredAction
train
public static IAction getRegisteredAction(String id) { IAction action = getRegistry(false).get(id); return action == null ? getRegistry(true).get(id) : action; }
java
{ "resource": "" }
q16939
ActionRegistry.getRegisteredActions
train
public static Collection<IAction> getRegisteredActions(ActionScope scope) { Map<String, IAction> actions = new HashMap<>(); if (scope == ActionScope.BOTH || scope == ActionScope.GLOBAL) { actions.putAll(getRegistry(true).map); } if (scope == ActionScope.BOTH || scope == ActionScope.LOCAL) { actions.putAll(getRegistry(false).map); } return actions.values(); }
java
{ "resource": "" }
q16940
ActionRegistry.getRegistry
train
private static ActionRegistry getRegistry(boolean global) { if (global) { return instance; } Page page = ExecutionContext.getPage(); ActionRegistry registry = (ActionRegistry) page.getAttribute(ATTR_LOCAL_REGISTRY); if (registry == null) { page.setAttribute(ATTR_LOCAL_REGISTRY, registry = new ActionRegistry()); } return registry; }
java
{ "resource": "" }
q16941
Progress.updateProgress
train
ProgressEvent updateProgress(double val, long now) { if (val<0 || val>1) { throw new IllegalArgumentException("Value out of range [0, 1]: " + val); } if (val<=progress.getProgress()) { reset(start); } double pD = val - progress.getProgress(); long tD = now - tstamp; if (step > 0) { step = step * 0.3 + (tD / pD) * 0.7; } else { step = (tD / pD); } double etcMs = step * (1 - val); progress = new ProgressEvent(val, new Date(now + (long)Math.round(etcMs))); tstamp = now; return progress; }
java
{ "resource": "" }
q16942
JMSService.connect
train
private boolean connect() { if (this.factory == null) { return false; } if (isConnected()) { return true; } try { this.connection = this.factory.createConnection(); this.session = (TopicSession) this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE); this.connection.start(); return true; } catch (Exception e) { log.error("Error communicating with JMS server: " + e.getMessage()); disconnect(); return false; } }
java
{ "resource": "" }
q16943
JMSService.disconnect
train
private void disconnect() { if (this.session != null) { try { this.session.close(); } catch (Exception e) { log.error("Error closing JMS topic session.", e); } } if (this.connection != null) { try { this.connection.stop(); this.connection.close(); } catch (Exception e) { log.error("Error closing JMS topic connection.", e); } } this.session = null; this.connection = null; }
java
{ "resource": "" }
q16944
ElementUI.getAssociatedElement
train
public static ElementUI getAssociatedElement(BaseComponent component) { return component == null ? null : (ElementUI) component.getAttribute(ASSOC_ELEMENT); }
java
{ "resource": "" }
q16945
ElementUI.getDesignContextMenu
train
public static Menupopup getDesignContextMenu(BaseComponent component) { return component == null ? null : (Menupopup) component.getAttribute(CONTEXT_MENU); }
java
{ "resource": "" }
q16946
ElementUI.getTemplateUrl
train
protected String getTemplateUrl() { return "web/" + getClass().getPackage().getName().replace(".", "/") + "/" + StringUtils.uncapitalize(getClass().getSimpleName()) + ".fsp"; }
java
{ "resource": "" }
q16947
ElementUI.setDesignMode
train
@Override public void setDesignMode(boolean designMode) { super.setDesignMode(designMode); for (ElementTrigger trigger : triggers) { trigger.setDesignMode(designMode); } setDesignContextMenu(designMode ? DesignContextMenu.getInstance().getMenupopup() : null); mask.update(); }
java
{ "resource": "" }
q16948
ElementUI.afterParentChanged
train
@Override protected void afterParentChanged(ElementBase oldParent) { if (getParent() != null) { if (!getDefinition().isInternal()) { bind(); } setDesignMode(getParent().isDesignMode()); } }
java
{ "resource": "" }
q16949
ElementUI.getVisibleChild
train
private ElementUI getVisibleChild(boolean first) { int count = getChildCount(); int start = first ? 0 : count - 1; int inc = first ? 1 : -1; for (int i = start; i >= 0 && i < count; i += inc) { ElementUI child = (ElementUI) getChild(i); if (child.isVisible()) { return child; } } return null; }
java
{ "resource": "" }
q16950
ElementUI.getNextSibling
train
public ElementUI getNextSibling(boolean visibleOnly) { ElementUI parent = getParent(); if (parent != null) { int count = parent.getChildCount(); for (int i = getIndex() + 1; i < count; i++) { ElementUI child = (ElementUI) parent.getChild(i); if (!visibleOnly || child.isVisible()) { return child; } } } return null; }
java
{ "resource": "" }
q16951
ElementUI.afterMoveChild
train
@Override protected void afterMoveChild(ElementBase child, ElementBase before) { moveChild(((ElementUI) child).getOuterComponent(), ((ElementUI) before).getOuterComponent()); updateMasks(); }
java
{ "resource": "" }
q16952
ElementUI.applyColor
train
protected void applyColor(BaseUIComponent comp) { if (comp instanceof BaseLabeledComponent) { comp.invoke(comp.sub("lbl"), "css", "color", getColor()); } else if (comp != null) { comp.addStyle("background-color", getColor()); } }
java
{ "resource": "" }
q16953
ElementUI.hasVisibleElements
train
protected boolean hasVisibleElements(BaseUIComponent component) { for (BaseUIComponent child : component.getChildren(BaseUIComponent.class)) { ElementUI ele = getAssociatedElement(child); if (ele != null && ele.isVisible()) { return true; } if (hasVisibleElements(child)) { return true; } } return false; }
java
{ "resource": "" }
q16954
ByteArrayList.set
train
public void set(int i, byte value) { if (i < 0 || i >= size) { throw new IndexOutOfBoundsException(); } elements[i] = value; }
java
{ "resource": "" }
q16955
ByteArrayList.add
train
public void add(byte[] values) { ensureCapacity(size + values.length); for (byte element : values) { this.add(element); } }
java
{ "resource": "" }
q16956
Multinomials.normalizeProps
train
public static double normalizeProps(double[] props) { double propSum = DoubleArrays.sum(props); if (propSum == 0) { for (int d = 0; d < props.length; d++) { props[d] = 1.0 / (double)props.length; } } else if (propSum == Double.POSITIVE_INFINITY) { int count = DoubleArrays.count(props, Double.POSITIVE_INFINITY); if (count == 0) { throw new RuntimeException("Unable to normalize since sum is infinite but contains no infinities: " + Arrays.toString(props)); } double constant = 1.0 / (double) count; for (int d=0; d<props.length; d++) { if (props[d] == Double.POSITIVE_INFINITY) { props[d] = constant; } else { props[d] = 0.0; } } } else { for (int d = 0; d < props.length; d++) { props[d] /= propSum; assert(!Double.isNaN(props[d])); } } return propSum; }
java
{ "resource": "" }
q16957
Multinomials.normalizeLogProps
train
public static double normalizeLogProps(double[] logProps) { double logPropSum = DoubleArrays.logSum(logProps); if (logPropSum == Double.NEGATIVE_INFINITY) { double uniform = FastMath.log(1.0 / (double)logProps.length); for (int d = 0; d < logProps.length; d++) { logProps[d] = uniform; } } else if (logPropSum == Double.POSITIVE_INFINITY) { int count = DoubleArrays.count(logProps, Double.POSITIVE_INFINITY); if (count == 0) { throw new RuntimeException("Unable to normalize since sum is infinite but contains no infinities: " + Arrays.toString(logProps)); } double constant = FastMath.log(1.0 / (double) count); for (int d=0; d<logProps.length; d++) { if (logProps[d] == Double.POSITIVE_INFINITY) { logProps[d] = constant; } else { logProps[d] = Double.NEGATIVE_INFINITY; } } } else { for (int d = 0; d < logProps.length; d++) { logProps[d] -= logPropSum; assert(!Double.isNaN(logProps[d])); } } return logPropSum; }
java
{ "resource": "" }
q16958
Multinomials.klDivergence
train
public static double klDivergence(double[] p, double[] q) { if (p.length != q.length) { throw new IllegalStateException("The length of p and q must be the same."); } double delta = 1e-8; if (!Multinomials.isMultinomial(p, delta)) { throw new IllegalStateException("p is not a multinomial"); } if (!Multinomials.isMultinomial(q, delta)) { throw new IllegalStateException("q is not a multinomial"); } double kl = 0.0; for (int i=0; i<p.length; i++) { if (p[i] == 0.0 || q[i] == 0.0) { continue; } kl += p[i] * FastMath.log(p[i] / q[i]); } return kl; }
java
{ "resource": "" }
q16959
IntDoubleHashVector.toNativeArray
train
public double[] toNativeArray() { final double[] arr = new double[getNumImplicitEntries()]; iterate(new FnIntDoubleToVoid() { @Override public void call(int idx, double val) { arr[idx] = val; } }); return arr; }
java
{ "resource": "" }
q16960
AboutParams.getLabel
train
private String getLabel(String key) { String label = StrUtil.getLabel("cwf.shell.about." + key.toString()); return label == null ? key : label; }
java
{ "resource": "" }
q16961
H2DataSource.init
train
public H2DataSource init() throws Exception { if (dbMode == DBMode.LOCAL) { String port = getPort(); if (port.isEmpty()) { server = Server.createTcpServer(); } else { server = Server.createTcpServer("-tcpPort", port); } server.start(); } return this; }
java
{ "resource": "" }
q16962
H2DataSource.getPort
train
private String getPort() { String url = getUrl(); int i = url.indexOf("://") + 3; int j = url.indexOf("/", i); String s = i == 2 || j == -1 ? "" : url.substring(i, j); i = s.indexOf(":"); return i == -1 ? "" : s.substring(i + 1); }
java
{ "resource": "" }
q16963
SpewGenerator.nextLine
train
public String nextLine(Map<String,Object> extraClasses) { return mainClass.render(null, preprocessExtraClasses(extraClasses)); }
java
{ "resource": "" }
q16964
HelpTopic.isDuplicate
train
public boolean isDuplicate(HelpTopic topic) { return ObjectUtils.equals(url, topic.url) && compareTo(topic) == 0; }
java
{ "resource": "" }
q16965
PluginStatus.updateStatus
train
protected void updateStatus() { if (!plugins.isEmpty()) { boolean disabled = isDisabled(); for (ElementPlugin container : plugins) { container.setDisabled(disabled); } } }
java
{ "resource": "" }
q16966
PHS398FellowshipSupplementalV1_2Generator.getYesNoEnum
train
private Enum getYesNoEnum(String answer) { return answer.equals("Y") ? YesNoDataType.Y_YES : YesNoDataType.N_NO; }
java
{ "resource": "" }
q16967
ActionUtil.createAction
train
public static IAction createAction(String label, String script) { return new Action(script, label, script); }
java
{ "resource": "" }
q16968
ActionUtil.removeAction
train
public static ActionListener removeAction(BaseComponent component, String eventName) { ActionListener listener = getListener(component, eventName); if (listener != null) { listener.removeAction(); } return listener; }
java
{ "resource": "" }
q16969
ActionUtil.disableAction
train
public static void disableAction(BaseComponent component, String eventName, boolean disable) { ActionListener listener = getListener(component, eventName); if (listener != null) { listener.setDisabled(disable); } }
java
{ "resource": "" }
q16970
ActionUtil.createAction
train
private static IAction createAction(String action) { IAction actn = null; if (!StringUtils.isEmpty(action)) { if ((actn = ActionRegistry.getRegisteredAction(action)) == null) { actn = ActionUtil.createAction(null, action); } } return actn; }
java
{ "resource": "" }
q16971
ActionUtil.getListener
train
public static ActionListener getListener(BaseComponent component, String eventName) { return (ActionListener) component.getAttribute(ActionListener.getAttrName(eventName)); }
java
{ "resource": "" }
q16972
CertificateLoader.buildSSLContext
train
public static SSLContext buildSSLContext(HttpClientConfig config) throws IOException, GeneralSecurityException { KeyManagerFactory kmf = null; if (isSslKeyManagerEnabled(config)) { kmf = getKeyManagerFactory(config.getKeyStorePath(), new StoreProperties(config.getKeyStorePassword(), config.getKeyManagerType(), config.getKeyStoreType(), config.getKeyStoreProvider())); } TrustManagerFactory tmf = null; if (isSslTrustStoreEnbaled(config)) { tmf = getTrustManagerFactory(config.getTrustStorePath(), new StoreProperties(config.getTrustStorePassword(), config.getTrustManagerType(), config.getTrustStoreType(), config.getTrustStoreProvider())); } SSLContext sslContext = SSLContext.getInstance(config.getSslContextType()); sslContext.init(kmf != null ? kmf.getKeyManagers() : null, tmf != null ? tmf.getTrustManagers() : null, null); return sslContext; }
java
{ "resource": "" }
q16973
CertificateLoader.getResourceAsStream
train
private static InputStream getResourceAsStream(String path) throws IOException { if (StringUtils.isEmpty(path)) { return null; } // first try to load as file File file = new File(path); if (file.exists() && file.isFile()) { return new FileInputStream(file); } // if not a file fallback to classloader resource return CertificateLoader.class.getResourceAsStream(path); }
java
{ "resource": "" }
q16974
CertificateLoader.getFilenameInfo
train
private static String getFilenameInfo(String path) { if (StringUtils.isEmpty(path)) { return null; } try { return new File(path).getCanonicalPath(); } catch (IOException ex) { return new File(path).getAbsolutePath(); } }
java
{ "resource": "" }
q16975
CertificateLoader.isSslKeyManagerEnabled
train
public static boolean isSslKeyManagerEnabled(HttpClientConfig config) { return StringUtils.isNotEmpty(config.getSslContextType()) && StringUtils.isNotEmpty(config.getKeyManagerType()) && StringUtils.isNotEmpty(config.getKeyStoreType()) && StringUtils.isNotEmpty(config.getKeyStorePath()); }
java
{ "resource": "" }
q16976
CertificateLoader.isSslTrustStoreEnbaled
train
public static boolean isSslTrustStoreEnbaled(HttpClientConfig config) { return StringUtils.isNotEmpty(config.getSslContextType()) && StringUtils.isNotEmpty(config.getTrustManagerType()) && StringUtils.isNotEmpty(config.getTrustStoreType()) && StringUtils.isNotEmpty(config.getTrustStorePath()); }
java
{ "resource": "" }
q16977
CertificateLoader.createDefaultSSlContext
train
public static SSLContext createDefaultSSlContext() throws SSLInitializationException { try { final SSLContext sslcontext = SSLContext.getInstance(SSL_CONTEXT_TYPE_DEFAULT); sslcontext.init(null, null, null); return sslcontext; } catch (NoSuchAlgorithmException ex) { throw new SSLInitializationException(ex.getMessage(), ex); } catch (KeyManagementException ex) { throw new SSLInitializationException(ex.getMessage(), ex); } }
java
{ "resource": "" }
q16978
ByteSort.swap
train
private static void swap(byte[] array, int i, int j) { if (i != j) { byte valAtI = array[i]; array[i] = array[j]; array[j] = valAtI; numSwaps++; } }
java
{ "resource": "" }
q16979
MockupTypeEnumerator.getUrl
train
public String getUrl(String mockupType) { return mockupType == null ? null : mockupTypes.getProperty(mockupType); }
java
{ "resource": "" }
q16980
MockupTypeEnumerator.iterator
train
@Override public Iterator<String> iterator() { List<String> list = new ArrayList<>(mockupTypes.stringPropertyNames()); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list.iterator(); }
java
{ "resource": "" }
q16981
ShortArrayList.lookupIndex
train
public int lookupIndex(short value) { for (int i=0; i<elements.length; i++) { if (elements[i] == value) { return i; } } return -1; }
java
{ "resource": "" }
q16982
ShortArrayList.ensureCapacity
train
public static short[] ensureCapacity(short[] elements, int size) { if (size > elements.length) { short[] tmp = new short[size*2]; System.arraycopy(elements, 0, tmp, 0, elements.length); elements = tmp; } return elements; }
java
{ "resource": "" }
q16983
CareWebShellEx.pluginById
train
private PluginDefinition pluginById(String id) { PluginDefinition def = pluginRegistry.get(id); if (def == null) { throw new PluginException(EXC_UNKNOWN_PLUGIN, null, null, id); } return def; }
java
{ "resource": "" }
q16984
CareWebShellEx.registerMenu
train
public ElementMenuItem registerMenu(String path, String action) { ElementMenuItem menu = getElement(path, getDesktop().getMenubar(), ElementMenuItem.class); menu.setAction(action); return menu; }
java
{ "resource": "" }
q16985
CareWebShellEx.registerLayout
train
public void registerLayout(String path, String resource) throws Exception { Layout layout = LayoutParser.parseResource(resource); ElementUI parent = parentFromPath(path); if (parent != null) { layout.materialize(parent); } }
java
{ "resource": "" }
q16986
CareWebShellEx.parentFromPath
train
private ElementUI parentFromPath(String path) throws Exception { if (TOOLBAR_PATH.equalsIgnoreCase(path)) { return getDesktop().getToolbar(); } String[] pieces = path.split(delim, 2); ElementTabPane tabPane = pieces.length == 0 ? null : findTabPane(pieces[0]); ElementUI parent = pieces.length < 2 ? null : getPathResolver().resolvePath(tabPane, pieces[1]); return parent == null ? tabPane : parent; }
java
{ "resource": "" }
q16987
CareWebShellEx.findTabPane
train
private ElementTabPane findTabPane(String name) throws Exception { ElementTabView tabView = getTabView(); ElementTabPane tabPane = null; while ((tabPane = tabView.getChild(ElementTabPane.class, tabPane)) != null) { if (name.equalsIgnoreCase(tabPane.getLabel())) { return tabPane; } } tabPane = new ElementTabPane(); tabPane.setParent(tabView); tabPane.setLabel(name); return tabPane; }
java
{ "resource": "" }
q16988
CareWebShellEx.getDefaultPluginId
train
private String getDefaultPluginId() { if (defaultPluginId == null) { try { defaultPluginId = PropertyUtil.getValue("CAREWEB.INITIAL.SECTION", null); if (defaultPluginId == null) { defaultPluginId = ""; } } catch (Exception e) { defaultPluginId = ""; } } return defaultPluginId; }
java
{ "resource": "" }
q16989
MockPropertyService.setResources
train
public void setResources(Resource[] resources) throws IOException { clear(); for (Resource resource : resources) { addResource(resource); } }
java
{ "resource": "" }
q16990
StatusPanel.afterInitialized
train
@Override public void afterInitialized(BaseComponent comp) { super.afterInitialized(comp); createLabel("default"); getEventManager().subscribe(EventUtil.STATUS_EVENT, this); }
java
{ "resource": "" }
q16991
StatusPanel.getLabel
train
private Label getLabel(String pane) { Label lbl = root.findByName(pane, Label.class); return lbl == null ? createLabel(pane) : lbl; }
java
{ "resource": "" }
q16992
StatusPanel.createLabel
train
private Label createLabel(String label) { Pane pane = new Pane(); root.addChild(pane); Label lbl = new Label(); lbl.setName(label); pane.addChild(lbl); adjustPanes(); return lbl; }
java
{ "resource": "" }
q16993
EventSubscriptions.addSubscriber
train
public synchronized int addSubscriber(String eventName, IGenericEvent<T> subscriber) { List<IGenericEvent<T>> subscribers = getSubscribers(eventName, true); subscribers.add(subscriber); return subscribers.size(); }
java
{ "resource": "" }
q16994
EventSubscriptions.removeSubscriber
train
public synchronized int removeSubscriber(String eventName, IGenericEvent<T> subscriber) { List<IGenericEvent<T>> subscribers = getSubscribers(eventName, false); if (subscribers != null) { subscribers.remove(subscriber); if (subscribers.isEmpty()) { subscriptions.remove(eventName); } return subscribers.size(); } return -1; }
java
{ "resource": "" }
q16995
EventSubscriptions.hasSubscribers
train
public boolean hasSubscribers(String eventName, boolean exact) { while (!StringUtils.isEmpty(eventName)) { if (hasSubscribers(eventName)) { return true; } else if (exact) { return false; } else { eventName = stripLevel(eventName); } } return false; }
java
{ "resource": "" }
q16996
EventSubscriptions.getSubscribers
train
public synchronized Iterable<IGenericEvent<T>> getSubscribers(String eventName) { List<IGenericEvent<T>> subscribers = getSubscribers(eventName, false); return subscribers == null ? null : new ArrayList<>(subscribers); }
java
{ "resource": "" }
q16997
EventSubscriptions.invokeCallbacks
train
public void invokeCallbacks(String eventName, T eventData) { String name = eventName; while (!StringUtils.isEmpty(name)) { Iterable<IGenericEvent<T>> subscribers = getSubscribers(name); if (subscribers != null) { for (IGenericEvent<T> subscriber : subscribers) { try { if (log.isDebugEnabled()) { log.debug(String.format("Firing local Event[name=%s,data=%s]", eventName, eventData)); } subscriber.eventCallback(eventName, eventData); } catch (Throwable e) { log.error("Error during local event callback.", e); } } } name = stripLevel(name); } }
java
{ "resource": "" }
q16998
EventSubscriptions.getSubscribers
train
private List<IGenericEvent<T>> getSubscribers(String eventName, boolean canCreate) { List<IGenericEvent<T>> subscribers = subscriptions.get(eventName); if (subscribers == null && canCreate) { subscribers = new LinkedList<>(); subscriptions.put(eventName, subscribers); } return subscribers; }
java
{ "resource": "" }
q16999
EventSubscriptions.stripLevel
train
private String stripLevel(String eventName) { int i = eventName.lastIndexOf('.'); return i > 1 ? eventName.substring(0, i) : ""; }
java
{ "resource": "" }