Java Code Examples for org.apache.commons.lang.StringUtils#split()
The following examples show how to use
org.apache.commons.lang.StringUtils#split() .
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: SqlBuilder.java From rice with Educational Community License v2.0 | 6 votes |
private void addNotCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, Criteria criteria, boolean allowWildcards) { String[] splitPropVal = StringUtils.split(propertyValue, SearchOperator.NOT.op()); int strLength = splitPropVal.length; // if Not'ed empty criteria, ignore if (strLength == 0) { throw new IllegalArgumentException("Improper syntax of NOT operator in " + propertyName);} // if more than one NOT operator assume an implicit and (i.e. !a!b = !a&!b) if (strLength > 1) { String expandedNot = SearchOperator.NOT + StringUtils.join(splitPropVal, SearchOperator.AND.op() + SearchOperator.NOT.op()); // we know that since this method is called, treatWildcardsAndOperatorsAsLiteral is false addCriteria(propertyName, expandedNot, propertyType, caseInsensitive, allowWildcards, criteria); } else { // only one so add a not like (all the rest) or not equal (decimal types) if (TypeUtils.isDecimalClass(propertyType)) { criteria.notEqual(propertyName, splitPropVal[0], propertyType, allowWildcards); } else { criteria.notLike(propertyName, splitPropVal[0], propertyType, allowWildcards); } } }
Example 2
Source File: SqlBuilder.java From rice with Educational Community License v2.0 | 6 votes |
private void addLogicalOperatorCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, Criteria criteria, String splitValue, boolean allowWildcards) { String[] splitPropVal = StringUtils.split(propertyValue, splitValue); Criteria subCriteria = new Criteria("N/A"); for (String element : splitPropVal) { Criteria predicate = new Criteria("N/A", criteria.getAlias()); // we know that since this method is called, treatWildcardsAndOperatorsAsLiteral is false addCriteria(propertyName, element, propertyType, caseInsensitive, allowWildcards, predicate); if (splitValue == SearchOperator.OR.op()) { subCriteria.or(predicate); } if (splitValue == SearchOperator.AND.op()) { subCriteria.and(predicate); } } criteria.and(subCriteria); }
Example 3
Source File: Reduce.java From hiped2 with Apache License 2.0 | 6 votes |
protected TaggedMapOutput combine(Object[] tags, Object[] values) { // an inner join requires that both sides contain an entry for the // join key // if (tags.length < 2) return null; StringBuilder joinedStr = new StringBuilder(); for (int i = 0; i < tags.length; i++) { if (i > 0) { joinedStr.append("\t"); } // strip first column as it is the key on which we joined String line = ((((TaggedMapOutput) values[i]).getData())).toString(); String[] tokens = StringUtils.split(line, "\t", 2); joinedStr.append(tokens[1]); } textOutput.set(joinedStr.toString()); output.setData(textOutput); //output.setTag((Text) tags[0]); return output; }
Example 4
Source File: DocumentSearchCriteriaProcessorKEWAdapter.java From rice with Educational Community License v2.0 | 6 votes |
private String prefixFieldConversions(String fieldConversions) { StringBuilder newFieldConversions = new StringBuilder(KRADConstants.EMPTY_STRING); String[] conversions = StringUtils.split(fieldConversions, KRADConstants.FIELD_CONVERSIONS_SEPARATOR); for (int l = 0; l < conversions.length; l++) { String conversion = conversions[l]; //String[] conversionPair = StringUtils.split(conversion, KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR); String[] conversionPair = StringUtils.split(conversion, KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR, 2); String conversionFrom = conversionPair[0]; String conversionTo = conversionPair[1]; conversionTo = KewApiConstants.DOCUMENT_ATTRIBUTE_FIELD_PREFIX + conversionTo; newFieldConversions.append(conversionFrom) .append(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR) .append(conversionTo); if (l < conversions.length) { newFieldConversions.append(KRADConstants.FIELD_CONVERSIONS_SEPARATOR); } } return newFieldConversions.toString(); }
Example 5
Source File: EntityMeta.java From ymate-platform-v2 with Apache License 2.0 | 6 votes |
/** * 处理字段名称,使其符合JavaBean属性串格式<br> * 例如:属性名称为"user_name",其处理结果为"UserName"<br> * * @param propertyName 属性名称 * @return 符合JavaBean属性格式串 */ public static String propertyNameToFieldName(String propertyName) { if (StringUtils.contains(propertyName, '_')) { String[] _words = StringUtils.split(propertyName, '_'); if (_words != null) { if (_words.length > 1) { StringBuilder _returnBuilder = new StringBuilder(); for (String _word : _words) { _returnBuilder.append(StringUtils.capitalize(_word.toLowerCase())); } return _returnBuilder.toString(); } return StringUtils.capitalize(_words[0].toLowerCase()); } } return StringUtils.capitalize(propertyName.toLowerCase()); }
Example 6
Source File: RangerHiveAuthorizer.java From ranger with Apache License 2.0 | 6 votes |
@Override public void init() { super.init(); RangerHivePlugin.UpdateXaPoliciesOnGrantRevoke = getConfig().getBoolean(RangerHadoopConstants.HIVE_UPDATE_RANGER_POLICIES_ON_GRANT_REVOKE_PROP, RangerHadoopConstants.HIVE_UPDATE_RANGER_POLICIES_ON_GRANT_REVOKE_DEFAULT_VALUE); RangerHivePlugin.BlockUpdateIfRowfilterColumnMaskSpecified = getConfig().getBoolean(RangerHadoopConstants.HIVE_BLOCK_UPDATE_IF_ROWFILTER_COLUMNMASK_SPECIFIED_PROP, RangerHadoopConstants.HIVE_BLOCK_UPDATE_IF_ROWFILTER_COLUMNMASK_SPECIFIED_DEFAULT_VALUE); RangerHivePlugin.DescribeShowTableAuth = getConfig().get(RangerHadoopConstants.HIVE_DESCRIBE_TABLE_SHOW_COLUMNS_AUTH_OPTION_PROP, RangerHadoopConstants.HIVE_DESCRIBE_TABLE_SHOW_COLUMNS_AUTH_OPTION_PROP_DEFAULT_VALUE); String fsSchemesString = getConfig().get(RANGER_PLUGIN_HIVE_ULRAUTH_FILESYSTEM_SCHEMES, RANGER_PLUGIN_HIVE_ULRAUTH_FILESYSTEM_SCHEMES_DEFAULT); fsScheme = StringUtils.split(fsSchemesString, FILESYSTEM_SCHEMES_SEPARATOR_CHAR); if (fsScheme != null) { for (int i = 0; i < fsScheme.length; i++) { fsScheme[i] = fsScheme[i].trim(); } } }
Example 7
Source File: AviaterRegexFilter.java From binlake with Apache License 2.0 | 6 votes |
public AviaterRegexFilter(String pattern, boolean defaultEmptyValue) { this.defaultEmptyValue = defaultEmptyValue; List<String> list = null; if (StringUtils.isEmpty(pattern)) { list = new ArrayList<String>(); } else { String[] ss = StringUtils.split(pattern, SPLIT); list = Arrays.asList(ss); } // 对pattern按照从长到短的排序 // 因为 foo|foot 匹配 foot 会出错,原因是 foot 匹配了 foo 之后,会返回 foo,但是 foo 的长度和 foot // 的长度不一样 Collections.sort(list, COMPARATOR); // 对pattern进行头尾完全匹配 list = completionPattern(list); this.pattern = StringUtils.join(list, PATTERN_SPLIT); }
Example 8
Source File: Job.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @deprecated "Implementing institutions likely want to call Job#withinCutoffWindowForDate" */ public static boolean isPastCutoffWindow(Date date, Collection<String> runDates) { DateTimeService dTService = SpringContext.getBean(DateTimeService.class); ParameterService parameterService = SpringContext.getBean(ParameterService.class); Calendar jobRunDate = dTService.getCalendar(date); if (parameterService.parameterExists(KfsParameterConstants.FINANCIAL_SYSTEM_BATCH.class, RUN_DATE_CUTOFF_PARM_NM)) { String[] cutOffTime = StringUtils.split(parameterService.getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_BATCH.class, RUN_DATE_CUTOFF_PARM_NM), ':'); Calendar runDate = null; for (String runDateStr : runDates) { try { runDate = dTService.getCalendar(dTService.convertToDate(runDateStr)); runDate.add(Calendar.DAY_OF_YEAR, 1); runDate.set(Calendar.HOUR_OF_DAY, Integer.parseInt(cutOffTime[0])); runDate.set(Calendar.MINUTE, Integer.parseInt(cutOffTime[1])); runDate.set(Calendar.SECOND, Integer.parseInt(cutOffTime[2])); } catch (ParseException e) { LOG.error("ParseException occured parsing " + runDateStr, e); } if (jobRunDate.before(runDate)) { return false; } } } return true; }
Example 9
Source File: TfsRevisionNumber.java From azure-devops-intellij with MIT License | 5 votes |
public static TfsRevisionNumber tryParse(final String s) { try { final String[] sections = StringUtils.split(s, SEPARATOR); if (sections == null || sections.length != 3) { return null; } return new TfsRevisionNumber(Integer.parseInt(sections[0]), sections[1], sections[2]); } catch (NumberFormatException e) { logger.error("Could not parse revision number: " + s, e); return null; } }
Example 10
Source File: StringTokBench.java From hiped2 with Apache License 2.0 | 5 votes |
public static long runStringUtils(List<String> strings) { long start = System.currentTimeMillis(); for (String s : strings) { String[] parts = StringUtils.split(s, ' '); for (String p : parts) { //System.out.println("runStringUtils: " + p); } } return System.currentTimeMillis() - start; }
Example 11
Source File: CommonUtil.java From framework with Apache License 2.0 | 5 votes |
/** * Description: 从拼接的字符串中获取id数组<br> * * @author 王伟<br> * @taskId <br> * @param idStr * @param splitor * @return <br> */ public static Integer[] splitId(final String idStr, final String splitor) { Integer[] ids = null; if (StringUtils.isNotEmpty(idStr)) { String[] strs = StringUtils.split(idStr, splitor); ids = new Integer[strs.length]; for (int i = 0; i < strs.length; i++) { ids[i] = Integer.valueOf(strs[i]); } } return ids; }
Example 12
Source File: RoleDBStore.java From ranger with Apache License 2.0 | 5 votes |
public List<RangerRole> getRoles(Long serviceId) { List<RangerRole> ret = ListUtils.EMPTY_LIST; if (serviceId != null) { String serviceTypeName = daoMgr.getXXServiceDef().findServiceDefTypeByServiceId(serviceId); if (LOG.isDebugEnabled()) { LOG.debug("Service Type for serviceId (" + serviceId + ") = " + serviceTypeName); } String serviceTypesToGetAllRoles = config.get("ranger.admin.service.types.for.returning.all.roles", "solr"); boolean getAllRoles = false; if (StringUtils.isNotEmpty(serviceTypesToGetAllRoles)) { String[] allRolesServiceTypes = StringUtils.split(serviceTypesToGetAllRoles, ","); if (allRolesServiceTypes != null) { for (String allRolesServiceType : allRolesServiceTypes) { if (StringUtils.equalsIgnoreCase(serviceTypeName, allRolesServiceType)) { getAllRoles = true; break; } } } } List<XXRole> rolesFromDb = getAllRoles ? daoMgr.getXXRole().getAll() : daoMgr.getXXRole().findByServiceId(serviceId); if (CollectionUtils.isNotEmpty(rolesFromDb)) { ret = new ArrayList<>(); for (XXRole xxRole : rolesFromDb) { ret.add(roleService.read(xxRole.getId())); } } } return ret; }
Example 13
Source File: StringHelper.java From snakerflow with Apache License 2.0 | 5 votes |
/** * 构造排序条件 * @param order 排序方向 * @param orderby 排序字段 * @return 组装好的排序sql */ public static String buildPageOrder(String order, String orderby) { if(isEmpty(orderby) || isEmpty(order)) return ""; String[] orderByArray = StringUtils.split(orderby, ','); String[] orderArray = StringUtils.split(order, ','); if(orderArray.length != orderByArray.length) throw new SnakerException("分页多重排序参数中,排序字段与排序方向的个数不相等"); StringBuilder orderStr = new StringBuilder(30); orderStr.append(" order by "); for (int i = 0; i < orderByArray.length; i++) { orderStr.append(orderByArray[i]).append(" ").append(orderArray[i]).append(" ,"); } orderStr.deleteCharAt(orderStr.length() - 1); return orderStr.toString(); }
Example 14
Source File: ShopCustomerCustomisationSupportImpl.java From yes-cart with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public List<Pair<String, I18NModel>> getSupportedCustomerTypes(final Shop shop) { final AttrValue av = getShopCustomerTypes(shop); if (av != null && StringUtils.isNotBlank(av.getVal())) { final String[] types = StringUtils.split(av.getVal(), ','); final I18NModel model = new StringI18NModel(av.getDisplayVal()); final Map<String, String[]> values = new HashMap<>(); for (final Map.Entry<String, String> displayValues : model.getAllValues().entrySet()) { values.put(displayValues.getKey(), StringUtils.split(displayValues.getValue(), ',')); } final List<Pair<String, I18NModel>> out = new ArrayList<>(types.length); for (int i = 0; i < types.length; i++) { final String type = types[i].trim(); final Map<String, String> names = new HashMap<>(); for (final Map.Entry<String, String[]> entry : values.entrySet()) { if (entry.getValue().length > i) { names.put(entry.getKey(), entry.getValue()[i]); } } out.add(new Pair<>(type, new FailoverStringI18NModel(names, type))); } return out; } return Collections.emptyList(); }
Example 15
Source File: ClassificationAssociatorTest.java From atlas with Apache License 2.0 | 5 votes |
private void assertSummaryElement(String summaryElement, String operation, String status, String classificationName) { String[] splits = StringUtils.split(summaryElement, MESSAGE_SEPARATOR); String[] nameSplits = StringUtils.split(splits[3], ENTITY_NAME_SEPARATOR); if (nameSplits.length > 1) { assertEquals(nameSplits[1].trim(), classificationName); } assertEquals(splits[0], operation); assertEquals(splits[4], status); }
Example 16
Source File: ResourceMessageProvider.java From rice with Educational Community License v2.0 | 5 votes |
/** * Retrieves the list of configured bundle names for the application * * <p> * Resource bundle names are configured for the application using the configuration property * <code>resourceBundleNames</code> * </p> * * @return List<String> list of bundle names configured for the application */ protected List<String> getResourceBundleNamesForApplication() { String resourceBundleNamesConfig = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString( "resourceBundleNames"); if (StringUtils.isNotBlank(resourceBundleNamesConfig)) { String[] resourceBundleNames = StringUtils.split(resourceBundleNamesConfig, ","); return Arrays.asList(resourceBundleNames); } return null; }
Example 17
Source File: EditInstanceVcloud.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
private boolean checkInstanceType(Long imageNo, String instanceType) { ImageVcloud imageVcloud = imageVcloudDao.read(imageNo); if (StringUtils.isEmpty(imageVcloud.getInstanceTypes())) { return false; } for (String instanceType2 : StringUtils.split(imageVcloud.getInstanceTypes(), ",")) { if (StringUtils.equals(instanceType, instanceType2.trim())) { return true; } } return false; }
Example 18
Source File: CapitalAssetBuilderModuleServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * Capital Asset validation: If the item has a transaction type, check that the transaction type is acceptable for the object * code sub-types of all the object codes on the associated accounting lines. * * @param objectCode * @param capitalAssetTransactionType * @param warn A boolean which should be set to true if warnings are to be set on the calling document * @param itemIdentifier * @return */ protected boolean validateObjectCodeVersusTransactionType(ObjectCode objectCode, CapitalAssetBuilderAssetTransactionType capitalAssetTransactionType, String itemIdentifier, boolean quantityBasedItem) { boolean valid = true; String[] objectCodeSubTypes = {}; String itemTypeStr = null; String alternativeItemTypeStr = null; String capitalAssetSubtypeRequiredText = null; if (isCapitalAssetObjectCode(objectCode)) { if (quantityBasedItem) { String capitalAssetQuantitySubtypeRequiredText = capitalAssetTransactionType.getCapitalAssetQuantitySubtypeRequiredText(); itemTypeStr = PurapConstants.ITEM_TYPE_QTY; alternativeItemTypeStr = PurapConstants.ITEM_TYPE_NO_QTY; capitalAssetSubtypeRequiredText = capitalAssetQuantitySubtypeRequiredText; if (capitalAssetQuantitySubtypeRequiredText != null) { objectCodeSubTypes = StringUtils.split(capitalAssetQuantitySubtypeRequiredText, ";"); } } else { String capitalAssetNonquantitySubtypeRequiredText = capitalAssetTransactionType.getCapitalAssetNonquantitySubtypeRequiredText(); itemTypeStr = PurapConstants.ITEM_TYPE_NO_QTY; alternativeItemTypeStr = PurapConstants.ITEM_TYPE_QTY; capitalAssetSubtypeRequiredText = capitalAssetNonquantitySubtypeRequiredText; if (capitalAssetNonquantitySubtypeRequiredText != null) { objectCodeSubTypes = StringUtils.split(capitalAssetNonquantitySubtypeRequiredText, ";"); } } boolean found = false; for (String subType : objectCodeSubTypes) { if (StringUtils.equals(subType, objectCode.getFinancialObjectSubTypeCode())) { found = true; break; } } if (!found) { List<String> errorPath = GlobalVariables.getMessageMap().getErrorPath(); if (errorPath != null && errorPath.isEmpty()) { String errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + PurapPropertyConstants.ITEM; GlobalVariables.getMessageMap().addToErrorPath(errorPathPrefix); GlobalVariables.getMessageMap().putError(PurapPropertyConstants.ITEM_CAPITAL_ASSET_TRANSACTION_TYPE, CabKeyConstants.ERROR_ITEM_TRAN_TYPE_OBJECT_CODE_SUBTYPE, itemIdentifier, itemTypeStr, capitalAssetTransactionType.getCapitalAssetTransactionTypeDescription(), objectCode.getFinancialObjectCodeName(), capitalAssetSubtypeRequiredText, alternativeItemTypeStr); GlobalVariables.getMessageMap().removeFromErrorPath(errorPathPrefix); } else { GlobalVariables.getMessageMap().putError(PurapPropertyConstants.ITEM_CAPITAL_ASSET_TRANSACTION_TYPE, CabKeyConstants.ERROR_ITEM_TRAN_TYPE_OBJECT_CODE_SUBTYPE, itemIdentifier, itemTypeStr, capitalAssetTransactionType.getCapitalAssetTransactionTypeDescription(), objectCode.getFinancialObjectCodeName(), capitalAssetSubtypeRequiredText, alternativeItemTypeStr); } valid &= false; } } return valid; }
Example 19
Source File: Member.java From antsdb with GNU Lesser General Public License v3.0 | 4 votes |
public String getHost() { String[] result = StringUtils.split(endpoint, ':'); return result[0]; }
Example 20
Source File: FreeSqlDataProcessor.java From das with Apache License 2.0 | 4 votes |
private void processMethodHost(TaskSqlView task, String namespace, List<JavaMethodHost> methods, Map<String, JavaMethodHost> freeSqlPojoHosts) throws Exception { JavaMethodHost method = new JavaMethodHost(); method.setSql(task.getSql_content()); method.setName(task.getMethod_name()); method.setPackageName(namespace); method.setScalarType(task.getScalarType()); method.setPojoType(task.getPojoType()); method.setPaging(task.getPagination()); method.setCrud_type(task.getCrud_type()); method.setComments(task.getComment()); method.setField_type(task.getField_type()); // method.setLength(task.getLength()); if (task.getPojo_name() != null && !task.getPojo_name().isEmpty()) { method.setPojoClassName(WordUtils.capitalize(task.getPojo_name() /*+ "Pojo"*/)); } List<JavaParameterHost> params = new ArrayList<>(); for (String param : StringUtils.split(task.getParameters(), ";")) { String[] splitedParam = StringUtils.split(param, ","); JavaParameterHost p = new JavaParameterHost(); p.setName(splitedParam[0]); p.setSqlType(Integer.valueOf(splitedParam[1])); p.setJavaClass(CodeGenConsts.jdbcSqlTypeToJavaClass.get(p.getSqlType())); p.setValidationValue(DbUtils.mockATest(p.getSqlType())); boolean sensitive = splitedParam.length >= 3 ? Boolean.parseBoolean(splitedParam[2]) : false; p.setSensitive(sensitive); params.add(p); } SqlBuilder.rebuildJavaInClauseSQL(task.getSql_content(), params); method.setParameters(params); method.setHints(task.getHints()); methods.add(method); if (method.getPojoClassName() != null && !method.getPojoClassName().isEmpty() && !freeSqlPojoHosts.containsKey(method.getPojoClassName()) && !"update".equalsIgnoreCase(method.getCrud_type())) { List<JavaParameterHost> paramHosts = new ArrayList<>(); List<AbstractParameterHost> hosts = DbUtils.testAQuerySql(task.getAlldbs_id(), task.getSql_content(), task.getParameters(), new JavaGivenSqlResultSetExtractor()); for (AbstractParameterHost _ahost : hosts) { JavaParameterHost host = (JavaParameterHost) _ahost; host.setField_type(task.getField_type()); paramHosts.add(host); } List<JavaParameterHost> list = paramHosts.stream().filter(field -> DataFieldTypeEnum.SQL_DATE.getDetail().equals(field.getJavaClass().getName())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { paramHosts.stream().forEach(p -> p.setSqlDateExist(true)); } method.setFields(paramHosts); freeSqlPojoHosts.put(method.getPojoClassName(), method); } else if ("update".equalsIgnoreCase(method.getCrud_type())) { DbUtils.testUpdateSql(task.getAlldbs_id(), task.getSql_content(), task.getParameters()); } }