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

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

Introduction

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

Prototype

public static String[] splitPreserveAllTokens(String str, String separatorChars) 

Source Link

Document

Splits the provided text into an array, separators specified, preserving all tokens, including empty tokens created by adjacent separators.

Usage

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   ww w . jav a 2  s.c  o  m*/
    this.sql = StringUtils.trim(sql);
    this.sqlSplited = StringUtils.splitPreserveAllTokens(this.sql, "?");
    this.parameterNumber = sqlSplited.length - 1;
}

From source file:com.npower.unicom.sync.firmware.FirmwareFileSyncItemReader.java

@Override
protected SyncItem parse(String line) throws ParseException {
    FirmwareSyncItem item = new FirmwareSyncItem();
    String[] cols = StringUtils.splitPreserveAllTokens(line, '\t');
    if (cols == null || cols.length != 7) {
        throw new ParseException("Error data: " + line);
    }// w ww . j a v  a 2s. co  m
    item.setId(cols[0]);
    item.setActionAsString(cols[1]);
    item.setManufacturer(cols[2]);
    item.setModel(cols[3]);
    item.setFromVersion(cols[4]);
    item.setToVersion(cols[5]);
    item.setFirmwareName(cols[6]);
    return item;
}

From source file:com.npower.unicom.sync.device.FileSyncItemReader4Device.java

@Override
protected SyncItem parse(String line) throws ParseException {
    if (StringUtils.isEmpty(line)) {
        return null;
    }//from   w ww  . j ava  2  s. c om
    String cols[] = StringUtils.splitPreserveAllTokens(line, '\t');
    if (cols == null || cols.length != 8) {
        throw new ParseException("Error data: " + line);
    }
    DeviceSyncItem item = new DeviceSyncItem(cols[0], SyncAction.valueOfByString(cols[1]));
    item.setMsisdn(cols[2]);
    item.setImsi(cols[3]);
    item.setImei(cols[4]);
    item.setCompanyName(cols[5]);
    item.setTerminalModel(cols[6]);
    item.setVersion(cols[7]);
    return item;
}

From source file:com.npower.unicom.sync.model.FileSyncModelItemReader.java

@Override
protected SyncItem parse(String line) throws ParseException {
    SyncModelItem item = null;/*from w  w  w  . ja v a 2s.  c  om*/
    if (StringUtils.isNotEmpty(line)) {
        item = new SyncModelItem();
        String[] cols = StringUtils.splitPreserveAllTokens(line, '\t');
        if (cols == null || (cols.length != 94 && cols.length != 93)) {
            throw new ParseException("parse error: " + line);
        }
        item.setId(cols[0]);
        item.setCompanyName(cols[2]);
        item.setTerminalModel(cols[3]);
        item.setOs(cols[4]);
        item.setOsVersion(cols[5]);
        item.setVersion(cols[6]);
        item.setUaProf(cols[7]);
        item.setGprs(cols[8]);
        item.setWcdma(cols[9]);
        item.setHsdpa(cols[10]);
        item.setHsupa(cols[11]);
        item.setWap(cols[12]);
        item.setWapVersion(cols[13]);
        item.setBrowserVendor(cols[14]);
        item.setBrowserVersion(cols[15]);
        item.setInternetBrowser(cols[16]);
        item.setInternetBrowserVersion(cols[17]);
        item.setHttpDownload(cols[18]);
        item.setOmaDownload(cols[19]);
        item.setDmClient(cols[20]);
        item.setDmVersion(cols[21]);
        item.setReleaseData(cols[22]);
        item.setIsTouchScreen(cols[23]);
        item.setIsColorScreen(cols[24]);
        item.setScreenHeight(cols[25]);
        item.setScreenWidth(cols[26]);
        item.setColums(cols[27]);
        item.setRows(cols[28]);
        item.setGreyscale(cols[29]);
        item.setGif(cols[30]);
        item.setJpg(cols[31]);
        item.setBmp(cols[32]);
        item.setGif_animated(cols[33]);
        item.setRingtoneDownload(cols[34]);
        item.setRingtone_wav(cols[35]);
        item.setRingtone_mp3(cols[36]);
        item.setVideo(cols[37]);
        item.setVideoFamat(cols[38]);
        item.setBlueTooth(cols[39]);
        item.setBlueToothVersion(cols[40]);
        item.setIrDa(cols[41]);
        item.setUsb(cols[42]);
        item.setUsbVersion(cols[43]);
        item.setFm(cols[44]);
        item.setSpeaker(cols[45]);
        item.setCamera(cols[46]);
        item.setCameraResolutionpixels(cols[47]);
        item.setCameraNum(cols[48]);
        item.setCameraFlash(cols[49]);
        item.setExtMemory(cols[50]);
        item.setExtMemoryType(cols[51]);
        item.setExtMemoryMaxSize(cols[52]);
        item.setOmadrm(cols[53]);
        item.setDrmVersion(cols[54]);
        item.setStreaming(cols[55]);
        item.setStreamingH263(cols[56]);
        item.setStreamingH264(cols[57]);
        item.setStreamingACC(cols[58]);
        item.setStreamingMP4(cols[59]);
        item.setStreaming3gpp(cols[60]);
        item.setStreamingWMV(cols[61]);
        item.setStreamingMOV(cols[62]);
        item.setSteamingRM8(cols[63]);
        item.setStreamingRM10(cols[64]);
        item.setJ2me(cols[65]);
        item.setJ2meDownload(cols[66]);
        item.setJarDLMaxSize(cols[67]);
        item.setJavaCLDCVersion(cols[68]);
        item.setJavaMIDPVersion(cols[69]);
        item.setMms(cols[70]);
        item.setMms3gpp(cols[71]);
        item.setMmsWBXML(cols[72]);
        item.setMmspng(cols[73]);
        item.setMmsWML(cols[74]);
        item.setMmsVideo(cols[75]);
        item.setMmsMaxSize(cols[76]);
        item.setMmsForward(cols[77]);
        item.setFlash(cols[78]);
        item.setVt(cols[79]);
        item.setVtH263(cols[80]);
        item.setVtH264(cols[81]);
        item.setVtMP4(cols[82]);
        item.setImap4(cols[83]);
        item.setPop3(cols[84]);
        item.setEmailClient(cols[85]);
        item.setEmailClientName(cols[86]);
        item.setEmailClientVersion(cols[87]);
        item.setAgps(cols[88]);
        item.setBarRecog(cols[89]);
        item.setSip(cols[90]);
        item.setPim(cols[91]);
        item.setSycML(cols[92]);
        if (cols.length == 94) {
            item.setVideoSharing(cols[93]);
        }
    }
    return item;
}

From source file:com.npower.unicom.sync.RequestHeader.java

/**
 * Reader/*from   www.  jav a 2  s. c o m*/
 * @param reader
 * @return
 * @throws IOException
 */
public static RequestHeader parseHeaderInfo(Reader in) throws IOException {
    BufferedReader reader = new BufferedReader(in);
    String line = reader.readLine();
    RequestHeader header = null;

    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
    if (StringUtils.isNotEmpty(line)) {
        String[] cols = StringUtils.splitPreserveAllTokens(line, '\t');
        header = new RequestHeader();
        header.setSerialNumber(cols[0]);
        header.setVersion(cols[1]);
        try {
            header.setGeneratedTime(format.parse(cols[2]));
        } catch (ParseException e) {
            log.error("error to parse generated time: " + cols[2], e);
        }
        header.setGeneratedBy(cols[3]);
        try {
            header.setStartTime(format.parse(cols[4]));
        } catch (ParseException e) {
            log.error("error to parse start time: " + cols[4], e);
        }
        try {
            header.setEndTime(format.parse(cols[5]));
        } catch (ParseException e) {
            log.error("error to parse end time: " + cols[5], e);
        }
        header.setTotalRecords(Integer.parseInt(cols[6]));
        header.setMemo(cols[7]);
    }
    reader.close();
    return header;
}

From source file:bazaar4idea.data.BzrUrl.java

private String findUserInfoPart(int index) {
    String userInfo = uri.getUserInfo();
    if (StringUtils.isBlank(userInfo)) {
        return null;
    }/*from   w  w w.  j a  v  a 2  s  .  c o m*/

    String[] parts = StringUtils.splitPreserveAllTokens(userInfo, ':');
    if (parts.length > index && StringUtils.isNotBlank(parts[index])) {
        return parts[index];
    }
    return null;
}

From source file:edu.ku.brc.ui.StringFormatHelper.java

public boolean createFormatter(final String formatStr, final boolean displayError) {
    String[] fmts = StringUtils.splitPreserveAllTokens(formatStr, '%');
    if (fmts != null && fmts.length > 0) {
        ArrayList<String> fmtList = new ArrayList<String>();
        for (String str : fmts) {
            if (StringUtils.isNotEmpty(str)) {
                fmtList.add("%" + str);
            }/* w w  w. ja  v a2 s.  com*/
        }
        formats = new String[fmtList.size()];
        fmtList.toArray(formats);
        return true;
    }
    return false;
}

From source file:es.emergya.comunications.MessageProcessor.java

/**
 * @param datragam/*from w  w w  .  j a  v  a2 s  .com*/
 * @param origen
 * @return
 * @throws MessageProcessingException
 */
public void processingMessage(Inbox entrada) throws MessageProcessingException {

    // Divide el datagram
    String[] campos = StringUtils.splitPreserveAllTokens(entrada.getDatagramaTetra(),
            LogicConstants.FIELD_SEPARATOR);

    if (entrada.getOrigen() == null)
        throw new MessageProcessingException("No sabemos el origen", entrada);
    if (entrada.getDatagramaTetra() == null)
        throw new MessageProcessingException("El mensaje no tenia contenido", entrada);

    /*
     * Server format: Datagram structure: ID_MESSAGE (0) | ID_MESSAGE_TYPE
     * (1) | MESSAGE BODY (2 .. n)
     * 
     * EME format: Datagram structure: ID_MESSAGE_TYPE (0) | MESSAGE BODY (1
     * .. n)
     */
    MessageProcessor.log
            .debug("Ha llegado un mensaje de " + entrada.getOrigen() + ":" + entrada.getDatagramaTetra());
    int codeMessageType = getTipoMensaje(entrada, campos);
    try {
        processMessage(entrada, campos, codeMessageType);
    } catch (MessageProcessingException e) {
        log.error("Error al procesar el mensaje");
    }
    save(entrada);
}

From source file:com.htmlhifive.tools.jslint.engine.option.CheckOptionPropertyWrapper.java

@Override
public CheckOption getOption(String key, String engine) {

    String rawValue = optionProp.getProperty(getPrefix() + key);
    String[] valueClass = StringUtils.splitPreserveAllTokens(rawValue, JSLintPluginConstant.OPTION_SEPARATOR);
    Class<?> clazz = null;/*from  w  w  w. j  a  v a  2 s  .c o m*/
    if (StringUtils.equals(valueClass[2], "Boolean")) {
        clazz = Boolean.class;
    } else if (StringUtils.equals(valueClass[2], "Integer")) {
        clazz = Integer.class;
    }
    // TODO ?
    CheckOption option = new CheckOption(key, "", clazz, valueClass[3], valueClass[4]);

    option.setValue(valueClass[1]);
    option.setEnable(Boolean.valueOf(valueClass[0]));
    return option;
}

From source file:com.amalto.core.server.security.jaas.DefaultLoginModule.java

private String[] getArrayFromOption(Map<String, ?> options, String option) {
    String values = (String) options.get(option);
    if (values.contains(Crypt.ENCRYPT)) {
        values = values.replaceAll(Crypt.ENCRYPT, ";encrypt"); //$NON-NLS-1$
    }// ww w  .  ja v a2  s  . co m
    String[] valueArray = StringUtils.splitPreserveAllTokens(values, ',');
    return valueArray;
}