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:io.wcm.tooling.netbeans.sightly.completion.classLookup.RequestAttributeResolver.java
public Set<String> resolve(String filter) { Set<String> ret = new LinkedHashSet<>(); // only display results if filter contains @ if (!StringUtils.contains(text, "@") || !StringUtils.contains(text, "data-sly-use")) { return ret; }//from w ww . j a va 2 s . com ElementUtilities.ElementAcceptor acceptor = new ElementUtilities.ElementAcceptor() { @Override public boolean accept(Element e, TypeMirror type) { // we are looking for the annotations for (AnnotationMirror mirror : e.getAnnotationMirrors()) { if (mirror.getAnnotationType() != null && mirror.getAnnotationType().asElement() != null && StringUtils.equalsIgnoreCase(REQUEST_ATTRIBUTE_CLASSNAME, mirror.getAnnotationType().asElement().toString())) { return true; } } return false; } }; String clazz = StringUtils.substringBetween(text, "'"); Set<Element> elems = getMembersFromJavaSource(clazz, acceptor); for (Element elem : elems) { if (StringUtils.startsWithIgnoreCase(elem.getSimpleName().toString(), filter) && !StringUtils.contains(text, elem.getSimpleName().toString() + " ") && !StringUtils.contains(text, elem.getSimpleName().toString() + "=")) { ret.add(elem.getSimpleName().toString()); } } if (ret.isEmpty()) { for (String att : getAttributesFromClassLoader(clazz)) { if (StringUtils.startsWithIgnoreCase(att, filter) && !StringUtils.contains(text, att + " ") && !StringUtils.contains(text, att + "=")) { ret.add(att); } } } return ret; }
From source file:biz.netcentric.vlt.upgrade.handler.GroovyConsoleHandler.java
/** * returns the correct Phase for a script name by its prefix. * Important to handle PREPARE_FAILED and PREPARE correctly * @param text the script name//from w w w . j ava2s. c o m * @return related phase. defaults to INSTALLED */ private Phase getPhaseFromPrefix(String text) { String scriptName = text.toLowerCase(); Phase phase = Phase.INSTALLED; for (int i = phases.length - 1; i >= 0; i--) { if (StringUtils.startsWithIgnoreCase(scriptName, phases[i].name())) { phase = phases[i]; break; } } return phase; }
From source file:mitm.application.djigzo.james.matchers.MailVariableResolver.java
/** * Returns the mail value of the mail variable. Returns null if the mail does not support a variable with the given name. *//*from w w w . j a v a 2s . c o m*/ @Override public String resolveVariable(String variable) throws FunctionException { /* * Note: non numbers must be single quoted (ie. 'value') */ try { /* * Mail vars should start with mail. */ if (StringUtils.startsWithIgnoreCase(variable, MAIL_VAR_PREFIX)) { if (SIZE.equalsIgnoreCase(variable)) { return Long.toString(mail.getMessageSize()); } else if (RECIPIENTS_SIZE.equalsIgnoreCase(variable)) { return Integer.toString(mail.getRecipients().size()); } else if (CONTENT_TYPE.equalsIgnoreCase(variable)) { MimeMessage message = mail.getMessage(); return message != null ? message.getContentType() : ""; } else if (StringUtils.startsWithIgnoreCase(variable, MAIL_ATTRIBUTE_PREFIX)) { /* * Check to see whether Mail has an attribute with the name */ String attrName = StringUtils.substringAfter(variable, MAIL_ATTRIBUTE_PREFIX); if (StringUtils.isNotEmpty(variable)) { Object attr = mail.getAttribute(attrName); if (attr != null) { return "'" + attr.toString() + "'"; } } } return NULL_STRING; } return null; } catch (MessagingException e) { throw new FunctionException(e); } }
From source file:au.org.ala.delta.intkey.directives.DisplayImagesDirective.java
private void processToken(String token, DisplayImagesDirectiveInvocation invoc, StringBuilder stringRepresentationBuilder) { if (StringUtils.startsWithIgnoreCase(ImageDisplayMode.AUTO.name(), token)) { invoc.setDisplayMode(ImageDisplayMode.AUTO); stringRepresentationBuilder.append(ImageDisplayMode.AUTO.name()); } else if (StringUtils.startsWithIgnoreCase(ImageDisplayMode.MANUAL.name(), token)) { invoc.setDisplayMode(ImageDisplayMode.MANUAL); stringRepresentationBuilder.append(ImageDisplayMode.MANUAL.name()); } else if (StringUtils.startsWithIgnoreCase(ImageDisplayMode.OFF.name(), token)) { invoc.setDisplayMode(ImageDisplayMode.OFF); stringRepresentationBuilder.append(ImageDisplayMode.OFF.name()); } else if (StringUtils.startsWithIgnoreCase(DisplayImagesReportType.MISSING_IMAGE_LIST.name(), token)) { invoc.setReportType(DisplayImagesReportType.MISSING_IMAGE_LIST); stringRepresentationBuilder.append(DisplayImagesReportType.MISSING_IMAGE_LIST.name()); } else if (StringUtils.startsWithIgnoreCase(DisplayImagesReportType.CHARACTER_IMAGE_LIST.name(), token)) { invoc.setReportType(DisplayImagesReportType.CHARACTER_IMAGE_LIST); stringRepresentationBuilder.append(DisplayImagesReportType.CHARACTER_IMAGE_LIST.name()); } else if (StringUtils.startsWithIgnoreCase(DisplayImagesReportType.TAXON_IMAGE_LIST.name(), token)) { invoc.setReportType(DisplayImagesReportType.TAXON_IMAGE_LIST); stringRepresentationBuilder.append(DisplayImagesReportType.TAXON_IMAGE_LIST.name()); }//from ww w.ja va 2s. c o m }
From source file:ddf.catalog.source.opensearch.OpenSearchConnection.java
/** * Default Constructor/*from w ww .jav a2 s. c o m*/ * @param endpointUrl - OpenSearch URL to connect to * @param filterAdapter - adapter to translate between DDF REST and OpenSearch * @param securitySettings - Service used to obtain settings for secure communications. * @param username - Basic Auth user name * @param password - Basic Auth password */ public OpenSearchConnection(String endpointUrl, FilterAdapter filterAdapter, SecuritySettingsService securitySettings, String username, String password) { this.filterAdapter = filterAdapter; this.username = username; this.password = password; this.securitySettingsService = securitySettings; openSearch = JAXRSClientFactory.create(endpointUrl, OpenSearch.class); openSearchClient = WebClient.client(openSearch); RestUrl restUrl = newRestUrl(endpointUrl); if (restUrl != null) { restService = JAXRSClientFactory.create(restUrl.buildUrl(), RESTService.class); restServiceClient = WebClient.client(restService); if (StringUtils.startsWithIgnoreCase(endpointUrl, "https")) { setTLSOptions(openSearchClient); setTLSOptions(restServiceClient); } } }
From source file:com.hangum.tadpole.engine.sql.util.executer.procedure.OracleProcedureExecuter.java
@Override public boolean exec(List<InOutParameterDAO> parameterList) throws Exception { initResult();/* ww w .ja v a 2s .c o m*/ java.sql.Connection javaConn = null; java.sql.CallableStatement cstmt = null; java.sql.PreparedStatement pstmt = null; OracleDbmsOutputUtil dbmsOutput = null; try { if (listOutParamValues == null) getOutParameters(); SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); try { dbmsOutput = new OracleDbmsOutputUtil(javaConn); dbmsOutput.enable(1000000); } catch (SQLException e) { logger.error("dbmsoutput exception", e); } // make the script String strExecuteScript = getMakeExecuteScript(); if (StringUtils.startsWithIgnoreCase(strExecuteScript, "SELECT")) { // function execute... pstmt = javaConn.prepareStatement(strExecuteScript); for (InOutParameterDAO inOutParameterDAO : parameterList) { pstmt.setObject(inOutParameterDAO.getOrder(), inOutParameterDAO.getValue()); } // Set the OUT Parameter for (int i = 0; i < listOutParamValues.size(); i++) { InOutParameterDAO dao = listOutParamValues.get(i); //pstmt.registerOutParameter(dao.getOrder(), RDBTypeToJavaTypeUtils.getJavaType(dao.getRdbType())); pstmt.setObject(dao.getOrder(), ""); } ResultSet rs = pstmt.executeQuery(); setResultCursor(rs); } else { // set prepare call cstmt = javaConn.prepareCall(strExecuteScript); // Set input value for (InOutParameterDAO inOutParameterDAO : parameterList) { cstmt.setObject(inOutParameterDAO.getOrder(), inOutParameterDAO.getValue()); } // Set the OUT Parameter for (int i = 0; i < listOutParamValues.size(); i++) { InOutParameterDAO dao = listOutParamValues.get(i); if (logger.isDebugEnabled()) logger.debug("Out Parameter " + dao.getOrder() + " JavaType is " + RDBTypeToJavaTypeUtils.getJavaType(dao.getRdbType())); cstmt.registerOutParameter(dao.getOrder(), RDBTypeToJavaTypeUtils.getJavaType(dao.getRdbType())); } cstmt.execute(); // // set // // cursor list // boolean is cursor boolean isCursor = false; for (int i = 0; i < listOutParamValues.size(); i++) { InOutParameterDAO dao = listOutParamValues.get(i); if (logger.isDebugEnabled()) logger.debug("Execute Procedure result " + dao.getName() + "=" + cstmt.getString(dao.getOrder())); Object obj = cstmt.getObject(dao.getOrder()); // String? Type Cast .... String ... if (obj != null) { if ("SYS_REFCURSOR".equals(dao.getRdbType())) { isCursor = true; ResultSet rs = (ResultSet) obj; setResultCursor(rs); // cursor? ? ? 1. } else { dao.setValue(obj.toString()); } } } if (!isCursor) { List<Map<Integer, Object>> sourceDataList = new ArrayList<Map<Integer, Object>>(); Map<Integer, Object> tmpRow = null; for (int i = 0; i < listOutParamValues.size(); i++) { InOutParameterDAO dao = listOutParamValues.get(i); tmpRow = new HashMap<Integer, Object>(); tmpRow.put(0, "" + dao.getOrder()); tmpRow.put(1, "" + dao.getName()); tmpRow.put(2, "" + dao.getType()); tmpRow.put(3, "" + dao.getRdbType()); tmpRow.put(4, "" + dao.getLength()); tmpRow.put(5, "" + dao.getValue()); sourceDataList.add(tmpRow); } setResultNoCursor(new TadpoleResultSet(sourceDataList)); } } try { dbmsOutput.show(); } catch (SQLException e) { logger.error("dbmsoutput exception", e); } setStrOutput(dbmsOutput.getOutput()); return true; } catch (Exception e) { logger.error("ProcedureExecutor executing error", e); throw e; } finally { try { if (pstmt != null) pstmt.close(); } catch (Exception e) { } try { if (cstmt != null) cstmt.close(); } catch (Exception e) { } try { if (dbmsOutput != null) dbmsOutput.close(); } catch (Exception e) { } try { if (javaConn != null) javaConn.close(); } catch (Exception e) { } } }
From source file:com.hangum.tadpole.engine.sql.util.SQLUtil.java
/** * ? ?./*from www . j a v a2 s. co m*/ * ? ?? ... -- / ** * / / * * / * * @param strSQL * @return */ public static boolean isNotAllowed(String strSQL) { boolean isRet = false; String cmpSql = StringUtils.trim(removeComment(strSQL)); for (String strNAllSQL : NOT_ALLOWED_SQL) { if (StringUtils.startsWithIgnoreCase(cmpSql, strNAllSQL)) { return true; } } return isRet; }
From source file:com.microsoft.alm.plugin.idea.common.starters.ApplicationStarterBase.java
@Override public void main(String[] args) { logger.debug("Args passed to VSTS to process: {}", Arrays.toString(args)); try {//from w ww . ja v a 2 s .c o m if (StringUtils.startsWithIgnoreCase(args[1], URI_PREFIX)) { // pass the uri but after removing it's prefix since it isn't needed anymore processUri(args[1].replaceFirst(URI_PREFIX, StringUtils.EMPTY)); } else { List<String> argsList = new ArrayList<String>(Arrays.asList(args)); // remove first arg which is just the generic command "vsts" that got us to this point argsList.remove(0); processCommand(argsList); } } catch (Exception e) { logger.error(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, e.getMessage())); logMetrics(false, e.getClass().getSimpleName()); saveAll(); // exit code IntelliJ uses for exceptions System.exit(1); } catch (Throwable t) { logger.error(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, t.getMessage())); logMetrics(false, t.getClass().getSimpleName()); saveAll(); // exit code IntelliJ uses for throwables System.exit(2); } // log metrics and save settings before IDE closes logMetrics(true, null); saveAll(); }
From source file:com.hangum.tadpole.rdb.core.editors.main.execute.sub.ExecuteBatchSQL.java
/** * select? execute ./*from w ww . j a v a 2 s . co m*/ * @param errMsg * * @param listQuery * @param reqQuery * @param userDB * @param userType * @param intCommitCount * @param userEmail * @throws Exception */ public static void runSQLExecuteBatch(String errMsg, List<String> listQuery, final RequestQuery reqQuery, final UserDBDAO userDB, final String userType, final int intCommitCount, final String userEmail) throws Exception { if (!PermissionChecker.isExecute(userType, userDB, listQuery)) { throw new Exception(errMsg); } // Check the db access control for (String strQuery : listQuery) { if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getDdl_lock())) { throw new Exception(errMsg); } PublicTadpoleDefine.QUERY_DML_TYPE queryType = SQLUtil.sqlQueryType(strQuery); if (reqQuery.getSqlType() == SQL_TYPE.DDL) { if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getDdl_lock())) { throw new Exception(errMsg); } } if (queryType == QUERY_DML_TYPE.INSERT) { if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getInsert_lock())) { throw new Exception(errMsg); } } if (queryType == QUERY_DML_TYPE.UPDATE) { if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getUpdate_lock())) { throw new Exception(errMsg); } } if (queryType == QUERY_DML_TYPE.DELETE) { if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getDbAccessCtl().getDelete_locl())) { throw new Exception(errMsg); } } } java.sql.Connection javaConn = null; Statement statement = null; try { if (reqQuery.isAutoCommit()) { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); } else { javaConn = TadpoleSQLTransactionManager.getInstance(userEmail, userDB); } statement = javaConn.createStatement(); int count = 0; for (String strQuery : listQuery) { // ? commit? rollback? ??? if (!TransactionManger.calledCommitOrRollback(reqQuery.getSql(), userEmail, userDB)) { if (StringUtils.startsWithIgnoreCase(strQuery.trim(), "CREATE TABLE")) { //$NON-NLS-1$ strQuery = StringUtils.replaceOnce(strQuery, "(", " ("); //$NON-NLS-1$ //$NON-NLS-2$ } } statement.addBatch(strQuery); if (++count % intCommitCount == 0) { statement.executeBatch(); count = 0; } } statement.executeBatch(); } catch (Exception e) { logger.error("Execute batch update", e); //$NON-NLS-1$ throw e; } finally { try { statement.close(); } catch (Exception e) { } if (reqQuery.isAutoCommit()) { try { javaConn.close(); } catch (Exception e) { } } } }
From source file:com.hangum.tadpole.db.metadata.MakeContentAssistUtil.java
/** * ? ? ?? .. //from w w w . ja va 2s. c o m * content assist tester.tablename ? ?? . ? ? ? ? ?. * * @param userDB * @param strArryCursor * @return */ protected String getSchemaOrTableContentAssist(UserDBDAO userDB, String[] strArryCursor) { String strCntAsstList = getContentAssist(userDB); String strCursorText = strArryCursor[0] + strArryCursor[1]; if (StringUtils.contains(strCursorText, '.')) { String strSchemaName = StringUtils.substringBefore(strCursorText, ".") + "."; // String strTableName = StringUtils.substringAfter(strCursorText, "."); int intSep = StringUtils.indexOf(strCursorText, "."); if (logger.isDebugEnabled()) { logger.debug("[0]" + strArryCursor[0]); logger.debug("[1]" + strArryCursor[1]); logger.debug("[1][intSep]" + intSep); logger.debug("[1][strArryCursor[0].length()]" + strArryCursor[0].length()); logger.debug("==> [Return table list]" + (strArryCursor[0].length() >= intSep)); } // ? ? ? . if (strArryCursor[0].length() >= intSep) { String strNewCntAsstList = ""; String[] listGroup = StringUtils.splitByWholeSeparator(strCntAsstList, _PRE_GROUP); if (listGroup == null) return strNewCntAsstList; for (String strDefault : listGroup) { String[] listDefault = StringUtils.split(strDefault, _PRE_DEFAULT); if (listDefault != null & listDefault.length == 2) { if (StringUtils.startsWithIgnoreCase(listDefault[0], strSchemaName)) strNewCntAsstList += makeObjectPattern("", StringUtils.removeStartIgnoreCase(listDefault[0], strSchemaName), listDefault[1]); } // } return strNewCntAsstList; } } return strCntAsstList; }