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.microsoft.azure.vmagent.test.ITAzureVMManagementServiceDelegate.java

private void uploadCustomScript(String uploadFileName, String writtenData) {

    AzureVMAgentTemplate templateMock = mock(AzureVMAgentTemplate.class);
    when(templateMock.getStorageAccountName()).thenReturn(testEnv.azureStorageAccountName);
    when(templateMock.getResourceGroupName()).thenReturn(testEnv.azureResourceGroup);
    when(templateMock.getLocation()).thenReturn(testEnv.azureLocation);
    when(templateMock.getInitScript()).thenReturn(writtenData);
    when(templateMock.getStorageAccountType()).thenReturn(SkuName.STANDARD_LRS.toString());

    try {/* w ww. j  a  v  a2 s .co m*/
        delegate.uploadCustomScript(templateMock, uploadFileName);

        final String downloadedData = downloadFromAzure(testEnv.azureResourceGroup,
                testEnv.azureStorageAccountName, Constants.CONFIG_CONTAINER_NAME, uploadFileName);
        /*Data padded before upload to Page Blob so we need to use strip*/
        Assert.assertEquals(StringUtils.strip(writtenData), StringUtils.strip(downloadedData));
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, null, e);
        Assert.assertTrue(e.getMessage(), false);
    }
}

From source file:com.predic8.membrane.core.util.TextUtil.java

public static String removeCommonLeadingIndentation(String src) {
    // TODO: only handles tabs at the moment
    String lines[] = src.split("\n");
    int indent = Integer.MAX_VALUE;
    for (String line : lines) {
        if (StringUtils.strip(line).length() == 0)
            continue;
        int i = 0;
        while (i < line.length() && line.charAt(i) == '\t')
            i++;//from   w ww  . j  a va 2s.  c o  m
        indent = Math.min(indent, i);
    }
    if (indent == 0 || indent == Integer.MAX_VALUE)
        return src;
    for (int i = 0; i < lines.length; i++)
        lines[i] = lines[i].length() > indent ? lines[i].substring(indent) : "";
    return StringUtils.join(lines, '\n');
}

From source file:com.sic.bb.jenkins.plugins.sicci_for_xcode.io.OCUnitOutputParser.java

private boolean matchTestCaseStarted(String line) {
    Matcher matcher = testCaseStarted.matcher(line);

    if (!matcher.matches())
        return false;

    OCUnitTestSuite lastTestSuite = this.testSuites.lastElement();

    if (!matcher.group(1).contains(lastTestSuite.getTestSuiteName()))
        return false;

    String testCaseName = StringUtils
            .strip(StringUtils.substringAfter(matcher.group(1), lastTestSuite.getTestSuiteName()));

    this.testSuites.lastElement().addTestCase(new OCUnitTestCase(testCaseName));

    return true;//ww w  .  j a  va 2  s  .c  om
}

From source file:edu.ku.brc.af.core.expresssearch.ExpressResultsTableInfo.java

/**
 * Fill the current object with the info from the DOM depending on the LOAD_TYPE
 * @param tableElement the DOM4J element used to fill the object
 *//*from w  ww  .  j av a  2s.c  o  m*/
public void fill(final Element tableElement, final ResourceBundle resBundle) {
    id = tableElement.attributeValue("id"); //$NON-NLS-1$
    tableId = tableElement.attributeValue("tableid"); //$NON-NLS-1$
    name = tableElement.attributeValue("name"); //$NON-NLS-1$
    color = UIHelper.parseRGB(tableElement.attributeValue("color")); //$NON-NLS-1$

    if (isExpressSearch) {
        title = resBundle.getString(name);
        if (StringUtils.isEmpty(title)) {
            log.error("Express Search with name[" + name //$NON-NLS-1$
                    + "] is missing it's title in the expressearch properties file."); //$NON-NLS-1$
        }
        description = resBundle.getString(name + "_desc"); //$NON-NLS-1$
        if (StringUtils.isEmpty(description)) {
            log.error("Express Search with name[" + name //$NON-NLS-1$
                    + "] is missing it's description in the expressearch properties file."); //$NON-NLS-1$
        }
    } else {
        DBTableInfo tblInfo = getTableInfo();
        if (tblInfo != null) {
            title = tblInfo.getTitle();
        }
    }

    if (StringUtils.isEmpty(title)) {
        title = getResourceString("ExpressResultsTableInfo.NOTITLE"); // XXX This should never happen! //$NON-NLS-1$
    }

    Element viewElement = (Element) tableElement.selectSingleNode("detailView"); //$NON-NLS-1$
    Element sqlElement = (Element) viewElement.selectSingleNode("sql"); //$NON-NLS-1$

    isFieldNameOnlyForSQL = getAttr(sqlElement, "fieldnameonly", false); //$NON-NLS-1$
    viewSql = StringUtils.strip(sqlElement.getText());
    iconName = viewElement.attributeValue("icon"); //$NON-NLS-1$

    List<?> captionItems = viewElement.selectNodes("captions/caption"); //$NON-NLS-1$
    if (captionItems.size() > 0) {
        int captionCount = captionItems.size();
        captionInfo = new Vector<ERTICaptionInfo>(captionCount);
        int i = 0;
        for (Iterator<?> capIter = captionItems.iterator(); capIter.hasNext();) {
            Element captionElement = (Element) capIter.next();
            ERTICaptionInfo capInfo = new ERTICaptionInfo(captionElement, resBundle);

            if (capInfo.isVisible()) {
                captionInfo.add(capInfo);
                capInfo.setPosIndex(i);
                if (capInfo.getColName() == null && capInfo.getColInfoList().size() > 0) {
                    i += capInfo.getColInfoList().size() - 1;
                }
            } else {
                capInfo.setPosIndex(-1);
            }
            i++;
        }

        if (captionInfo.size() != captionCount) {
            // Create mappings of visible items
            visibleCaptionInfo = new Vector<ERTICaptionInfo>(captionInfo.size());
            for (ERTICaptionInfo c : captionInfo) {
                visibleCaptionInfo.add(c);
            }
        }

    } else {
        throw new RuntimeException("No Captions!"); //$NON-NLS-1$
    }

    List<?> joinColItems = tableElement.selectNodes("joins/join"); //$NON-NLS-1$
    if (joinColItems != null && joinColItems.size() > 0) {
        joinCols = new ERTIJoinColInfo[joinColItems.size()];
        for (int i = 0; i < joinColItems.size(); i++) {
            joinCols[i] = new ERTIJoinColInfo((Element) joinColItems.get(i));
        }
    }
}

From source file:com.github.amsacode.predict4java.TLE.java

/**
 * Constructor.// w w w .j a v  a 2  s .com
 *
 * @param tle the three line elements
 * @throws IllegalArgumentException here was something wrong with the TLE
 */
public TLE(final String[] tle) throws IllegalArgumentException {
    {
        if (null == tle) {
            throw new IllegalArgumentException("TLE was null");
        }

        if (tle.length != THREELINES) {
            throw new IllegalArgumentException("TLE had " + tle.length + " elements");
        }

        int lineCount = 0;

        for (final String line : tle) {

            testArguments(lineCount, line);

            lineCount++;
        }

        catnum = Integer.parseInt(StringUtils.strip(tle[1].substring(2, 7)));
        name = tle[0].trim();
        setnum = Integer.parseInt(StringUtils.strip(tle[1].substring(64, 68)));
        year = Integer.parseInt(StringUtils.strip(tle[1].substring(18, 20)));
        refepoch = Double.parseDouble(tle[1].substring(20, 32));
        incl = Double.parseDouble(tle[2].substring(8, 16));
        raan = Double.parseDouble(tle[2].substring(17, 25));
        eccn = 1.0e-07 * Double.parseDouble(tle[2].substring(26, 33));
        argper = Double.parseDouble(tle[2].substring(34, 42));
        meanan = Double.parseDouble(tle[2].substring(43, 51));
        meanmo = Double.parseDouble(tle[2].substring(52, 63));
        drag = Double.parseDouble(tle[1].substring(33, 43));

        double tempnum = 1.0e-5 * Double.parseDouble(tle[1].substring(44, 50));
        nddot6 = tempnum / Math.pow(10.0, Double.parseDouble(tle[1].substring(51, 52)));

        tempnum = 1.0e-5 * Double.parseDouble(tle[1].substring(53, 59));

        bstar = tempnum / Math.pow(10.0, Double.parseDouble(tle[1].substring(60, 61)));

        orbitnum = Integer.parseInt(StringUtils.strip(tle[2].substring(63, 68)));

        /* reassign the values to thse which get used in calculations */
        epoch = (1000.0 * getYear()) + getRefepoch();

        double temp = incl;
        temp *= DEG2RAD;
        xincl = temp;

        temp = raan;
        temp *= DEG2RAD;
        xnodeo = temp;

        eo = eccn;

        temp = argper;
        temp *= DEG2RAD;
        omegao = temp;

        temp = meanan;
        temp *= DEG2RAD;
        xmo = temp;

    }

    /* Preprocess tle set */
    {
        double temp;
        temp = TWO_PI / MINS_PERDAY / MINS_PERDAY;
        xno = meanmo * temp * MINS_PERDAY;
        xndt2o = drag * temp;

        double dd1 = XKE / xno;
        final double a1 = Math.pow(dd1, TWO_THIRDS);
        final double r1 = Math.cos(xincl);
        dd1 = 1.0 - eo * eo;
        temp = CK2 * 1.5f * (r1 * r1 * 3.0 - 1.0) / Math.pow(dd1, 1.5);
        final double del1 = temp / (a1 * a1);
        final double ao = a1 * (1.0 - del1 * (TWO_THIRDS * .5 + del1 * (del1 * 1.654320987654321 + 1.0)));
        final double delo = temp / (ao * ao);
        final double xnodp = xno / (delo + 1.0);

        /* Select a deep-space/near-earth ephemeris */

        deepspace = TWO_PI / xnodp / MINS_PERDAY >= 0.15625;
    }

}

From source file:com.haulmont.cuba.core.global.QueryParserAstBased.java

@Override
public String getEntityAlias() {
    IdentificationVariableNode mainEntityIdentification = getQueryAnalyzer().getMainEntityIdentification();
    if (mainEntityIdentification != null) {
        return mainEntityIdentification.getVariableName();
    }/*w w w  .  ja  va2s.  c o  m*/
    throw new RuntimeException(format("Unable to find entity alias [%s]", StringUtils.strip(query)));
}

From source file:com.netflix.dynomitemanager.sidecore.AbstractConfigSource.java

private List<String> getTrimmedStringList(String[] strings) {
    List<String> list = Lists.newArrayList();
    for (String s : strings) {
        list.add(StringUtils.strip(s));
    }//from  w  ww.  jav a2s. c o m
    return list;
}

From source file:com.neusoft.mid.clwapi.service.usr.UsrServiceImpl.java

/**
 * ??.//ww  w  .  ja v a 2s. c  o m
 * 
 * @param behaviorInfo
 *            ?.
 * @return .
 */
@Override
public Response behavior(String token, String behaviorInfo) {
    logger.info("???");

    // ?
    UserBehavior userBehavior = JacksonUtils.fromJsonRuntimeException(behaviorInfo, UserBehavior.class);
    // ???
    if (null != userBehavior) {
        // ????
        if (StringUtils.isEmpty(StringUtils.strip(userBehavior.getModuleId()))
                || StringUtils.isEmpty(StringUtils.strip(userBehavior.getModuleSonId()))) {
            logger.error("??[?]?");
            // ???
            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 {
                userBehavior.setUsrId(userId);
                userBehavior.setEntrepriseId(enterpriseId);
                // ???
                usrMapper.insertUserBehavior(userBehavior);
                return Response.ok().build();
            }
        }
    } else {
        logger.error("???");
        throw new ApplicationException(ErrorConstant.ERROR10001, Response.Status.BAD_REQUEST);
    }

}

From source file:io.seldon.dbcp.DbcpFactory.java

@Override
public void configUpdated(String configKey, String configValue) {
    configValue = StringUtils.strip(configValue);
    logger.info("KEY WAS " + configKey);
    logger.info("Received new dbcp settings: " + configValue);

    if (StringUtils.length(configValue) == 0) {
        logger.warn("*WARNING* no dbcp is set!");
    } else {/*from  www  . j av  a  2s.com*/
        try {
            logger.info("Processing configs " + configValue);
            ObjectMapper mapper = new ObjectMapper();
            DbcpConfigList configs = mapper.readValue(configValue, DbcpConfigList.class);
            if (configs != null && configs.dbs != null) {
                for (DbcpConfig config : configs.dbs)
                    createDbcp(config);
            }
            updateInitialised();
            logger.info("Successfully set dbcp.");
        } catch (IOException e) {
            logger.error("Problem changing dbcp ", e);
        }
    }

    if (dataSources.size() == 0) {
        logger.error(
                "No DBCP settings. Seldon will not run without a database connection. Please add settings to /config/dbcp");
        throw new DbcpUninitialisedException();
    }
}

From source file:com.neusoft.mid.clwapi.service.oauth.OauthServiceImpl.java

/**
 * ???./*from  ww w . ja v a  2 s .  c  o m*/
 * 
 * @param token
 *            ?.
 * @param clientid
 *            .
 * @return ????.
 */
@Override
public Response pushMsgBinding(String token, String reqCont) {
    logger.info("?????");

    MobileBindingInfo bindInfo = JacksonUtils.fromJsonRuntimeException(reqCont, MobileBindingInfo.class);

    if (null == bindInfo || StringUtils.isEmpty(StringUtils.strip(bindInfo.getClientid()))) {
        logger.info("?clientid");
        return Response.status(Response.Status.BAD_REQUEST).entity(ErrorConstant.ERROR10002.toJson())
                .header("Content-Type", "application/json;charset=UTF-8").build();
    } else {
        logger.info("?clientid:" + bindInfo.getClientid());
        String userId = context.getHttpHeaders().getHeaderString(UserInfoKey.USR_ID);
        if (CheckRequestParam.isEmpty(userId)) {
            logger.error("?ID?");
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
                    .entity(ErrorConstant.ERROR90000.toJson())
                    .header("Content-Type", "application/json;charset=UTF-8").build();
        }
        DeliverMsgResult result = sendDeliverMsgService.sendMobileInfoToCoreService(userId,
                bindInfo.getClientid());

        if (null != result && "0".equals(result.getCode())) {
            logger.info("?????");
            return Response.ok().header(HttpHeaders.CACHE_CONTROL, "no-store").header("Pragma", "no-cache")
                    .build();
        } else {
            logger.info("??");
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
                    .entity(ErrorConstant.ERROR90000.toJson())
                    .header("Content-Type", "application/json;charset=UTF-8").build();
        }
    }

}