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

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

Introduction

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

Prototype

public static String trim(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String, handling null by returning null.

Usage

From source file:com.hangum.tadpole.db.bander.cubrid.CubridExecutePlanUtils.java

/**
 * cubrid execute plan/*  w w  w .j a v a  2s . c om*/
 * 
 * @param userDB
 * @param sql
 * @return
 * @throws Exception
 */
public static String plan(UserDBDAO userDB, String sql) throws Exception {
    if (!sql.toLowerCase().startsWith("select")) {
        logger.error("[cubrid execute plan ]" + sql);
        throw new Exception("This statment not select. please check.");
    }
    Connection conn = null;
    ResultSet rs = null;
    PreparedStatement pstmt = null;

    try {
        //         Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
        //         conn = DriverManager.getConnection(userDB.getUrl(), userDB.getUsers(), userDB.getPasswd());
        //         conn.setAutoCommit(false); //     auto commit? false  .
        conn = TadpoleSQLManager.getInstance(userDB).getDataSource().getConnection();
        conn.setAutoCommit(false); //     auto commit? false  .

        sql = StringUtils.trim(sql).substring(6);
        if (logger.isDebugEnabled())
            logger.debug("[qubrid modifying query]" + sql);
        sql = "select " + RECOMPILE + sql;

        pstmt = conn.prepareStatement(sql);
        ((CUBRIDStatement) pstmt).setQueryInfo(true);
        rs = pstmt.executeQuery();

        String plan = ((CUBRIDStatement) pstmt).getQueryplan(); //  ?    .
        //         conn.commit();

        if (logger.isDebugEnabled())
            logger.debug("cubrid plan text : " + plan);

        return plan;

    } finally {
        if (rs != null)
            rs.close();
        if (pstmt != null)
            pstmt.close();
        if (conn != null)
            conn.close();
    }
}

From source file:com.hp.application.automation.tools.model.OctaneServerSettingsModel.java

@DataBoundConstructor
public OctaneServerSettingsModel(String uiLocation, String username, Secret password, String impersonatedUser) {
    this.uiLocation = StringUtils.trim(uiLocation);
    this.username = username;
    this.password = password;
    this.impersonatedUser = impersonatedUser;
}

From source file:com.taobao.tdhs.jdbc.TDHSPreparedStatement.java

public TDHSPreparedStatement(Connection connection, TDHSClient client, String db, String sql)
        throws SQLException {
    super(connection, client, db);
    if (StringUtils.isBlank(sql)) {
        throw new SQLException("sql can't be null");
    }//from w  w  w .  j  a  v a 2s  .  com
    this.sql = StringUtils.trim(sql);
    this.sqlSplited = StringUtils.splitPreserveAllTokens(this.sql, "?");
    this.parameterNumber = sqlSplited.length - 1;
}

From source file:com.adobe.acs.tools.csv.impl.Column.java

public Column(final String raw, final int index) {
    this.index = index;
    this.raw = StringUtils.trim(raw);

    String paramsStr = StringUtils.substringBetween(raw, "{{", "}}");
    String[] params = StringUtils.split(paramsStr, ":");

    if (StringUtils.isBlank(paramsStr)) {
        this.propertyName = this.getRaw();
    } else {/*  w  w w.  ja v a2  s .co  m*/
        this.propertyName = StringUtils.trim(StringUtils.substringBefore(this.getRaw(), "{{"));

        if (params.length == 2) {
            this.dataType = nameToClass(StringUtils.stripToEmpty(params[0]));
            this.multi = StringUtils.equalsIgnoreCase(StringUtils.stripToEmpty(params[1]), MULTI);
        }

        if (params.length == 1) {
            if (StringUtils.equalsIgnoreCase(MULTI, StringUtils.stripToEmpty(params[0]))) {
                this.multi = true;
            } else {
                this.dataType = nameToClass(StringUtils.stripToEmpty(params[0]));
            }
        }
    }
}

From source file:com.hp.application.automation.tools.model.SvPerformanceModelSelection.java

@DataBoundConstructor
public SvPerformanceModelSelection(SelectionType selectionType, String performanceModel) {
    this.selectionType = selectionType;
    this.performanceModel = StringUtils.trim(performanceModel);
}

From source file:com.hp.application.automation.tools.model.SvDataModelSelection.java

@DataBoundConstructor
public SvDataModelSelection(SelectionType selectionType, String dataModel) {
    this.selectionType = selectionType;
    this.dataModel = StringUtils.trim(dataModel);
}

From source file:liquibase.database.core.TrueOrFalseBooleanType.java

@Override
public String convertObjectToString(Object value, Database database) {
    if (value == null) {
        return null;
    } else if (value.toString().equalsIgnoreCase("null")) {
        return "null";
    }/*from w  w w  .j  a  v  a 2 s  . c  o  m*/

    String returnValue;
    TypeConverter converter = TypeConverterFactory.getInstance().findTypeConverter(database);
    BooleanType booleanType = converter.getBooleanType();
    if (value instanceof String) {
        String trim = StringUtils.trim((String) value);
        if ("T".equals(trim)) {
            return booleanType.getTrueBooleanValue();
        } else if ("F".equals(trim) || StringUtils.isEmpty((String) value) || "0".equals(trim)) {
            return booleanType.getFalseBooleanValue();
        } else {
            throw new UnexpectedLiquibaseException("Unknown boolean value: " + value);
        }
    } else if (value instanceof Integer) {
        if (Integer.valueOf(1).equals(value)) {
            returnValue = booleanType.getTrueBooleanValue();
        } else {
            returnValue = booleanType.getFalseBooleanValue();
        }
    } else if (value instanceof Long) {
        if (Long.valueOf(1).equals(value)) {
            returnValue = booleanType.getTrueBooleanValue();
        } else {
            returnValue = booleanType.getFalseBooleanValue();
        }
    } else if (((Boolean) value)) {
        returnValue = booleanType.getTrueBooleanValue();
    } else {
        returnValue = booleanType.getFalseBooleanValue();
    }

    return returnValue;
}

From source file:com.edgenius.wiki.render.macro.QAMacro.java

public void execute(StringBuffer buffer, MacroParameter params) throws MalformedMacroException {
    String question = StringUtils.trim(params.getContent());

    String answer = "";
    int idx = question.indexOf("\n");
    if (idx != -1) {
        answer = question.substring(idx + 1);
        question = question.substring(0, idx);
    }/*from   ww  w. j av  a  2  s.  co m*/
    //surround \n in question text - so that it can render correctly. For example, if question has table macro, then the 
    //last \n can correct separate table filter and <div>. Looks |table cell|\n</div> otherwise, </div> is treated as a part of table.
    buffer.append("<div class=\"macroQA\"><div class=\"question\">").append(question)
            .append("</div><div class=\"answer\">\n").append(answer).append("\n</div></div>");
}

From source file:com.surveypanel.web.admin.ScriptAction.java

@Override
protected Script bind() {
    Script script = new Script();
    script.setSource(StringUtils.trim(source));
    script.setName(StringUtils.trim(name));
    script.setId(id == null ? 0 : id);/*from  w  w w  .  j ava 2 s.c om*/
    script.setSurveyId(surveyId);
    return script;
}

From source file:fitnesse.wiki.WikiPageProperty.java

public void setValue(String value) {
    this.value = StringUtils.trim(value);
}