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:com.livinglogic.ul4.BoundStringMethodStrip.java

public static String call(String object) {
    return StringUtils.strip(object);
}

From source file:com.cognifide.cq.cqsm.core.scripts.ScriptUtils.java

public static String parseCommand(String command, Map<String, String> definitions)
        throws ActionCreationException {
    command = StringUtils.strip(command);

    Set<String> definitionNames = new HashSet<>();
    Matcher matcher = DEFINITION.matcher(command);
    while (matcher.find()) {
        String definitionName = matcher.group(1);
        definitionNames.add(definitionName);
    }/*from   w w w . ja va 2 s .c  o m*/

    for (String definitionName : definitionNames) {
        if (definitions == null) {
            throw new ActionCreationException("Definitions map is not specified");
        }
        String definitionValue = definitions.get(definitionName);
        if (definitionValue == null) {
            throw new ActionCreationException("Definition " + definitionName + " not found");
        }

        command = StringUtils.replace(command, String.format("${%s}", definitionName), definitionValue);
    }

    return command;
}

From source file:com.huasoft.entity.ErrorBean.java

/**
 * /*from www.  java  2  s .c o m*/
 * 
 * @param errorCode
 *            ?
 * @param errorDes
 *            ??
 */
public ErrorBean(String errorCode, String errorDes) {
    errorCode = StringUtils.strip(errorCode);
    errorDes = StringUtils.strip(errorDes);
    // ?jackson?json
    if (StringUtils.isEmpty(errorCode) || StringUtils.isEmpty(errorDes)) {
        this.errorCode = "99999";
        this.errorDes = "Uknow Exception";
    } else {
        this.errorCode = errorCode;
        this.errorDes = errorDes;
    }
}

From source file:com.processpuzzle.fundamental_types.domain.ParameterValue.java

public static ParameterValue parse(String definitionText)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    ParameterDefinition definition = ParameterDefinition.parse(definitionText);

    Pattern valuePattern = Pattern.compile("=([^/]+)/{0,2}");
    Matcher valueFinder = valuePattern.matcher(definitionText);
    String valueString = null;//w w  w .  ja  v a 2  s.  c o  m
    if (valueFinder.find()) {
        int valueStringLength = valueFinder.group().contains("//") ? valueFinder.group().length() - 2
                : valueFinder.group().length();
        valueString = StringUtils.strip(valueFinder.group().substring(1, valueStringLength));
    }

    Object valueObject = null;
    if (definition.getType().equals(String.class))
        valueObject = new String(valueString);
    else if (definition.getType().equals(Integer.class))
        valueObject = new Integer(valueString);
    else if (definition.getType().equals(Long.class))
        valueObject = new Long(valueString);
    else if (definition.getType().equals(Double.class))
        valueObject = new Double(valueString);

    return new ParameterValue(definition, valueObject);
}

From source file:au.edu.anu.portal.portlets.basiclti.support.CollectionsSupport.java

/**
 * Split a String to a List, based on the given delimiter, and also chomp any new lines that may be present.
 * @param str         the string/*from  w  ww .j  a v a 2 s .  c om*/
 * @param delimiter      delimiter to split on
 * @param chomp         remove new lines as well?
 * @return
 */
public static List<String> splitStringToList(String str, String delimiter, boolean chomp) {
    String[] array = StringUtils.split(str, delimiter);
    if (chomp) {
        //iterate and chomp
        for (int i = 0; i < array.length; i++) {
            array[i] = StringUtils.strip(array[i]);
        }
    }
    List<String> list = Arrays.asList(array);
    return list;
}

From source file:de.thischwa.pmcms.tool.XY.java

/**
 * Constructor to interpret to comma-separated values, e.g.: <code>1,2</code>
 * // w  w w.j a  va 2s  .c o  m
 * @param str
 */
public XY(final String str) {
    if (StringUtils.isEmpty(str))
        return;
    String tmp = StringUtils.strip(str);
    String values[] = StringUtils.split(tmp, ",");
    if (values.length != 2 && !(StringUtils.isNumeric(values[0]) && StringUtils.isNumeric(values[1])))
        throw new IllegalArgumentException("Can't interpret coordinate string!");
    setLocation(Integer.parseInt(values[0].trim()), Integer.parseInt(values[1].trim()));
}

From source file:com.htmlhifive.tools.rhino.FunctionBodyVisitor.java

@Override
public boolean visit(AstNode node) {

    if (node instanceof FunctionNode) {
        this.functionBody = (Block) ((FunctionNode) node).getBody();
        this.functionNode = (FunctionNode) node;
        functionBody.visit(new NodeVisitor() {

            @Override//from   w w  w .j  ava2 s.  c om
            public boolean visit(AstNode node) {

                if (node instanceof Word
                        && StringUtils.equals("{", StringUtils.strip(((Word) node).getValue()))) {
                    if (startWord == null) {
                        startWord = (Word) node;
                    }
                    return false;
                }
                return true;
            }
        });
        return false;
    }
    return true;
}

From source file:com.neusoft.mid.clwapi.service.advise.AdviseServiceImpl.java

/**
 * ??./*  w  ww  .ja  va2s.  c  om*/
 * 
 * @param token
 *            ?.
 * @param adviseCont
 *            ??.
 * @return ??.
 */
@Override
public Response sendTtMsg(String token, String adviseCont) {

    UserAdviseReq reqInfo = JacksonUtils.fromJsonRuntimeException(adviseCont, UserAdviseReq.class);

    if (StringUtils.isEmpty(StringUtils.strip(reqInfo.getAdviseCont()))) {
        logger.info("??");
        // ???
        throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
    } else {
        String userId = context.getHttpHeaders().getHeaderString(UserInfoKey.USR_ID);
        String enterpriseId = context.getHttpHeaders().getHeaderString(UserInfoKey.ENTERPRISE_ID);
        if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(enterpriseId)) {
            logger.info("??USER_IDENTERPRISE_ID?");
            // ???
            throw new ApplicationException(ErrorConstant.ERROR90000, Response.Status.INTERNAL_SERVER_ERROR);
        } else {
            // ????.
            adviseMapper.insertUserAdviseInfo(userId, enterpriseId, reqInfo.getAdviseCont());
            return Response.ok().header(HttpHeaders.CACHE_CONTROL, "no-store").header("Pragma", "no-cache")
                    .build();
        }
    }
}

From source file:com.adobe.acs.tools.tag_maker.tagdataconverters.impl.DefaultConverterImpl.java

@Override
public final TagData convert(final String data) {
    final String name = StringUtils.lowerCase(JcrUtil.createValidName(StringUtils.strip(data)));

    final TagData tagData = new TagData(name);

    tagData.setTitle(data);//from  ww  w.  j ava2  s .co  m

    return tagData;
}

From source file:ar.com.zauber.commons.launcher.Launcher.java

/**
 * Creates the Launcher./*from  ww  w .ja v  a 2s  . co  m*/
 *
 * @param webApplicationPath el path a la aplicacion (puede ser un war)
 * @param contextPath donde publicar
 * @param port donde publicar
 */
public Launcher(final String webApplicationPath, final String contextPath, final int port) {
    super();
    Validate.notNull(webApplicationPath);
    Validate.notNull(contextPath);
    Validate.isTrue(!StringUtils.strip(webApplicationPath).equals(""));
    Validate.isTrue(!StringUtils.strip(contextPath).equals(""));
    Validate.isTrue(port > 0);
    this.contextPath = contextPath;
    this.webApplicationPath = webApplicationPath;
    this.port = port;
}