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

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

Introduction

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

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:cec.easyshop.storefront.filters.CustomerLocationRestorationFilter.java

@Override
public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws ServletException, IOException {
    if (getCustomerLocationFacade().getUserLocationData() == null) {
        final Cookie[] cookies = request.getCookies();

        if (cookies != null) {
            for (final Cookie cookie : cookies) {
                if (getCustomerLocationCookieGenerator().getCookieName().equals(cookie.getName())) {
                    final UserLocationData cookieUserLocationData = decipherUserLocationData(
                            StringUtils.remove(cookie.getValue(), "\""));
                    getCustomerLocationFacade().setUserLocationData(cookieUserLocationData);
                    break;
                }//from  www  . jav  a  2s. c  o m
            }
        }
    }

    filterChain.doFilter(request, response);
}

From source file:com.hangum.tadpole.mongodb.erd.core.relation.RelationUtil.java

/**
 * <pre>/*ww  w .  j a  va  2 s. c  om*/
 *  ?  .
 * 
 * object type? org.bson.types.ObjectId ? field?? _id   _id ?? ?  ??.
 * </pre>
 * 
 * @param userDB
 * @param mapDBTables
 * @param db
 * @param refTableNames
 * @throws Exception
 */
public static void calRelation(UserDBDAO userDB, Map<String, Table> mapDBTables, DB db, String refTableNames)
        throws Exception {
    List<ReferencedTableDAO> listRealRefTableDAO = new ArrayList<ReferencedTableDAO>();

    Set<String> keySet = mapDBTables.keySet();
    for (String keyTable : keySet) {
        Table table = mapDBTables.get(keyTable);
        EList<Column> listColumn = table.getColumns();
        for (Column column : listColumn) {
            String strField = column.getField();

            if (MongodbUtils.isReferenceKey(column.getType(), strField)) {
                String strRefName = StringUtils.remove(strField, "_id");

                ReferencedTableDAO refTableDao = new ReferencedTableDAO();
                refTableDao.setTable_name(table.getName());
                refTableDao.setColumn_name(strRefName);
                refTableDao.setReferenced_table_name(strRefName);
                refTableDao.setReferenced_column_name(table.getName());
                refTableDao.setConstraint_name(strRefName);

                listRealRefTableDAO.add(refTableDao);
            }
        }
    }

    calRelation(userDB, mapDBTables, db, listRealRefTableDAO);
}

From source file:com.google.gdt.eclipse.designer.gxt.uibinder.model.GxtUiBinderModelTest.java

/**
 * Configures test module, for example for using some specific library.
 *///from ww w  . java2  s . co m
@Override
protected void configureModule(ModuleDescription moduleDescription) throws Exception {
    super.configureModule(moduleDescription);
    m_testProject.addExternalJar(ExtGwtTests.GXT_LOCATION + "/gxt.jar");
    new ConfigureExtGwtOperation(moduleDescription, ExtGwtTests.GXT_LOCATION).run(null);
    // don't use "strict" mode
    {
        String html = getFileContent("war/Module.html");
        html = StringUtils.remove(html, "<!doctype html>");
        setFileContent("war/Module.html", html);
    }
}

From source file:com.mmounirou.spotirss.spotify.tracks.XTracks.java

private String cleanTrackName(String trackName) {
    String[] spotifyExtensions = new String[] { " - Explicit Version", " - Live", " - Radio Edit" };
    String strSong = trackName;/*from   www  .j a va 2  s.c om*/

    for (String extensions : spotifyExtensions) {
        if (StringUtils.contains(strSong, extensions)) {
            strSong = "X " + StringUtils.remove(trackName, extensions);
        }
    }

    String[] braces = { "[]", "()" };

    for (String brace : braces) {

        String extendedinfo = null;
        do {
            extendedinfo = StringUtils.defaultString(
                    StringUtils.substringBetween(strSong, brace.charAt(0) + "", brace.charAt(1) + ""));
            if (StringUtils.isNotBlank(extendedinfo)) {
                if (StringUtils.startsWith(extendedinfo, "feat.")) {
                    String strArtist = StringUtils.removeStart("feat.", extendedinfo);
                    strSong = StringUtils.replace(strSong,
                            String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), "");
                    m_artistsInTrackName.addAll(cleanArtist(strArtist));
                }

                else {
                    strSong = StringUtils.replace(strSong,
                            String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), "");
                    strSong = "X " + strSong;
                }
            }

        } while (StringUtils.isNotBlank(extendedinfo));

    }

    String[] strSongSplitted = strSong.split("featuring");
    if (strSongSplitted.length > 1) {
        strSong = strSongSplitted[0];
        m_artistsInTrackName.add(strSongSplitted[1]);
    }

    String[] strSongWithFeaturing = strSong.split("-");
    if (strSongWithFeaturing.length > 1 && strSongWithFeaturing[1].contains("feat.")) {
        strSong = strSongWithFeaturing[0];
        m_artistsInTrackName.addAll(cleanArtist(StringUtils.remove(strSongWithFeaturing[1], "feat.")));
    } else {
        strSongWithFeaturing = strSong.split("feat.");
        if (strSongWithFeaturing.length > 1) {
            strSong = strSongWithFeaturing[0];
            m_artistsInTrackName.addAll(cleanArtist(strSongWithFeaturing[1]));
        }
    }

    return strSong.trim().toLowerCase();
}

From source file:com.nanyou.framework.jdbc.sql.dynamic.DynamicSql.java

private void findChildren(DynamicParent parent, String sql) {
    try {/*from   www  . ja v a 2 s  .  co  m*/
        sql = StringUtils.remove(sql, ";");

        BufferedReader in = new BufferedReader(new StringReader(sql));
        while (true) {
            String line = in.readLine();
            if (line == null) {
                break;
            }
            if (StringUtils.trim(line).startsWith("--<")) {
                line = StringUtils.trim(line);
                line = new String(line.substring(3, line.lastIndexOf('>')));
                StringTokenizer st = new StringTokenizer(line, "= \t");
                String tagName = st.nextToken();
                SqlTag child = new SqlTag();
                child.setName(tagName);
                child.setHandler(SqlTagHandlerFactory.getSqlTagHandler(tagName));
                while (st.hasMoreTokens()) {
                    String key = st.nextToken();
                    String value = StringUtils.remove(st.nextToken(), "\"");
                    if ("prepend".equalsIgnoreCase(key)) {
                        child.setPrependAttr(value);
                    } else if ("property".equalsIgnoreCase(key)) {
                        child.setPropertyAttr(value);
                    } else if ("open".equalsIgnoreCase(key)) {
                        child.setOpenAttr(value);
                    } else if ("close".equalsIgnoreCase(key)) {
                        child.setCloseAttr(value);
                    } else if ("conjunction".equalsIgnoreCase(key)) {
                        child.setConjunctionAttr(value);
                    } else if ("compareProperty".equalsIgnoreCase(key)) {
                        child.setComparePropertyAttr(value);
                    } else if ("compareValue".equalsIgnoreCase(key)) {
                        child.setCompareValueAttr(value);
                    }
                }
                String endTagName = "</" + tagName + ">";
                StringBuffer sb = new StringBuffer();
                while (true) {
                    line = in.readLine();
                    if (line == null) {
                        break;
                    }
                    if (line.indexOf(endTagName) > 0) {
                        break;
                    }
                    sb.append(line).append("\n");
                }
                findChildren(child, sb.toString());
                parent.addChild(child);
            } else {
                SqlText child = new SqlText();
                ((SqlText) child).setText(line);
                parent.addChild(child);
            }
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}

From source file:com.ctc.storefront.filters.CustomerLocationRestorationFilter.java

protected void setUserLocationDataFromCookies(final Cookie[] cookies) {
    for (final Cookie cookie : cookies) {
        if (getCustomerLocationCookieGenerator().getCookieName().equals(cookie.getName())) {
            final UserLocationData cookieUserLocationData = decipherUserLocationData(
                    StringUtils.remove(cookie.getValue(), "\""));
            getCustomerLocationFacade().setUserLocationData(cookieUserLocationData);
            break;
        }// ww w  . ja  va2s.  c o  m
    }
}

From source file:com.akrema.stringeval.StringEvaluator.java

/**
 * {@inheritDoc}//from w w  w . j  av a 2s  .  c  om
 */
@Override
public void WalkThroughtExpression(String expression) throws ParseExpressionException, InputStringException {
    this.fullExpression = StringUtils.remove(expression, ' ');
    System.out.println(this.fullExpression);
    int indexleftPar = 0;
    int indexrightPar = 0;
    int length = this.fullExpression.length();
    int index = 0;
    //loop throught expression
    while (index < length) {
        //define parameters index in expression
        if (this.fullExpression.charAt(index) == StringCONST.LEFT_PARENTHESE)
            indexleftPar = index;
        if (this.fullExpression.charAt(index) == StringCONST.RIGHT_PARENTHESE)
            indexrightPar = index;
        index++;
    }

    //extract method ,list of arguments and store them in listOfArgument
    this.currentMethod = this.getMMethodByName(this.fullExpression.substring(0, indexleftPar));
    this.listOfArgument = this.getArguments(this.fullExpression, indexleftPar, this.fullExpression.length());
}

From source file:hydrograph.ui.graph.handler.GraphPropertiesHandler.java

private String getCurrentGraphName() {
    String graphName = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()
            .getEditorInput().getName();
    graphName = StringUtils.remove(graphName, Constants.JOB_EXTENSION);
    graphName = StringUtils.abbreviate(graphName, 20);
    return graphName;
}

From source file:com.google.gdt.eclipse.designer.gwtext.GwtExtModelTest.java

@Override
protected void configureModule(ModuleDescription moduleDescription) throws Exception {
    m_testProject.addBundleJars("com.google.gdt.eclipse.designer.GWTExt", "/resources");
    new ConfigureGwtExtOperation(moduleDescription).run(null);
    // don't use "strict" mode
    {//  www  . j a v a 2  s .  c  om
        String html = getFileContent("war/Module.html");
        html = StringUtils.remove(html, "<!doctype html>");
        setFileContent("war/Module.html", html);
    }
}

From source file:com.google.gdt.eclipse.designer.gxt.model.GxtModelTest.java

@Override
protected void configureModule(ModuleDescription moduleDescription) throws Exception {
    new ConfigureExtGwtOperation(moduleDescription, ExtGwtTests.GXT_LOCATION).run(null);
    // don't use "strict" mode
    {//from  w w w. ja v a2 s. c o  m
        String html = getFileContent("war/Module.html");
        html = StringUtils.remove(html, "<!doctype html>");
        setFileContent("war/Module.html", html);
    }
}