List of usage examples for org.apache.commons.lang StringUtils substringBefore
public static String substringBefore(String str, String separator)
Gets the substring before the first occurrence of a separator.
From source file:com.enonic.cms.core.search.query.QueryFieldAndValue.java
public String getValueForIdQuery() { if (queryValue.isNumeric()) { return StringUtils.substringBefore(queryValue.getStringValueNormalized(), "."); }/*from w w w. jav a2 s. c o m*/ return queryValue.getStringValueNormalized(); }
From source file:com.hangum.tadpole.engine.sql.util.OracleObjectCompileUtils.java
/** * view compile/*from ww w .ja va 2s . co m*/ * * @param selection * @param userDB */ public static String viewCompile(String viewName, UserDBDAO userDB) throws Exception { // ? DEBUG? ? ? ?. TableDAO viewDao = new TableDAO(); if (StringUtils.contains(viewName, '.')) { //?? ?? ... viewDao.setSchema_name(StringUtils.substringBefore(viewName, ".")); viewDao.setTable_name(StringUtils.substringAfter(viewName, ".")); viewDao.setSysName(StringUtils.substringAfter(viewName, ".")); } else { // ? . viewDao.setSchema_name(userDB.getSchema()); viewDao.setTable_name(viewName); viewDao.setSysName(viewName); } return viewCompile(viewDao, userDB); }
From source file:com.enonic.cms.core.preference.PreferenceScopeKey.java
public PreferenceScopeKey(String key) { if (key == null) { throw new IllegalArgumentException("Given key cannot be null"); }/*from w w w .ja v a2s . com*/ if (key.indexOf(":") > -1) { StringTokenizer st = new StringTokenizer(key, ":"); try { firstKey = Integer.valueOf(st.nextToken()); } catch (NumberFormatException e) { throw new InvalidKeyException(key, this.getClass(), "first key not a number"); } try { secondKey = Integer.valueOf(StringUtils.substringBefore(st.nextToken(), ".")); } catch (NumberFormatException e) { throw new InvalidKeyException(key, this.getClass(), "second key not a number"); } keyAsString = firstKey + ":" + secondKey; } else { try { firstKey = Integer.valueOf(key); } catch (NumberFormatException e) { throw new InvalidKeyException(key, this.getClass(), "first key not a number"); } keyAsString = firstKey.toString(); } }
From source file:com.xyz.util.PropertyFilter.java
/** * //from w ww . ja v a 2 s. c om * @param filterName EQ_S_NAME * @param value */ public PropertyFilter(final String filterName, final Object value) { String matchTypeCode = StringUtils.substringBefore(filterName, "_"); try { matchType = Enum.valueOf(MatchType.class, matchTypeCode.toUpperCase()); } catch (RuntimeException e) { throw new IllegalArgumentException("filter??,.", e); } String propertyNameStr = StringUtils.substringAfter(filterName, "_"); propertyNames = StringUtils.split(propertyNameStr, PropertyFilter.OR_SEPARATOR); this.value = value; }
From source file:com.google.gdt.eclipse.designer.hosted.tdt.Utils.java
static String getDevLibLocation(final IModuleDescription moduleDescription) { String userJarFolder = getUserJarFolder(moduleDescription); // try to find gwt-dev.jar in classpath {//from w w w .j a va2s. c o m String devLocation = ExecutionUtils.runObject(new RunnableObjectEx<String>() { public String runObject() throws Exception { List<String> locations = moduleDescription.getLocations(); return getDevJarLocation(locations); } }); if (devLocation != null) { return devLocation; } } // Maven if (userJarFolder.contains("/gwt/gwt-user/")) { String gwtFolder = StringUtils.substringBefore(userJarFolder, "/gwt-user/"); String versionString = StringUtils.substringAfter(userJarFolder, "/gwt/gwt-user/"); String devFolder = gwtFolder + "/gwt-dev/" + versionString; String devFileName = "gwt-dev-" + versionString + ".jar"; String devLocation = devFolder + "/" + devFileName; if (new File(devLocation).exists()) { return devLocation; } } // gwt-dev in same folder as gwt-user.jar String path = userJarFolder + "/gwt-dev.jar"; if (new File(path).exists()) { return path; } // no gwt-dev return null; }
From source file:jetbrick.tools.chm.reader.AnchorNameManager.java
public static String replaceAnchor(String url) { String anchor = StringUtils.substringAfter(url, "#"); if ("".equals(anchor)) return url; return StringUtils.substringBefore(url, "#") + "#" + getNewAnchorName(anchor); }
From source file:co.freeside.betamax.message.AbstractMessage.java
public String getContentType() { String contentTypeHeader = getHeader(CONTENT_TYPE); if (!StringUtils.isBlank(contentTypeHeader)) { return StringUtils.substringBefore(contentTypeHeader, ";"); } else {//from ww w . ja v a 2s . c om return DEFAULT_CONTENT_TYPE; } }
From source file:info.magnolia.cms.security.auth.Base64CallbackHandler.java
/** * @param credentials Base64 encoded string * *//* ww w. j a va2 s . co m*/ public Base64CallbackHandler(String credentials) { credentials = getDecodedCredentials(credentials.substring(6).trim()); this.name = StringUtils.substringBefore(credentials, ":"); this.pswd = StringUtils.substringAfter(credentials, ":").toCharArray(); }
From source file:com.haulmont.cuba.security.global.UserUtils.java
private static String parseParam(String param, String firstName, String lastName, String middleName) throws ParseException { if (param == null || param.length() == 0) throw new ParseException("Pattern error", 0); String last = StringUtils.substringAfter(param, "|"); String first = StringUtils.upperCase(StringUtils.substringBefore(param, "|")); if (first == null || first.length() == 0) throw new ParseException("Pattern error", 0); char type = first.charAt(0); boolean all = true; int length = 0; if (first.length() > 1) { char ch = first.charAt(1); switch (ch) { case 'F': case 'L': case 'M': if (first.length() != 2 || type != ch) throw new ParseException("Pattern error", 2); break; default://w w w . j a v a 2 s . c o m length = Integer.parseInt(first.substring(1, first.length())); break; } } else { all = false; length = 1; } switch (type) { case 'F': first = firstName; break; case 'L': first = lastName; break; case 'M': first = middleName; break; default: throw new ParseException("Pattern error", 0); } if (!all) { first = StringUtils.left(first, length); } return (first.length() > 0) ? first + last : ""; }
From source file:com.constellio.app.modules.es.connectors.http.fetcher.config.BasicUrlNormalizer.java
@Override public String normalize(String url) throws MalformedURLException, URISyntaxException { String trimmedUrl = StringUtils.trim(url); String noFragmentUrl = StringUtils.substringBefore(trimmedUrl, "#"); if (StringUtils.isEmpty(new URL(noFragmentUrl).getFile())) { noFragmentUrl = noFragmentUrl + "/"; }/* www. j a v a 2 s .c o m*/ URL normalizedUrl = new URL(noFragmentUrl); String lowerCaseHost = StringUtils.lowerCase(normalizedUrl.getHost()); normalizedUrl = new URL(normalizedUrl.getProtocol(), lowerCaseHost, normalizedUrl.getPort(), normalizedUrl.getFile()); return normalizedUrl.toURI().normalize().toString(); }