List of usage examples for org.apache.commons.lang3 StringUtils substringAfterLast
public static String substringAfterLast(final String str, final String separator)
Gets the substring after the last occurrence of a separator.
From source file:com.quartercode.femtoweb.impl.ActionUriResolver.java
private static String[] splitAtLastSeparator(String string, String separator) { if (!string.contains(separator)) { return new String[] { "", string }; } else {//from w ww . j av a 2 s . co m return new String[] { StringUtils.substringBeforeLast(string, separator), StringUtils.substringAfterLast(string, separator) }; } }
From source file:com.thinkbiganalytics.metadata.sla.DefaultServiceLevelAgreementScheduler.java
private String getUniqueName(String name) { String uniqueName = name;/*from w w w .ja v a 2s.c o m*/ final String checkName = name; String matchingName = Iterables.tryFind(scheduledJobNames.values(), new Predicate<String>() { @Override public boolean apply(String s) { return s.equalsIgnoreCase(checkName); } }).orNull(); if (matchingName != null) { //get numeric string after '-'; if (StringUtils.contains(matchingName, "-")) { String number = StringUtils.substringAfterLast(matchingName, "-"); if (StringUtils.isNotBlank(number)) { number = StringUtils.trim(number); if (StringUtils.isNumeric(number)) { Integer num = Integer.parseInt(number); num++; uniqueName += "-" + num; } else { uniqueName += "-1"; } } } else { uniqueName += "-1"; } } return uniqueName; }
From source file:fi.helsinki.opintoni.security.SAMLUserDetailsService.java
private String getStudentNumber(SAMLCredential credential) { return StringUtils.substringAfterLast(credential.getAttributeAsString(SAML_ATTRIBUTE_STUDENT_NUMBER), ":"); }
From source file:de.jcup.egradle.codeassist.dsl.XMLType.java
@Override public String getShortName() { return StringUtils.substringAfterLast(name, "."); }
From source file:net.sf.dynamicreports.examples.complex.applicationform.ApplicationFormDesign.java
private HorizontalListBuilder dateOfBirth(Date dateOfBirth) { String date = new SimpleDateFormat("MM/dd/yyyy").format(dateOfBirth); HorizontalListBuilder list = cmp.horizontalList().add(label("Date Of Birth", 5)) .add(textCell(StringUtils.substringBefore(date, "/"), 2), label("/", 1, centeredStyle)) .add(textCell(StringUtils.substringBetween(date, "/"), 2), label("/", 1, centeredStyle)) .add(textCell(StringUtils.substringAfterLast(date, "/"), 4)); return list;/*www . ja va 2 s. c o m*/ }
From source file:com.neatresults.mgnltweaks.ui.action.SaveConfigAddNodeDialogAction.java
@Override public void execute() throws ActionExecutionException { // First Validate validator.showValidation(true);/*from w w w .j a va 2 s . c om*/ if (validator.isValid()) { // we support only JCR item adapters if (!(item instanceof JcrItemAdapter)) { return; } // don't save if no value changes occurred on adapter if (!((JcrItemAdapter) item).hasChangedProperties()) { return; } if (item instanceof AbstractJcrNodeAdapter) { // Saving JCR Node, getting updated node first AbstractJcrNodeAdapter nodeAdapter = (AbstractJcrNodeAdapter) item; try { String nodePath = ((String) nodeAdapter.getItemProperty("path").getValue()).trim(); String nodeType = NodeTypes.ContentNode.NAME; if (nodeAdapter.getItemProperty("nodeType") != null) { nodeType = ((String) nodeAdapter.getItemProperty("nodeType").getValue()).trim(); } String parentNodeType = NodeTypes.Content.NAME; if (nodeAdapter.getItemProperty("parentNodeType") != null) { parentNodeType = ((String) nodeAdapter.getItemProperty("parentNodeType").getValue()).trim(); } Node node = nodeAdapter.getJcrItem(); String propertyName = null; if (nodePath.contains("@")) { propertyName = StringUtils.substringAfter(nodePath, "@").trim(); if (StringUtils.isEmpty(propertyName)) { propertyName = null; } nodePath = StringUtils.substringBefore(nodePath, "@"); } String nodeName = nodePath; if (nodePath.contains("/")) { nodeName = StringUtils.substringAfterLast(nodePath, "/"); String parentPath = StringUtils.substringBeforeLast(nodePath, "/"); for (String parentName : parentPath.split("/")) { node = JcrUtils.getOrAddNode(node, parentName, parentNodeType); } } node = node.addNode(nodeName, nodeType); if (propertyName != null) { String value = ""; if (nodeAdapter.getItemProperty("value") != null) { value = ((String) nodeAdapter.getItemProperty("value").getValue()); } node.setProperty(propertyName, value == null ? "" : value); } node.getSession().save(); Location location = subAppContext.getLocation(); String param = location.getParameter(); param = node.getPath() + (propertyName != null ? ("@" + propertyName) : "") + ":" + StringUtils.substringAfter(param, ":"); location = new DefaultLocation(location.getAppType(), location.getAppName(), location.getSubAppId(), param); adminEventBus.fireEvent(new LocationChangedEvent(location)); } catch (RepositoryException e) { log.error("Could not save changes to node", e); } callback.onSuccess(getDefinition().getName()); } else if (item instanceof JcrPropertyAdapter) { super.execute(); } } else { log.debug("Validation error(s) occurred. No save performed."); } }
From source file:blue.lapis.pore.ap.event.EventVerifierProcessor.java
private void verifyName(TypeElement type) { TypeElement bukkitEvent = (TypeElement) ((DeclaredType) type.getSuperclass()).asElement(); String poreName = StringUtils.removeStart(type.getQualifiedName().toString(), PORE_PREFIX); String porePackage = StringUtils.substringBeforeLast(poreName, "."); poreName = StringUtils.substringAfterLast(poreName, "."); String bukkitName = StringUtils.removeStart(bukkitEvent.getQualifiedName().toString(), BUKKIT_PREFIX); String bukkitPackage = StringUtils.substringBeforeLast(bukkitName, "."); bukkitName = StringUtils.substringAfterLast(bukkitName, "."); String expectedName = "Pore" + bukkitName; if (!poreName.equals(expectedName)) { processingEnv.getMessager().printMessage(SEVERITY, poreName + " should be called " + expectedName, type);//from w w w .j a va2 s. com } if (!porePackage.equals(bukkitPackage)) { processingEnv.getMessager().printMessage(SEVERITY, poreName + " is in wrong package: should be in " + PORE_PREFIX + bukkitPackage, type); } }
From source file:net.ripe.ipresource.Ipv6Address.java
private static String getIpv6AddressWithIpv4SectionInIpv6Notation(String ipAddressString) { String ipv6Section = StringUtils.substringBeforeLast(ipAddressString, ":"); String ipv4Section = StringUtils.substringAfterLast(ipAddressString, ":"); try {/* w w w .j av a 2s. c om*/ String ipv4SectionInIpv6Notation = StringUtils.join( new Ipv6Address(Ipv4Address.parse(ipv4Section).getValue()).toString().split(":"), ":", 2, 4); return ipv6Section + ":" + ipv4SectionInIpv6Notation; } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Embedded Ipv4 in IPv6 address is invalid: " + ipAddressString, e); } }
From source file:com.thruzero.common.core.utils.ExceptionUtilsExt.java
public static String findMethodAfterClassFromTrace(final Class<?> clazz) { String result = findTraceAfter(clazz); result = StringUtils.substringBefore(result, "("); return StringUtils.substringAfterLast(result, "."); }
From source file:ambroafb.clients.dialog.ClientDialogController.java
private void changeSceneVisualAsPerson(String delimiter) { first_name.setText(conf.getTitleFor("first_name")); last_name.setText(conf.getTitleFor("last_name")); VBox lastNameVBox = new VBox(last_name, lastName); namesRootPane.getChildren().add(1, lastNameVBox); lastNameVBox.getStyleClass().add("couple"); setStylesForNamesPaneElements("oneThirds", "couple", "couple"); String firmDescrip = firstName.getText(); String firstNameText = StringUtils.substringBeforeLast(firmDescrip, delimiter); String lastNameText = StringUtils.substringAfterLast(firmDescrip, delimiter); firstName.setText(firstNameText.trim()); lastName.setText(lastNameText.trim()); }