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

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

Introduction

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

Prototype

public static String[] split(String str) 

Source Link

Document

Splits the provided text into an array, using whitespace as the separator.

Usage

From source file:com.hangum.tadpole.sql.query.TadpoleSystem_SchemaHistory.java

/**
 * save schema_history /*from   w  w  w.  j a  va2  s  . c om*/
 * 
 * @param user_seq
 * @param userDB
 * @param strSQL
 */
public static SchemaHistoryDAO save(int user_seq, UserDBDAO userDB, String strSQL) {
    SchemaHistoryDAO schemaDao = new SchemaHistoryDAO();

    try {
        //
        //
        //
        String strWorkSQL = strSQL.replaceAll("(\r\n|\n|\r)", ""); // ? .
        strWorkSQL = strWorkSQL.replaceAll("\\p{Space}", " "); // ?  .
        if (logger.isDebugEnabled())
            logger.debug("[start sql]\t" + strWorkSQL);

        String[] arrSQL = StringUtils.split(strWorkSQL);
        String strWorkType = arrSQL[0];

        // object type
        String strObjecType = arrSQL[1];

        // objectId
        String strObjectId = StringUtils.remove(arrSQL[2], "(");

        if (StringUtils.equalsIgnoreCase("or", strObjecType)) {
            strObjecType = arrSQL[3];
            strObjectId = StringUtils.remove(arrSQL[4], "(");
        }

        schemaDao = new SchemaHistoryDAO();
        schemaDao.setDb_seq(userDB.getSeq());
        schemaDao.setUser_seq(user_seq);

        schemaDao.setWork_type(strWorkType);
        schemaDao.setObject_type(strObjecType);
        schemaDao.setObject_id(strObjectId);

        schemaDao.setCreate_date(new Timestamp(System.currentTimeMillis()));

        SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
        SchemaHistoryDAO schemaHistoryDao = (SchemaHistoryDAO) sqlClient.insert("sqlHistoryInsert", schemaDao); //$NON-NLS-1$

        insertResourceData(schemaHistoryDao, strSQL);
    } catch (Exception e) {
        logger.error("Schema histor save error", e);
    }

    return schemaDao;
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.server.util.TSVRenderer.java

/**
 * @return <var>value</var> with white-spaces cleaned in the same way that HTML works (all
 *         contiguous white-spaces are replaced with single space)
 *//*from   ww  w  . ja  v a  2s  . c  o m*/
private String cleanWhitespaces(String value) {
    String[] tokens = StringUtils.split(value);
    String result = StringUtils.join(tokens, " ");
    return result;
}

From source file:com.egt.core.db.util.InterpreteSqlSQLServer.java

@Override
public String getComandoExecute(String comando, int argumentos, EnumTipoResultadoSQL tipoResultado) {
    boolean retornaResultadoCompuesto = EnumTipoResultadoSQL.COMPUESTO.equals(tipoResultado);
    String execute = StringUtils.stripToNull(comando);
    String command = retornaResultadoCompuesto ? COMANDO_EXECUTE_2 : COMANDO_EXECUTE_1;
    if (execute != null) {
        String[] token = StringUtils.split(execute);
        String parametros = "()";
        if (argumentos > 0) {
            parametros = "";
            for (int i = 0; i < argumentos; i++, parametros += ",?") {
            }/*from w w  w .  j a  va2  s  .  c om*/
            parametros = "(" + parametros.substring(1) + ")";
        }
        if (!token[0].equalsIgnoreCase(COMANDO_EXECUTE_1)) {
            execute = command + " " + execute;
        }
        if (!execute.endsWith(parametros) && !execute.endsWith(";")) {
            execute += parametros;
        }
    }
    Bitacora.trace(execute);
    return execute;
}

From source file:ips1ap101.lib.core.db.util.InterpreteSqlSQLServer.java

@Override
public String getComandoExecute(String comando, int argumentos, EnumTipoResultadoSQL tipoResultado) {
    boolean retornaResultadoCompuesto = EnumTipoResultadoSQL.COMPOUND.equals(tipoResultado);
    String execute = StringUtils.stripToNull(comando);
    String command = retornaResultadoCompuesto ? COMANDO_EXECUTE_2 : COMANDO_EXECUTE_1;
    if (execute != null) {
        String[] token = StringUtils.split(execute);
        String parametros = "()";
        if (argumentos > 0) {
            parametros = "";
            for (int i = 0; i < argumentos; i++, parametros += ",?") {
            }/*from   w  w  w.j a  v  a  2 s  .c  om*/
            parametros = "(" + parametros.substring(1) + ")";
        }
        if (!token[0].equalsIgnoreCase(COMANDO_EXECUTE_1)) {
            execute = command + " " + execute;
        }
        if (!execute.endsWith(parametros) && !execute.endsWith(";")) {
            execute += parametros;
        }
    }
    Bitacora.trace(execute);
    return execute;
}

From source file:com.rapidbackend.socialutil.install.dbinstall.SQLScriptRunner.java

/** Creates a new instance of SQLScriptRunner */
public SQLScriptRunner(InputStream is) throws IOException {

    BufferedReader in = new BufferedReader(new InputStreamReader(is));
    String command = "";
    String line;/*  w w w .  j a  va  2 s  . co  m*/
    while ((line = in.readLine()) != null) {
        line = line.trim();

        if (!line.startsWith("--")) { // ignore lines starting with "--"    

            if (line.indexOf("--") > 0) {
                // trim comment off end of line
                line = line.substring(0, line.indexOf("--")).trim();
            }

            // add line to current command
            command += line.trim();
            if (command.endsWith(";")) {
                // ";" is end of command, so add completed command to list
                String cmd = command.substring(0, command.length() - 1);
                String[] cmdArray = StringUtils.split(cmd);
                cmd = StringUtils.join(cmdArray, " ");
                commands.add(cmd);
                command = "";
            } else if (StringUtils.isNotEmpty(command)) {
                command += " "; // still more command coming so add space
            }
        }
    }
    in.close();
}

From source file:com.senacor.wbs.web.user.UserAdminPage.java

public UserAdminPage() {
    SearchUserPanel searchUserPanel = new SearchUserPanel(middleColumn.getListPanel().newChildId()) {
        @Override//w ww.  j a va  2  s  .  c  o m
        protected void doSearch(final AjaxRequestTarget target, final User userCriteria) {
            // foundUser = userManager.find(userCriteria);
            // Workaround bis userManager.find(userCriteria)
            // funktioniert
            userListPanel.setCurrentPage(0);
            foundUser.clear();
            for (User user : userManager.findAll()) {
                if (startsWith(user.getVorname(), userCriteria.getVorname())
                        && startsWith(user.getName(), userCriteria.getName())
                        && startsWith(user.getUsername(), userCriteria.getUsername())) {
                    foundUser.add(user);
                }
            }
            target.addComponent(userListPanel);
        }

        @Override
        protected Iterator<User> doGetChoices(final String input) {
            if (StringUtils.isBlank(input)) {
                return new ArrayList<User>().iterator();
            } else {
                String stripped = input.replaceAll("\\(|\\)", "");
                String[] inputParts = StringUtils.split(stripped);
                String criteria = StringUtils.join(inputParts, "* ");
                criteria = criteria + "*";
                System.out.println("criteria: " + criteria);
                List<User> userList = userManager.findPerIndex(criteria);
                return userList.iterator();
            }
        }
    };
    middleColumn.getListPanel().add(searchUserPanel);
    IModel userDataModel = new AbstractReadOnlyModel() {
        @Override
        public Object getObject() {
            return foundUser;
        }
    };
    userListPanel = new UserListPanel(middleColumn.getListPanel().newChildId(),
            new UserDataSource(userDataModel));
    userListPanel.setOutputMarkupId(true);
    userListPanel.setRenderBodyOnly(false);
    middleColumn.getListPanel().add(userListPanel);
}

From source file:barrysw19.calculon.uci.UCIInterface.java

private void startInterface() throws IOException {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    String command;//w w w.  j  a  va 2s.c  o  m
    while ((command = input.readLine()) != null) {
        log.fine("UCI(in): '" + command + "'");
        List<String> splitCommand = new ArrayList<String>(Arrays.asList(StringUtils.split(command)));
        if (splitCommand.size() == 0) {
            log.warning("Empty command received from interface");
            continue;
        }
        Command exec = commands.get(splitCommand.get(0));
        if (exec == null) {
            log.warning("Unknown/unsupported command: " + command);
            continue;
        }
        splitCommand.remove(0);
        exec.execute(splitCommand);
        if (terminate) {
            break;
        }
    }
}

From source file:com.davis.ddf.crs.utils.CheckUtil.java

public static List<CRSEndpointResponse> checkForResults(Date start, Date end, String bottomRight,
        String topLeft, String queryString, Map<String, CRSEndpointResponse> cannedResponses) {
    List<CRSEndpointResponse> result = new ArrayList<>();
    String latSegments[] = StringUtils.split(topLeft);
    String lngSegments[] = StringUtils.split(bottomRight);
    double topLeftLat = Double.parseDouble(latSegments[0]);

    double topLeftLng = Double.parseDouble(latSegments[1]);

    double bottomRightLat = Double.parseDouble(lngSegments[0]);

    double bottomRightLng = Double.parseDouble(lngSegments[1]);

    for (CRSEndpointResponse e : cannedResponses.values()) {
        if (checkResultForMatching(topLeftLat, topLeftLng, bottomRightLat, bottomRightLng, queryString, start,
                end, e)) {//from   ww w  .j a va 2 s  .  c o m
            result.add(e);
        }
    }

    return result;
}

From source file:gov.nih.nci.cabig.caaers.accesscontrol.filter.query.QuerySecurityFilterer.java

/**
 * Will take care of applying the filter.
 * Obtain the base query, then replace the base entity and its alias with "index name" and "index alias"
 * then issue couple of joins with the entity.
 * /*www .j  ava 2 s.  co  m*/
 * @param query
 */
public void applyFilter(AbstractQuery query) {
    /*
    Note :-
    "select p from Participant p, ParticipantIndex i where p = i.participant" takes longer time
    compared to "select p from ParticipantIndex i join i.participant p".
    */

    String hql = query.getBaseQueryString();
    String[] hqlElements = StringUtils.split(hql);

    int etIndex = ArrayUtils.indexOf(hqlElements, entityName);
    if (etIndex <= 0 && hqlElements.length <= etIndex) {
        log.warn("Query [" + query.getClass().getName() + "] is incorrectly framed [" + hql + "]");
        throw new IllegalArgumentException("The query supplied for index filtering " + "["
                + query.getClass().getName() + "], do not follow the conventions");
    }

    String entityAlias = hqlElements[etIndex + 1];

    //replace the base query after replacing the entity and its alias with equivalent indexName and indexAlias
    hqlElements[etIndex] = indexName;
    hqlElements[etIndex + 1] = indexAlias;

    String newQuery = StringUtils.join(hqlElements, " ");
    query.modifyQueryString(newQuery);

    //issue joins with index and extra conditions.

    // the index alias join should be joined at the beginning
    query.joinAtTheBeginningOfList(getIndexAlias() + "." + getEntityAssociation() + " " + entityAlias);
    query.andWhere(getIndexAlias() + ".loginId = :loginId");
    query.andWhere("bitand(" + getIndexAlias() + ".role, " + getRole() + ") > 0");
    query.setParameter("loginId", getLoginId());
    query.setFiltered(true);
}

From source file:com.hangum.tadpole.engine.query.sql.TadpoleSystem_SchemaHistory.java

/**
 * save schema_history //from w ww  .  ja  v  a  2  s .  c o  m
 * 
 * @param user_seq
 * @param userDB
 * @param strSQL
 */
public static SchemaHistoryDAO save(int user_seq, UserDBDAO userDB, String strSQL) {
    SchemaHistoryDAO schemaDao = new SchemaHistoryDAO();

    try {
        //
        //
        //
        String strWorkSQL = strSQL.replaceAll("(\r\n|\n|\r)", ""); // ? .
        strWorkSQL = strWorkSQL.replaceAll("\\p{Space}", " "); // ?  .
        if (logger.isDebugEnabled())
            logger.debug("[start sql]\t" + strWorkSQL);

        String[] arrSQL = StringUtils.split(strWorkSQL);
        if (arrSQL.length != 5)
            return null;
        String strWorkType = arrSQL[0];

        // object type
        String strObjecType = arrSQL[1];

        // objectId
        String strObjectId = StringUtils.remove(arrSQL[2], "(");

        if (StringUtils.equalsIgnoreCase("or", strObjecType)) {
            strObjecType = arrSQL[3];
            strObjectId = StringUtils.remove(arrSQL[4], "(");
        }

        schemaDao = new SchemaHistoryDAO();
        schemaDao.setDb_seq(userDB.getSeq());
        schemaDao.setUser_seq(user_seq);

        schemaDao.setWork_type(strWorkType);
        schemaDao.setObject_type(strObjecType);
        schemaDao.setObject_id(strObjectId);

        schemaDao.setCreate_date(new Timestamp(System.currentTimeMillis()));

        schemaDao.setIpaddress(RWT.getRequest().getRemoteAddr());

        SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
        SchemaHistoryDAO schemaHistoryDao = (SchemaHistoryDAO) sqlClient.insert("sqlHistoryInsert", schemaDao); //$NON-NLS-1$

        insertResourceData(schemaHistoryDao, strSQL);
    } catch (Exception e) {
        logger.error("Schema histor save error", e);
    }

    return schemaDao;
}