List of usage examples for org.apache.commons.lang StringUtils splitByWholeSeparatorPreserveAllTokens
public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator)
Splits the provided text into an array, separator string specified.
From source file:com.livinglogic.ul4.BoundStringMethodSplit.java
public static List<String> call(String object, String separator) { if (separator == null) return call(object); return Arrays.asList(StringUtils.splitByWholeSeparatorPreserveAllTokens(object, separator)); }
From source file:ch.systemsx.cisd.openbis.generic.shared.util.UuidUtil.java
/** @return true if the parameter is a valid canonical string representation of the UUID */ public static final boolean isValidUUID(final String uuid) { assert uuid != null : "Unspecified UUID"; final String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(uuid, "-"); if (split.length != 5) { return false; }/*w w w. ja va 2 s .c o m*/ return UUID_PATTERN.matcher(uuid).matches(); }
From source file:com.intuit.tank.vm.common.util.TimingPageName.java
/** * @param pageName// w w w .j av a2 s . c o m */ public TimingPageName(String pageName) { super(); String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(pageName, ReportUtil.PAGE_NAME_SEPERATOR); if (split.length > 0 && !StringUtils.isBlank(split[0])) { this.id = split[0].trim(); } if (split.length > 1 && !StringUtils.isBlank(split[1])) { this.name = split[1].trim(); } if (name == null && id == null) { id = pageName.trim(); name = pageName.trim(); } if (id == null) { id = name; } if (name == null) { name = id; } if (split.length > 2) { String indStr = split[2].trim(); if (NumberUtils.isDigits(indStr)) { try { index = Integer.parseInt(indStr); } catch (NumberFormatException e) { LOG.warn("Error parsing index " + indStr + ": " + e); } } } }
From source file:apps.fiskfq.online.action.Txn1534011Action.java
@Override public LFixedLengthProtocol process(LFixedLengthProtocol msg) throws Exception { // //from w ww . ja v a2 s.c om String[] fieldArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(new String(msg.msgBody), "|"); // String chrid = fieldArray[0]; String billtype_code = fieldArray[1]; String billno = fieldArray[2]; String billMoney = fieldArray[3]; String bank_indate = fieldArray[4]; String incomestatus = fieldArray[5]; String pm_code = fieldArray[6]; String cheque_no = fieldArray[7]; String payerbank = fieldArray[8]; String payeraccount = fieldArray[9]; String set_year = fieldArray[10]; String route_user_code = fieldArray[11]; String license = fieldArray[12]; String business_id = fieldArray[13]; logger.info("[1534011][]" + msg.branchID + "[]" + msg.tellerID + " []" + billtype_code + " [] " + billno + "[]" + billMoney); try { Tia2402 tia = new Tia2402(); tia.Body.Object.Record.chr_id = chrid; tia.Body.Object.Record.billtype_code = billtype_code; tia.Body.Object.Record.bill_no = billno; tia.Body.Object.Record.bill_money = billMoney; tia.Body.Object.Record.bank_indate = bank_indate; tia.Body.Object.Record.incomestatus = incomestatus; tia.Body.Object.Record.pm_code = pm_code; tia.Body.Object.Record.cheque_no = cheque_no; tia.Body.Object.Record.payerbank = payerbank; tia.Body.Object.Record.payeraccount = payeraccount; tia.Body.Object.Record.set_year = set_year; tia.Body.Object.Record.route_user_code = route_user_code; tia.Body.Object.Record.license = license; tia.Body.Object.Record.business_id = business_id; tia.Head.msgId = msg.txnTime + msg.serialNo; tia.Head.workDate = msg.txnTime.substring(0, 8); ToaXml toa = (ToaXml) txn1534011Service.process(msg.tellerID, msg.branchID, tia); // TODO } catch (Exception e) { logger.error("[1534011][fiskfq]", e); msg.rtnCode = TxnRtnCode.TXN_EXECUTE_FAILED.getCode(); String errmsg = e.getMessage(); if (StringUtils.isEmpty(errmsg)) { msg.msgBody = TxnRtnCode.TXN_EXECUTE_FAILED.getTitle().getBytes(THIRDPARTY_SERVER_CODING); } else msg.msgBody = e.getMessage().getBytes(THIRDPARTY_SERVER_CODING); } return msg; }
From source file:com.spotify.hdfs2cass.misc.TokenNode.java
public TokenNode(final String encodedStr) { final String[] parts = StringUtils.splitByWholeSeparatorPreserveAllTokens(encodedStr, ":"); if ((parts == null) || (parts.length != 2)) { throw new RuntimeException("Unable to decode " + encodedStr); }/*from w w w . j a v a 2 s . c om*/ startToken = new BigIntegerToken(parts[0]); endToken = new BigIntegerToken(parts[1]); }
From source file:com.moz.fiji.schema.util.JavaIdentifiers.java
/** * Determines whether a string could be the name of a Java class. * * <p>If this method returns true, it does not necessarily mean that the Java class with * <code>className</code> exists; it only means that one could write a Java class with * that fully-qualified name.</p>// w w w .j a va 2 s.c om * * @param className A string to test. * @return Whether the class name was valid. */ public static boolean isValidClassName(String className) { // A valid class name is a bunch of valid Java identifiers separated by dots. for (String part : StringUtils.splitByWholeSeparatorPreserveAllTokens(className, ".")) { if (!isValidIdentifier(part)) { return false; } } return true; }
From source file:com.opengamma.id.ObjectId.java
/** * Parses an {@code ObjectId} from a formatted scheme and value. * <p>//from ww w. ja va2 s . c om * This parses the identifier from the form produced by {@code toString()} * which is {@code <SCHEME>~<VALUE>}. * * @param str the object identifier to parse, not null * @return the object identifier, not null * @throws IllegalArgumentException if the identifier cannot be parsed */ @FromString public static ObjectId parse(String str) { ArgumentChecker.notEmpty(str, "str"); if (str.contains("~") == false) { str = StringUtils.replace(str, "::", "~"); // leniently parse old data } String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(str, "~"); switch (split.length) { case 2: return ObjectId.of(split[0], split[1]); } throw new IllegalArgumentException("Invalid identifier format: " + str); }
From source file:msi.gama.util.file.GamaFileMetaData.java
protected String[] split(final String s) { return StringUtils.splitByWholeSeparatorPreserveAllTokens(s, DELIMITER); }
From source file:be.dnsbelgium.rate.spring.security.LeakyBucketVoter.java
@Override public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) { int amount = this.defaultAmount; if (attributes != null) { for (ConfigAttribute attribute : attributes) { if (attribute.getAttribute() != null && attribute.getAttribute().startsWith(PREFIX + SEPARATOR)) { String amountAttributeValue = StringUtils .splitByWholeSeparatorPreserveAllTokens(attribute.getAttribute(), SEPARATOR)[1]; try { // should be minimum zero amount = Math.max(0, Integer.parseInt(amountAttributeValue)); } catch (NumberFormatException nfe) { LOGGER.debug(String.format("%s is NaN. Defaulting to %s for amount.", amountAttributeValue, defaultAmount), nfe); }/*from w w w . j a v a2 s . com*/ } } } if (amount == 0) { return ACCESS_GRANTED; } int result = ACCESS_DENIED; T key = keyFactory.create(SecurityContextHolder.getContext()); try { if (leakyBucketService.add(key, amount)) { result = ACCESS_GRANTED; } } catch (IllegalArgumentException iae) { // this should never occur since amount is minimum zero (Math.max) LOGGER.error(String.format("Illegal amount of tokens added to bucket: %s", amount), iae); throw iae; } if (result == ACCESS_DENIED) { throw new RDAPErrorException(TOO_MANY_REQUESTS_HTTP_CODE, "Too many requests"); } return result; }
From source file:eionet.cr.dao.readers.FactsheetReader.java
/** * * @param objectData//from w w w.ja va2s . com * @return */ private ObjectDTO parseObjectData(String objectData, String predUri) { if (StringUtils.isBlank(objectData)) { return null; } String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(objectData, OBJECT_DATA_SPLITTER); if (split == null || split.length > 8) { throw new CRRuntimeException("Was expecting a length <=8 for the split array"); } String label = StringUtils.isBlank(split[0]) ? "" : split[0].trim(); String language = StringUtils.isBlank(split[1]) ? null : split[1].trim(); URI datatype = StringUtils.isBlank(split[2]) ? null : new URIImpl(split[2].trim()); String objectUri = StringUtils.isBlank(split[3]) ? null : split[3].trim(); boolean isLiteral = objectUri == null; boolean isAnonymous = StringUtils.isBlank(split[4]) ? false : split[4].trim().equals("1") || split[4].trim().equals("true"); String graphUri = StringUtils.isBlank(split[5]) ? null : split[5].trim(); int objectLength = StringUtils.isBlank(split[6]) ? 0 : Integer.parseInt(split[6].trim()); String objectMD5 = StringUtils.isBlank(split[7]) ? "" : split[7].trim(); ObjectDTO objectDTO = null; if (isLiteral) { objectDTO = new ObjectDTO(label, language, true, false, datatype); } else { objectDTO = new ObjectDTO(objectUri, null, false, isAnonymous); if (!StringUtils.isBlank(label) && !label.equals(objectUri)) { ObjectDTO labelObjectDTO = new ObjectDTO(label, language, true, false, datatype); objectDTO.setLabelObject(labelObjectDTO); } } objectDTO.setSourceUri(graphUri); // If literal object and its length in the database is actually bigger than the length // of the value we retrieved (because the query asks only for the N first characters), // then set the object's database-calculated MD5 hash, so that we can later retrieve the // full object value on the factsheet page. As a double measure, make also sure that the // database-calculated hash differs indeed from the Java-calculated hash of the first N // characters that we got here. if (isLiteral) { String value = objectDTO.getValue(); if (objectLength > WebConstants.MAX_OBJECT_LENGTH && !DigestUtils.md5Hex(value).equalsIgnoreCase(objectMD5)) { objectDTO.setObjectMD5(objectMD5); LOGGER.trace("Object's database-calculated length is " + objectLength); } } return objectDTO; }