Example usage for org.apache.commons.lang StringUtils isAlpha

List of usage examples for org.apache.commons.lang StringUtils isAlpha

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isAlpha.

Prototype

public static boolean isAlpha(String str) 

Source Link

Document

Checks if the String contains only unicode letters.

Usage

From source file:ips1ap101.lib.base.util.StrUtils.java

public static boolean esIdentificadorSqlValido(String string) {
    String validChars = VALID_CHARS;
    return StringUtils.isNotBlank(string) && StringUtils.containsOnly(string.toLowerCase(), validChars)
            && StringUtils.isAlpha(string.substring(0, 1));
}

From source file:com.ibm.jaql.util.shell.JaqlShellArguments.java

private static OutputAdapter getOutputAdapter(String outOptions) throws Exception {
    if (outOptions.equals(""))
        outOptions = "jsonStream";

    // special casing here, to enable shortcut notation
    if (outOptions.equals("json") || outOptions.equals("del") || outOptions.equals("xml")) {
        outOptions += "Stream";
    }//from   w  w w .  ja  v  a2 s  .  c o m

    // construct json record for json, del and xml
    if (StringUtils.isAlpha(outOptions)) {
        outOptions = "{" + Adapter.TYPE_NAME + ": '" + outOptions + "'}";
    }
    outOptions += ";";

    // get output adapter
    JaqlQuery query = new JaqlQuery();
    query.setQueryString(outOptions);
    JsonRecord options = (JsonRecord) query.evaluate();
    OutputAdapter oa = (OutputAdapter) JaqlUtil.getAdapterStore().output.getAdapter(options);
    if (oa == null)
        throw new NullPointerException();
    else
        return oa;
}

From source file:com.plm.model.RecordingQueue.java

public void setPackageAssetId(String assetId) {
    if (assetId.length() == 16 && StringUtils.isAlpha(Character.toString(assetId.charAt(0)))) {
        /*/*from   ww w . ja  v  a 2s.c  om*/
         * Added as workaround for auto approve functionality.
         * Should be removed once SQL procedure is fixed.
         */
        this.assetId = RCSConstants.PACKAGE_ASSET_ID_PREFIX + assetId;
    } else {
        this.assetId = assetId;
    }
}

From source file:de.citec.sc.matoll.process.Matoll_CreateMax.java

private static Set<Integer> getBagOfWords(Model sentence, Stopwords stopwords,
        Map<String, Integer> mapping_word_id) {
    String query = "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " + "SELECT ?number ?form WHERE {"
            + "?sentence <conll:wordnumber> ?number . " + "?sentence <conll:form> ?form ." + "}";
    QueryExecution qExec = QueryExecutionFactory.create(query, sentence);
    ResultSet rs = qExec.execSelect();
    Set<Integer> words = new HashSet<>();
    while (rs.hasNext()) {
        QuerySolution qs = rs.next();/*  ww w .  java  2  s  .  co  m*/
        try {
            String term = qs.get("?form").toString();
            if (StringUtils.isAlpha(term) && !stopwords.isStopword(term, EN)) {
                //words.add(term);
                if (!mapping_word_id.containsKey(term)) {
                    int value = mapping_word_id.size();
                    value += 1;
                    mapping_word_id.put(term, value);
                    words.add(value);
                    try (FileWriter fw = new FileWriter("mapping_words_to_ids_goldstandard.tsv", true);
                            BufferedWriter bw = new BufferedWriter(fw);
                            PrintWriter out = new PrintWriter(bw)) {
                        out.println(term + "\t" + value);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else
                    words.add(mapping_word_id.get(term));
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    qExec.close();
    return words;
}

From source file:com.manydesigns.portofino.model.database.DatabaseLogic.java

static String checkFirstLetter(String letter) {
    letter = StringUtils.replaceChars(letter, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz");

    if (letter.equals("_") || letter.equals("$") || StringUtils.isAlpha(letter)) {
        return letter;
    } else if (StringUtils.isNumeric(letter)) {
        return "_" + letter;
    } else {/*ww  w  .j a va  2 s .  c  o m*/
        return "_";
    }
}

From source file:ips1ap101.lib.core.util.STP.java

public static boolean esIdentificadorSqlValido(String string) {
    String validChars = StrUtils.VALID_CHARS;
    return StringUtils.isNotBlank(string) && StringUtils.containsOnly(string.toLowerCase(), validChars)
            && StringUtils.isAlpha(string.substring(0, 1));
}

From source file:com.egt.core.util.STP.java

public static boolean esIdentificadorSqlValido(String string) {
    String validChars = "abcdefghijklmnopqrstuvwxyz_1234567890";
    return (StringUtils.isNotBlank(string) && StringUtils.containsOnly(string, validChars)
            && StringUtils.isAlpha(string.substring(0, 1)));
}

From source file:com.virtusa.akura.student.controller.StudentTermMarkController.java

/**
 * Handle monlthy term marks.// w w  w  . j a v  a 2s .c  o  m
 * 
 * @param request the request
 * @param map the map
 * @param errorMsgLoader the error msg loader
 * @param isMarks the is marks
 * @throws AkuraAppException the akura app exception
 */
private void handleMonlthyTermMarks(HttpServletRequest request, ModelMap map, ErrorMsgLoader errorMsgLoader,
        String isMarks) throws AkuraAppException {

    String[] studentSubTermMarks = request.getParameterValues(MONTHLYMARKS);
    String[] studentSubTermMarkIDs = request.getParameterValues(SUB_TERM_MARK_ID);
    List<StudentSubTermMark> studentSubTermMarkList = new ArrayList<StudentSubTermMark>();

    for (int i = 0; i < studentSubTermMarks.length; i++) {

        if (AkuraConstant.ABSENT.equalsIgnoreCase(studentSubTermMarks[i])) {
            StudentSubTermMark studentSubTermMark = studentService
                    .findStudentSubTermMark(Integer.parseInt(studentSubTermMarkIDs[i]));
            studentSubTermMark.setAbsent(true);
            studentSubTermMark.seteditMarkState(true);
            studentSubTermMarkList.add(studentSubTermMark);
        } else {

            if (StringUtils.isAlpha(studentSubTermMarks[i].trim())
                    && !StringUtils.isEmpty(studentSubTermMarks[i].trim())) {
                errorMsgLoader = new ErrorMsgLoader();
                String message = errorMsgLoader.getErrorMessage(ERROR_MSG_KEY_INVALID_TERM_MARK);
                map.addAttribute(AkuraConstant.MESSAGE, message);
            } else {
                float studentMonthlyMark = 0;
                if (!StringUtils.isEmpty(studentSubTermMarks[i].trim())) {
                    studentMonthlyMark = Float.parseFloat(studentSubTermMarks[i]);
                }
                StudentSubTermMark studentSubTermMark = studentService
                        .findStudentSubTermMark(Integer.parseInt(studentSubTermMarkIDs[i]));

                // retrieves the relevant student term mark object.
                StudentTermMark studentTermMark = getStudentTermMark(studentSubTermMark);

                // retrieves the maximum grade subject mark.
                float gradeSubjectMaxMark = commonService
                        .findGradeSubjectMaxMarkById(studentTermMark.getGradeSubjectId());

                if (studentMonthlyMark >= AkuraConstant.MINIMUM_MARK
                        && studentMonthlyMark <= gradeSubjectMaxMark) {

                    studentSubTermMark.setGradingID(null);

                    // calculates the marks and set.
                    studentSubTermMark.setMarks(setMark(studentMonthlyMark, gradeSubjectMaxMark));

                    studentSubTermMark.setAbsent(false);
                    if (studentMonthlyMark != AkuraConstant.MINIMUM_MARK) {
                        studentSubTermMark.seteditMarkState(true);
                    }
                    studentSubTermMarkList.add(studentSubTermMark);
                } else {
                    errorMsgLoader = new ErrorMsgLoader();
                    String message = errorMsgLoader.getErrorMessage(ERROR_MSG_KEY_INVALID_TERM_MARK);
                    map.addAttribute(AkuraConstant.MESSAGE, message);
                }

            }
        }
    }
    studentService.updateStudentSubTermMarkList(studentSubTermMarkList);

    map.addAttribute(IS_MARKS, isMarks);
}

From source file:architecture.ee.web.spring.controller.SecureMoSKitoController.java

protected architecture.ee.web.monitoring.moskito.LongValue getLongStatValue(IStats stat, String name,
        String intervalName, net.anotheria.moskito.core.stats.TimeUnit timeUnit) {
    long value = 0L;
    try {//from  www  .j ava  2s. c om
        String stringValue = stat.getValueByNameAsString(name, intervalName, timeUnit);
        if (StringUtils.isNotEmpty(stringValue) && !StringUtils.isAlpha(stringValue))
            value = Long.parseLong(stringValue);
    } catch (Exception e) {
    }
    return new architecture.ee.web.monitoring.moskito.LongValue(name, value);
}

From source file:nattable.ColorNatInstance.java

/**
 * Validate: First three chars must be alphabetic and the following must be
 * numeric/*from   w w w .j  a v  a 2  s  .c o m*/
 */
private static IDataValidator getSecurtityIdValidator() {
    return new DataValidator() {

        public boolean validate(int columnIndex, int rowIndex, Object newValue) {
            if (newValue == null) {
                return false;
            }
            String value = (String) newValue;
            if (value.length() > 3) {
                String alphabeticPart = value.substring(0, 2);
                String numericPart = value.substring(3, value.length());
                return StringUtils.isAlpha(alphabeticPart) && StringUtils.isNumeric(numericPart);
            } else {
                String alphabeticPart = value.substring(0, value.length());
                return StringUtils.isAlpha(alphabeticPart);
            }
        }
    };
}