code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
@Override
public void cloneLayout(LayoutIdentifier layout, LayoutIdentifier layout2) {
String text = getLayoutContent(layout);
saveLayout(layout2, text);
} | java |
@Override
public String getLayoutContent(LayoutIdentifier layout) {
return propertyService.getValue(getPropertyName(layout.shared), layout.name);
} | java |
@Override
public String getLayoutContentByAppId(String appId) {
String value = propertyService.getValue(PROPERTY_LAYOUT_ASSOCIATION, appId);
return value == null ? null : getLayoutContent(new LayoutIdentifier(value, true));
} | java |
@Override
public List<String> getLayouts(boolean shared) {
List<String> layouts = propertyService.getInstances(getPropertyName(shared), shared);
Collections.sort(layouts, String.CASE_INSENSITIVE_ORDER);
return layouts;
} | java |
@Override
public CWFAuthenticationDetails buildDetails(HttpServletRequest request) {
log.trace("Building details");
CWFAuthenticationDetails details = new CWFAuthenticationDetails(request);
return details;
} | java |
protected void init(String classifier, String moduleBase) throws MojoExecutionException {
this.classifier = classifier;
this.moduleBase = moduleBase;
stagingDirectory = new File(buildDirectory, classifier + "-staging");
configTemplate = new ConfigTemplate(classifier + "-spring.xml");
... | java |
protected String getModuleVersion() {
StringBuilder sb = new StringBuilder();
int pcs = 0;
for (String pc : projectVersion.split("\\.")) {
if (pcs++ > 3) {
break;
} else {
appendVersionPiece(sb, pc);
}
}
... | java |
public File newStagingFile(String entryName, long modTime) {
File file = new File(stagingDirectory, entryName);
if (modTime != 0) {
file.setLastModified(modTime);
}
file.getParentFile().mkdirs();
return file;
} | java |
public void throwMojoException(String msg, Throwable e) throws MojoExecutionException {
if (failOnError) {
throw new MojoExecutionException(msg, e);
} else {
getLog().error(msg, e);
}
} | java |
protected void assembleArchive() throws Exception {
getLog().info("Assembling " + classifier + " archive");
if (resources != null && !resources.isEmpty()) {
getLog().info("Copying additional resources.");
new ResourceProcessor(this, moduleBase, resources).transform();
... | java |
private File createArchive() throws Exception {
getLog().info("Creating archive.");
Artifact artifact = mavenProject.getArtifact();
String clsfr = noclassifier ? "" : ("-" + classifier);
String archiveName = artifact.getArtifactId() + "-" + artifact.getVersion() + clsfr + ".jar";
... | java |
public static void startThread(Thread thread) {
if (log.isDebugEnabled()) {
log.debug("Starting background thread: " + thread);
}
ExecutorService executor = getTaskExecutor();
if (executor != null) {
executor.execute(thread);
} else {
thread.... | java |
protected static SessionService create(IPublisherInfo self, String sessionId, IEventManager eventManager,
ISessionUpdate callback) {
String sendEvent = StrUtil.formatMessage(EVENT_SEND, sessionId);
String joinEvent = StrUtil.formatMessage(EVENT_JOIN, sessionId)... | java |
public ChatMessage sendMessage(String text) {
if (text != null && !text.isEmpty()) {
ChatMessage message = new ChatMessage(self, text);
eventManager.fireRemoteEvent(sendEvent, message);
return message;
}
return null;
} | java |
@Override
public int compareTo(HelpSearchHit hit) {
int result = -NumUtil.compare(confidence, hit.confidence);
return result != 0 ? result : topic.compareTo(hit.topic);
} | java |
protected static byte toUnsignedByte(int intVal) {
byte byteVal;
if (intVal > 127) {
int temp = intVal - 256;
byteVal = (byte) temp;
} else {
byteVal = (byte) intVal;
}
return byteVal;
} | java |
public static KeyStore getKeyStore(String keystoreLocation, String keystoreType) throws NoSuchAlgorithmException,
CertificateException, IOException,
Key... | java |
public static boolean verify(PublicKey key, String base64Signature, String content, String timestamp, int duration)
throws Exception {
if (key == null || base64Signature == null || content == n... | java |
public static String sign(PrivateKey key, String content) throws Exception {
Signature signature = Signature.getInstance(SIGN_ALGORITHM);
signature.initSign(key);
signature.update(content.getBytes());
return Base64.encodeBase64String(signature.sign());
} | java |
public static void validateTime(String timestamp, int duration) throws Exception {
Date date = getTimestampFormatter().parse(timestamp);
long sign_time = date.getTime();
long now_time = System.currentTimeMillis();
long diff = now_time - sign_time;
long min_diff = diff / (60 * 100... | java |
public static String getTimestamp(Date time) {
return getTimestampFormatter().format(time == null ? new Date() : time);
} | java |
public static String encrypt(Key key, String content) throws Exception {
try {
Cipher cipher = Cipher.getInstance(CRYPTO_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, key);
return Base64.encodeBase64String(cipher.doFinal(content.getBytes()));
} catch (Exception e) {
... | java |
public static String decrypt(Key key, String content) throws Exception {
try {
Cipher cipher = Cipher.getInstance(CRYPTO_ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, key);
return new String(cipher.doFinal(Base64.decodeBase64(content)));
} catch (Exception e) {
... | java |
public String getManifestAttribute(String attributeName) {
if (attributeName != null) {
Map<Object,Object> mf = getManifestAttributes();
for (Object att : mf.keySet()) {
if (attributeName.equals(att.toString())) {
return mf.get(att).toString();
... | java |
public Map<Object, Object> getManifestAttributes() {
Map<Object, Object> manifestAttributes = null;
manifestAttributes = getExplodedWarManifestAttributes();
if (manifestAttributes == null) {
manifestAttributes = getPackagedWarManifestAttributes();
}
if (manifestAttributes == null) {
man... | java |
private Map<Object, Object> getExplodedWarManifestAttributes() {
Map<Object, Object> manifestAttributes = null;
FileInputStream fis = null;
try {
if (servletContext != null) {
final String appServerHome = servletContext.getRealPath("");
final File ... | java |
private Map<Object, Object> getPackagedWarManifestAttributes() {
Map<Object, Object> manifestAttributes = null;
try {
LOGGER.debug("Using Manifest file:{}", servletContext.getResource(MANIFEST).getPath());
Manifest manifest = new Manifest(servletContext.getResou... | java |
@Override
public CountryContract getCountryFromCode(String countryCode) {
if(StringUtils.isBlank(countryCode)) return null;
CountryContract country = getKcCountryService().getCountryByAlternateCode(countryCode);
if(country==null){
country = getKcCountryService().getCountry(countr... | java |
@Override
public StateContract getStateFromName(String countryAlternateCode, String stateName) {
CountryContract country = getCountryFromCode(countryAlternateCode);
return getKcStateService().getState(country.getCode(), stateName);
} | java |
public static boolean isSegmented(Name name, byte marker) {
return name.size() > 0 && name.get(-1).getValue().buf().get(0) == marker;
} | java |
public static long parseSegment(Name name, byte marker) throws EncodingException {
if (name.size() == 0) {
throw new EncodingException("No components to parse.");
}
return name.get(-1).toNumberWithMarker(marker);
} | java |
public static Name removeSegment(Name name, byte marker) {
return isSegmented(name, marker) ? name.getPrefix(-1) : new Name(name);
} | java |
public static List<Data> segment(Data template, InputStream bytes) throws IOException {
return segment(template, bytes, DEFAULT_SEGMENT_SIZE);
} | java |
public static byte[] readAll(InputStream bytes) throws IOException {
ByteArrayOutputStream builder = new ByteArrayOutputStream();
int read = bytes.read();
while (read != -1) {
builder.write(read);
read = bytes.read();
}
builder.flush();
bytes.close();
return builder.toByteArray()... | java |
@Override
protected void init(Object target, PropertyInfo propInfo, PropertyGrid propGrid) {
propInfo.getConfig().setProperty("readonly", Boolean.toString(!SecurityUtil.hasDebugRole()));
super.init(target, propInfo, propGrid);
List<IAction> actions = new ArrayList<>(ActionRegistry.getRegiste... | java |
public CountryCodeDataType.Enum getCountryCodeDataType(String countryCode) {
CountryCodeDataType.Enum countryCodeDataType = null;
CountryContract country = s2SLocationService.getCountryFromCode(countryCode);
if (country != null) {
StringBuilder countryDetail = new StringBuilder();
countryDetail.append(count... | java |
public StateCodeDataType.Enum getStateCodeDataType(String countryAlternateCode, String stateName) {
StateCodeDataType.Enum stateCodeDataType = null;
StateContract state = s2SLocationService.getStateFromName(countryAlternateCode, stateName);
if (state != null) {
StringBuilder stateDetail = new StringBuilder();
... | java |
public AddressDataType getAddressDataType(RolodexContract rolodex) {
AddressDataType addressDataType = AddressDataType.Factory.newInstance();
if (rolodex != null) {
String street1 = rolodex.getAddressLine1();
addressDataType.setStreet1(street1);
String street2 = rolodex.getAddressLine2();
if (street2 ... | java |
public HumanNameDataType getHumanNameDataType(ProposalPersonContract person) {
HumanNameDataType humanName = HumanNameDataType.Factory.newInstance();
if (person != null) {
humanName.setFirstName(person.getFirstName());
humanName.setLastName(person.getLastName());
String middleName = person.getMiddleName()... | java |
public HumanNameDataType getHumanNameDataType(RolodexContract rolodex) {
HumanNameDataType humanName = HumanNameDataType.Factory.newInstance();
if (rolodex != null) {
humanName.setFirstName(rolodex.getFirstName());
humanName.setLastName(rolodex.getLastName());
String middleName = rolodex.getMiddleName();
... | java |
public ContactPersonDataType getContactPersonDataType(ProposalPersonContract person) {
ContactPersonDataType contactPerson = ContactPersonDataType.Factory
.newInstance();
if (person != null) {
contactPerson.setName((getHumanNameDataType(person)));
String phone = person.getOfficePhone();
if (phone != nu... | java |
public Map<String, URL> nextImageSet() {
return buildImageSet(dirs.get(random.nextInt(dirs.size())));
} | java |
public static Object getController(BaseComponent comp, boolean recurse) {
return recurse ? comp.findAttribute(Constants.ATTR_COMPOSER) : comp.getAttribute(Constants.ATTR_COMPOSER);
} | java |
@SuppressWarnings("unchecked")
public static <T> T getController(BaseComponent comp, Class<T> type) {
while (comp != null) {
Object controller = getController(comp);
if (type.isInstance(controller)) {
return (T) controller;
}
... | java |
@Override
public void afterInitialized(BaseComponent comp) {
root = (BaseUIComponent) comp;
this.comp = root;
comp.setAttribute(Constants.ATTR_COMPOSER, this);
comp.addEventListener(ThreadEx.ON_THREAD_COMPLETE, threadCompletionListener);
appContext = SpringUtil.getAppContext(... | java |
public static DropContainer render(BaseComponent dropRoot, BaseComponent droppedItem) {
IDropRenderer dropRenderer = DropUtil.getDropRenderer(droppedItem);
if (dropRenderer == null || !dropRenderer.isEnabled()) {
return null;
}
BaseComponent renderedItem = d... | java |
private static DropContainer create(BaseComponent dropRoot, BaseComponent cmpt, String title,
List<ActionListener> actionListeners) {
DropContainer dc = (DropContainer) PageUtil.createPage(TEMPLATE, null);
dc.actionListeners = actionListeners;
dc.setTitle(... | java |
@Override
public void doAction(Action action) {
switch (action) {
case REMOVE:
close();
break;
case HIDE:
setVisible(false);
break;
case SHOW:
setVisible(true);
... | java |
@EventHandler("drop")
private void onDrop(DropEvent event) {
BaseComponent dragged = event.getRelatedTarget();
if (dragged instanceof DropContainer) {
getParent().addChild(dragged, this);
}
} | java |
public Span addContent(Row row, String label) {
Span cell = new Span();
cell.addChild(CWFUtil.getTextComponent(label));
row.addChild(cell);
return cell;
} | java |
public Cell addCell(Row row, String label) {
Cell cell = new Cell(label);
row.addChild(cell);
return cell;
} | java |
public Column addColumn(Grid grid, String label, String width, String sortBy) {
Column column = new Column();
grid.getColumns().addChild(column);
column.setLabel(label);
column.setWidth(width);
column.setSortComparator(sortBy);
column.setSortOrder(SortOrder.ASCENDING);
... | java |
public String outputNameFor(String output) {
Report report = openReport(output);
return outputNameOf(report);
} | java |
@Override
protected void init(Object target, PropertyInfo propInfo, PropertyGrid propGrid) {
super.init(target, propInfo, propGrid);
Iterable<?> iter = (Iterable<?>) propInfo.getPropertyType().getSerializer();
for (Object value : iter) {
appendItem(value.toString(), value);
... | java |
public Jashing bootstrap() {
if (bootstrapped.compareAndSet(false, true)) {
/* bootstrap event sources* */
ServiceManager eventSources = injector.getInstance(ServiceManager.class);
eventSources.startAsync();
/* bootstrap server */
Service application... | java |
public void shutdown() {
if (bootstrapped.compareAndSet(true, false)) {
LOGGER.info("Shutting down Jashing...");
injector.getInstance(ServiceManager.class).stopAsync().awaitStopped();
injector.getInstance(JashingServer.class).stopAsync().awaitTerminated();
/* s... | java |
public static void copyAttributes(Element source, Map<String, String> dest) {
NamedNodeMap attributes = source.getAttributes();
if (attributes != null) {
for (int i = 0; i < attributes.getLength(); i++) {
Node attribute = attributes.item(i);
dest.put(attribut... | java |
public static void copyAttributes(Map<String, String> source, Element dest) {
for (Entry<String, String> entry : source.entrySet()) {
dest.setAttribute(entry.getKey(), entry.getValue());
}
} | java |
private void initTopicTree() {
DefaultMutableTreeNode topicTree = getDataAsTree();
if (topicTree != null) {
initTopicTree(rootNode, topicTree.getRoot());
}
} | java |
private void initTopicTree(HelpTopicNode htnParent, TreeNode ttnParent) {
for (int i = 0; i < ttnParent.getChildCount(); i++) {
TreeNode ttnChild = ttnParent.getChildAt(i);
HelpTopic ht = getTopic(ttnChild);
HelpTopicNode htnChild = new HelpTopicNode(ht);
... | java |
protected DefaultMutableTreeNode getDataAsTree() {
try {
return (DefaultMutableTreeNode) MethodUtils.invokeMethod(view, "getDataAsTree", null);
} catch (Exception e) {
return null;
}
} | java |
public static Treenode findNodeByLabel(Treeview tree, String label, boolean caseSensitive) {
for (Treenode item : tree.getChildren(Treenode.class)) {
if (caseSensitive ? label.equals(item.getLabel()) : label.equalsIgnoreCase(item.getLabel())) {
return item;
}
}
... | java |
public static String getPath(Treenode item, boolean useLabels) {
StringBuilder sb = new StringBuilder();
boolean needsDelim = false;
while (item != null) {
if (needsDelim) {
sb.insert(0, '\\');
} else {
needsDelim = true;
}
... | java |
public static void sort(BaseComponent parent, boolean recurse) {
if (parent == null || parent.getChildren().size() < 2) {
return;
}
int i = 1;
int size = parent.getChildren().size();
while (i < size) {
Treenode item1 = (Treenode) parent.getChildren().get... | java |
private static int compare(Treenode item1, Treenode item2) {
String label1 = item1.getLabel();
String label2 = item2.getLabel();
return label1 == label2 ? 0 : label1 == null ? -1 : label2 == null ? -1 : label1.compareToIgnoreCase(label2);
} | java |
private static Treenode search(Iterable<Treenode> root, String text, ITreenodeSearch search) {
for (Treenode node : root) {
if (search.isMatch(node, text)) {
return node;
}
}
return null;
} | java |
public Command get(String commandName, boolean forceCreate) {
Command command = commands.get(commandName);
if (command == null && forceCreate) {
command = new Command(commandName);
add(command);
}
return command;
} | java |
private void bindShortcuts(Map<Object, Object> shortcuts) {
for (Object commandName : shortcuts.keySet()) {
bindShortcuts(commandName.toString(), shortcuts.get(commandName).toString());
}
} | java |
public PropertiesLoaderBuilder loadProperty(String name) {
if (env.containsProperty(name)) {
props.put(name, env.getProperty(name));
}
return this;
} | java |
public PropertiesLoaderBuilder addProperty(String name, String value) {
props.put(name, value);
return this;
} | java |
protected <C extends BaseUIComponent> C createCell(BaseComponent parent, Object value, String prefix, String style,
String width, Class<C> clazz) {
C container = null;
try {
container = clazz.newInstance();
container.setPare... | java |
public static byte[] removeEntry(byte[] a, int idx) {
byte[] b = new byte[a.length - 1];
for (int i = 0; i < b.length; i++) {
if (i < idx) {
b[i] = a[i];
} else {
b[i] = a[i + 1];
}
}
return b;
} | java |
private Map<String, Object> getConfigParams(Class<?> clazz) {
Map<String, Object> params = new HashMap<>();
for (Field field : clazz.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.getName().endsWith("_CONFIG")) {
try {
... | java |
public static String buildWhereClause(Object object, MapSqlParameterSource params) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
LOGGER.debug("Building query");
final StringBuilder query = new StringBuilder();
boolean first = true;
for (Field field : object.getClass().getD... | java |
public static void show(boolean manage, String deflt, IEventListener closeListener) {
Map<String, Object> args = new HashMap<>();
args.put("manage", manage);
args.put("deflt", deflt);
PopupDialog.show(RESOURCE_PREFIX + "layoutManager.fsp", args, true, true, true, closeListener);
} | java |
@Override
public int compareTo(IManagedContext<DomainClass> o) {
int pri1 = o.getPriority();
int pri2 = getPriority();
return this == o ? 0 : pri1 < pri2 ? -1 : 1;
} | java |
public static void pruneMenus(BaseComponent parent) {
while (parent != null && parent instanceof BaseMenuComponent) {
if (parent.getChildren().isEmpty()) {
BaseComponent newParent = parent.getParent();
parent.destroy();
parent = newParent;
... | java |
public static BaseMenuComponent findMenu(BaseComponent parent, String label, BaseComponent insertBefore) {
for (BaseMenuComponent child : parent.getChildren(BaseMenuComponent.class)) {
if (label.equalsIgnoreCase(child.getLabel())) {
return child;
}
}
Bas... | java |
public static void sortMenu(BaseComponent parent, int startIndex, int endIndex) {
List<BaseComponent> items = parent.getChildren();
int bottom = startIndex + 1;
for (int i = startIndex; i < endIndex;) {
BaseComponent item1 = items.get(i++);
BaseComponent item2 = items.ge... | java |
public static String getPath(BaseMenuComponent comp) {
StringBuilder sb = new StringBuilder();
getPath(comp, sb);
return sb.toString();
} | java |
private static void getPath(BaseComponent comp, StringBuilder sb) {
while (comp instanceof BaseMenuComponent) {
sb.insert(0, "\\" + ((BaseMenuComponent) comp).getLabel());
comp = comp.getParent();
}
} | java |
@Override
public void onPluginEvent(PluginEvent event) {
switch (event.getAction()) {
case SUBSCRIBE: // Upon initial subscription, begin listening for specified generic events.
plugin = event.getPlugin();
doSubscribe(true);
break;
... | java |
@Override
public void retry(Face face, Interest interest, OnData onData, OnTimeout onTimeout) throws IOException {
RetryContext context = new RetryContext(face, interest, onData, onTimeout);
retryInterest(context);
} | java |
private synchronized void retryInterest(RetryContext context) throws IOException {
LOGGER.info("Retrying interest: " + context.interest.toUri());
context.face.expressInterest(context.interest, context, context);
totalRetries++;
} | java |
public void register() throws IOException {
try {
registeredPrefixId = face.registerPrefix(prefix, this, new OnRegisterFailed() {
@Override
public void onRegisterFailed(Name prefix) {
registeredPrefixId = UNREGISTERED;
logger.log(Level.SEVERE, "Failed to register prefix: " ... | java |
public static boolean isMessageExcluded(Message message, Recipient recipient) {
return isMessageExcluded(message, recipient.getType(), recipient.getValue());
} | java |
public static boolean isMessageExcluded(Message message, RecipientType recipientType, String recipientValue) {
Recipient[] recipients = (Recipient[]) message.getMetadata("cwf.pub.recipients");
if (recipients == null || recipients.length == 0) {
return false;
}
... | java |
public String getLabel() {
String label = getProperty(labelProperty);
label = label == null ? node.getLabel() : label;
if (label == null) {
label = getDefaultInstanceName();
setProperty(labelProperty, label);
}
return label;
... | java |
private String getProperty(String propertyName) {
return propertyName == null ? null : (String) getPropertyValue(propertyName);
} | java |
public QueueSpec setField(String fieldName, Object value) {
fieldData.put(fieldName, value);
return this;
} | java |
public static void changeUser(IUser user) {
try {
getUserContext().requestContextChange(user);
} catch (Exception e) {
log.error("Error during user context change.", e);
}
} | java |
@SuppressWarnings("unchecked")
public static ISharedContext<IUser> getUserContext() {
return (ISharedContext<IUser>) ContextManager.getInstance().getSharedContext(UserContext.class.getName());
} | java |
private PHSCoverLetter12Document getPHSCoverLetter() {
PHSCoverLetter12Document phsCoverLetterDocument = PHSCoverLetter12Document.Factory
.newInstance();
PHSCoverLetter12 phsCoverLetter = PHSCoverLetter12.Factory
.newInstance();
CoverLetterFile coverLetterFile = CoverLetterFile.Factory.newInstance(... | java |
private void setBudgetYearDataType(RRBudget1013 rrBudget,BudgetPeriodDto periodInfo) {
BudgetYearDataType budgetYear = rrBudget.addNewBudgetYear();
if (periodInfo != null) {
budgetYear.setBudgetPeriodStartDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getStartDate()));
... | java |
@Override
public void setApplicationContext(ApplicationContext appContext) throws BeansException {
try (InputStream is = originalResource.getInputStream();) {
ConfigurableListableBeanFactory beanFactory = ((AbstractRefreshableApplicationContext) appContext)
.getBeanFactory();... | java |
protected List<String> getCellLines(String explanation) {
int startPos = 0;
List<String> cellLines = new ArrayList<>();
for (int commaPos = 0; commaPos > -1;) {
commaPos = explanation.indexOf(",", startPos);
if (commaPos >= 0) {
String cellLine = (explanation.substring(startPos, commaPos).tr... | java |
public void reset() throws IOException {
if (t1==null || t2==null) {
throw new IllegalStateException("Cannot swap after close.");
}
if (getOutput().length()>0) {
toggle = !toggle;
// reset the new output to length()=0
try (OutputStream unused = new FileOutputStream(getOutput())) {
//this is empty ... | java |
public void close() throws IOException {
if (t1==null || t2==null) {
return;
}
try {
if (getOutput().length() > 0) {
Files.copy(getOutput().toPath(), output.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
else if (getInput().length() > 0) {
Files.copy(getInput().toPath(), output.toPath(), St... | java |
public AddressRequireCountryDataType getAddressRequireCountryDataType(DepartmentalPersonDto person) {
AddressRequireCountryDataType address = AddressRequireCountryDataType.Factory.newInstance();
if (person != null) {
String street1 = person.getAddress1();
address.setStreet1(str... | java |
public HumanNameDataType getHumanNameDataType(KeyPersonDto keyPerson) {
HumanNameDataType humanName = HumanNameDataType.Factory.newInstance();
humanName.setFirstName(keyPerson.getFirstName());
humanName.setLastName(keyPerson.getLastName());
String middleName = keyPerson.getMiddleName();... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.