List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(String str, String searchStr)
Checks if String contains a search String irrespective of case, handling null
.
From source file:edu.wfu.inotado.impl.InotadoServiceImpl.java
/** * Validate the input string and parse it * /*from w w w .j a v a2 s .c om*/ * @param text * @return * @throws InotadoException */ private Map<String, Properties> getCustomProperties(String text) throws InotadoException { Map<String, Properties> propMap = new HashMap<String, Properties>(); Scanner scanner = new Scanner(text); String[] propKeys = null; String[] propValues = null; int ln = 0; while (scanner.hasNextLine()) { String line = scanner.nextLine(); ln++; if (ln == 1) { // process header if (!StringUtils.containsIgnoreCase(line, "siteid")) { log.error("\"siteId\" is not found in the header line. Aboard operation."); throw new InotadoException("Header row is not properly specified"); } propKeys = StringUtils.split(line, "\t"); } else { // process content propValues = StringUtils.split(line, "\t"); // skip to next if this line is not properly entered if (propValues.length < propKeys.length) { log.warn("There is no enough value contained in this line: " + line); continue; } String siteId = propValues[1]; if (!siteService.siteExists(siteId)) { // not site found, skip this line continue; } Properties props = new Properties(); // get properties for (int i = 2; i < propValues.length; i++) { props.put(propKeys[i], propValues[i]); } propMap.put(siteId, props); } } return propMap; }
From source file:edu.monash.merc.system.parser.nextprot.NxXMLParser.java
private PEEvidenceBean parsePEOthCurEvidence(Element protein, String nxAc) { Element proteinExistenceEle = protein.getChild(ELE_PROTEIN_EXISTENCE); if (proteinExistenceEle != null) { Attribute proteinExistenceAttr = proteinExistenceEle.getAttribute(ATTR_PROTEIN_EXISTENCE_VALUE); if (proteinExistenceAttr != null) { PEEvidenceBean peOthCurEvidenceBean = new PEEvidenceBean(); String proteinExistence = proteinExistenceAttr.getValue(); //create a TPBDataTypeBean TPBDataTypeBean hpbDataTypeBean = new TPBDataTypeBean(); //set the data type hpbDataTypeBean.setDataType(DataType.PE_OTH_CUR.type()); //set the traffic lights level to 3 hpbDataTypeBean.setLevel(TLLevel.TL3.level()); //There is no color level 3 //If it's protein level, then set color level into 4 if (StringUtils.containsIgnoreCase(proteinExistence, NXConts.PE_PROTEIN_LEVEL)) { peOthCurEvidenceBean.setColorLevel(ColorType.GREEN.color()); } else if (StringUtils.containsIgnoreCase(proteinExistence, NXConts.PE_TRANSCRIPT_LEVEL)) { //if it's transcript level, then set color level into 2 (original as 3) // : change the Color Level to Red peOthCurEvidenceBean.setColorLevel(ColorType.RED.color()); //if it's homology or predicted or uncertian. or others, then set color level into 1 //rest of other value. then set color level into 1 } else { peOthCurEvidenceBean.setColorLevel(ColorType.BLACK.color()); }// w w w .j a v a2s . c om peOthCurEvidenceBean.setTpbDataTypeBean(hpbDataTypeBean); peOthCurEvidenceBean.setEvidenceValue(proteinExistence); peOthCurEvidenceBean.setHyperlink(NXConts.PE_OTH_CUR_NX_BASE_URL + nxAc); return peOthCurEvidenceBean; } } return null; }
From source file:hydrograph.ui.propertywindow.widgets.utility.SchemaRowValidation.java
private boolean validationCheckForBigDecimalDatatype(GridRow gridRow, String componentType, TableItem tableItem) {/* w w w . j a v a2 s .com*/ int precision = 0, scale = 0; if (StringUtils.isNotBlank(gridRow.getPrecision()) && StringUtils.isNotBlank(gridRow.getScale())) { try { precision = Integer.parseInt(gridRow.getPrecision()); } catch (NumberFormatException exception) { logger.debug("Failed to parse the precision ", exception); return false; } try { scale = Integer.parseInt(gridRow.getScale()); } catch (NumberFormatException exception) { logger.debug("Failed to parse the scale ", exception); return false; } } if (StringUtils.containsIgnoreCase(componentType, HIVE) || StringUtils.containsIgnoreCase(componentType, PARQUET)) { if (StringUtils.isBlank(gridRow.getPrecision()) || StringUtils.isBlank(gridRow.getScale()) || StringUtils.equalsIgnoreCase(gridRow.getScaleTypeValue(), NONE) || !(gridRow.getScale().matches(REGULAR_EXPRESSION_FOR_NUMBER)) || !(gridRow.getPrecision().matches(REGULAR_EXPRESSION_FOR_NUMBER)) || precision <= scale) { setRedColor(tableItem); return true; } else { setBlackColor(tableItem); return false; } } else if (StringUtils.isBlank(gridRow.getScale()) || StringUtils.equalsIgnoreCase(gridRow.getScaleTypeValue(), NONE) || !(gridRow.getScale().matches(REGULAR_EXPRESSION_FOR_NUMBER)) || (!(gridRow.getPrecision().matches(REGULAR_EXPRESSION_FOR_NUMBER)) && StringUtils.isNotBlank(gridRow.getPrecision()))) { setRedColor(tableItem); return true; } else { setBlackColor(tableItem); return false; } }
From source file:hydrograph.ui.dataviewer.find.FindViewDataDialog.java
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++;// w ww . j a v a 2 s . c o m } 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; } } }
From source file:adalid.commons.velocity.Writer.java
private void writePlatform(WriterContext basicWriterContext, File platformPropertiesFile) { logger.info("propertiesFile=" + platformPropertiesFile.getPath()); try {/* w w w. ja va 2 s . co m*/ VelocityContext platformContext = basicWriterContext.getVelocityContextClone(); String platform = StringUtils.removeEndIgnoreCase(platformPropertiesFile.getName(), PROPERTIES_SUFFIX); platformContext.put(VC_PLATFORM, platform); TLB.setProgrammers(basicWriterContext.programmers); TLB.setWrapperClasses(basicWriterContext.wrapperClasses); putProperties(platformContext, platformPropertiesFile); Properties properties = mergeProperties(platformContext, platformPropertiesFile); putStrings(platformContext, properties); ExtendedProperties mergeExtendedProperties = mergeExtendedProperties(platformContext, platformPropertiesFile); createDirectories(mergeExtendedProperties); deletePreviouslyGeneratedFiles(mergeExtendedProperties); WriterContext platformWriterContext = newWriterContext(platformContext); File platformsFolder = platformPropertiesFile.getParentFile(); ExtendedProperties platformExtendedProperties = PropertiesHandler .getExtendedProperties(platformPropertiesFile); String[] pathnames = platformExtendedProperties.getStringArray(FILE_RESOURCE_LOADER_PATH); String[] pathfilters = platformExtendedProperties.getStringArray(FILE_RESOURCE_LOADER_PATH_FILTER); Map<String, File> folders = new LinkedHashMap<>(); if (pathnames == null || pathnames.length == 0) { } else { for (File folder : bootstrappingPlatformsFolders) { folders.putAll(FilUtils.directoriesMap(folder, pathnames, folder)); } } if (pathfilters != null && pathfilters.length > 0) { String[] keyArray = folders.keySet().toArray(new String[folders.keySet().size()]); String slashedFilter, slashedPath; for (String pathfilter : pathfilters) { slashedFilter = pathfilter.replace(FILE_SEPARATOR, SLASH); for (String key : keyArray) { slashedPath = key.replace(FILE_SEPARATOR, SLASH) + SLASH; if (StringUtils.containsIgnoreCase(slashedPath, slashedFilter)) { folders.remove(key); logger.debug(pathfilter + " excludes " + key); } } } } File[] templateFiles; Properties templateProperties; String disabled; String disabledMissing; String pattern; String template; String message; String platformsFolderPath = platformsFolder.getPath(); // + FILE_SEPARATOR; for (File folder : folders.values()) { log(_detailLevel, "write", "path=" + StringUtils.removeStart(folder.getPath(), platformsFolderPath)); templateFiles = folder.listFiles(propertiesFileFilter); Arrays.sort(templateFiles); for (File templatePropertiesFile : templateFiles) { if (reject(templatePropertiesFile, pathfilters)) { continue; } templateProperties = PropertiesHandler.loadProperties(templatePropertiesFile); disabled = templateProperties.getProperty(TP_DISABLED, Boolean.FALSE.toString()); disabledMissing = templateProperties.getProperty(TP_DISABLED_MISSING); templates++; if (BitUtils.valueOf(disabled)) { disabledTemplates++; template = StringUtils.removeEndIgnoreCase(templatePropertiesFile.getName(), PROPERTIES_SUFFIX); pattern = "template \"{0}\" ignored, check property \"{1}\" at file \"{2}\""; message = MessageFormat.format(pattern, template, TP_DISABLED, templatePropertiesFile); log(_alertLevel, message); warnings++; } else if (missing(disabledMissing)) { disabledTemplates++; template = StringUtils.removeEndIgnoreCase(templatePropertiesFile.getName(), PROPERTIES_SUFFIX); pattern = "template \"{0}\" ignored because {3} is missing, check property \"{1}\" at file \"{2}\""; message = MessageFormat.format(pattern, template, TP_DISABLED_MISSING, templatePropertiesFile, disabledMissing); log(_alertLevel, message); warnings++; } else { writeTemplate(platformWriterContext, templatePropertiesFile); } } } platforms++; } catch (Throwable throwable) { error(throwable); } printSummary(); }
From source file:com.snaplogic.snaps.firstdata.Create.java
/** * @param method//from ww w.j a v a2 s.c o m * @return SnapType */ private SnapType getDataTypes(String type) { if (StringUtils.contains(type, INT)) { return SnapType.INTEGER; } else if (StringUtils.containsIgnoreCase(type, Float.class.getSimpleName()) || StringUtils.containsIgnoreCase(type, Long.class.getSimpleName()) || StringUtils.containsIgnoreCase(type, Double.class.getSimpleName())) { return SnapType.NUMBER; } else if (StringUtils.containsIgnoreCase(type, Calendar.class.getName())) { return SnapType.DATETIME; } else return SnapType.STRING; }
From source file:gov.nih.nci.cabig.caaers.domain.Study.java
/** * Gets the identifier containing.// www. j av a 2 s .c o m * * @param text the text * @return the identifier containing */ @Transient public String getIdentifierContaining(String text) { for (Identifier identifier : getIdentifiers()) { if (StringUtils.containsIgnoreCase(identifier.getValue(), text)) { return identifier.getValue(); } } return getPrimaryIdentifierValue(); }
From source file:hydrograph.ui.dataviewer.find.FindViewDataDialog.java
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;/* w w w.j a v a2s.c o m*/ } 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; } } }
From source file:hydrograph.ui.dataviewer.find.FindViewDataDialog.java
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++;//ww w . j a v a2 s. co m } } findColIndex = 1; } findRowIndex = 0; findColIndex = 0; if (recordCount > 0) { label.setVisible(true); label.setText("Match count - " + recordCount); } else { label.setVisible(false); } }
From source file:edu.monash.merc.system.parser.xml.HPAWSXmlParser.java
private DbSourceAcEntryBean createDbSourceAcEntry(String dbName, String accession) { DbSourceAcEntryBean dbSourceAcEntryBean = new DbSourceAcEntryBean(); if (StringUtils.isNotBlank(dbName) && StringUtils.isNotBlank(accession)) { AccessionBean accessionBean = new AccessionBean(); accessionBean.setAccession(accession); if (StringUtils.containsIgnoreCase(dbName, DbAcType.Ensembl.type())) { accessionBean.setAcType(DbAcType.Gene.type()); }/*from w w w . j av a 2 s.c om*/ if (StringUtils.containsIgnoreCase(dbName, DbAcType.SwissProt.type())) { accessionBean.setAcType(DbAcType.SwissProt.type()); } DBSourceBean dbSourceBean = new DBSourceBean(); if (StringUtils.containsIgnoreCase(dbName, DbAcType.Ensembl.type())) { dbSourceBean.setDbName(DbAcType.Ensembl.type()); } if (StringUtils.containsIgnoreCase(dbName, DbAcType.SwissProt.type())) { dbSourceBean.setDbName(DbAcType.SwissProt.type()); } dbSourceAcEntryBean.setAccessionBean(accessionBean); dbSourceAcEntryBean.setDbSourceBean(dbSourceBean); return dbSourceAcEntryBean; } return null; }