List of usage examples for org.apache.commons.lang StringUtils substringAfter
public static String substringAfter(String str, String separator)
Gets the substring after the first occurrence of a separator.
From source file:eionet.cr.util.FolderUtil.java
/** * Extracts user name from the given URI. A user name is returned only if the given URI returns true for * {@link URIUtil#startsWithUserHome(String)}. Otherwise null is returned. * * @param uri The given URI.//from w ww .jav a2 s. c o m * @return See method description. */ public static String extractUserName(String uri) { if (!startsWithUserHome(uri)) { return null; } String str = StringUtils.substringAfter(uri, GeneralConfig.getRequiredProperty(GeneralConfig.APPLICATION_HOME_URL) + "/home/"); return StringUtils.substringBefore(str, "/"); }
From source file:jetbrick.tools.chm.reader.JavaInfoReader.java
private void addClassFieldMethod(ClassInfo classinfo) throws IOException { File file = new File(Config.apiLocation, classinfo.getUrl()); String html = FileUtils.readFileToString(file, Config.encoding); Pattern p = Config.style.getJavaFieldRegex(); Matcher m = p.matcher(html);/* w w w. j a va2 s . c o m*/ while (m.find()) { String name = m.group(2); String url = m.group(1); url = StringUtils.remove(url, "../"); url = StringUtils.remove(url, "./"); String anchor = StringUtils.substringAfter(url, "#"); String linkUrl = StringUtils.substringBefore(url, "#") + "#" + AnchorNameManager.getNewAnchorName(anchor); if (Config.style.isMethod(url)) { MethodInfo info = new MethodInfo(); info.setName(name); info.setFullName(Config.style.getMethodFullName(url)); info.setUrl(linkUrl); classinfo.addMethod(info); } else { FieldInfo info = new FieldInfo(); info.setName(name); info.setUrl(linkUrl); classinfo.addField(info); } } }
From source file:info.magnolia.commands.CommandsManager.java
/** * Use a delimiter to separate the catalog and command name * @param commandName/*from w w w. j a v a2s . co m*/ * @return the command */ public Command getCommand(String commandName) { String catalogName = DEFAULT_CATALOG; if (StringUtils.contains(commandName, COMMAND_DELIM)) { catalogName = StringUtils.substringBefore(commandName, COMMAND_DELIM); commandName = StringUtils.substringAfter(commandName, COMMAND_DELIM); } Command command = getCommand(catalogName, commandName); if (command == null) { command = getCommand(DEFAULT_CATALOG, commandName); } return command; }
From source file:com.abssh.util.PropertyFilter.java
/** * @param filterName/* w ww . ja v a 2s .co m*/ * ,???. eg. LIKES_NAME_OR_LOGIN_NAME * @param value * . */ @SuppressWarnings("unchecked") public PropertyFilter(final String filterName, final Object value) { String matchTypeStr = StringUtils.substringBefore(filterName, "_"); String matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1); String propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1, matchTypeStr.length()); try { matchType = Enum.valueOf(MatchType.class, matchTypeCode); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } try { propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue(); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } String propertyNameStr = StringUtils.substringAfter(filterName, "_"); propertyNames = propertyNameStr.split(PropertyFilter.OR_SEPARATOR); Assert.isTrue(propertyNames.length > 0, "filter??" + filterName + ",??."); // entity property. if (value != null && (value.getClass().isArray() || Collection.class.isInstance(value) || value.toString().split(",").length > 1)) { // IN ? Object[] vObjects = null; if (value.getClass().isArray()) { vObjects = (Object[]) value; } else if (Collection.class.isInstance(value)) { vObjects = ((Collection) value).toArray(); } else { vObjects = value.toString().split(","); } this.propertyValue = new Object[vObjects.length]; for (int i = 0; i < vObjects.length; i++) { propertyValue[i] = ReflectionUtils.convertValue(vObjects[i], propertyType); } } else { Object tObject = ReflectionUtils.convertValue(value, propertyType); if (tObject != null && matchType == MatchType.LE && propertyType.getName().equals("java.util.Date")) { // LED ??tObject2010-08-13 00:00:00 // ?2010-08-13 23:59:59 Date leDate = (Date) tObject; Calendar c = GregorianCalendar.getInstance(); c.setTime(leDate); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); tObject = c.getTime(); } else if (tObject != null && matchType == MatchType.LEN && propertyType.getName().equals("java.util.Date")) { // LED ??tObject2010-08-13 00:00:00 // ?2010-08-13 23:59:59 // Date leDate = (Date) tObject; // Calendar c = GregorianCalendar.getInstance(); // c.setTime(leDate); // tObject = c.getTime(); } else if (tObject != null && matchType == MatchType.LIKE) { tObject = ((String) tObject).replace("%", "\\%").replace("_", "\\_"); } this.propertyValue = new Object[] { tObject }; } }
From source file:info.magnolia.cms.module.ModuleUtil.java
/** * registers the properties in the repository * @param hm//from w w w . j a v a 2 s. c om * @param name * @throws IOException * @throws RepositoryException * @throws PathNotFoundException * @throws AccessDeniedException */ public static void registerProperties(HierarchyManager hm, String name) throws IOException, AccessDeniedException, PathNotFoundException, RepositoryException { Map map = new ListOrderedMap(); // not using properties since they are not ordered // Properties props = new Properties(); // props.load(ModuleUtil.class.getResourceAsStream("/" + name.replace('.', '/') + ".properties")); InputStream stream = ModuleUtil.class.getResourceAsStream("/" + name.replace('.', '/') + ".properties"); //$NON-NLS-1$ //$NON-NLS-2$ LineNumberReader lines = new LineNumberReader(new InputStreamReader(stream)); String line = lines.readLine(); while (line != null) { line = line.trim(); if (line.length() > 0 && !line.startsWith("#")) { //$NON-NLS-1$ String key = StringUtils.substringBefore(line, "=").trim(); //$NON-NLS-1$ String value = StringUtils.substringAfter(line, "=").trim(); //$NON-NLS-1$ map.put(key, value); } line = lines.readLine(); } IOUtils.closeQuietly(lines); IOUtils.closeQuietly(stream); registerProperties(hm, map); }
From source file:com.weixin.core.util.Struts2Utils.java
/** * ?contentTypeheaders.//from w ww . j av a2s . c o m */ private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) { // ?headers? String encoding = DEFAULT_ENCODING; boolean noCache = DEFAULT_NOCACHE; HttpServletResponse response = ServletActionContext.getResponse(); for (String header : headers) { String headerName = StringUtils.substringBefore(header, ":"); String headerValue = StringUtils.substringAfter(header, ":"); if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) { encoding = headerValue; } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) { noCache = Boolean.parseBoolean(headerValue); } else if (StringUtils.equalsIgnoreCase(headerName, "Cache-Control") || StringUtils.equalsIgnoreCase(headerName, "Pragma")) { response.setHeader(headerName, headerValue); noCache = false; } else { throw new IllegalArgumentException(headerName + "??header"); } } // headers? String fullContentType = contentType + ";charset=" + encoding; response.setContentType(fullContentType); response.setHeader("Pragma:", "public"); if (noCache) { ServletUtils.setDisableCacheHeader(response); } return response; }
From source file:com.prowidesoftware.swift.model.field.SwiftParseUtils.java
/** * @param value//from ww w. j a v a2 s . c om * @param prefix * @return s */ public static String removePrefix(final String value, final String prefix) { if (StringUtils.isNotBlank(value) && StringUtils.isNotBlank(prefix) && value.startsWith(prefix)) { return StringUtils.substringAfter(value, prefix); } return value; }
From source file:eu.annocultor.xconverter.impl.XmlElementForVelocity.java
public static String removeNamespacePrefix(String value) throws Exception { return StringUtils.substringAfter(value, NAMESPACE_PREFIX_SEPARATOR); }
From source file:com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.java
private static String getTestCaseName(SMInputCursor testCaseCursor) throws XMLStreamException { String classname = testCaseCursor.getAttrValue("classname"); String name = testCaseCursor.getAttrValue("name"); if (StringUtils.contains(classname, "$")) { return StringUtils.substringAfter(classname, "$") + "/" + name; }/*from w w w. jav a2s .c o m*/ return name; }
From source file:io.wcm.tooling.netbeans.sightly.completion.classLookup.MemberLookupResolver.java
/** * The actual lookup/*ww w.ja v a 2s.co m*/ * * @return set of all elements which match the lookup */ public Set<MemberLookupResult> performMemberLookup(String variable) { // if there is more than one "." we need to do some magic and resolve the definition fragmented if (variable.contains(".")) { return performNestedLookup(variable); } Set<MemberLookupResult> ret = new LinkedHashSet<>(); // check, if the current variable resolves to a data-sly-use command ParsedStatement statement = getParsedStatement(variable); if (statement == null) { return ret; } if (StringUtils.equals(statement.getCommand(), DataSlyCommands.DATA_SLY_USE.getCommand())) { // this ends the search and we can perform the actual lookup ret.addAll(getResultsForClass(statement.getValue(), variable)); } else { Set<MemberLookupResult> subResults = performMemberLookup( StringUtils.substringBefore(statement.getValue(), ".")); for (MemberLookupResult result : subResults) { if (result.matches(StringUtils.substringAfter(statement.getValue(), "."))) { ret.addAll(getResultsForClass(result.getReturnType(), variable)); } } } return ret; }