List of usage examples for org.apache.commons.lang3 StringUtils isAlpha
public static boolean isAlpha(final CharSequence cs)
Checks if the CharSequence contains only Unicode letters.
null will return false .
From source file:com.thinkbiganalytics.policy.validation.CharacterValidator.java
@Override public boolean validate(String value) { if (StringUtils.isBlank(validationType)) { return true; }//from w w w . j a va 2 s . com String trimmedValue = StringUtils.deleteWhitespace(value); if ("UPPERCASE".equalsIgnoreCase(validationType)) { return trimmedValue.toUpperCase().equals(trimmedValue); } else if ("LOWERCASE".equalsIgnoreCase(validationType)) { return trimmedValue.toLowerCase().equals(trimmedValue); } else if ("ALPHA_NUMERIC".equalsIgnoreCase(validationType)) { return StringUtils.isAlphanumeric(trimmedValue); } else if ("ALPHA".equalsIgnoreCase(validationType)) { return StringUtils.isAlpha(trimmedValue); } else if ("NUMERIC".equalsIgnoreCase(validationType)) { return StringUtils.isNumeric(trimmedValue); } return true; }
From source file:de.jfachwert.steuer.UStIdNr.java
private static String toLaenderkuerzel(String nr) { String kuerzel = nr.substring(0, 2).toUpperCase(); if (StringUtils.isAlpha(kuerzel)) { return kuerzel; } else {//from w w w.j a v a2 s. co m throw new InvalidValueException(nr, "country"); } }
From source file:net.ceos.project.poi.annotated.core.CellFormulaConverter.java
/** * Calculate the range address based at template range address passed as * parameter and also the propagation type. * <p>/* www. jav a 2 s .c o m*/ * Assuming we having 15 registry, start at 5 * <ul> * <li>(input) => D => (output) => D5:D20 * <li>(input) => D:F => (output) => D5:F20 * <li>(input) => 7 => (output) => E7:S7 * <li>(input) => 7:8 => (output) => E7:S8 * <li> * </ul> * * @param configCriteria * the {@link XConfigCriteria} * @param templateRangeAddress * the template range address * @return the range address calculated */ protected static String calculateRangeAddressFromTemplate(final XConfigCriteria configCriteria, String templateRangeAddress) throws ConfigurationException { String start = ""; String end = ""; /* remove all possible separators */ String rangeAddressWithoutSeparator = removeRangeSeparator(templateRangeAddress); /* validate propagation with template */ validatePropagationWithRangeAddress(configCriteria, rangeAddressWithoutSeparator); /* check if specific range group */ if (PredicateFactory.isReadyRangeAddress.test(rangeAddressWithoutSeparator)) { /* if true, return the range address */ return templateRangeAddress; } /* split by separator all possible separators */ String[] splitted = splitRangeSeparator(templateRangeAddress); if (splitted.length == 2) { /* range group */ start = transformToStartRange(configCriteria, splitted[0]); end = transformToEndRange(configCriteria, splitted[1]); } else if (splitted.length == 1) { /* dynamic list */ if (StringUtils.isNumeric(splitted[0])) { start = transformToRange(configCriteria, splitted[0], configCriteria.getStartCellInmutable()); end = transformToRange(configCriteria, splitted[0], configCriteria.getLastCellIndex()); } else if (StringUtils.isAlpha(splitted[0])) { start = transformToRange(configCriteria, splitted[0], configCriteria.getStartRowInmutable()); end = transformToRange(configCriteria, splitted[0], configCriteria.getSheet().getLastRowNum() + 1); } } return start + ":" + end; }
From source file:net.ceos.project.poi.annotated.core.CellFormulaConverter.java
/** * Validate propagation with template range address passed as parameter. * <p>//from ww w. ja v a2 s . c om * Acceptable values are: * <ul> * <li>if PropagationType.HORIZONTAL, only numeric values allowed * <li>if PropagationType.VERTICAL, only letters values allowed * </ul> * * @param configCriteria * the {@link XConfigCriteria} * @param templateRangeAddress * the template range address * @throws ConfigurationException */ private static void validatePropagationWithRangeAddress(final XConfigCriteria configCriteria, String templateRangeAddress) throws ConfigurationException { if (PredicateFactory.isPropagationHorizontal.test(configCriteria.getPropagation()) && StringUtils.isNumeric(templateRangeAddress) || PredicateFactory.isPropagationVertical.test(configCriteria.getPropagation()) && StringUtils.isAlpha(templateRangeAddress)) { throw new ConfigurationException( ExceptionMessage.CONFIGURATION_CONFLICT_CONDITIONAL_FORMAT.getMessage()); } }
From source file:net.ceos.project.poi.annotated.core.CellFormulaConverter.java
/** * Transform the start range address to a valid cell position. * <p>/*from w w w . j av a 2 s . co m*/ * Apply this method in case of the template contain a template range * address (eg. 'N:M' or '4:5'). * <p> * The start range address will be treated here. * * @param configCriteria * the {@link XConfigCriteria} * @param splitted * the base range address to transform * @return the range address converted to a valid cell position */ private static String transformToStartRange(final XConfigCriteria configCriteria, String startRange) { String start = null; if (StringUtils.isNumeric(startRange)) { start = transformToRange(configCriteria, startRange, configCriteria.getStartCellInmutable()); } else if (StringUtils.isAlpha(startRange)) { start = transformToRange(configCriteria, startRange, configCriteria.getStartRowInmutable()); } return start; }
From source file:net.ceos.project.poi.annotated.core.CellFormulaConverter.java
/** * Transform the end range address to a valid cell position. * <p>/* ww w. j ava 2s .c o m*/ * Apply this method in case of the template contain a template range * address (eg. 'N:M' or '4:5'). * <p> * The end range address will be treated here. * * @param configCriteria * the {@link XConfigCriteria} * @param endRange * the base range address to transform * @return the range address converted to a valid cell position */ private static String transformToEndRange(final XConfigCriteria configCriteria, String endRange) { String end = null; if (StringUtils.isNumeric(endRange)) { end = transformToRange(configCriteria, endRange, configCriteria.getLastCellIndex()); } else if (StringUtils.isAlpha(endRange)) { end = transformToRange(configCriteria, endRange, configCriteria.getSheet().getLastRowNum() + 1); } return end; }
From source file:com.sonicle.webtop.core.CoreManager.java
/** * Send SMS through the configured SMS provider. * @param number The destination number/* w w w . j av a 2s . c o m*/ * @param text The SMS text * @return true if the SMS was accpeted by the provider, false otherwise */ public void smsSend(String number, String text) throws WTException { initSms(); if (sms == null) { throw new WTException("SMS not initialized"); } UserProfileId targetPid = getTargetProfileId(); CoreServiceSettings css = new CoreServiceSettings(CoreManifest.ID, targetPid.getDomainId()); CoreUserSettings us = new CoreUserSettings(targetPid); //use common service settings or webtop username/password String username = css.getSmsWebrestUser(); if (username == null) username = targetPid.getUserId(); String spassword = css.getSmsWebrestPassword(); char[] password = spassword != null ? spassword.toCharArray() : RunContext.getPrincipal().getPassword(); String sender = css.getSmsSender(); String userSender = us.getSmsSender(); if (userSender != null && userSender.trim().length() > 0) sender = userSender; if (sender == null) sender = wta.getPlatformName(); boolean isAlpha = StringUtils.isAlpha(sender); String fromMobile = isAlpha ? null : sender; String fromName = isAlpha ? sender : null; sms.send(fromName, fromMobile, number, text, username, password); }
From source file:com.xpn.xwiki.XWiki.java
/** * Construct a list of language codes (ISO 639-1) from the Accept-Languages header. This method filters out some * bugs in different browsers or containers, like returning '*' as a language (Jetty) or using '_' as a * language--country delimiter (some versions of Opera). * //from ww w. ja v a2 s . c o m * @param request The client request. * @return A list of language codes, in the client preference order; might be empty if the header is not well * formed. */ @SuppressWarnings("unchecked") private List<String> getAcceptedLanguages(XWikiRequest request) { List<String> result = new ArrayList<String>(); Enumeration<Locale> e = request.getLocales(); while (e.hasMoreElements()) { String language = e.nextElement().getLanguage().toLowerCase(); // All language codes should have 2 letters. if (StringUtils.isAlpha(language)) { result.add(language); } } return result; }
From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java
private void initialiseAutoCompletion() { EventStream<Integer> changesEventStream = xpathExpressionArea.plainTextChanges().map(characterChanges -> { if (characterChanges.getRemoved().length() > 0) { return characterChanges.getRemovalEnd() - 1; }//w w w. ja v a 2 s . co m return characterChanges.getInsertionEnd(); }); EventStream<Integer> keyCombo = EventStreams.eventsOf(xpathExpressionArea, KeyEvent.KEY_PRESSED) .filter(key -> key.isControlDown() && key.getCode().equals(KeyCode.SPACE)) .map(searchPoint -> xpathExpressionArea.getCaretPosition()); // captured in the closure final ContextMenu autoCompletePopup = new ContextMenuWithNoArrows(); autoCompletePopup.setId("xpathAutocomplete"); autoCompletePopup.setHideOnEscape(true); EventStreams.merge(keyCombo, changesEventStream).map(searchPoint -> { int indexOfSlash = xpathExpressionArea.getText().lastIndexOf("/", searchPoint - 1) + 1; String input = xpathExpressionArea.getText(); if (searchPoint > input.length()) { searchPoint = input.length(); } input = input.substring(indexOfSlash, searchPoint); return Tuples.t(indexOfSlash, input); }).filter(t -> StringUtils.isAlpha(t._2)).subscribe(s -> autoComplete(s._1, s._2, autoCompletePopup)); }
From source file:opennlp.tools.parse_thicket.opinion_processor.LinguisticPhraseManager.java
public List<String> formStandardizedTopic() { Set<ParseTreeChunk> keys = entry_group.keySet(); for (ParseTreeChunk k : keys) { List<ParseTreeChunk> lingPhrases = entry_group.get(k); for (int i = 0; i < lingPhrases.size(); i++) for (int j = i + 1; j < lingPhrases.size(); j++) { ParseTreeChunk chI = lingPhrases.get(i); ParseTreeChunk chJ = lingPhrases.get(j); List<String> lemmas = new ArrayList<String>(chI.getLemmas()); lemmas.retainAll(chJ.getLemmas()); if (lemmas.size() < 2) continue; String buf = ""; List<String> candTopicLst = new ArrayList<String>(); for (String w : lemmas) { if (w.length() < MIN_LENGTH_OF_WORD_TO_CONSIDER) continue; if (!StringUtils.isAlpha(w)) continue; // find POS of w boolean bAccept = false; for (int iw = 0; iw < chI.getLemmas().size(); iw++) { if (w.equals(chI.getLemmas().get(iw))) { if (chI.getPOSs().get(iw).startsWith("NN") || chI.getPOSs().get(iw).startsWith("JJ") || chI.getPOSs().get(iw).startsWith("VB")) bAccept = true; }/*from w w w . j a v a2 s . c om*/ } if (bAccept) { // buf+=w+" "; String ws = substituteSynonym(w); candTopicLst.add(ws); } } // remove duplicates like 'new new house' // candTopicLst = new ArrayList<String>(new // HashSet<String>(candTopicLst)); for (String w : candTopicLst) { buf += w + " "; } buf = buf.trim(); if (buf.indexOf(' ') < 0) continue; if (!standardizedTopics.contains(buf)) { standardizedTopics.add(buf); std_group.put(buf, lingPhrases); } } } cleanUpStandardizedTopics(); return standardizedTopics; }