List of usage examples for org.apache.commons.lang StringUtils reverse
public static String reverse(String str)
Reverses a String as per StrBuilder#reverse() .
From source file:org.openlegacy.terminal.support.SimpleScreenIdentifier.java
@Override public boolean match(TerminalSnapshot terminalSnapshot) { if ((position.getColumn() + text.length() - 1) > terminalSnapshot.getSize().getColumns()) { logger.error(/*from ww w. j a va 2 s . co m*/ MessageFormat.format("Found illegal identifier {0} in position {1}", getText(), getPosition())); return false; } String foundText = terminalSnapshot.getText(position, text.length()); if (foundText.equals(text)) { if (logger.isTraceEnabled()) { logger.trace(MessageFormat.format("Found text on screen:\''{0}\'' matched to identifier:\''{1}\''", foundText, text)); } return true; } if (supportRightToLeft) { int identifierEnd = position.getColumn() + text.length() - 2; if (identifierEnd > terminalSnapshot.getSize().getColumns()) { logger.error(MessageFormat.format("Found illegal identifier {0} in position {1}", getText(), getPosition())); return false; } foundText = terminalSnapshot.getText(new SimpleTerminalPosition(position.getRow(), terminalSnapshot.getSize().getColumns() - identifierEnd), text.length()); foundText = StringUtils.reverse(foundText); if (foundText.equals(text)) { return true; } } if (logger.isTraceEnabled()) { logger.trace(MessageFormat.format( "Found text on screen:\''{0}\'' wasnt matched to identifier:\''{1}\''", foundText, text)); } return false; }
From source file:org.springframework.data.solr.core.QueryParserTest.java
@Test public void testRegisterAlternateConverter() { Criteria criteria = new Criteria("field_1").is(100); queryParser.registerConverter(new Converter<Number, String>() { @Override//from w ww.j a va 2 s .co m public String convert(Number arg0) { return StringUtils.reverse(arg0.toString()); } }); Assert.assertEquals("field_1:001", queryParser.createQueryStringFromCriteria(criteria)); }
From source file:org.wso2.carbon.integration.common.tests.utils.DistributionValidationTestUtils.java
public static void identifyDuplicateJars(List<File> jarFileListInDistribution, File distributionVersion, HashSet<String> distributionDuplicateJarList, ArrayList<String> unidentifiedVersionJars) { Iterator<File> itJarList = jarFileListInDistribution.iterator(); ArrayList<String> tempArr = new ArrayList<String>(); ArrayList<File> pathListForAddedJarToJarVersions = new ArrayList<File>(); HashMap<String, String> jarVersions = new HashMap<String, String>(); StringBuilder builder = new StringBuilder(); Pattern numeric = Pattern.compile("[^0-9_.-]"); Pattern nonNumeric = Pattern.compile("[a-zA-Z]"); while (itJarList.hasNext()) { File jarFilePath = itJarList.next(); String jarName = (jarFilePath).getName(); if (!jarFilePath.getAbsolutePath().contains(distributionVersion.getName().replaceAll(".zip", "") + File.separator + TEMP_DIRECTORY + File.separator)) { for (int letter = jarName.length() - 1; letter >= 0; letter--) { char singleChar = jarName.charAt(letter); Matcher matcher = numeric.matcher(Character.toString(singleChar)); // Find all matches if (!matcher.find()) { // Get the matching string builder.append(singleChar); } else if (nonNumeric.matcher(Character.toString(singleChar)).find()) { if (builder.length() > 1) { tempArr.add(builder.toString()); builder.setLength(0); } else { builder.setLength(0); }/*from ww w.j a v a 2 s .c o m*/ } } int max; int previousMax = 0; String[] version = new String[1]; for (String element : tempArr) { max = element.length(); if (max > previousMax) { previousMax = max; version[0] = element; } } tempArr.clear(); if (version[0] != null) { String jar = jarName.split((StringUtils.reverse(version[0])))[0]; if (jar.length() >= 2) { if (jarVersions.containsKey(jar)) { if (!jarVersions.get(jar).equals(jarName.split(jar)[1])) { // removing patches - plugins duplication if (distributionDuplicateJarList.toString().contains(jarName)) { for (String itemDistributionDuplicateJarList : distributionDuplicateJarList) { if (itemDistributionDuplicateJarList.contains(jarName) && (itemDistributionDuplicateJarList.contains("patches") || itemDistributionDuplicateJarList.contains("plugins"))) { if (!(jarFilePath.getAbsolutePath().contains("patches") || jarFilePath.getAbsolutePath().contains("plugins"))) { distributionDuplicateJarList.add(jarFilePath.getAbsolutePath()); } } } } else { distributionDuplicateJarList.add(jarFilePath.getAbsolutePath()); } for (File pathListForAddedJarToJarVersion : pathListForAddedJarToJarVersions) { String path = pathListForAddedJarToJarVersion.toString(); if (path.contains(jar + jarVersions.get(jar))) { distributionDuplicateJarList.add(path); break; } } } } else { jarVersions.put(jar, jarName.split(jar)[1]); pathListForAddedJarToJarVersions.add(jarFilePath); } } else { log.info("Unable to identify the version " + jar); unidentifiedVersionJars.add(jarFilePath.getAbsolutePath()); } } else { jarVersions.put(jarName, null); pathListForAddedJarToJarVersions.add(jarFilePath); } } } }
From source file:pl.edu.icm.cermine.metadata.model.DocumentAffiliation.java
public DocumentAffiliation(String id, String index, String rawText) { this.id = id; this.index = ContentCleaner.clean(index); if (rawText.matches(".+ \\([^\\(\\)]*\\)$")) { rawText = StringUtils.reverse(rawText).replaceFirst("\\)", "").replaceFirst("\\( ", " ,"); rawText = StringUtils.reverse(rawText); }/*w w w . j av a 2s . c o m*/ this.rawText = MetadataTools.cleanAndNormalize(rawText); this.tokens = new ArrayList<Token<AffiliationLabel>>(); }
From source file:tml.conceptmap.Concept.java
/** * Cleans terms from non writable characters * @param term/*from w ww . j av a 2s.com*/ * @return the clean term */ private String cleanTerm(String term) { term = term.toLowerCase().trim(); term = term.replaceFirst("^[\\.,;-_]+", ""); term = StringUtils.reverse(term); term = term.replaceFirst("^[\\.,;-_]+", ""); term = StringUtils.reverse(term); return term; }