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

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

Introduction

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

Prototype

public static String strip(String str) 

Source Link

Document

Strips whitespace from the start and end of a String.

Usage

From source file:org.kuali.kpme.pm.util.QualifierValueKeyValueFinder.java

@Override
public List<KeyValue> getKeyValues(ViewModel model, InputField field) {

    MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
    HrBusinessObject anHrObject = (HrBusinessObject) docForm.getDocument().getNewMaintainableObject()
            .getDataObject();/*from  w  ww.  j a  v  a  2 s.  c  o  m*/
    List<KeyValue> options = new ArrayList<KeyValue>();

    if (field.getId().contains("add")) {
        // For "add" line, just delegate to getKeyValues(model) method as it is working correctly
        options = getKeyValues(model);
    } else {
        // Strip index off field id
        String fieldId = field.getId();
        int line_index = fieldId.indexOf("line");
        int index = Integer.parseInt(fieldId.substring(line_index + 4));

        ClassificationBo aClass = (ClassificationBo) anHrObject;
        List<ClassificationQualificationBo> qualificationList = aClass.getQualificationList(); // holds "added" lines
        ClassificationQualificationBo aQualification = (ClassificationQualificationBo) qualificationList
                .get(index);

        if (aQualification != null) {
            String aTypeId = aQualification.getQualificationType();
            PstnQlfrTypeContract aTypeObj = PmServiceLocator.getPstnQlfrTypeService()
                    .getPstnQlfrTypeById(aTypeId);
            ;
            if (aTypeObj != null) {
                if (aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)) {
                    String[] aCol = aTypeObj.getSelectValues().split(",");
                    for (String aString : aCol) {
                        aString = StringUtils.strip(aString);
                        options.add(new ConcreteKeyValue(aString, aString));
                    }
                } else {
                    return new ArrayList<KeyValue>();
                }
            }
        }
    }

    return options;

}

From source file:org.kuali.ole.fp.businessobject.lookup.DisbursementPayeeLookupableHelperServiceImpl.java

/**
 * Splits the last name from the specified payeeName, which is in the format of "lastName,firstName".
 * If comma doesn't exist in the name, then the whole string is returned;
 *//*from w w w . j ava2  s .c  o m*/
protected String splitLastName(String payeeName) {
    return StringUtils.strip(StringUtils.substringBefore(payeeName, OLEConstants.COMMA));
}

From source file:org.kuali.ole.fp.businessobject.lookup.DisbursementPayeeLookupableHelperServiceImpl.java

/**
 * Splits the first name from the specified payeeName, which is in the format of "lastName,firstName".
 * If comma doesn't exist in the name, then an empty string is returned.
 *//*  www. j  a v  a2  s  .  c o  m*/
protected String splitFirstName(String payeeName) {
    return StringUtils.strip(StringUtils.substringAfter(payeeName, OLEConstants.COMMA));
}

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

/**
 * Convert a string to a javascript value - especially for use for options used to initialize
 * widgets such as the tree and rich table
 * /*from w ww.j  a  va 2  s .c o m*/
 * @param value the string to be converted
 * @return the converted value
 */
public static String convertToJsValue(String value) {

    // save input value to preserve any whitespace formatting
    String originalValue = value;

    // remove whitespace for correct string matching
    value = StringUtils.strip(value);

    // If an option value starts with { or [, it would be a nested value
    // and it should not use quotes around it
    if (StringUtils.startsWith(value, "{") || StringUtils.startsWith(value, "[")) {
        return originalValue;
    }
    // need to be the base boolean value "false" is true in js - a non
    // empty string
    else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("true")) {
        return originalValue.toLowerCase();
    }
    // if it is a call back function, do not add the quotes
    else if (StringUtils.startsWith(value, "function") && StringUtils.endsWith(value, "}")) {
        return originalValue;
    }
    // for numerics
    else if (NumberUtils.isNumber(value)) {
        return originalValue;
    } else {
        // String values require double quotes
        return "\"" + originalValue + "\"";
    }
}

From source file:org.ldmud.jldmud.GameConfiguration.java

/**
 * Load the given properties and validate them.
 *
 * @param properties The properties file read from the input source.
 * @param overrideProperties A manually created set of properties, overriding those in the properties file.
 * @param propertyList The list of property instances to load the values into.
 * @return A list of errors, if any property value failed to validate.
 *///from  ww  w  .  ja  v a2 s.  c o  m
List<String> loadProperties(Properties properties, Properties overrideProperties,
        List<SettingBase<?>> propertyList) {
    List<String> errors = new ArrayList<>();

    for (SettingBase<?> entry : propertyList) {
        String value = overrideProperties.containsKey(entry.name) ? overrideProperties.getProperty(entry.name)
                : properties.getProperty(entry.name);
        String error = null;
        if (value != null) {
            error = entry.parseValue(StringUtils.strip(value));
        }
        if (StringUtils.isEmpty(error) && entry.value == null && entry.required) {
            error = "Setting is required.";
        }
        if (!StringUtils.isEmpty(error)) {
            errors.add("Setting '" + entry.name + "': " + error);
        }
    }
    return errors;
}

From source file:org.metaabm.act.provider.AActItemProvider.java

protected String suggestSeperatedSourceLabel(Object object, String seperator) {
    AAct source = (AAct) object;/*w w  w .  j a v  a 2s. c  o m*/
    EList<AAct> sources = source.getSources();
    String label;
    switch (sources.size()) {
    case 0:
        label = seperator + " Undefined";
        break;
    case 1:
        label = "(" + seperator + ") " + StringUtils.strip(sources.get(0).getLabel());
        break;
    default:
        label = "(" + StringUtils.join(labels(sources).iterator(), " " + seperator + " ") + ")";
    }
    // if (source.getSelected() != null && source.getSelected().getLabel() != null) {
    // String selLabel = source.getSelected().getLabel();
    // label = selLabel + " " + label.replace(selLabel + ": ", "");
    // }
    return label;
}

From source file:org.metaabm.act.provider.ALogicItemProvider.java

/**
 * This returns the label text for the adapted class. <!-- begin-user-doc
 * --> <!-- end-user-doc -->//  w  w  w .ja v a 2s . co  m
 * 
 * @generated NOT
 */
@Override
public String getText(Object object) {
    Collection<?> texts = texts(((ALogic) object).getSources());
    String strip = StringUtils.strip(StringUtils.join(texts.iterator(), ", "));
    return texts.size() > 1 ? "(" + strip + ")" : strip;
}

From source file:org.mili.core.resource.ResourceUtilImpl.java

private void cacheText(Resources r, Locale locale, String baseName) {
    List<Text> l = r.getText();
    Map<String, String> resMap = getResourceMap(baseName, locale);
    for (int i = 0, n = l.size(); i < n; i++) {
        Object o = l.get(i);// w  w  w .java 2s  . com
        if (o instanceof Text) {
            Text t = (Text) o;
            resMap.put(t.getName(), StringUtils.strip(t.getContent().toString().trim()));
        }
    }
}

From source file:org.ojbc.intermediaries.sn.notification.NotificationRequest.java

public NotificationRequest(Document document) throws Exception {

    this.requestDocument = document;

    String notificationEventDateTimeString = XmlUtils.xPathStringSearch(document,
            getNotificationEventDateRootXpath() + "/nc:DateTime");
    String notificationEventDateOnlyString = XmlUtils.xPathStringSearch(document,
            getNotificationEventDateRootXpath() + "/nc:Date");

    if (StringUtils.isNotEmpty(notificationEventDateTimeString)) {
        notificationEventDate = XmlUtils.parseXmlDateTime(notificationEventDateTimeString);
        isNotificationEventDateInclusiveOfTime = true;
    } else if (StringUtils.isNotEmpty(notificationEventDateOnlyString)) {
        notificationEventDate = XmlUtils.parseXmlDate(notificationEventDateOnlyString);
        isNotificationEventDateInclusiveOfTime = false;
    } else {// w  ww.  j ava2s  .c  o m
        notificationEventDate = null;
    }

    personActivityInvolvementText = XmlUtils.xPathStringSearch(document,
            "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/nc:ActivityInvolvedPersonAssociation/nc:PersonActivityInvolvementText");

    String personReference = XmlUtils.xPathStringSearch(document,
            "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/nc:ActivityInvolvedPersonAssociation/nc:PersonReference/@s:ref");

    if (StringUtils.isNotBlank(personReference)) {
        personFirstName = StringUtils.strip(XmlUtils.xPathStringSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/jxdm41:Person[@s:id='"
                        + personReference + "']/nc:PersonName/nc:PersonGivenName"));
        personMiddleName = StringUtils.strip(XmlUtils.xPathStringSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/jxdm41:Person[@s:id='"
                        + personReference + "']/nc:PersonName/nc:PersonMiddleName"));
        personLastName = StringUtils.strip(XmlUtils.xPathStringSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/jxdm41:Person[@s:id='"
                        + personReference + "']/nc:PersonName/nc:PersonSurName"));
        personNameSuffix = StringUtils.strip(XmlUtils.xPathStringSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/jxdm41:Person[@s:id='"
                        + personReference + "']/nc:PersonName/nc:PersonNameSuffixText"));
        personBirthDate = StringUtils.strip(XmlUtils.xPathStringSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/jxdm41:Person[@s:id='"
                        + personReference + "']/nc:PersonBirthDate/nc:Date"));

        try {
            personAge = NotificationBrokerUtils.calculatePersonAgeFromDate(personBirthDate);
        } catch (Exception ex) {
            log.error("Unable to calculate person age.");
        }

        NodeList aliasNodes = XmlUtils.xPathNodeListSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/jxdm41:Person[@s:id='"
                        + personReference + "']/nc:PersonAlternateName");

        if (aliasNodes != null && aliasNodes.getLength() > 0) {
            for (int i = 0; i < aliasNodes.getLength(); i++) {
                if (aliasNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {

                    Element aliasElement = (Element) aliasNodes.item(i);

                    Alias alias = new Alias();

                    alias.setPersonFirstName(
                            StringUtils.strip(XmlUtils.xPathStringSearch(aliasElement, "nc:PersonGivenName")));
                    alias.setPersonLastName(
                            StringUtils.strip(XmlUtils.xPathStringSearch(aliasElement, "nc:PersonSurName")));

                    aliases.add(alias);

                }
            }
        }

        String personContactInfoReference = XmlUtils.xPathStringSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/nc:PersonContactInformationAssociation/nc:ContactInformationReference/@s:ref");

        NodeList telephoneNumberNodes = XmlUtils.xPathNodeListSearch(document,
                "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage//nc:ContactInformation[@s:id='"
                        + personContactInfoReference
                        + "']/nc:ContactTelephoneNumber/nc:FullTelephoneNumber/nc:TelephoneNumberFullID");

        if (telephoneNumberNodes != null && telephoneNumberNodes.getLength() > 0) {
            for (int i = 0; i < telephoneNumberNodes.getLength(); i++) {
                if (telephoneNumberNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {

                    if (StringUtils.isNotBlank(telephoneNumberNodes.item(i).getTextContent())) {
                        personTelephoneNumbers
                                .add(StringUtils.strip(telephoneNumberNodes.item(i).getTextContent()));
                    }
                }
            }
        }

    } else {
        log.error("Unable to find person reference. Unable to XQuery for person name.");
    }

    NodeList officerReferences = XmlUtils.xPathNodeListSearch(document, getOfficerNameReferenceXPath());

    if (officerReferences != null && officerReferences.getLength() > 0) {
        for (int i = 0; i < officerReferences.getLength(); i++) {
            if (officerReferences.item(i).getNodeType() == Node.ATTRIBUTE_NODE) {

                String officerReference = officerReferences.item(i).getTextContent();
                String officerName = XmlUtils.xPathStringSearch(document,
                        "/b-2:Notify/b-2:NotificationMessage/b-2:Message/notfm-exch:NotificationMessage/jxdm41:Person[@s:id='"
                                + officerReference + "']/nc:PersonName/nc:PersonFullName");

                if (StringUtils.isNotEmpty(officerName)) {
                    officerNames.add(StringUtils.strip(officerName));
                }
            }
        }
    }

    notificationEventIdentifier = XmlUtils.xPathStringSearch(document, getNotificationEventIdentifierXpath());
    notificationEventIdentifier = StringUtils.strip(notificationEventIdentifier);

    notifyingAgencyName = XmlUtils.xPathStringSearch(document, getNotifyingAgencyXpath());
    notifyingAgencyName = StringUtils.strip(notifyingAgencyName);

    notifyingAgencyOri = StringUtils
            .trimToNull(XmlUtils.xPathStringSearch(document, getNotifyingAgencyOriXpath()));

    notifyingAgencyPhoneNumber = XmlUtils.xPathStringSearch(document, getNotificationAgencyPhoneNumberXpath());
    notifyingAgencyPhoneNumber = StringUtils.strip(notifyingAgencyPhoneNumber);

    notifyingSystemName = XmlUtils.xPathStringSearch(document, getNotifyingSystemNameXPath());
    notifyingSystemName = StringUtils.strip(notifyingSystemName);

    // subjectIdentification intentionally omitted - should be populated in subclass

    Node topicNode = XmlUtils.xPathNodeSearch(document, "/b-2:Notify/b-2:NotificationMessage/b-2:Topic");
    String unqualifiedTopic = topicNode.getTextContent();
    topic = NotificationBrokerUtils.getFullyQualifiedTopic(unqualifiedTopic);

}

From source file:org.ojbc.intermediaries.sn.topic.chcycle.ChCycleNotificationRequest.java

public String getPersonFullName() {
    String personFirstName = StringUtils.strip(getPersonFirstName());
    String personLastName = StringUtils.strip(getPersonLastName());
    return personFirstName + " " + personLastName;
}