Java Code Examples for org.apache.commons.lang.StringUtils#INDEX_NOT_FOUND
The following examples show how to use
org.apache.commons.lang.StringUtils#INDEX_NOT_FOUND .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IOpenShiftBuildVerifier.java From jenkins-plugin with Apache License 2.0 | 6 votes |
@Override public int compare(IBuild o1, IBuild o2) { String id1 = o1.getName(); String id2 = o2.getName(); int at = StringUtils.indexOfDifference(id1, id2); // no index means strings equal if (at == StringUtils.INDEX_NOT_FOUND) return 0; String rem0 = id1.substring(at); String rem1 = id2.substring(at); // means id2 is just longer, so id1 < id2, so return -1 if (StringUtils.isBlank(rem0)) return -1; // means id1 is just longer, so id1 > id2, so return 1 if (StringUtils.isBlank(rem1)) return 1; if (Integer.valueOf(rem0) < Integer.valueOf(rem1)) return -1; return 1; }
Example 2
Source File: ContractsGrantsInvoiceDocumentErrorLogLookupableHelperServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * Manipulate fields for search criteria in order to get the results the user really wants. * * @param fieldValues * @return updated search criteria fieldValues */ protected Map<String, String> updateFieldValuesForSearchCriteria(Map<String, String> fieldValues) { Map<String, String> newFieldValues = new HashMap<>(); newFieldValues.putAll(fieldValues); // Add wildcard character to start and end of accounts field so users can search for single account // within the delimited list of accounts without having to add the wildcards explicitly themselves. String accounts = newFieldValues.get(ArPropertyConstants.ContractsGrantsInvoiceDocumentErrorLogLookupFields.ACCOUNTS); if (StringUtils.isNotBlank(accounts)) { // only add wildcards if they haven't already been added (for some reason this method gets called twice when generating the pdf report) if (!StringUtils.startsWith(accounts, KFSConstants.WILDCARD_CHARACTER)) { accounts = KFSConstants.WILDCARD_CHARACTER + accounts; } if (!StringUtils.endsWith(accounts, KFSConstants.WILDCARD_CHARACTER)) { accounts += KFSConstants.WILDCARD_CHARACTER; } } newFieldValues.put(ArPropertyConstants.ContractsGrantsInvoiceDocumentErrorLogLookupFields.ACCOUNTS, accounts); // Increment to error date by one day so that the correct results are retrieved. // Since the error date is stored as both a date and time in the database records with an error date // the same as the error date the user enters on the search criteria aren't retrieved without this modification. String errorDate = newFieldValues.get(ArPropertyConstants.ContractsGrantsInvoiceDocumentErrorLogLookupFields.ERROR_DATE_TO); int index = StringUtils.indexOf(errorDate, SearchOperator.LESS_THAN_EQUAL.toString()); if (index == StringUtils.INDEX_NOT_FOUND) { index = StringUtils.indexOf(errorDate, SearchOperator.BETWEEN.toString()); if (index != StringUtils.INDEX_NOT_FOUND) { incrementErrorDate(newFieldValues, errorDate, index); } } else { incrementErrorDate(newFieldValues, errorDate, index); } return newFieldValues; }
Example 3
Source File: FileUtils.java From Aooms with Apache License 2.0 | 5 votes |
/** * 获取扩展名 * * @param fileName * @return */ public static String getExtension(String fileName) { if (StringUtils.INDEX_NOT_FOUND == StringUtils.indexOf(fileName, DOT)) return StringUtils.EMPTY; String ext = StringUtils.substring(fileName, StringUtils.lastIndexOf(fileName, DOT)); return StringUtils.trimToEmpty(ext); }
Example 4
Source File: FileUtils.java From Aooms with Apache License 2.0 | 5 votes |
/** * 获取扩展名 不带点 * * @param fileName * @return */ public static String getExtensionNoDot(String fileName) { if (StringUtils.INDEX_NOT_FOUND == StringUtils.indexOf(fileName, DOT)) return StringUtils.EMPTY; String ext = StringUtils.substring(fileName, StringUtils.lastIndexOf(fileName, DOT) + 1); return StringUtils.trimToEmpty(ext); }
Example 5
Source File: KRADLegacyDataAdapterImpl.java From rice with Educational Community License v2.0 | 4 votes |
@Override public org.kuali.rice.krad.bo.DataObjectRelationship getDataObjectRelationship(Object dataObject, Class<?> dataObjectClass, String attributeName, String attributePrefix, boolean keysOnly, boolean supportsLookup, boolean supportsInquiry) { RelationshipDefinition ddReference = getDictionaryRelationship(dataObjectClass, attributeName); org.kuali.rice.krad.bo.DataObjectRelationship relationship = null; DataObjectAttributeRelationship rel = null; if (PropertyAccessorUtils.isNestedOrIndexedProperty(attributeName)) { if (ddReference != null) { if (classHasSupportedFeatures(ddReference.getTargetClass(), supportsLookup, supportsInquiry)) { relationship = populateRelationshipFromDictionaryReference(dataObjectClass, ddReference, attributePrefix, keysOnly); return relationship; } } if (dataObject == null) { try { dataObject = KRADUtils.createNewObjectFromClass(dataObjectClass); } catch (RuntimeException e) { // found interface or abstract class, just swallow exception and return a null relationship return null; } } // recurse down to the next object to find the relationship int nextObjectIndex = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(attributeName); if (nextObjectIndex == StringUtils.INDEX_NOT_FOUND) { nextObjectIndex = attributeName.length(); } String localPrefix = StringUtils.substring(attributeName, 0, nextObjectIndex); String localAttributeName = StringUtils.substring(attributeName, nextObjectIndex + 1); Object nestedObject = ObjectPropertyUtils.getPropertyValue(dataObject, localPrefix); Class<?> nestedClass = null; if (nestedObject == null) { nestedClass = ObjectPropertyUtils.getPropertyType(dataObject, localPrefix); } else { nestedClass = nestedObject.getClass(); } String fullPrefix = localPrefix; if (StringUtils.isNotBlank(attributePrefix)) { fullPrefix = attributePrefix + "." + localPrefix; } relationship = getDataObjectRelationship(nestedObject, nestedClass, localAttributeName, fullPrefix, keysOnly, supportsLookup, supportsInquiry); return relationship; } // non-nested reference, get persistence relationships first int maxSize = Integer.MAX_VALUE; if (isPersistable(dataObjectClass)) { DataObjectMetadata metadata = dataObjectService.getMetadataRepository().getMetadata(dataObjectClass); DataObjectRelationship dataObjectRelationship = metadata.getRelationship(attributeName); if (dataObjectRelationship != null) { List<DataObjectAttributeRelationship> attributeRelationships = dataObjectRelationship.getAttributeRelationships(); for (DataObjectAttributeRelationship dataObjectAttributeRelationship : attributeRelationships) { if (classHasSupportedFeatures(dataObjectRelationship.getRelatedType(), supportsLookup, supportsInquiry)) { maxSize = attributeRelationships.size(); relationship = transformToDeprecatedDataObjectRelationship(dataObjectClass, attributeName, attributePrefix, dataObjectRelationship.getRelatedType(), dataObjectAttributeRelationship); break; } } } } else { ModuleService moduleService = kualiModuleService.getResponsibleModuleService(dataObjectClass); if (moduleService != null && moduleService.isExternalizable(dataObjectClass)) { relationship = getRelationshipMetadata(dataObjectClass, attributeName, attributePrefix); if ((relationship != null) && classHasSupportedFeatures(relationship.getRelatedClass(), supportsLookup, supportsInquiry)) { return relationship; } else { return null; } } } if (ddReference != null && ddReference.getPrimitiveAttributes().size() < maxSize) { if (classHasSupportedFeatures(ddReference.getTargetClass(), supportsLookup, supportsInquiry)) { relationship = populateRelationshipFromDictionaryReference(dataObjectClass, ddReference, null, keysOnly); } } return relationship; }