code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public void update() {
boolean shouldShow = shouldShow();
if (visible != shouldShow) {
visible = shouldShow;
BaseUIComponent target = element.getMaskTarget();
if (visible) {
Menupopup contextMenu = ElementUI.getDesignContextMenu(target);
... | java |
@Override
protected URL toURL(String filename) {
try {
return new File(filename).toURI().toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
} | java |
public float putAndGet(final int key, final float value) {
int index = findInsertionIndex(key);
float previous = missingEntries;
boolean newMapping = true;
if (index < 0) {
index = changeIndexSign(index);
previous = values[index];
newMapping = false;
... | java |
private void growTable() {
final int oldLength = states.length;
final int[] oldKeys = keys;
final float[] oldValues = values;
final byte[] oldStates = states;
final int newLength = RESIZE_MULTIPLIER * oldLength;
final int[] newKeys = new int[newLength];
... | java |
public static <T> T newObject(Class<T> clazz) {
return getFactory(clazz).newObject(clazz);
} | java |
public static <T> T fetchObject(Class<T> clazz, String id) {
return getFactory(clazz).fetchObject(clazz, id);
} | java |
public static <T> List<T> fetchObjects(Class<T> clazz, String[] ids) {
return getFactory(clazz).fetchObjects(clazz, ids);
} | java |
@SuppressWarnings("unchecked")
public static <T> IDomainFactory<T> getFactory(Class<T> clazz) {
for (IDomainFactory<?> factory : instance) {
String alias = factory.getAlias(clazz);
if (alias != null) {
return (IDomainFactory<T>) factory;
}
... | java |
public static int compare(float a, float b, float delta) {
if (equals(a, b, delta)) {
return 0;
}
return Float.compare(a, b);
} | java |
public static short countCommon(short[] indices1, short[] indices2) {
short numCommonIndices = 0;
int i = 0;
int j = 0;
while (i < indices1.length && j < indices2.length) {
if (indices1[i] < indices2[j]) {
i++;
} else if (indices2[j] < indices1[i])... | java |
public boolean isSponsorInHierarchy(DevelopmentProposalContract sponsorable, String sponsorHierarchy,String level1) {
return sponsorHierarchyService.isSponsorInHierarchy(sponsorable.getSponsor().getSponsorCode(), sponsorHierarchy, 1, level1);
} | java |
public Map<String, String> getSubmissionType(ProposalDevelopmentDocumentContract pdDoc) {
Map<String, String> submissionInfo = new HashMap<>();
S2sOpportunityContract opportunity = pdDoc.getDevelopmentProposal().getS2sOpportunity();
if (opportunity != null) {
if (opportunity.getS2sSu... | java |
private RRBudgetDocument getRRBudget() {
deleteAutoGenNarratives();
RRBudgetDocument rrBudgetDocument = RRBudgetDocument.Factory
.newInstance();
RRBudget rrBudget = RRBudget.Factory.newInstance();
rrBudget.setFormVersion(FormVersion.v1_1.getVersion());
if (pdDoc.getDevelopmentProposal().getApplicantOrg... | java |
private BudgetYear1DataType getBudgetYear1DataType(
BudgetPeriodDto periodInfo) {
BudgetYear1DataType budgetYear = BudgetYear1DataType.Factory
.newInstance();
if (periodInfo != null) {
budgetYear.setBudgetPeriodStartDate(s2SDateTimeService
.convertDateToCalendar(periodInfo.getStartDate()));
budge... | java |
private CumulativeEquipments getCumulativeEquipments(
BudgetSummaryDto budgetSummaryData) {
CumulativeEquipments cumulativeEquipments = CumulativeEquipments.Factory
.newInstance();
if (budgetSummaryData != null
&& budgetSummaryData.getCumEquipmentFunds() != null) {
cumulativeEquipments
.setCumul... | java |
private CumulativeOtherDirect getCumulativeOtherDirect(
BudgetSummaryDto budgetSummaryData) {
CumulativeOtherDirect cumulativeOtherDirect = CumulativeOtherDirect.Factory
.newInstance();
cumulativeOtherDirect
.setCumulativeTotalFundsRequestedOtherDirectCosts(BigDecimal.ZERO);
if (budgetSummaryData != nu... | java |
private OtherDirectCosts getOtherDirectCosts(BudgetPeriodDto periodInfo) {
OtherDirectCosts otherDirectCosts = OtherDirectCosts.Factory
.newInstance();
if (periodInfo != null && periodInfo.getOtherDirectCosts().size() > 0) {
if (periodInfo.getOtherDirectCosts().get(0).getpublications() != null) {
otherD... | java |
private Others getOthersForOtherDirectCosts(BudgetPeriodDto periodInfo) {
Others others = Others.Factory.newInstance();
if (periodInfo != null && periodInfo.getOtherDirectCosts() != null) {
Others.Other otherArray[] = new Others.Other[periodInfo
.getOtherDirectCosts().size()];
int Otherscount = 0;
fo... | java |
public static void status(String statusText) {
try {
getEventManager().fireLocalEvent(STATUS_EVENT, statusText == null ? "" : statusText);
} catch (Throwable e) {
log.error(e);
}
} | java |
public static void ping(String responseEvent, List<PingFilter> filters, Recipient... recipients) {
IEventManager eventManager = getEventManager();
IGlobalEventDispatcher ged = ((ILocalEventDispatcher) eventManager).getGlobalEventDispatcher();
if (ged != null) {
ged.Ping(responseEven... | java |
public static String getChannelName(String eventName) {
return eventName == null ? null : EVENT_PREFIX + eventName.split("\\.", 2)[0];
} | java |
public static String getEventName(String channelName) {
int i = channelName.indexOf(EVENT_PREFIX);
return i < 0 ? channelName : channelName.substring(i + EVENT_PREFIX.length());
} | java |
@Override
public void refresh() {
String url = mockupTypes.getUrl(mockupType);
if (mockupId == null || url == null) {
iframe.setSrc(null);
return;
}
iframe.setSrc(String.format(url, mockupId, System.currentTimeMillis()));
} | java |
public String getPath() {
if (path == null) {
HelpModule module = HelpModule.getModule(id);
path = module == null ? "" : module.getTitle();
}
return path;
} | java |
public String getAction() {
if (action == null) {
HelpModule module = HelpModule.getModule(id);
action = module == null ? ""
: "groovy:" + CareWebUtil.class.getName() + ".showHelpTopic(\"" + id + "\",\""
+ (topic == null ? "" : topic) + "\"... | java |
public static ApplicationContext createAppContext(Page page) {
XmlWebApplicationContext appContext = new FrameworkAppContext();
new AppContextInitializer(page).initialize(appContext);
appContext.refresh();
return appContext;
} | java |
public static void destroyAppContext(Page page) {
XmlWebApplicationContext appContext = getAppContext(page);
if (appContext != null) {
appContext.close();
}
} | java |
@Override
public ApplicationContext getChildAppContext() {
ApplicationContext appContext = getAppContext(ExecutionContext.getPage());
return appContext == null ? getRootAppContext() : appContext;
} | java |
public static XmlWebApplicationContext getAppContext(Page page) {
return page == null ? null : (XmlWebApplicationContext) page.getAttribute(APP_CONTEXT_ATTRIB);
} | java |
private String firstUpper(String value) {
return value == null ? null : value.substring(0, 1).toUpperCase() + value.substring(1);
} | java |
public Object getPropertyValue(Object instance, boolean forceDirect) {
try {
if (instance == null) {
return dflt == null || !isSerializable() ? null : getPropertyType().getSerializer().deserialize(dflt);
}
if (!forceDirect && instance instanceof I... | java |
public void setPropertyValue(Object instance, Object value, boolean forceDirect) {
try {
if (!forceDirect && instance instanceof IPropertyAccessor) {
((IPropertyAccessor) instance).setPropertyValue(this, value);
return;
}
Method me... | java |
public Integer getConfigValueInt(String key, Integer dflt) {
try {
return Integer.parseInt(getConfigValue(key));
} catch (Exception e) {
return dflt;
}
} | java |
public Double getConfigValueDouble(String key, Double dflt) {
try {
return Double.parseDouble(getConfigValue(key));
} catch (Exception e) {
return dflt;
}
} | java |
public Boolean getConfigValueBoolean(String key, Boolean dflt) {
try {
String value = getConfigValue(key);
return value == null ? dflt : Boolean.parseBoolean(value);
} catch (Exception e) {
return dflt;
}
} | java |
public String[] getConfigValueArray(String key, String delimiter) {
return StringUtils.split(getConfigValue(key), delimiter);
} | java |
@Override
public boolean include(T result) {
return getDateRange().inRange(DateUtil.stripTime(dateTypeExtractor.getDateByType(result, dateType)), true, true);
} | java |
public static void appendResponse(StringBuilder buffer, String response) {
if (response != null && !response.isEmpty()) {
if (buffer.length() > 0) {
buffer.append("\r\n");
}
buffer.append(response);
}
} | java |
public void ccowJoin() {
if (ccowIsActive()) {
return;
}
if (ccowContextManager == null && ccowEnabled) {
ccowContextManager = new CCOWContextManager();
ccowContextManager.subscribe(this);
ccowContextManager.run("CareWebFramework#", "", true, "*")... | java |
public void init(IManagedContext<?> item, ISurveyCallback callback) {
contextItems.clear();
if (ccowIsActive()) {
contextItems.addItems(ccowContextManager.getCCOWContext());
}
if (item != null) {
initItem(item, callback);
} else {
SurveyRespo... | java |
private void initItem(IManagedContext<?> item, ISurveyCallback callback) {
try {
localChangeBegin(item);
if (hasSubject(item.getContextName())) {
item.setContextItems(contextItems);
} else {
item.init();
}
localChangeE... | java |
private boolean hasSubject(String subject) {
boolean result = false;
String s = subject + ".";
int c = s.length();
for (String propName : contextItems.getItemNames()) {
result = s.equalsIgnoreCase(propName.substring(0, c));
if (result) {
break;
... | java |
private void commitContexts(boolean accept, boolean all) {
Stack<IManagedContext<?>> stack = commitStack;
commitStack = new Stack<>();
// First, commit or cancel all pending context changes.
for (IManagedContext<?> managedContext : stack) {
if (managedContext.isPending()) {
... | java |
public void setCCOWEnabled(boolean ccowEnabled) {
this.ccowEnabled = ccowEnabled;
if (!ccowEnabled && ccowContextManager != null) {
ccowContextManager.suspend();
ccowContextManager = null;
}
updateCCOWStatus();
} | java |
public ContextItems getMarshaledContext() {
ContextItems marshaledContext = new ContextItems();
for (IManagedContext<?> managedContext : managedContexts) {
marshaledContext.addItems(managedContext.getContextItems(false));
}
return marshaledContext;
} | java |
private CCOWStatus getCCOWStatus() {
if (ccowContextManager == null) {
return ccowEnabled ? CCOWStatus.NONE : CCOWStatus.DISABLED;
} else if (ccowTransaction) {
return CCOWStatus.CHANGING;
} else {
switch (ccowContextManager.getState()) {
case ... | java |
private void updateCCOWStatus() {
if (ccowEnabled && eventManager != null) {
eventManager.fireLocalEvent("CCOW", Integer.toString(getCCOWStatus().ordinal()));
}
} | java |
@Override
public void registerObject(Object object) {
if (object instanceof IManagedContext) {
managedContexts.add((IManagedContext<?>) object);
}
} | java |
@Override
public void unregisterObject(Object object) {
if (object instanceof IContextEvent) {
for (IManagedContext<?> managedContext : managedContexts) {
managedContext.removeSubscriber((IContextEvent) object);
}
}
if (object instanceof IManagedConte... | java |
private void localChangeEnd(IManagedContext<?> managedContext, boolean silent, boolean deferCommit,
ISurveyCallback callback) throws ContextException {
if (pendingStack.isEmpty() || pendingStack.peek() != managedContext) {
throw new ContextException("Illegal context ... | java |
private void resetItem(IManagedContext<?> item, boolean silent, ISurveyCallback callback) {
try {
localChangeBegin(item);
item.reset();
localChangeEnd(item, silent, true, callback);
} catch (ContextException e) {
execCallback(callback, e);
}
} | java |
@Override
public void ccowPending(CCOWContextManager sender, ContextItems contextItems) {
ccowTransaction = true;
updateCCOWStatus();
setMarshaledContext(contextItems, false, response -> {
if (response.rejected()) {
sender.setSurveyResponse(response.toString());
... | java |
private void initTopicTree() {
try {
Object data = view.getViewData();
if (!(data instanceof TopicTree)) {
return;
}
TopicTree topicTree = (TopicTree) data;
HelpTopicNode baseNode;
if (... | java |
private void parseResources(Element element, BeanDefinitionBuilder builder,
ManagedList<AbstractBeanDefinition> resourceList) {
NodeList resources = element.getChildNodes();
for (int i = 0; i < resources.getLength(); i++) {
Node node = resources.item(i);
... | java |
private void parseAuthorities(Element element, BeanDefinitionBuilder builder,
ManagedList<AbstractBeanDefinition> authorityList) {
NodeList authorities = element.getChildNodes();
for (int i = 0; i < authorities.getLength(); i++) {
Node node = authorities.it... | java |
private void parseProperties(Element element, BeanDefinitionBuilder builder,
ManagedList<AbstractBeanDefinition> propertyList) {
NodeList properties = element.getChildNodes();
for (int i = 0; i < properties.getLength(); i++) {
Node node = properties.item(i);... | java |
private void parseConfig(Element property, BeanDefinitionBuilder propertyBuilder) {
Element config = (Element) getTagChildren("config", property).item(0);
if (config != null) {
Properties properties = new Properties();
NodeList entries = getTagChildren("entry", config);
... | java |
private ResourceType getResourceType(String resourceTag) {
if (resourceTag == null || !resourceTag.endsWith("-resource")) {
return ResourceType.unknown;
}
try {
return ResourceType.valueOf(resourceTag.substring(0, resourceTag.length() - 9));
} catch (Exception e)... | java |
public Fixture getFixture( String name, String... params ) throws Throwable
{
Type<?> type = loadType( name );
Object target = type.newInstanceUsingCoercion( params );
return new DefaultFixture( target );
} | java |
protected int readWord(InputStream inputStream) throws IOException {
byte[] bytes = new byte[2];
boolean success = inputStream.read(bytes) == 2;
return !success ? -1 : readWord(bytes, 0);
} | java |
protected int readWord(byte[] data, int offset) {
int low = data[offset] & 0xff;
int high = data[offset + 1] & 0xff;
return high << 8 | low;
} | java |
protected String getString(byte[] data, int offset) {
if (offset < 0) {
return "";
}
int i = offset;
while (data[i++] != 0x00) {
;
}
return getString(data, offset, i - offset - 1);
} | java |
protected String getString(byte[] data, int offset, int length) {
return new String(data, offset, length, CS_WIN1252);
} | java |
protected byte[] loadBinaryFile(String file) throws IOException {
try (InputStream is = resource.getInputStream(file)) {
return IOUtils.toByteArray(is);
}
} | java |
public static <T> IQueryResult<T> abortResult(String reason) {
return packageResult(null, CompletionStatus.ABORTED,
reason == null ? null : Collections.singletonMap("reason", (Object) reason));
} | java |
public static <T> IQueryResult<T> errorResult(Throwable exception) {
return packageResult(null, CompletionStatus.ERROR,
exception == null ? null : Collections.singletonMap("exception", (Object) exception));
} | java |
public List<T> filter(List<T> results) {
if (filters.isEmpty() || results == null) {
return results;
}
List<T> include = new ArrayList<>();
for (T result : results) {
if (include(result)) {
include.add(result);
}
... | java |
@Override
protected void updateVisibility(boolean visible, boolean activated) {
tab.setVisible(visible);
tab.setSelected(visible && activated);
} | java |
private void init() {
add("text", PropertySerializer.STRING, PropertyEditorText.class);
add("color", PropertySerializer.STRING, PropertyEditorColor.class);
add("choice", PropertySerializer.STRING, PropertyEditorChoiceList.class);
add("action", PropertySerializer.STRING, PropertyEditorAct... | java |
private void computeInputParatemeter(final EntryPoint entryPoint, final String[] parameterNames, final Set<Class<?>> consolidatedTypeBlacklist,
final Set<String> consolidatedNameBlacklist, MethodParameter methodParameter) {
// If the type is part of the blacklist, we discard it
if (consolidatedTypeBlacklist.co... | java |
public static Method findSetter(String methodName, Object instance, Class<?> valueClass) throws NoSuchMethodException {
return findMethod(methodName, instance, valueClass, true);
} | java |
public static Method findGetter(String methodName, Object instance, Class<?> valueClass) throws NoSuchMethodException {
return findMethod(methodName, instance, valueClass, false);
} | java |
private static Method findMethod(String methodName, Object instance, Class<?> valueClass, boolean setter)
throws NoSuchMethodException {
if (methodName == null) {
return null;
}
... | java |
protected ScaleTwoDecimal getTotalCost(BudgetModularContract budgetModular) {
ScaleTwoDecimal totalCost = ScaleTwoDecimal.ZERO;
if (budgetModular.getTotalDirectCost() != null) {
totalCost = budgetModular.getTotalDirectCost();
}
for (BudgetModularIdcContract budgetModularIdc : budgetModular
.getBudgetModu... | java |
protected String getCognizantFederalAgency(RolodexContract rolodex) {
StringBuilder agency = new StringBuilder();
if(rolodex.getOrganization()!=null){
agency.append(rolodex.getOrganization());
}agency.append(COMMA_SEPERATOR);
if(rolodex.getFirstName()!=null){
agency.append(rolodex.getFirstName());
}agency... | java |
@Override
public boolean transform(IResource resource) throws Exception {
String path = resource.getSourcePath();
if (path.startsWith("META-INF/")) {
return false;
}
if (hsFile == null && loader.isHelpSetFile(path)) {
hsFile = getResourceBase... | java |
@Provides
public VCSConfiguration loadConfiguration(Gson gson) {
try {
URL resource = ResourceUtils.getResourceAsURL(VCS_CONFIG_JSON);
if (null == resource) {
throw new IncorrectConfigurationException("Unable to find VCS configuration");
}
retu... | java |
protected IQueueMessage<ID, DATA> takeFromQueue() {
KafkaMessage kMsg = kafkaClient.consumeMessage(consumerGroupId, true, topicName, 1000,
TimeUnit.MILLISECONDS);
return kMsg != null ? deserialize(kMsg.content()) : null;
} | java |
public ParticipantListener createSessionListener(String sessionId, ISessionUpdate callback) {
return SessionService.create(self, sessionId, eventManager, callback);
} | java |
public void createSession(String sessionId) {
boolean newSession = sessionId == null;
sessionId = newSession ? newSessionId() : sessionId;
SessionController controller = sessions.get(sessionId);
if (controller == null) {
controller = SessionController.create(sessionI... | java |
public void setActive(boolean active) {
if (this.active != active) {
this.active = active;
inviteListener.setActive(active);
acceptListener.setActive(active);
participants.clear();
participants.add(self);
participantListener.setActive(activ... | java |
public void invite(String sessionId, Collection<IPublisherInfo> invitees, boolean cancel) {
if (invitees == null || invitees.isEmpty()) {
return;
}
List<Recipient> recipients = new ArrayList<>();
for (IPublisherInfo invitee : invitees) {
recipien... | java |
public static void store(String absolutePath, Properties configs) throws IOException {
OutputStream outStream = null;
try {
outStream = new FileOutputStream(new File(absolutePath));
configs.store(outStream, null);
} finally {
try {
if (o... | java |
@Override
public void registerObject(Object object) {
if (object instanceof ICareWebStartup) {
startupRoutines.add((ICareWebStartup) object);
}
} | java |
public void execute() {
List<ICareWebStartup> temp = new ArrayList<>(startupRoutines);
for (ICareWebStartup startupRoutine : temp) {
try {
if (startupRoutine.execute()) {
unregisterObject(startupRoutine);
}
} catch (Thr... | java |
public void setStretch(boolean stretch) {
this.stretch = stretch;
image.setWidth(stretch ? "100%" : null);
image.setHeight(stretch ? "100%" : null);
} | java |
public static <T> T getBean(Class<T> clazz) {
ApplicationContext appContext = getAppContext();
try {
return appContext == null ? null : appContext.getBean(clazz);
} catch (Exception e) {
return null;
}
} | java |
public static String getProperty(String name) {
if (propertyProvider == null) {
initPropertyProvider();
}
return propertyProvider.getProperty(name);
} | java |
public static Resource getResource(String location) {
Resource resource = resolver.getResource(location);
return resource.exists() ? resource : null;
} | java |
public static Resource[] getResources(String locationPattern) {
try {
return resolver.getResources(locationPattern);
} catch (IOException e) {
throw MiscUtil.toUnchecked(e);
}
} | java |
protected static void setShell(CareWebShell shell) {
if (getShell() != null) {
throw new RuntimeException("A CareWeb shell instance has already been registered.");
}
ExecutionContext.getPage().setAttribute(Constants.SHELL_INSTANCE, shell);
} | java |
public static void showMessage(String message, String caption) {
getShell().getMessageWindow().showMessage(message, caption);
} | java |
public static void showHelpTopic(String module, String topic, String label) {
getShell().getHelpViewer();
HelpUtil.show(module, topic, label);
} | java |
public static String getUrlMapping(String url, Map<String, String> urlMappings) {
if (urlMappings != null) {
for (String pattern : urlMappings.keySet()) {
if (urlMatcher.match(pattern, url)) {
return urlMappings.get(pattern);
}
}
... | java |
public static String generateRandomPassword(int minLength, int maxLength, String[] constraints) {
if (constraints == null || constraints.length == 0 || minLength <= 0 || maxLength < minLength) {
throw new IllegalArgumentException();
}
int pwdLength = RandomUtils.nextInt(maxL... | java |
public String[] getMessageWithParams() {
String[] messageWithParams = new String[getParams().length+1];
messageWithParams[0]=errorMessage;
System.arraycopy(params, 0, messageWithParams, 1, messageWithParams.length - 1);
return messageWithParams;
} | java |
@Override
public boolean validateName(String name) {
return name != null && !name.isEmpty() && StringUtils.isAlphanumericSpace(name.replace('_', ' '));
} | java |
@Override
public boolean layoutExists(LayoutIdentifier layout) {
return getLayouts(layout.shared).contains(layout.name);
} | java |
@Override
public void saveLayout(LayoutIdentifier layout, String content) {
propertyService.saveValue(getPropertyName(layout.shared), layout.name, layout.shared, content);
} | java |
@Override
public void renameLayout(LayoutIdentifier layout, String newName) {
String text = getLayoutContent(layout);
saveLayout(new LayoutIdentifier(newName, layout.shared), text);
deleteLayout(layout);
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.