List of usage examples for org.apache.commons.lang StringUtils startsWithIgnoreCase
public static boolean startsWithIgnoreCase(String str, String prefix)
Case insensitive check if a String starts with a specified prefix.
From source file:eionet.cr.web.action.JsonActionBean.java
/** * * @return//from w w w.ja va 2s . c om */ public Resolution tags() { List<TagDTO> tagList = ApplicationCache.getTagCloudSortedByName(0); String query = getContext().getRequestParameter("query"); List<String> matchingTags = new ArrayList<String>(tagList.size()); for (TagDTO tagDTO : tagList) { String tag = tagDTO.getTag(); if (StringUtils.isBlank(query) || StringUtils.startsWithIgnoreCase(tag, query)) { matchingTags.add(tag); } } return createSuggestionsResolution(matchingTags, query); }
From source file:ch.unibas.fittingwizard.application.fitting.FitResult.java
public List<Double> findValuesByPrefix(String prefix) { prefix = getPrefix(prefix);// w w w . jav a 2s .co m List<Double> result = new ArrayList<>(); for (ChargeValue chargeValue : chargeValues) { if (StringUtils.startsWithIgnoreCase(chargeValue.getType(), prefix)) { result.add(chargeValue.getValue()); } } return result; }
From source file:com.adobe.acs.commons.quickly.operations.impl.HelpOperationImpl.java
@Override protected List<Result> withParams(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final Command cmd) { final List<Result> results = new ArrayList<Result>(); for (final Result result : operations) { if (StringUtils.startsWithIgnoreCase(result.getTitle(), cmd.getParam())) { results.add(result);/*from w w w . ja v a2 s .c om*/ } } return results; }
From source file:com.siberhus.ngai.core.CrudHelper.java
public final static Number count(EntityManager em, QTO qto) { String queryString = StringUtils.trim(qto.getQueryString()); if (StringUtils.startsWithIgnoreCase(queryString, "select")) { throw new UnsupportedOperationException( "Query string cannot begin with \"select\"." + "It should start with \"from\""); }/* w w w . j av a2 s . co m*/ return ((Number) CrudHelper.createQueryObject(em, "select count(*) " + queryString, qto.getParameterList()) .getSingleResult()).intValue(); }
From source file:adalid.commons.util.FilUtils.java
public static String getCurrentEnvironmentalWorkspaceFolderPath() { if (StringUtils.isBlank(HOME_DIR) && StringUtils.isBlank(USER_HOME)) { return workspace_folder_path; }//from w w w. j a v a2 s. c o m if (StringUtils.startsWithIgnoreCase(workspace_folder_path, HOME_DIR)) { return HOME_VAR + StringUtils.removeStartIgnoreCase(workspace_folder_path, HOME_DIR); } if (StringUtils.startsWithIgnoreCase(workspace_folder_path, USER_HOME)) { return HOME_VAR + StringUtils.removeStartIgnoreCase(workspace_folder_path, USER_HOME); } return workspace_folder_path; }
From source file:com.taobao.tdhs.jdbc.NonRegisteringDriver.java
public Properties parseURL(String url, Properties defaults) throws java.sql.SQLException { Properties urlProps = (defaults != null) ? new Properties(defaults) : new Properties(); if (url == null) { return null; }/*from www. jav a2s .c om*/ if (!StringUtils.startsWithIgnoreCase(url, URL_PREFIX)) { return null; } int beginningOfSlashes = url.indexOf("//"); int index = url.indexOf("?"); if (index != -1) { String paramString = url.substring(index + 1, url.length()); url = url.substring(0, index); StringTokenizer queryParams = new StringTokenizer(paramString, "&"); while (queryParams.hasMoreTokens()) { String parameterValuePair = queryParams.nextToken(); int indexOfEquals = StringUtils.indexOfIgnoreCase(parameterValuePair, "=", 0); String parameter = null; String value = null; if (indexOfEquals != -1) { parameter = parameterValuePair.substring(0, indexOfEquals); if (indexOfEquals + 1 < parameterValuePair.length()) { value = parameterValuePair.substring(indexOfEquals + 1); } } if ((value != null && value.length() > 0) && (parameter != null && parameter.length() > 0)) { try { urlProps.put(parameter, URLDecoder.decode(value, "UTF-8")); } catch (UnsupportedEncodingException badEncoding) { // punt urlProps.put(parameter, URLDecoder.decode(value)); } catch (NoSuchMethodError nsme) { // punt again urlProps.put(parameter, URLDecoder.decode(value)); } } } } url = url.substring(beginningOfSlashes + 2); String hostStuff = null; int slashIndex = StringUtil.indexOfIgnoreCaseRespectMarker(0, url, "/", ALLOWED_QUOTES, ALLOWED_QUOTES, true); if (slashIndex != -1) { hostStuff = url.substring(0, slashIndex); if ((slashIndex + 1) < url.length()) { urlProps.put(DBNAME_PROPERTY_KEY, url.substring((slashIndex + 1), url.length())); } } else { hostStuff = url; } if ((hostStuff != null) && (hostStuff.trim().length() > 0)) { String[] hostPortPair = StringUtils.split(hostStuff, ":"); if (StringUtils.isNotBlank(hostPortPair[0])) { urlProps.setProperty(HOST_PROPERTY_KEY, hostPortPair[0]); } else { urlProps.setProperty(HOST_PROPERTY_KEY, "localhost"); } if (hostPortPair.length > 1 && StringUtils.isNotBlank(hostPortPair[1])) { urlProps.setProperty(PORT_PROPERTY_KEY, hostPortPair[1]); } else { urlProps.setProperty(PORT_PROPERTY_KEY, "9999"); } } else { urlProps.setProperty(HOST_PROPERTY_KEY, "localhost"); urlProps.setProperty(PORT_PROPERTY_KEY, "9999"); } return urlProps; }
From source file:com.hangum.tadpole.engine.sql.util.QueryUtils.java
/** * select ?? // w ww .jav a2 s . c o m * * @param reqQuery * @exception */ private static Object runSQLOther(final UserDBDAO userDB, String strQuery, final List<Object> listParam) throws SQLException, Exception { // is tajo if (DBDefine.TAJO_DEFAULT == userDB.getDBDefine()) { logger.error("Not support TAJO."); } else { java.sql.Connection javaConn = null; PreparedStatement prepareStatement = null; try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); prepareStatement = javaConn.prepareStatement(strQuery); // TODO mysql? https://github.com/hangum/TadpoleForDBTools/issues/3 ? create table ? ?? '(' ?? ? ?? . if (userDB.getDBDefine() == DBDefine.MYSQL_DEFAULT || userDB.getDBDefine() == DBDefine.MARIADB_DEFAULT) { final String checkSQL = strQuery.trim().toUpperCase(); if (StringUtils.startsWithIgnoreCase(checkSQL, "CREATE TABLE")) { //$NON-NLS-1$ strQuery = StringUtils.replaceOnce(strQuery, "(", " ("); //$NON-NLS-1$ //$NON-NLS-2$ } } // // hive executeUpdate() ? . 13.08.19-hangum // if(userDB.getDBDefine() == DBDefine.HIVE_DEFAULT | // userDB.getDBDefine() == DBDefine.HIVE2_DEFAULT // ) { // return prepareStatement.execute(strQuery); // } else { for (int i = 0; i < listParam.size(); i++) { Object objParam = listParam.get(i); prepareStatement.setObject(i + 1, objParam); } return prepareStatement.executeUpdate(); } finally { try { prepareStatement.close(); } catch (Exception e) { } } } // end which db return false; }
From source file:morphy.command.CommandContext.java
public CommandContext(String commandFileName) { BufferedReader reader = null; try {//from ww w. jav a 2 s . com File commandFilesDir = Morphy.getInstance().getMorphyFileProvider().getCommandFilesDirectory(); String filePath = String.format("%s/%s.txt", commandFilesDir.getAbsolutePath(), commandFileName); reader = new BufferedReader(new FileReader(new File(filePath))); StringBuilder helpContent = new StringBuilder(1200); String lineTerminator = Morphy.getInstance().getMorphyPreferences() .getString(PreferenceKeys.SocketConnectionLineDelimiter); boolean isParsingContent = false; String currentLine = null; while ((currentLine = reader.readLine()) != null) { if (isParsingContent) { helpContent.append(currentLine + lineTerminator); } else { if (StringUtils.startsWithIgnoreCase(currentLine, "Name:")) { name = currentLine.substring(5).trim().toLowerCase(); } else if (StringUtils.startsWithIgnoreCase(currentLine, "UserLevel:")) { userLevel = UserLevel.valueOf(currentLine.substring(10).trim()); } else if (StringUtils.startsWithIgnoreCase(currentLine, "Usage:")) { usage = currentLine.substring(6).trim(); } else if (StringUtils.startsWithIgnoreCase(currentLine, "Aliases:")) { String content = currentLine.substring(8).trim(); MorphyStringTokenizer tok = new MorphyStringTokenizer(content, " "); List<String> aliasesList = new ArrayList<String>(10); while (tok.hasMoreTokens()) { aliasesList.add(tok.nextToken()); } aliases = aliasesList.toArray(new String[0]); } else if (StringUtils.startsWithIgnoreCase(currentLine, "SeeAlso:") || StringUtils.startsWithIgnoreCase(currentLine, "See Also:")) { String content = currentLine.substring(8).trim(); MorphyStringTokenizer tok = new MorphyStringTokenizer(content, " "); List<String> seeAlsoList = new ArrayList<String>(10); while (tok.hasMoreTokens()) { seeAlsoList.add(tok.nextToken()); } aliases = seeAlsoList.toArray(new String[0]); } else if (StringUtils.startsWithIgnoreCase(currentLine, "LastModifiedBy:")) { lastModifiedBy = currentLine.substring(15).trim(); } else if (StringUtils.startsWithIgnoreCase(currentLine, "LastModifiedDate:")) { lastModifiedDate = currentLine.substring(17).trim(); } else if (StringUtils.startsWithIgnoreCase(currentLine, "Help:")) { isParsingContent = true; helpContent.append(currentLine.substring(5)); continue; } else { LOG.warn("Encountered command header without a known keyword " + currentLine); } } } help = helpContent.toString(); if (StringUtils.isBlank(getName())) { throw new IllegalArgumentException("Could not find Name: header in command. " + commandFileName); } if (userLevel == null) { throw new IllegalArgumentException( "Could not find UserLevel: header in command. " + commandFileName); } } catch (Throwable t) { if (LOG.isErrorEnabled()) LOG.error("Error reading help file: " + commandFileName, t); } finally { if (reader != null) { try { reader.close(); } catch (Throwable t) { } } } }
From source file:de.fhg.iais.cortex.services.ingest.worker.ArchiveContentWorker.java
@Override public boolean apply(IIngestContext context) { this.storage.storeAIP(context.getAipObject()); try {//w w w .j a v a 2 s.c o m IAipBinaries binaries = context.getAipObject().getBinaries(); try { binaries.setBeforeFirstBinary(); } catch (IllegalStateException e) { context.reportAndThrowTechnicalError(RevisionReport.INGEST_PART, ReportSections.BINARY, "ArchiveBinaryContentWorker: ZipStreamAipBinaries can be only read once!", e); } INamedBinaryStream namedStream; while ((namedStream = binaries.nextBinary()) != null) { String name = namedStream.getBinaryName(); if (name != null) { name = FilenameUtils.separatorsToUnix(name); if (StringUtils.startsWithIgnoreCase(name, "binaries/")) { InputStream stream = namedStream.getBinaryStream(); this.storage.writeBinary(context.getItemId(), name, stream); } } } } catch (Exception e) { LOGGER.error("Storing AIP (" + context.getItemId() + ") failed: ", e); context.reportAndThrowDataError(RevisionReport.INGEST_PART, ReportSections.STORE, "Storing AIP (" + context.getItemId() + ") failed", e); } context.reportSuccess(RevisionReport.INGEST_PART, ReportSections.STORE); return true; }
From source file:com.microsoft.alm.common.utils.UrlHelper.java
public static boolean isSshGitRemoteUrl(final String gitRemoteUrl) { if (isGitRemoteUrl(gitRemoteUrl) && isTeamServicesUrl(gitRemoteUrl)) { if (StringUtils.startsWithIgnoreCase(gitRemoteUrl, "https://") || StringUtils.startsWithIgnoreCase(gitRemoteUrl, "http://")) { return false; }//from w w w. j av a 2 s. c om if (StringUtils.startsWithIgnoreCase(gitRemoteUrl, "ssh://")) { return true; } // check for @ in url - team project name, repo name, collection name and account name don't allow @ // E.g of valid url formats: // ssh://account@account.visualstudio.com:22/Collection/_git/Repo // account@account.visualstudio.com:22/Collection/_git/Repo if (StringUtils.contains(gitRemoteUrl, "@")) { return true; } } return false; }