Example usage for org.apache.commons.lang StringUtils splitByWholeSeparator

List of usage examples for org.apache.commons.lang StringUtils splitByWholeSeparator

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils splitByWholeSeparator.

Prototype

public static String[] splitByWholeSeparator(String str, String separator) 

Source Link

Document

Splits the provided text into an array, separator string specified.

Usage

From source file:org.kuali.rice.kim.impl.type.IdentityManagementTypeAttributeTransactionalDocument.java

public String getCommaDelimitedAttributesLabels(String commaDelimitedAttributesNamesList) {
    String[] names = StringUtils.splitByWholeSeparator(commaDelimitedAttributesNamesList,
            KimConstants.KimUIConstants.COMMA_SEPARATOR);
    List<String> commaDelimitedAttributesLabels = new ArrayList<String>(names.length);
    for (String name : names) {
        Object attributeEntry = getAttributeEntry().get(name.trim());
        if (attributeEntry != null) {
            commaDelimitedAttributesLabels.add(attributeEntry.toString());
        }//from w  w  w. j a va 2s  . c  om
    }
    return StringUtils.join(commaDelimitedAttributesLabels, KimConstants.KimUIConstants.COMMA_SEPARATOR);
}

From source file:org.kuali.rice.kim.impl.type.KimTypeAttributesHelper.java

public String getCommaDelimitedAttributesLabels(String commaDelimitedAttributesNamesList) {
    String[] names = StringUtils.splitByWholeSeparator(commaDelimitedAttributesNamesList,
            KimConstants.KimUIConstants.COMMA_SEPARATOR);
    StringBuffer commaDelimitedAttributesLabels = new StringBuffer();
    for (String name : names) {
        commaDelimitedAttributesLabels/*  w  w  w .j  a  v  a2 s  .co  m*/
                .append(getAttributeEntry().get(name.trim()) + KimConstants.KimUIConstants.COMMA_SEPARATOR);
    }
    if (commaDelimitedAttributesLabels.toString().endsWith(KimConstants.KimUIConstants.COMMA_SEPARATOR))
        commaDelimitedAttributesLabels.delete(
                commaDelimitedAttributesLabels.length() - KimConstants.KimUIConstants.COMMA_SEPARATOR.length(),
                commaDelimitedAttributesLabels.length());
    return commaDelimitedAttributesLabels.toString();
}

From source file:org.kuali.rice.kns.lookup.LookupUtils.java

public static Set<String> convertStringOfObjectIdsToSet(String objectIdsString) {
    Set<String> set = new HashSet<String>();

    if (StringUtils.isNotBlank(objectIdsString)) {
        String[] objectIds = StringUtils.splitByWholeSeparator(objectIdsString,
                KRADConstants.MULTIPLE_VALUE_LOOKUP_OBJ_IDS_SEPARATOR);
        for (String objectId : objectIds) {
            set.add(objectId);//from   w w  w .j a  v a2  s .c om
        }
    }
    return set;
}

From source file:org.kuali.rice.krad.uif.util.ClientValidationUtils.java

/**
 * Determines which fields are being evaluated in a boolean statement, so handlers can be
 * attached to them if needed, returns these names in a list.
 * /* www  .ja v  a 2s . c  o  m*/
 * @param statement statement to parse
 * @return list of field names
 */
private static List<String> parseOutFields(String statement) {
    List<String> fieldNames = new ArrayList<String>();
    String[] splits = StringUtils.splitByWholeSeparator(statement, "coerceValue(");
    for (String s : splits) {
        //must be a coerceValue param and not preceding content from the split, always starts with "'"
        if (!s.startsWith("'")) {
            continue;
        }

        s = s.substring(1);
        String fieldName = StringUtils.substringBefore(s, "'");
        //Only add field name once for this condition check
        if (!fieldNames.contains(fieldName)) {
            fieldNames.add(fieldName);
        }

    }
    return fieldNames;
}

From source file:org.onebusaway.nyc.vehicle_tracking.impl.inference.VehicleInferenceInstance.java

/****
 * Private Methods//from w ww .j av a  2  s. c o  m
 ****/
private void setLastRecordForDetails(VehicleLocationDetails details) {
    NycRawLocationRecord lastRecord = null;
    if (_previousObservation != null)
        lastRecord = _previousObservation.getRecord();

    if (lastRecord == null && _nycTestInferredLocationRecord != null) {
        lastRecord = new NycRawLocationRecord();
        lastRecord.setDestinationSignCode(_nycTestInferredLocationRecord.getDsc());
        lastRecord.setTime(_nycTestInferredLocationRecord.getTimestamp());
        lastRecord.setTimeReceived(_nycTestInferredLocationRecord.getTimestamp());
        lastRecord.setLatitude(_nycTestInferredLocationRecord.getLat());
        lastRecord.setLongitude(_nycTestInferredLocationRecord.getLon());
        lastRecord.setOperatorId(_nycTestInferredLocationRecord.getOperatorId());
        final String[] runInfo = StringUtils
                .splitByWholeSeparator(_nycTestInferredLocationRecord.getReportedRunId(), "-");

        if (runInfo != null && runInfo.length > 0) {
            lastRecord.setRunRouteId(runInfo[0]);
            if (runInfo.length > 1)
                lastRecord.setRunNumber(runInfo[1]);
        }
    }

    details.setLastObservation(lastRecord);
}

From source file:org.onebusaway.nyc.vehicle_tracking.model.library.RecordLibrary.java

public static NycRawLocationRecord getNycTestInferredLocationRecordAsNycRawLocationRecord(
        NycTestInferredLocationRecord record) {

    final NycRawLocationRecord vlr = new NycRawLocationRecord();

    vlr.setDestinationSignCode(record.getDsc());
    vlr.setLatitude(record.getLat());/*www.  j a  va 2  s . c  o  m*/
    vlr.setLongitude(record.getLon());
    vlr.setTime(record.getTimestamp());
    vlr.setTimeReceived(record.getTimestamp());
    vlr.setVehicleId(record.getVehicleId());
    vlr.setOperatorId(record.getOperatorId());
    final String[] runInfo = StringUtils.splitByWholeSeparator(record.getReportedRunId(), "-");
    if (runInfo != null && runInfo.length > 0) {
        vlr.setRunRouteId(runInfo[0]);
        if (runInfo.length > 1)
            vlr.setRunNumber(runInfo[1]);
    }

    return vlr;
}

From source file:org.onebusaway.nyc.vehicle_tracking.webapp.controllers.UpdateVehicleLocationController.java

@RequestMapping("/update-vehicle-location.do")
public ModelAndView index(@RequestParam(required = false, defaultValue = "") String time,
        @RequestParam() String vehicleId, @RequestParam() double lat, @RequestParam() double lon,
        @RequestParam() String dsc, @RequestParam(required = false, defaultValue = "null") String operatorId,
        @RequestParam(required = false, defaultValue = "null") String runId,
        @RequestParam(required = false, defaultValue = "false") boolean saveResults) throws ParseException {

    long t = System.currentTimeMillis();

    if (time != null && !time.trim().isEmpty()) {
        Date date = _format.parse(time);
        t = date.getTime();/*from  w ww .ja  v  a2s . co m*/
    }

    NycRawLocationRecord vlr = new NycRawLocationRecord();
    vlr.setTime(t);
    vlr.setVehicleId(AgencyAndIdLibrary.convertFromString(vehicleId));
    vlr.setLatitude(lat);
    vlr.setLongitude(lon);
    vlr.setDestinationSignCode(dsc);
    vlr.setOperatorId(operatorId);
    String[] runInfo = StringUtils.splitByWholeSeparator(runId, "_");
    if (runInfo != null && runInfo.length > 0) {
        vlr.setRunRouteId(runInfo[0]);
        if (runInfo.length > 1)
            vlr.setRunNumber(runInfo[1]);
    }

    _vehicleLocationService.handleNycRawLocationRecord(vlr);

    return new ModelAndView("update-vehicle-location.jspx");
}

From source file:org.openbel.framework.core.df.external.CacheableAnnotationDefinitionServiceImpl.java

/**
 * Reads each line after the [Values] block as enumeration values for the
 * annotation definition./*from   ww  w.  java2 s  .c o m*/
 * 
 * @param annotationCacheCopy {@link File}, the annotation file to read
 * from
 * @param valueDelimiter {@link String}, the delimiter that separates
 * annotation value lines
 * @param characterOffset <tt>long</tt>, the character offset of the
 * [Values] block in <tt>annotationCacheCopy</tt>
 * @return {@link List} of {@link String} that represents the enumeration
 * data
 * @throws IOException Thrown if an IO error occurred reading the BEL
 * annotation file
 */
private List<String> parseEnumData(File annotationCacheCopy, String valueDelimiter, long characterOffset)
        throws IOException {
    List<String> enumData = new ArrayList<String>();

    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new FileReader(annotationCacheCopy));
        reader.skip(characterOffset);

        String line = "";
        while ((line = reader.readLine()) != null) {
            String[] lineTokens = StringUtils.splitByWholeSeparator(line, valueDelimiter);

            if (lineTokens != null && lineTokens.length >= 1) {
                enumData.add(lineTokens[0]);
            }
        }
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (Exception e) {
            }
        }
    }

    return enumData;
}

From source file:org.opencommercesearch.Utils.java

public static String getRangeName(String fieldName, String expression) throws ParseException {
    if (expression.startsWith("[") && expression.endsWith("]")) {
        String[] parts = StringUtils.splitByWholeSeparator(expression.substring(1, expression.length() - 1),
                " TO ");
        if (parts.length == 2) {
            String key = Utils.RESOURCE_IN_RANGE;
            if ("*".equals(parts[0])) {
                key = Utils.RESOURCE_BEFORE;
            } else if ("*".equals(parts[1])) {
                key = Utils.RESOURCE_AFTER;
            }/*from   w w w. jav  a  2s.c  o m*/
            return Utils.getRangeName(fieldName, key, parts[0], parts[1], null);
        }
    }
    return expression;
}

From source file:org.opencommercesearch.Utils.java

public static String getRangeBreadCrumb(String fieldName, String expression, String defaultCrumb)
        throws ParseException {
    if (expression.startsWith("[") && expression.endsWith("]")) {
        String[] parts = StringUtils.splitByWholeSeparator(expression.substring(1, expression.length() - 1),
                " TO ");
        if (parts.length == 2) {
            return getRangeName(fieldName, Utils.RESOURCE_CRUMB, parts[0], parts[1], defaultCrumb);
        }//from w  ww .j a  va  2 s.  co  m
    }
    return expression;
}