/** * <p>Checks if the String contains only certain characters.</p> * * <p>A <code>null</code> String will return <code>false</code>. * A <code>null</code> valid character String will return <code>false</code>. * An empty String (length()=0) always returns <code>true</code>.</p> * * <pre> * StringUtils.containsOnly(null, *) = false * StringUtils.containsOnly(*, null) = false * StringUtils.containsOnly("", *) = true * StringUtils.containsOnly("ab", "") = false * StringUtils.containsOnly("abab", "abc") = true * StringUtils.containsOnly("ab1", "abc") = false * StringUtils.containsOnly("abz", "abc") = false * </pre> * * @param str the String to check, may be null * @param validChars a String of valid chars, may be null * @return true if it only contains valid chars and is non-null * @since 2.0 */ public static boolean containsOnly(String str, String validChars) { if (str == null || validChars == null) { return false; } return containsOnly(str, validChars.toCharArray()); }
private boolean containsNoLabel(@QueryParameter String value) { return StringUtils.isEmpty(value) || StringUtils.containsOnly(value, new char[]{',', ' '}); }
private boolean containsNoBranches(@QueryParameter String value) { return StringUtils.isEmpty(value) || StringUtils.containsOnly(value, new char[]{',', ' '}); }
/** * @param lowerKey * key to test. * @throws IllegalArgumentException * if key is invalid. */ public static final void assertKey( final String lowerKey ) throws IllegalArgumentException { Assert.assertNotEmpty( lowerKey, "Key cannot be null or empty" ); if ( !StringUtils.containsOnly( lowerKey, VALID_KEY_CHARS ) ) { throw new IllegalArgumentException( "Key contains invalid characters [validKeyCharacters=" + VALID_KEY_CHARS + "]" ); } if ( lowerKey.charAt( 0 ) == '-' ) { throw new IllegalArgumentException( "Key must not start with '-'" ); } if ( lowerKey.endsWith( "-" ) ) { throw new IllegalArgumentException( "Key must not end with '-'" ); } if ( "_".equals( lowerKey ) ) { throw new IllegalArgumentException( "Key must not be '_'" ); } }
if (isValid && StringUtils.containsOnly(path, "/")) { System.err.println(entity + ", Location: "+ entityLocation + ", Warn: location set to root, " + "not a recommended config.");
/** * <p>Checks if the String contains only certain characters.</p> * * <p>A <code>null</code> String will return <code>false</code>. * A <code>null</code> valid character String will return <code>false</code>. * An empty String ("") always returns <code>true</code>.</p> * * <pre> * StringUtils.containsOnly(null, *) = false * StringUtils.containsOnly(*, null) = false * StringUtils.containsOnly("", *) = true * StringUtils.containsOnly("ab", "") = false * StringUtils.containsOnly("abab", "abc") = true * StringUtils.containsOnly("ab1", "abc") = false * StringUtils.containsOnly("abz", "abc") = false * </pre> * * @param str the String to check, may be null * @param validChars a String of valid chars, may be null * @return true if it only contains valid chars and is non-null * @since 2.0 */ public static boolean containsOnly(String str, String validChars) { if (str == null || validChars == null) { return false; } return containsOnly(str, validChars.toCharArray()); }
/** * <p>Checks if the String contains only certain characters.</p> * * <p>A <code>null</code> String will return <code>false</code>. * A <code>null</code> valid character String will return <code>false</code>. * An empty String (length()=0) always returns <code>true</code>.</p> * * <pre> * StringUtils.containsOnly(null, *) = false * StringUtils.containsOnly(*, null) = false * StringUtils.containsOnly("", *) = true * StringUtils.containsOnly("ab", "") = false * StringUtils.containsOnly("abab", "abc") = true * StringUtils.containsOnly("ab1", "abc") = false * StringUtils.containsOnly("abz", "abc") = false * </pre> * * @param str the String to check, may be null * @param validChars a String of valid chars, may be null * @return true if it only contains valid chars and is non-null * @since 2.0 */ public static boolean containsOnly(String str, String validChars) { if (str == null || validChars == null) { return false; } return containsOnly(str, validChars.toCharArray()); }
/** * <p>Checks if the String contains only certain characters.</p> * * <p>A <code>null</code> String will return <code>false</code>. * A <code>null</code> valid character String will return <code>false</code>. * An empty String ("") always returns <code>true</code>.</p> * * <pre> * StringUtils.containsOnly(null, *) = false * StringUtils.containsOnly(*, null) = false * StringUtils.containsOnly("", *) = true * StringUtils.containsOnly("ab", "") = false * StringUtils.containsOnly("abab", "abc") = true * StringUtils.containsOnly("ab1", "abc") = false * StringUtils.containsOnly("abz", "abc") = false * </pre> * * @param str the String to check, may be null * @param validChars a String of valid chars, may be null * @return true if it only contains valid chars and is non-null * @since 2.0 */ public static boolean containsOnly(String str, String validChars) { if (str == null || validChars == null) { return false; } return containsOnly(str, validChars.toCharArray()); }
/** * <p>Checks if the String contains only certain characters.</p> * * <p>A <code>null</code> String will return <code>false</code>. * A <code>null</code> valid character String will return <code>false</code>. * An empty String (length()=0) always returns <code>true</code>.</p> * * <pre> * StringUtils.containsOnly(null, *) = false * StringUtils.containsOnly(*, null) = false * StringUtils.containsOnly("", *) = true * StringUtils.containsOnly("ab", "") = false * StringUtils.containsOnly("abab", "abc") = true * StringUtils.containsOnly("ab1", "abc") = false * StringUtils.containsOnly("abz", "abc") = false * </pre> * * @param str the String to check, may be null * @param validChars a String of valid chars, may be null * @return true if it only contains valid chars and is non-null * @since 2.0 */ public static boolean containsOnly(String str, String validChars) { if (str == null || validChars == null) { return false; } return containsOnly(str, validChars.toCharArray()); }
/** * <p>Checks if the String contains only certain characters.</p> * * <p>A <code>null</code> String will return <code>false</code>. * A <code>null</code> valid character String will return <code>false</code>. * An empty String (length()=0) always returns <code>true</code>.</p> * * <pre> * StringUtils.containsOnly(null, *) = false * StringUtils.containsOnly(*, null) = false * StringUtils.containsOnly("", *) = true * StringUtils.containsOnly("ab", "") = false * StringUtils.containsOnly("abab", "abc") = true * StringUtils.containsOnly("ab1", "abc") = false * StringUtils.containsOnly("abz", "abc") = false * </pre> * * @param str the String to check, may be null * @param validChars a String of valid chars, may be null * @return true if it only contains valid chars and is non-null * @since 2.0 */ public static boolean containsOnly(String str, String validChars) { if (str == null || validChars == null) { return false; } return containsOnly(str, validChars.toCharArray()); }
public static boolean validate(String value) { value = value.replaceAll("[.\\s]", ""); boolean isNumeric = StringUtils.isNumeric(value); int len = value.length(); if (len >= MIN_ACCOUNTNUMBER_LENGTH && len <= MAX_ACCOUNTNUMBER_LENGTH) { // regular account if (!isNumeric || !modula11(value)) { return false; } else if (StringUtils.containsOnly(value, "0")) { // check if only zeros return false; } } else if (len >= MIN_POSTACCOUNTNUMBER_LENGTH && len <= MAX_POSTACCOUNTNUMBER_LENGTH) { // post bank if (StringUtils.containsOnly(value, "pP0")) { // check if one of these: p, P, p0, P0, 0, 0000000 return false; } else if (len == MAX_POSTACCOUNTNUMBER_LENGTH && isNumeric) { // exactly 8 digits is an invalid account number return false; } else if (!isNumeric) { // contains letters, check if it is correct one in correct position int noOfLetters = value.replaceAll("\\d", "").length(); if (noOfLetters > 1) { // more then one letter is a problem return false; } else if (!value.substring(0, 1).equalsIgnoreCase("P")) { // P must be first if present return false; } } } else { // value too long or empty (it can happen, e.g.: ". . .") return false; } return true; }
private boolean resourceMatchHelper(List<String> policyResource) { boolean isMatchAny = false; if (isDebugEnabled) { LOG.debug("==> SimpleAtlasAuthorizer resourceMatchHelper"); } boolean optWildCard = true; List<String> policyValues = new ArrayList<>(); if (policyResource != null) { boolean isWildCardPresent = !optWildCard; for (String policyValue : policyResource) { if (StringUtils.isEmpty(policyValue)) { continue; } if (StringUtils.containsOnly(policyValue, WILDCARD_ASTERISK)) { isMatchAny = true; } else if (!isWildCardPresent && StringUtils.containsAny(policyValue, WILDCARDS)) { isWildCardPresent = true; } policyValues.add(policyValue); } optWildCard = optWildCard && isWildCardPresent; } else { isMatchAny = false; } if (isDebugEnabled) { LOG.debug("<== SimpleAtlasAuthorizer resourceMatchHelper"); } return isMatchAny; }
private String getConstantName(String nodeName) { List<String> enumNameGroups = new ArrayList<String>(asList(splitByCharacterTypeCamelCase(nodeName))); String enumName = ""; for (Iterator<String> iter = enumNameGroups.iterator(); iter.hasNext();) { if (containsOnly(ruleFactory.getNameHelper().replaceIllegalCharacters(iter.next()), "_")) { iter.remove(); } } enumName = upperCase(join(enumNameGroups, "_")); if (isEmpty(enumName)) { enumName = "__EMPTY__"; } else if (Character.isDigit(enumName.charAt(0))) { enumName = "_" + enumName; } return enumName; }
valid = false; else if (!StringUtils.containsOnly(dayOfWeekEntry.toUpperCase(), VALID_CHARACTERS))
protected boolean processSubAccount(IndirectCostRecoveryRateDetail item) { boolean success = true; Map pkMap = new HashMap(); String chart = item.getChartOfAccountsCode(); String acct = item.getAccountNumber(); String subAcct = item.getSubAccountNumber(); if(StringUtils.isNotBlank(subAcct) && !StringUtils.containsOnly(subAcct, "-")) { // if doesn't contain only dashes if(!propertyIsWildcard(chart)) { pkMap.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart); } if(!propertyIsWildcard(acct)) { pkMap.put(KFSPropertyConstants.ACCOUNT_NUMBER, acct); } if(!propertyIsWildcard(subAcct) && StringUtils.isNotBlank(subAcct) && !StringUtils.containsOnly(subAcct, "-")) { pkMap.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, subAcct); if(!checkExistenceFromTable(SubAccount.class, pkMap)) { logErrorUtility(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, RiceKeyConstants.ERROR_EXISTENCE); success = false; } } } return success; }
/** * Helper method to build an inquiry url for a result field. Special implementation to not build an inquiry link if the value is * all dashes. * * @param bo the business object instance to build the urls for * @param propertyName the property which links to an inquirable * @return String url to inquiry */ public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { if (PropertyUtils.isReadable(businessObject, attributeName)) { Object objFieldValue = ObjectUtils.getPropertyValue(businessObject, attributeName); String fieldValue = objFieldValue == null ? KFSConstants.EMPTY_STRING : objFieldValue.toString(); if (StringUtils.containsOnly(fieldValue, KFSConstants.DASH)) { return new AnchorHtmlData(); } } return super.getInquiryUrl(businessObject, attributeName, forceInquiry); }
protected boolean processSubObjectCode(IndirectCostRecoveryRateDetail item) { // chart being a wildcard implies account number being a wildcard, redundant checking? boolean success = true; Map pkMap = new HashMap(); Integer year = indirectCostRecoveryRate.getUniversityFiscalYear(); String chart = item.getChartOfAccountsCode(); String acct = item.getAccountNumber(); String objCd = item.getFinancialObjectCode(); String subObjCd = item.getFinancialSubObjectCode(); if(StringUtils.isNotBlank(subObjCd) && !propertyIsWildcard(subObjCd) && !StringUtils.containsOnly(subObjCd, "-")) { pkMap.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, year); if(!propertyIsWildcard(chart)) { pkMap.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart); } if(!propertyIsWildcard(acct)) { pkMap.put(KFSPropertyConstants.ACCOUNT_NUMBER, acct); } if(!propertyIsWildcard(objCd)) { pkMap.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, objCd); } pkMap.put(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, subObjCd); if(!GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(subObjCd) && !checkExistenceFromTable(SubObjectCode.class, pkMap)) { logErrorUtility(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, RiceKeyConstants.ERROR_EXISTENCE); success = false; } } return success; }
/** * Hook for quantity and setting asset numbers. * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#addNewLineToCollection(java.lang.String) */ @Override public void addNewLineToCollection(String collectionName) { // create handle for the addline section of the doc IndirectCostRecoveryRateDetail addLine = (IndirectCostRecoveryRateDetail) newCollectionLines.get(collectionName); List<IndirectCostRecoveryRateDetail> maintCollection = (List<IndirectCostRecoveryRateDetail>) ObjectUtils.getPropertyValue(getBusinessObject(), collectionName); if(StringUtils.isBlank(addLine.getSubAccountNumber()) || StringUtils.containsOnly(addLine.getSubAccountNumber(), "-")) { addLine.setSubAccountNumber(KFSConstants.getDashSubAccountNumber()); } if(StringUtils.isBlank(addLine.getFinancialSubObjectCode()) || StringUtils.containsOnly(addLine.getFinancialSubObjectCode(), "-")) { addLine.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode()); } Integer icrEntryNumberMax = 0; for(IndirectCostRecoveryRateDetail item : maintCollection) { if(icrEntryNumberMax < item.getAwardIndrCostRcvyEntryNbr()) { icrEntryNumberMax = item.getAwardIndrCostRcvyEntryNbr(); } } // addLine.setActive(true); // TODO remove after active indicator fixes addLine.setNewCollectionRecord(true); addLine.setAwardIndrCostRcvyEntryNbr(icrEntryNumberMax + 1); maintCollection.add(addLine); initNewCollectionLine(collectionName); }
if (!GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT.equals(item.getChartOfAccountsCode()) && !StringUtils.containsOnly(subAccountNumber, KFSConstants.DASH)) { GlobalVariables.getMessageMap().putError( KFSPropertyConstants.SUB_ACCOUNT_NUMBER, if (!(StringUtils.equals(GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY, subAccountNumber) || !StringUtils.containsOnly(subAccountNumber, KFSConstants.DASH))) { GlobalVariables.getMessageMap().putError(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_ACCOUNT_USE_EXPENDITURE_ENTRY_WILDCARD_RESTRICTION_ON_SUB_ACCOUNT);
isDayPerWeek = (isWild(dayOfMonth) || notApplicable(dayOfMonth)) && isWild(month) && daysOfWeekEntry.getDayInMonthOrdinal() == null && !isWild(daysOfWeek); boolean numericDayOfMonth = !notApplicable(dayOfMonth) && !isWild(dayOfMonth) && isWild(month) && notApplicable(daysOfWeek) && StringUtils.containsOnly(dayOfMonth.toUpperCase(), VALID_DAY_OF_MONTH); boolean dayOfWeekOfMonth = notApplicable(dayOfMonth) && isWild(month) && !isWild(daysOfWeek) && !notApplicable(daysOfWeek) && daysOfWeekEntry.getDayInMonthOrdinal() != null; isDaysPerMonth = dayOfWeekOfMonth || numericDayOfMonth;