List of usage examples for org.apache.commons.lang3 StringUtils substringBefore
public static String substringBefore(final String str, final String separator)
Gets the substring before the first occurrence of a separator.
From source file:bear.core.Registry.java
public Task<Object, TaskResult<?>> getByName(String name) { String className;/*from ww w . java 2 s . c o m*/ String taskName; if (!name.contains(".")) { className = "Bear"; } else { className = StringUtils.substringBefore(name, "."); } taskName = StringUtils.substringAfter(name, "."); return getTask(className, taskName); }
From source file:com.thinkbiganalytics.metadata.api.sla.DependentFeed.java
public DependentFeed(String categoryAndFeed) { super();//from w ww .j a v a2 s .com this.categoryName = StringUtils.substringBefore(categoryAndFeed, "."); this.feedName = StringUtils.substringAfter(categoryAndFeed, "."); this.categoryAndFeed = categoryAndFeed; }
From source file:com.droitfintech.licensing.LicenseService.java
public void initialize() { license = licenseProvider.retrieveLicense(); // This is a stopgap solution until we revamp our licensing. It can be made faster but it's not used // during trade processing so leaving alone for now. We have no standardized way of referring to a regime // so this adds both the prefix and the Tag's name for that prefix into the list. licensedRegimes = new HashSet<String>(); for (String moduleName : license.getWorkflowWhitelist().get(RequestContext.ApplicationType.WEBTOOL)) { String modulePrefix = StringUtils.substringBefore(moduleName, "_"); licensedRegimes.add(modulePrefix); Tag tag = Tag.getTagById(modulePrefix); if (tag != null) { licensedRegimes.add(tag.getName()); }/*from ww w . j a v a2 s . c om*/ // more hacky stuff, since Tags *mostly* refer to regimes but not always. Again needs to be revisited // ones we really figure out how we're going to use tags. licensedRegimes.add("deprecated"); licensedRegimes.add(Tag.getTagById("deprecated").getName()); licensedRegimes.add("NONE"); licensedRegimes.add(Tag.getTagById("NONE").getName()); licensedRegimes.add("Common Attr"); licensedRegimes.add(Tag.getTagById("Common Attr").getName()); } }
From source file:de.micromata.genome.util.matcher.BeanInspektorMatcherFactory.java
/** * Creates a new BeanInspektorMatcher object. * * @param pattern the pattern//from w w w . j a va 2 s .c o m * @return the matcher */ @Override public Matcher<Object> createMatcher(String pattern) { String matcherString = StringUtils.trim(StringUtils.substringBefore(pattern, "=")); String valueString = StringUtils.trimToNull(StringUtils.substringAfter(pattern, "=")); if (matcherString.trim().equals("instanceOf")) { try { // TODO (RK) wirklich nur von root classloader, nicht thread? return new BeanInstanceOfMatcher(Class.forName(valueString.trim())); } catch (Exception ex) { throw new RuntimeException(ex); // TODO better ex } } return new BeanPropertiesMatcher(matcherString, valueString); }
From source file:com.yiji.openapi.sdk.util.BeanMapper.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Map<String, Object> deepMap(Object source, String[] properties) throws Exception { Map<String, Object> map = Maps.newHashMap(); for (String property : properties) { if (StringUtils.contains(property, ".")) { String currentProperty = StringUtils.substringBefore(property, "."); String remainProperties = StringUtils.substringAfter(property, "."); Map<String, Object> remainMap = deepMap(BeanUtils.getDeclaredProperty(source, currentProperty), new String[] { remainProperties }); if (map.get(currentProperty) != null) { ((Map) map.get(currentProperty)).putAll(remainMap); } else { map.put(currentProperty, remainMap); }/*from w w w.ja va 2s .co m*/ } else { Object value = BeanUtils.getDeclaredProperty(source, property); if (value instanceof Collection) { } map.put(property, value); } } return map; }
From source file:com.palantir.docker.compose.configuration.RemoteHostIpResolver.java
@Override public String resolveIp(String dockerHost) { return Optional.ofNullable(emptyToNull(dockerHost)) .map(host -> StringUtils.substringAfter(host, TCP_PROTOCOL)) .map(ipAndMaybePort -> StringUtils.substringBefore(ipAndMaybePort, ":")) .orElseThrow(() -> new IllegalArgumentException("DOCKER_HOST cannot be blank/null")); }
From source file:de.blizzy.documentr.markdown.macro.impl.LabelMacro.java
@Override public String getHtml(IMacroContext macroContext) { String params = macroContext.getParameters(); String type = StringUtils.substringBefore(params, " ").trim(); //$NON-NLS-1$ String text = StringUtils.substringAfter(params, " ").trim(); //$NON-NLS-1$ return "<span class=\"label label-" + StringEscapeUtils.escapeHtml4(type) + "\">" + //$NON-NLS-1$ //$NON-NLS-2$ StringEscapeUtils.escapeHtml4(text) + "</span>"; //$NON-NLS-1$ }
From source file:de.blizzy.documentr.markdown.macro.impl.PanelMacro.java
@Override public String getHtml(IMacroContext macroContext) { String params = macroContext.getParameters(); String width = StringUtils.substringBefore(params, " ").trim(); //$NON-NLS-1$ boolean border = StringUtils.indexOf(params, " border") >= 0; //$NON-NLS-1$ return "<div class=\"span" + StringEscapeUtils.escapeHtml4(width) + "\">" + //$NON-NLS-1$ //$NON-NLS-2$ (border ? "<div class=\"span12 panel-border\">" : StringUtils.EMPTY) + //$NON-NLS-1$ macroContext.getBody() + (border ? "</div>" : StringUtils.EMPTY) + //$NON-NLS-1$ "</div>"; //$NON-NLS-1$ }
From source file:kenh.expl.functions.SubstringBefore.java
public String process(String str, String open, boolean last) { if (last)//from www. jav a 2s . c o m return StringUtils.substringBeforeLast(str, open); else return StringUtils.substringBefore(str, open); }
From source file:com.mgmtp.jfunk.data.generator.data.Field.java
public Field(final String id, final boolean unique, final String className) { this.dataKey = StringUtils.substringBefore(id, "."); this.entryKey = StringUtils.substringAfter(id, "."); this.unique = unique; this.className = className; }