Java Code Examples for org.apache.commons.lang.StringUtils.containsIgnoreCase()

The following are Jave code examples for showing how to use containsIgnoreCase() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Uranium   File: CraftEnchantment.java   Source Code and License Vote up 6 votes
private static String generateName(net.minecraft.enchantment.Enchantment target) {
    String candidate;
    Class<?> clz = target.getClass();
    if (clz.getName().startsWith("net.minecraft")) {
        // Keep pattern for vanilla
        candidate = "UNKNOWN_ENCHANT_" + target.effectId;
        return candidate;
    }
    candidate = clz.getSimpleName();
    // Make a nice name when it starts with Enchantment (e.g. EnchantmentSlowFall)
    if (StringUtils.containsIgnoreCase(candidate, "Enchantment")) {
        candidate = candidate.replaceFirst("[E|e]nchantment", "");
        // Add underscores at camelCase humps
        candidate = candidate.replaceAll("([a-z])([A-Z])", "\1_\2").toUpperCase();
        candidate = addSuffix(candidate.toUpperCase());
        return candidate;
    }
    // fall back to the FQN if naming pattern is broken
    candidate = clz.getName();
    candidate = candidate.replaceAll("([a-z])([A-Z])", "\1_\2");
    candidate = candidate.replaceAll("\\.", "_");
    candidate = addSuffix(candidate.toUpperCase());
    return candidate;
}
 
Example 2
Project: otter-G   File: ExceptionRuleMonitor.java   Source Code and License Vote up 6 votes
private void check(AlarmRule rule, NodeAlarmEvent alarmEvent) {
    if (!inPeriod(rule)) {
        return;
    }

    String matchValue = rule.getMatchValue();
    matchValue = StringUtils.substringBeforeLast(matchValue, "@");

    String[] matchValues = StringUtils.split(matchValue, ",");

    for (String match : matchValues) {
        if (StringUtils.containsIgnoreCase(alarmEvent.getMessage(), match)) {
            String message = String.format(MESAGE_FORMAT, alarmEvent.getPipelineId(), alarmEvent.getNid(),
                                           alarmEvent.getMessage());
            sendAlarm(rule, message);
            break;
        }
    }
}
 
Example 3
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 6 votes
private void selectAllInTable(TableViewer debugDataViewer, TableCursor tableCursor){
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	int recordCount = 0;
	
	for(int rowIndex = 0; rowIndex < tableItems.length; rowIndex++){
		TableItem tableItem = tableItems[rowIndex];
		for(int colIndex = 1; colIndex <= table.getColumnCount(); colIndex++){
			if(StringUtils.containsIgnoreCase(tableItem.getText(colIndex), findText.getText())){
				label.setVisible(false);
				tableItem.setBackground(colIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				recordCount++;
			}
		}
		findColIndex=1;
	}
	
	findRowIndex = 0;
	findColIndex = 0;
	
	if(recordCount > 0){
		label.setVisible(true);
		label.setText("Match count - " + recordCount);
	}else{ label.setVisible(false); }
	
}
 
Example 4
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 6 votes
private boolean isExistInTable(TableViewer tableViewer, String text){
  boolean isDataExist = false;
  Table table = tableViewer.getTable();
  TableItem[] tableItems = table.getItems();
  for(int i=0;i<tableItems.length;i++){
	TableItem tableItem = tableItems[i];
	for(int j=1;j <= table.getColumnCount()-1;j++){
		if(StringUtils.containsIgnoreCase(tableItem.getText(j), text)){
			label.setVisible(false);
			isDataExist = true;
			return isDataExist;
		}else{
			label.setVisible(true);
			label.setText(labelText);
			isDataExist =  false;
		}
		
	}
  }
return isDataExist;
 }
 
Example 5
Project: bdf2   File: AbstractDialect.java   Source Code and License Vote up 6 votes
/**
 * 判断是否是支持的数据库类型
 * @param connection 数据连接
 * @param dbProductName 数据库名称
 * @param dbMajorVersion 数据版本号
 * @return 返回当前方言是否支持当前数据库
 */
public boolean support(Connection connection,String dbProductName,String dbMajorVersion) {
	try {
		DatabaseMetaData databaseMetaData = connection.getMetaData();
		String databaseProductName = databaseMetaData
				.getDatabaseProductName();
		int databaseMajorVersion = databaseMetaData
		.getDatabaseMajorVersion();
		boolean containsMysql = StringUtils.containsIgnoreCase(
				databaseProductName,dbProductName);
		if(StringUtils.isNotEmpty(dbMajorVersion)){
			return containsMysql&&Integer.valueOf(dbMajorVersion)==databaseMajorVersion;
		}
		return containsMysql;
	} catch (SQLException e) {
		return false;
	}
}
 
Example 6
Project: bdf2   File: AbstractDialect.java   Source Code and License Vote up 6 votes
/**
 * 判断是否是支持的数据库类型
 * @param connection 数据连接
 * @param dbProductName 数据库名称
 * @param dbMajorVersion 数据版本号
 * @return 返回当前方言是否支持当前数据库
 */
public boolean support(Connection connection,String dbProductName,String dbMajorVersion) {
	try {
		DatabaseMetaData databaseMetaData = connection.getMetaData();
		String databaseProductName = databaseMetaData
				.getDatabaseProductName();
		int databaseMajorVersion = databaseMetaData
		.getDatabaseMajorVersion();
		boolean containsMysql = StringUtils.containsIgnoreCase(
				databaseProductName,dbProductName);
		if(StringUtils.isNotEmpty(dbMajorVersion)){
			return containsMysql&&Integer.valueOf(dbMajorVersion)==databaseMajorVersion;
		}
		return containsMysql;
	} catch (SQLException e) {
		return false;
	}
}
 
Example 7
Project: formatter   File: FormatUtil.java   Source Code and License Vote up 5 votes
/**
* 
* @Title: isHtml 
* @Description: Check if it is HTML string 
* @param @param html
* @param @return 
* @return boolean
* @throws
 */
public static boolean isHtml(String html)
{
    if (StringUtils.isEmpty(html))
    {
        return false;
    }

    if (StringUtils.containsIgnoreCase(html, FormatConst.HTML_LABEL))
    {
        return true;
    }

    return false;
}
 
Example 8
Project: ymate-payment-v2   File: DefaultAliPayRequestSender.java   Source Code and License Vote up 5 votes
public String executeActionForm() {
    // 此处在网关URL地址中添加字符集配置参数,主要为解决中文乱码问题
    if (!StringUtils.containsIgnoreCase(this.gatewayUrl, "charset=")) {
        Map<String, String> _params = new HashMap<String, String>();
        _params.put(IAliPay.Const.CHARSET, charset);
        //
        this.gatewayUrl = ParamUtils.appendQueryParamValue(this.gatewayUrl, _params, false, null);
    }
    return ParamUtils.buildActionForm(this.gatewayUrl, true, false, true, charset, requestParameters);
}
 
Example 9
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 5 votes
private void forwardTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
	TableItem previousSelectedTableItem = null;
	if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
		previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
		findColIndex++;
	}
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	if(findColIndex == prevColSelection && findRowIndex == prevRowSelection){
		findColIndex++;
	}
	if(findRowIndex < 0){
		findRowIndex = 0;
	}
	for(;findRowIndex<tableItems.length;){
		TableItem tableItem = tableItems[findRowIndex];
		for(;findColIndex <= table.getColumnCount();findColIndex++){
			if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
				if(prevColSelection > 0){
					previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
				}
				label.setVisible(false);
				table.showItem(tableItem);
				table.showColumn(table.getColumn(findColIndex));
				tableCursor.setSelection(findRowIndex, findColIndex);
				tableCursor.setVisible(false);
				tableItem.setBackground(findColIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
				debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
				prevColSelection = findColIndex;
				return;
			}
		}
		findRowIndex++;
		findColIndex=1;
		if(findRowIndex >= tableItems.length){ findRowIndex = 0;}
	}
}
 
Example 10
Project: Hydrograph   File: FindViewDataDialog.java   Source Code and License Vote up 5 votes
private void reverseTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
	TableItem previousSelectedTableItem = null;
	if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
		previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
		findColIndex -= 1;
	}
	if(findRowIndex < 0){
		findRowIndex = debugDataViewer.getTable().getItems().length - 1;
	}
	Table table = debugDataViewer.getTable();
	TableItem[] tableItems = table.getItems();
	for(; findRowIndex >=0; findRowIndex--){
		TableItem tableItem = tableItems[findRowIndex];
		for( ; findColIndex > 0 ;findColIndex--){
			if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
				if(prevColSelection > 0){
					previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
				}
				label.setVisible(false);
				table.showItem(tableItem);
				table.showColumn(table.getColumn(findColIndex));
				tableCursor.setSelection(findRowIndex, findColIndex);
				tableCursor.setVisible(false);
				tableItem.setBackground(findColIndex,Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
				if(findColIndex<=0){debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex-1);}else{
					debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
				}
				debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
				prevColSelection = findColIndex;
				prevRowSelection = findRowIndex;
				return ;
			}
			
		}
		if(findColIndex <= 0){ findColIndex = table.getColumnCount();}
		if(findRowIndex == 0){ findRowIndex = tableItems.length; }
	}
}
 
Example 11
Project: Hydrograph   File: HydrographComponentProposalProvider.java   Source Code and License Vote up 5 votes
@Override
public IContentProposal[] getProposals(String contents, int position) {

	proposalList.clear();
	List<PaletteContainer> paletteEntry = paletteRoot.getChildren();
	for (PaletteContainer paletteContainer : paletteEntry) {
		List<PaletteEntry> paletteDrawersList = paletteContainer.getChildren();
		for (PaletteEntry paletteDrawer : paletteDrawersList) {

			if (StringUtils.containsIgnoreCase(
					paletteDrawer.getParent().getLabel() + " : " + paletteDrawer.getLabel(), contents)) {
				String componentName = ((Class) ((CombinedTemplateCreationEntry) paletteDrawer).getTemplate())
						.getSimpleName();
				componentDetails = new ComponentDetails();
				Component component = XMLConfigUtil.INSTANCE.getComponent(componentName);
				componentDetails.setName(componentName);
				componentDetails.setCategoryAndPalletteName(
						paletteDrawer.getParent().getLabel() + " : " + paletteDrawer.getLabel());
				componentDetails.setDescription(component.getDescription());
				componentDetails.setDescriptor(paletteDrawer.getSmallIcon());
				proposalList.add(new ComponentContentProposal(componentDetails));
			}
		}
	}

	componentDetails = new ComponentDetails();
	componentDetails.setName(COMMENT_BOX);
	componentDetails.setCategoryAndPalletteName(COMMENT_BOX);
	componentDetails.setDescription(COMMENT_BOX);
	componentDetails.setDescriptor(getCommentBoxImageDisDescriptor());
	proposalList.add(new ComponentContentProposal(componentDetails));
	return proposalList.toArray(new IContentProposal[0]);
}
 
Example 12
Project: sonar-css-plugin   File: CommentContainsPatternChecker.java   Source Code and License Vote up 5 votes
@Override
public void visitComment(SyntaxTrivia trivia) {
  String comment = trivia.text();
  if (StringUtils.containsIgnoreCase(comment, pattern) && !isLetterAround(comment, pattern)) {
    addPreciseIssue(trivia, message);
  }
  super.visitComment(trivia);
}
 
Example 13
Project: bdf2   File: LobStoreServiceImpl.java   Source Code and License Vote up 5 votes
public Void doInConnection(Connection connection) throws SQLException,
		DataAccessException {
	String productName = connection.getMetaData().getDatabaseProductName();
	LobHandler lobHandler = null;
	if (StringUtils.containsIgnoreCase(productName, ORACLE)) {
		lobHandler = createOracleLobHandler();
	} else {
		lobHandler = createDefaultLobHandler(productName);
	}
	this.lobStoreServiceImpl.setLobHandler(lobHandler);
	return null;
}
 
Example 14
Project: bdf2   File: LobStoreServiceImpl.java   Source Code and License Vote up 5 votes
/**
 * 创建一个通用的的LobHandler,但对SqlServer数据库做了特殊处理.
 * 
 * @param productName
 *            数据库驱动的名称
 * @return 返回DefaultLobHandler对象
 */
private DefaultLobHandler createDefaultLobHandler(String productName) {
	DefaultLobHandler defaultLobHandler = new DefaultLobHandler();
	// 为支持sqljdbc4的处理方式,需要将其大对象流包装到BLOB/CLOB里,否则流将被自动关闭
	if (StringUtils.containsIgnoreCase(productName, SQLSERVER)) {
		defaultLobHandler.setWrapAsLob(true);
	}
	return defaultLobHandler;
}
 
Example 15
Project: s3-inventory-usage-examples   File: ReducedRedundancyLocatorExampleMain.java   Source Code and License Vote up 4 votes
public static void main(String[] args) throws Exception{
    String srcBucketName;
    String scrBucketKey;
    String destBucketName;
    String destPrefix;
    ArgumentParser argumentParser = new ArgumentParser();
    AmazonS3 s3Client = new AmazonS3Client();

    try {
        BucketKey location = argumentParser.parseArguments(args);
        srcBucketName = location.getSrcBucket();
        scrBucketKey = location.getSrcKey();
        destBucketName = location.getDestBucket();
        destPrefix = location.getDestPrefix();
    } catch (ParseException e) {
        LOG.info(PARSE_ERROR_MSG);
        throw new IllegalArgumentException("Parser throw a parse Exception", e);
    }

    // Obtain the original manifest files
    InventoryManifestRetriever inventoryManifestRetriever =
            new InventoryManifestRetriever(s3Client, srcBucketName, scrBucketKey);
    InventoryManifest manifest = inventoryManifestRetriever.getInventoryManifest();

    // Check if the inventory report includes the StorageClass column
    String fileSchema = manifest.getFileSchema();
    String filterColumn = "storageClass";
    if (!StringUtils.containsIgnoreCase(fileSchema, filterColumn)) {
        throw new StorageClassNotIncludedException();
    }

    //Create Spark Context
    SparkConf sparkConf = new SparkConf();
    JavaSparkContext sc = new JavaSparkContext(sparkConf);
    Broadcast<CachedS3ClientFactory> clientFactory = sc.broadcast(new CachedS3ClientFactory());

    // Get the inventory report, split it into lines, parse each line to a POJO,
    // Filter, and write new csv file to S3
    JavaRDD<InventoryManifest.Locator> locatorRDD = sc.parallelize(manifest.getLocators());
    List<InventoryManifest.Locator> newLocatorList = locatorRDD
            .map(new InventoryReportLineRetriever(clientFactory, manifest))
            .flatMap(new InventoryReportMapper(manifest))
            .filter(new ReducedRedundancyStorageClassFilter())
            .mapPartitions(new WriteNewInventoryReportFunc(clientFactory, srcBucketName, manifest,
                    destBucketName, destPrefix))
            .collect();

    // Generate new manifest files including new locators, and send them back to S3
    new ManifestWriter(s3Client, destBucketName, destPrefix, srcBucketName, manifest)
            .writeManifest(newLocatorList);

    sc.close();
}
 
Example 16
Project: otter-G   File: AuthContextValve.java   Source Code and License Vote up 4 votes
protected boolean isAPI(TurbineRunData rundata) {
	String requestUrl = rundata.getRequest().getRequestURI();
	return StringUtils.containsIgnoreCase(requestUrl, "/api/");
}
 
Example 17
Project: otter-G   File: MediaPushDataSourceHandler.java   Source Code and License Vote up 4 votes
public static boolean isMediaPushDataSource(String url) {
    return StringUtils.startsWithIgnoreCase(url, "jdbc:") && StringUtils.containsIgnoreCase(url, "groupKey");
}
 
Example 18
Project: otter-G   File: DdlUtils.java   Source Code and License Vote up 4 votes
private static Column readColumn(DatabaseMetaDataWrapper metaData, Map<String, Object> values) throws SQLException {
    Column column = new Column();

    column.setName((String) values.get("COLUMN_NAME"));
    column.setDefaultValue((String) values.get("COLUMN_DEF"));
    column.setTypeCode(((Integer) values.get("DATA_TYPE")).intValue());

    String typeName = (String) values.get("TYPE_NAME");
    // column.setType(typeName);

    if ((typeName != null) && typeName.startsWith("TIMESTAMP")) {
        column.setTypeCode(Types.TIMESTAMP);
    }
    // modify 2013-09-25,处理下unsigned
    if ((typeName != null) && StringUtils.containsIgnoreCase(typeName, "UNSIGNED")) {
        // 如果为unsigned,往上调大一个量级,避免数据溢出
        switch (column.getTypeCode()) {
            case Types.TINYINT:
                column.setTypeCode(Types.SMALLINT);
                break;
            case Types.SMALLINT:
                column.setTypeCode(Types.INTEGER);
                break;
            case Types.INTEGER:
                column.setTypeCode(Types.BIGINT);
                break;
            case Types.BIGINT:
                column.setTypeCode(Types.DECIMAL);
                break;
            default:
                break;
        }
    }

    Integer precision = (Integer) values.get("NUM_PREC_RADIX");

    if (precision != null) {
        column.setPrecisionRadix(precision.intValue());
    }

    String size = (String) values.get("COLUMN_SIZE");

    if (size == null) {
        size = (String) _defaultSizes.get(new Integer(column.getTypeCode()));
    }

    // we're setting the size after the precision and radix in case
    // the database prefers to return them in the size value
    column.setSize(size);

    int scale = 0;
    Object dec_digits = values.get("DECIMAL_DIGITS");

    if (dec_digits instanceof String) {
        scale = (dec_digits == null) ? 0 : NumberUtils.toInt(dec_digits.toString());
    } else if (dec_digits instanceof Integer) {
        scale = (dec_digits == null) ? 0 : (Integer) dec_digits;
    }

    if (scale != 0) {
        column.setScale(scale);
    }

    column.setRequired("NO".equalsIgnoreCase(((String) values.get("IS_NULLABLE")).trim()));
    column.setDescription((String) values.get("REMARKS"));
    return column;
}
 
Example 19
Project: monarch   File: DataCommandFunction.java   Source Code and License Vote up 4 votes
private String addLimit(String query) {
  if (StringUtils.containsIgnoreCase(query, " limit")
      || StringUtils.containsIgnoreCase(query, " count("))
    return query;
  return query + " limit " + getFetchSize();
}
 
Example 20
Project: satisfy   File: PDFWords.java   Source Code and License Vote up 4 votes
private boolean isContaining(String expectedValue, boolean ignoreCase, String content) {
    return ignoreCase ? StringUtils.containsIgnoreCase(content, expectedValue) : StringUtils.contains(content, expectedValue);
}