List of usage examples for org.apache.commons.lang StringUtils isAlphanumeric
public static boolean isAlphanumeric(String str)
Checks if the String contains only unicode letters or digits.
From source file:org.janusgraph.diskstorage.lucene.LuceneIndex.java
private Directory getStoreDirectory(String store) throws BackendException { Preconditions.checkArgument(StringUtils.isAlphanumeric(store), "Invalid store name: %s", store); String dir = basePath + File.separator + store; try {//from w ww . ja v a2s. co m File path = new File(dir); if (!path.exists()) path.mkdirs(); if (!path.exists() || !path.isDirectory() || !path.canWrite()) throw new PermanentBackendException("Cannot access or write to directory: " + dir); log.debug("Opening store directory [{}]", path); return FSDirectory.open(path); } catch (IOException e) { throw new PermanentBackendException("Could not open directory: " + dir, e); } }
From source file:org.jongo.config.JongoConfiguration.java
/** * From the given properties object, load the the different {@link org.jongo.config.DatabaseConfiguration}. * @param prop an instance of {@link java.util.Properties} with the properties from the file. * @return a list of {@link org.jongo.config.DatabaseConfiguration} * @throws StartupException if we're unable to load a {@link org.jongo.config.DatabaseConfiguration}. *//*from ww w . j a va 2 s.c om*/ private static List<DatabaseConfiguration> getDatabaseConfigurations(final Properties prop) throws StartupException { String databaseList = prop.getProperty(p_name_jongo_database_list); if (databaseList == null) { throw new StartupException("Failed to read list of aliases " + p_name_jongo_database_list, demo); } final String[] names = databaseList.split(","); List<DatabaseConfiguration> databases = new ArrayList<DatabaseConfiguration>(names.length); for (String name : names) { name = name.trim(); if (StringUtils.isAlphanumeric(name)) { DatabaseConfiguration c = generateDatabaseConfiguration(prop, name); databases.add(c); } else { l.warn("Database name " + name + " is invalid. Continuing without it."); } } return databases; }
From source file:org.jrimum.domkee.financeiro.banco.febraban.Agencia.java
public void verifyDv() { if (StringUtils.isBlank(digitoVerificador)) { throw new IllegalArgumentException( "O dgito verificador da agncia no pode ser null ou apenas espaos em branco"); }//from ww w. j a v a 2s . co m if (digitoVerificador.length() > 1) { throw new IllegalArgumentException("O dgito verificador da agncia deve possuir apenas um dgito"); } if (!StringUtils.isAlphanumeric(digitoVerificador)) { throw new IllegalArgumentException("O dgito verificador da agncia deve ser letra ou dgito"); } }
From source file:org.kuali.kfs.module.ld.util.TestDataLoader.java
public static void main(String[] args) { TestDataLoader testDataLoader = new TestDataLoader(); Date groupCreationDate = new Date(0); if (ArrayUtils.isEmpty(args) || args.length < 2) { System.out.println("The program requires at least two arguments."); return;/*from ww w.j a va 2 s. c om*/ } if (!StringUtils.isAlphanumeric(args[0])) { System.out.println("The first argument should be a number."); return; } for (int numOfRound = Integer.parseInt(args[0]); numOfRound > 0; numOfRound--) { if (ArrayUtils.contains(args, "poster")) { OriginEntryGroup group = new OriginEntryGroup(); group.setSourceCode(LABOR_SCRUBBER_VALID); group.setValid(true); group.setScrub(false); group.setProcess(true); group.setDate(groupCreationDate); int numOfData = testDataLoader.loadTransactionIntoOriginEntryTable(group); System.out.println("Number of Origin Entries for Poster = " + numOfData); } if (ArrayUtils.contains(args, "scrubber")) { OriginEntryGroup group = new OriginEntryGroup(); group.setSourceCode(LABOR_BACKUP); group.setValid(true); group.setScrub(true); group.setProcess(true); group.setDate(groupCreationDate); int numOfData = testDataLoader.loadTransactionIntoOriginEntryTable(group); System.out.println("Number of Origin Entries for Scrubber = " + numOfData); } if (ArrayUtils.contains(args, "pending")) { int numOfData = testDataLoader.loadTransactionIntoPendingEntryTable(); System.out.println("Number of Pending Entries = " + numOfData); } if (ArrayUtils.contains(args, "glentry")) { int numOfData = testDataLoader.loadTransactionIntoGLEntryTable(); System.out.println("Number of Labor GL Entries = " + numOfData); } } System.exit(0); }
From source file:org.kuali.student.enrollment.class2.courseoffering.rule.CourseOfferingEditRule.java
@Override protected boolean isDocumentValidForSave(MaintenanceDocument document) { boolean valid = super.isDocumentValidForSave(document); if (document.getNewMaintainableObject().getDataObject() instanceof CourseOfferingEditWrapper) { CourseOfferingEditWrapper newCOWrapper = (CourseOfferingEditWrapper) document.getNewMaintainableObject() .getDataObject();// w ww . j a v a 2 s.c o m CourseOfferingEditWrapper oldCOWrapper = (CourseOfferingEditWrapper) document.getOldMaintainableObject() .getDataObject(); // Only perform validateDuplicateSuffix check when CO code suffix part is changed, the code itself is readOnly and can't be modified at all. // also notice a problem: the suffix of a CO from OldMaintainableObject (the DB reference dataset) could be null // while even we didn't modify suffix in edit CO page, the suffix value in NewMaintainableObject became an empty string if (newCOWrapper.getCreateCO()) { // for Create CO page valid = validateRequiredFields(newCOWrapper); if (valid) { valid = validateDuplicateSuffixCreate(newCOWrapper); } } else { // for Edit CO page String newSuffix = StringUtils .trimToEmpty(newCOWrapper.getCourseOfferingInfo().getCourseNumberSuffix()); String oldSuffix = StringUtils .trimToEmpty(oldCOWrapper.getCourseOfferingInfo().getCourseNumberSuffix()); if (StringUtils.isNotEmpty(oldSuffix) || StringUtils.isNotEmpty(newSuffix)) { if (!StringUtils.equals(newSuffix, oldSuffix)) { valid &= validateDuplicateSuffix(newCOWrapper); } } // if no duplicate suffix then we validate the personnel ID if (valid) { valid = validatePersonnel(newCOWrapper); } } // valid the final exam driver: if final exam type is STANDARD, a final exam driver should be selected if (valid) { valid = validFinalExamDriver(newCOWrapper); } if (valid) { if (!StringUtils.isEmpty(newCOWrapper.getCourseOfferingInfo().getCourseNumberSuffix()) && !StringUtils .isAlphanumeric(newCOWrapper.getCourseOfferingInfo().getCourseNumberSuffix())) { valid = false; GlobalVariables.getMessageMap().putError( "document.newMaintainableObject.dataObject.courseOfferingInfo.courseNumberSuffix", CourseOfferingConstants.ERROR_INVALID_COURSECODE_SUFFIX); } } } return valid; }
From source file:org.medici.bia.common.util.ImageUtils.java
/** * Extract the folio number from the image file name * @param fileName the image file name//from www . j a v a2 s. c om * @return the folio number */ public static Integer extractFolioNumber(String fileName) { String folioNumber = fileName.trim(); if (StringUtils.isEmpty(folioNumber)) { return null; } boolean insert = StringUtils.contains(folioNumber, "["); int beforeIdx = indexOfOccurrence(folioNumber, "_", insert ? 2 : 1); int afterIdx = indexOfOccurrence(folioNumber, "_", insert ? 3 : 2); if (beforeIdx == -1 || afterIdx == -1) { logger.debug("Unable to find folio number. Image file " + fileName); return null; } folioNumber = folioNumber.substring(beforeIdx + 1, afterIdx); if (StringUtils.isNumeric(folioNumber)) { try { return new Integer(folioNumber); } catch (NumberFormatException numberFormatException) { logger.debug("Unable to convert folio number. Image file " + fileName, numberFormatException); return null; } } else { if (StringUtils.isAlphanumeric(folioNumber)) { try { return new Integer(folioNumber.substring(0, folioNumber.length() - 1)); } catch (NumberFormatException numberFormatException) { logger.error("Unable to convert folio number. Image file " + fileName, numberFormatException); return null; } } return null; } }
From source file:org.medici.bia.common.util.SimpleSearchUtils.java
/** * /*from ww w . jav a 2s .com*/ * @param volumeFields * @param words * @return */ public static StringBuilder constructConditionOnVolumeFields(String[] volumeFields, String[] words) { StringBuilder stringBuilder = new StringBuilder(0); // We add conditions on volume for (int i = 0; i < words.length; i++) { // if word is not in volume format we skip if (!VolumeUtils.isVolumeFormat(words[i])) { continue; } // if word contains volLetExt we manage with a specific condition if (StringUtils.isAlphanumeric(words[i])) { stringBuilder.append("(+(volume.volNum:"); stringBuilder.append(VolumeUtils.extractVolNum(words[i])); stringBuilder.append(") +(volume.volLetExt:"); stringBuilder.append(VolumeUtils.extractVolLetExt(words[i])); stringBuilder.append("))"); } else { stringBuilder.append("(volume.volNum:"); stringBuilder.append(VolumeUtils.extractVolNum(words[i])); stringBuilder.append(") "); } } return stringBuilder; }
From source file:org.medici.bia.common.util.VolumeUtils.java
/** * /*from w ww . j a v a 2s .c o m*/ * @param volume * @return */ public static String extractVolLetExt(String volume) { if (StringUtils.isEmpty(volume)) { return null; } String volumeToExtract = volume.trim(); if (StringUtils.isNumeric(volumeToExtract)) { return null; } else { if (StringUtils.isAlphanumeric(volumeToExtract)) { return volumeToExtract.substring(volumeToExtract.length() - 1); } return null; } }
From source file:org.medici.bia.common.util.VolumeUtils.java
/** * This method extract volNum from a complete volume string. * @param volume//from w w w. j a va 2s . c o m * @return */ public static Integer extractVolNum(String volume) { if (StringUtils.isEmpty(volume)) { return null; } String volumeToExtract = volume.trim(); if (StringUtils.isNumeric(volumeToExtract)) { try { return new Integer(volumeToExtract); } catch (NumberFormatException nfx) { return null; } } else { if (StringUtils.isAlphanumeric(volumeToExtract)) { try { return new Integer(volumeToExtract.substring(0, volumeToExtract.length() - 1)); } catch (NumberFormatException nfx) { return null; } } return null; } }
From source file:org.medici.bia.common.util.VolumeUtils.java
/** * This method check if a string is in volume Format * //from ww w . ja va 2 s .c o m * @param text * @return */ public static Boolean isVolumeFormat(String text) { if (StringUtils.isEmpty(text)) { return Boolean.FALSE; } String trimmedText = text.trim(); /**We put this control here because often a word for search is not a volume * E.g. Michele (it's not a volume) * E.g. a (word with a single letter cannot be consider as volume Letter Extension), * * Previously we have two check : * if (StringUtils.isAlpha(text) && text.length() > 1) * if (StringUtils.isAlpha(trimmedText) && trimmedText.length() == 1) **/ if (StringUtils.isAlpha(trimmedText)) { return Boolean.FALSE; } // E.g. 23 if (StringUtils.isNumeric(trimmedText)) { return Boolean.TRUE; } // E.g. 23a if (StringUtils.isAlphanumeric(trimmedText)) { // A correct volumeNumber E.g. 23a if (NumberUtils.isNumber(trimmedText.substring(0, trimmedText.length() - 1))) { return Boolean.TRUE; } else { // A correct volumeNumber E.g. 23da, volume Letter must be a single letter return Boolean.FALSE; } } // It 's not a volume format string return Boolean.FALSE; }