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

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

Introduction

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

Prototype

public static String[] splitByWholeSeparator(String str, String separator) 

Source Link

Document

Splits the provided text into an array, separator string specified.

Usage

From source file:cn.newtouch.util.orm.PropertyFilter.java

/**
 * @param filterName//from   w ww  .  j av  a  2 s . c  o m
 *            ,???. eg. LIKES_NAME_OR_LOGIN_NAME
 * @param value
 *            .
 */
public PropertyFilter(final String filterName, final String value) {

    String firstPart = StringUtils.substringBefore(filterName, "_");
    String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1);
    String propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length());

    try {
        this.matchType = Enum.valueOf(MatchType.class, matchTypeCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    try {
        this.propertyClass = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue();
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, "_");
    Assert.isTrue(StringUtils.isNotBlank(propertyNameStr),
            "filter??" + filterName + ",??.");
    this.propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR);

    this.matchValue = ConvertUtils.convertStringToObject(value, this.propertyClass);
}

From source file:com.blue.ssh.core.orm.PropertyFilter.java

/**
 * @param filterName/*  w w w  .  jav a  2  s  . c om*/
 *            ,???. eg. LIKES_NAME_OR_LOGIN_NAME
 * @param value
 *            .
 */
public PropertyFilter(final String filterName, final String value) {

    String firstPart = StringUtils.substringBefore(filterName, "_");
    String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1);
    String propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length());

    try {
        matchType = Enum.valueOf(MatchType.class, matchTypeCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    try {
        propertyClass = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue();
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, "_");
    Assert.isTrue(StringUtils.isNotBlank(propertyNameStr),
            "filter??" + filterName + ",??.");
    propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR);

    this.matchValue = ConvertUtils.convertStringToObject(value, propertyClass);
}

From source file:com.hangum.tadpole.db.metadata.MakeContentAssistUtil.java

/**
 *    ? ? ??     .. //from w  ww . j  a  va 2 s. c  o  m
 *   content assist   tester.tablename   ?  ?? . ?   ? ? ? ?. 
 * 
 * @param userDB
 * @param strArryCursor
 * @return
 */
protected String getSchemaOrTableContentAssist(UserDBDAO userDB, String[] strArryCursor) {
    String strCntAsstList = getContentAssist(userDB);
    String strCursorText = strArryCursor[0] + strArryCursor[1];

    if (StringUtils.contains(strCursorText, '.')) {
        String strSchemaName = StringUtils.substringBefore(strCursorText, ".") + ".";
        //         String strTableName       = StringUtils.substringAfter(strCursorText, ".");
        int intSep = StringUtils.indexOf(strCursorText, ".");

        if (logger.isDebugEnabled()) {
            logger.debug("[0]" + strArryCursor[0]);
            logger.debug("[1]" + strArryCursor[1]);
            logger.debug("[1][intSep]" + intSep);
            logger.debug("[1][strArryCursor[0].length()]" + strArryCursor[0].length());
            logger.debug("==> [Return table list]" + (strArryCursor[0].length() >= intSep));
        }

        // ?  ?  ?  .
        if (strArryCursor[0].length() >= intSep) {
            String strNewCntAsstList = "";

            String[] listGroup = StringUtils.splitByWholeSeparator(strCntAsstList, _PRE_GROUP);
            if (listGroup == null)
                return strNewCntAsstList;

            for (String strDefault : listGroup) {
                String[] listDefault = StringUtils.split(strDefault, _PRE_DEFAULT);
                if (listDefault != null & listDefault.length == 2) {
                    if (StringUtils.startsWithIgnoreCase(listDefault[0], strSchemaName))
                        strNewCntAsstList += makeObjectPattern("",
                                StringUtils.removeStartIgnoreCase(listDefault[0], strSchemaName),
                                listDefault[1]);
                } // 
            }

            return strNewCntAsstList;
        }
    }

    return strCntAsstList;
}

From source file:TemplateImporter.java

public static void downloadInfo(String url) throws Exception {

    List<Map<String, String>> items = getThumbNails(url);

    //List<String> names = getThumbNails();

    //Iterator<Map<String, String>> iter = item

    for (Map<String, String> item : items) {

        String name = item.get("Name");

        System.out.println("-----------------");
        System.out.println(name);
        String thumbnail = "http://www.freecsstemplates.org/templates/thumbnails/" + name + ".gif";
        String template = "http://www.freecsstemplates.org/templates/previews/" + name + "/";
        String path = "/home/kureem/csstemplates/" + name;
        File dir = new File(path);
        dir.mkdir();/* w w w .j  a  v a  2  s .  c o  m*/

        addFile(thumbnail, path + "/" + name + ".gif");
        //byte[] abImages = IOUtil.getStreamContentAsBytes(new URL(thumbnail).openStream());
        //FileOutputStream fout = new FileOutputStream(new File(path + "/" + name + ".gif"));
        //fout.write(abImages);
        //fout.flush();
        //fout.close();

        addFile(template, path + "/" + name + ".html");

        Source src = new Source(new FileInputStream(path + "/" + name + ".html"));
        List<Element> links = src.getAllElements("link");
        List<StartTag> linkStartTags = src.getAllStartTags(HTMLElementName.LINK);
        for (StartTag link : linkStartTags) {
            String css = link.getAttributeValue("href");
            String cssUrl = "http://www.freecsstemplates.org/templates/previews/" + name + "/" + css;
            addFile(cssUrl, path + "/" + css);

            String scss = IOUtil.getFileContenntAsString(path + "/" + css);
            String[] asParts = StringUtils.splitByWholeSeparator(scss, "url(");
            for (String s : asParts) {
                if (s.startsWith("images/")) {
                    String aaap = StringUtils.split(s, ")")[0];

                    new File(path + "/images").mkdir();
                    try {
                        addFile(template + aaap, path + "/" + aaap);
                    } catch (Exception e) {
                        System.out.println(template + aaap);
                    }
                }
            }
        }

    }

}

From source file:com.tesora.dve.sql.statement.dml.AliasInformation.java

private UnqualifiedName shortenAlias(String unq, int maxLen) {
    StringBuilder buf = new StringBuilder();

    // first look for '_' and pick the character following the '_' to make the alias
    String[] parts = StringUtils.splitByWholeSeparator(unq, "_");
    if (parts.length > 1) {
        buf.append(unq.charAt(0));//from  w w  w. j  ava2 s .  co m
        for (String part : parts) {
            buf.append(part.charAt(0));
        }
    } else {
        // pick every other character
        for (int i = 0; i < unq.length(); i++) {
            if ((i & 1) == 0) {
                buf.append(unq.charAt(i));
            }
        }
    }
    if (buf.length() > maxLen) {
        return shortenAlias(buf.toString(), maxLen);
    }

    return new UnqualifiedName(buf.toString());
}

From source file:com.hangum.tadpole.rdb.erd.core.dnd.TableTransferDropTargetListener.java

@Override
protected void handleDrop() {
    String strDragSource = (String) getCurrentEvent().data;
    try {// w  w w. ja v a  2  s .  co  m
        String[] arrayDragSourceData = StringUtils.splitByWholeSeparator(strDragSource,
                PublicTadpoleDefine.DELIMITER);

        int sourceDBSeq = Integer.parseInt(arrayDragSourceData[0]);
        if (userDB.getSeq() != sourceDBSeq) {
            MessageDialog.openWarning(null, Messages.get().Warning,
                    Messages.get().TableTransferDropTargetListener_1); //$NON-NLS-1$
            return;
        }
    } catch (Exception e) {
        logger.error("dragger error", e); //$NON-NLS-1$
        MessageDialog.openError(null, Messages.get().Error, "Draging exception : " + e.getMessage()); //$NON-NLS-1$
        return;
    }

    final int nextTableX = getDropLocation().x;
    final int nextTableY = getDropLocation().y;

    final String strFullData = StringUtils.substringAfter(strDragSource, PublicTadpoleDefine.DELIMITER);
    final String[] arryTables = StringUtils.splitByWholeSeparator(strFullData,
            PublicTadpoleDefine.DELIMITER_DBL);
    final Map<String, List<TableColumnDAO>> mapTable = new HashMap<>();

    Job job = new Job("Painting model") {
        @Override
        public IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Painting table object", IProgressMonitor.UNKNOWN);

            try {
                for (int i = 0; i < arryTables.length; i++) {
                    String strTable = arryTables[i];
                    monitor.subTask(String.format("Working %s/%s", i, arryTables.length));
                    String[] arryTable = StringUtils.splitByWholeSeparator(strTable,
                            PublicTadpoleDefine.DELIMITER);
                    if (arryTable.length == 0)
                        continue;

                    String schemaName = arryTable[0];
                    String tableName = arryTable[1];

                    TableDAO table = new TableDAO();
                    table.setSchema_name(schemaName);
                    table.setName(tableName);
                    table.setSysName(tableName);
                    mapTable.put(tableName, TDBDataHandler.getColumns(userDB, table));
                }

            } catch (Exception e) {
                logger.error("ERD Initialize excepiton", e);

                return new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage());
            } finally {
                monitor.done();
            }

            /////////////////////////////////////////////////////////////////////////////////////////
            return Status.OK_STATUS;
        }
    };

    // job? event  ?.
    job.addJobChangeListener(new JobChangeAdapter() {
        public void done(IJobChangeEvent event) {
            final IJobChangeEvent jobEvent = event;
            Display display = rdbEditor.getEditorSite().getShell().getDisplay();
            display.syncExec(new Runnable() {
                public void run() {

                    if (jobEvent.getResult().isOK()) {
                        paintingModel(nextTableX, nextTableY, arryTables, mapTable);
                    } else {
                        MessageDialog.openError(null, Messages.get().Error, jobEvent.getResult().getMessage());
                    }
                }
            }); // end display.asyncExec
        } // end done

    }); // end job

    job.setName(userDB.getDisplay_name());
    job.setUser(true);
    job.schedule();

}

From source file:com.hangum.tadpole.mongodb.erd.core.dnd.TableTransferDropTargetListener.java

@Override
protected void handleDrop() {
    String strDragSource = (String) getCurrentEvent().data;
    try {/* w  w  w .j  a v a2s  . c  o  m*/
        String[] arrayDragSourceData = StringUtils.splitByWholeSeparator(strDragSource,
                PublicTadpoleDefine.DELIMITER);

        int sourceDBSeq = Integer.parseInt(arrayDragSourceData[0]);
        if (userDB.getSeq() != sourceDBSeq) {
            MessageDialog.openWarning(null, Messages.get().Warning,
                    Messages.get().TableTransferDropTargetListener_1); //$NON-NLS-1$
            return;
        }
    } catch (Exception e) {
        logger.error("dragger error", e); //$NON-NLS-1$
        MessageDialog.openError(null, Messages.get().Error, "Draging exception : " + e.getMessage()); //$NON-NLS-1$
        return;
    }

    final int nextTableX = getDropLocation().x;
    final int nextTableY = getDropLocation().y;

    final String strFullData = StringUtils.substringAfter(strDragSource, PublicTadpoleDefine.DELIMITER);
    final String[] arryTables = StringUtils.splitByWholeSeparator(strFullData,
            PublicTadpoleDefine.DELIMITER_DBL);
    final Map<String, List<CollectionFieldDAO>> mapTable = new HashMap<>();

    Job job = new Job("Painting model") {
        @Override
        public IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Painting table object", IProgressMonitor.UNKNOWN);

            try {
                for (int i = 0; i < arryTables.length; i++) {
                    String strTable = arryTables[i];
                    monitor.subTask(String.format("Working %s/%s", i, arryTables.length));
                    String[] arryTable = StringUtils.splitByWholeSeparator(strTable,
                            PublicTadpoleDefine.DELIMITER);
                    if (arryTable.length == 0)
                        continue;

                    String tableName = arryTable[IDX_TABLE_NAME];
                    mapTable.put(tableName, getColumns(tableName));
                }

            } catch (Exception e) {
                logger.error("ERD Initialize excepiton", e);

                return new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage());
            } finally {
                monitor.done();
            }

            /////////////////////////////////////////////////////////////////////////////////////////
            return Status.OK_STATUS;
        }
    };

    // job? event  ?.
    job.addJobChangeListener(new JobChangeAdapter() {
        public void done(IJobChangeEvent event) {
            final IJobChangeEvent jobEvent = event;
            Display display = mongoEditor.getEditorSite().getShell().getDisplay();
            display.syncExec(new Runnable() {
                public void run() {

                    if (jobEvent.getResult().isOK()) {
                        paintingModel(nextTableX, nextTableY, arryTables, mapTable);
                    } else {
                        MessageDialog.openError(null, Messages.get().Confirm,
                                jobEvent.getResult().getMessage());
                    }
                }
            }); // end display.asyncExec
        } // end done

    }); // end job

    job.setName(userDB.getDisplay_name());
    job.setUser(true);
    job.schedule();

    //      super.handleDrop();
}

From source file:dk.dma.epd.common.prototype.model.route.RouParser.java

private static String[] parsePair(String str) throws RouteLoadException {
    String[] parts = StringUtils.splitByWholeSeparator(str, ": ");
    if (parts.length != 2) {
        throw new RouteLoadException("Error in ROU key value pair: " + str);
    }/*from   w w  w  . j a  v  a 2  s.co m*/
    return parts;
}

From source file:com.bsi.summer.core.dao.PropertyFilter.java

/**
 * @param filterName ,???. //  w  ww. j a v  a2  s. c  o  m
 *                      FILTER_LIKES_NAME_OR_LOGIN_NAME
 *                   
 *                value "SYS_" ??? 
 * 
 * @param value .
 */
public PropertyFilter(final String filterName, final String value) {

    String firstPart = StringUtils.substringBefore(filterName, "_");
    String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1);
    String propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length());

    try {
        matchType = Enum.valueOf(MatchType.class, matchTypeCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    try {
        propertyClass = Enum.valueOf(PropertyType.class, propertyTypeCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, "_");
    Assert.isTrue(StringUtils.isNotBlank(propertyNameStr),
            "filter??" + filterName + ",??.");
    propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR);
    if (StringUtils.split(value, "-").length == 1) {
        this.matchValue = getValue(value);
    } else {
        this.matchValue = getValue(StringUtils.split(value, "-")[0]);
        this.matchBetweenValue = getValue(StringUtils.split(value, "-")[1]);
    }
}

From source file:com.datatorrent.stram.LaunchContainerRunnable.java

public static void addFilesToLocalResources(LocalResourceType type, String commaSeparatedFileNames,
        Map<String, LocalResource> localResources, FileSystem fs) throws IOException {
    String[] files = StringUtils.splitByWholeSeparator(commaSeparatedFileNames, StramClient.LIB_JARS_SEP);
    for (String file : files) {
        final Path dst = new Path(file);
        addFileToLocalResources(dst.getName(), fs.getFileStatus(dst), type, localResources);
    }/*  w  w w  . ja  v  a 2 s.  c o m*/
}