List of usage examples for org.apache.commons.lang StringUtils remove
public static String remove(String str, char remove)
Removes all occurrences of a character from within the source string.
From source file:edu.ku.brc.specify.tools.datamodelgenerator.DataDict.java
/** * @param table/*from w ww. j ava2 s .c o m*/ */ @SuppressWarnings("unchecked") public void processTable(Element table) { // cheesy, but who cares for now String desc = StringUtils.replace( StringUtils.remove(table.selectSingleNode("caption/strong").getText(), '\n'), " ", " "); desc = StringUtils.replace(desc, " ", " "); desc = StringUtils.replace(desc, " ", " "); String[] parts = StringUtils.split(desc, "'"); TableDef tableDef = new TableDef(desc, parts[1]); Vector<FieldDef> fields = tableDef.getFields(); Vector<IndexDef> indexes = tableDef.getIndexes(); Vector<RelationshipDef> relationships = tableDef.getRelationships(); tables.add(tableDef); for (Element tr : (List<Element>) table.selectNodes("tr")) { List<Element> tds = tr.selectNodes("td"); if (tds.size() == 5) { String type = getText(tds.get(1).getText()); String[] tokens = StringUtils.split(type, "()"); FieldDef fd = new FieldDef(getName(tds.get(0)), type, getText(tds.get(2).getText()), getText(tds.get(3).getText()), getText(tds.get(4).getText())); if (tokens.length > 1) { fd.setLength(tokens[1]); } fields.add(fd); } else if (tds.size() == 2) { String col1 = getCol1(tds.get(0)); int inx = col1.indexOf(':'); if (inx > -1) { col1 = col1.substring(0, inx); } if (StringUtils.isNotBlank(col1)) { if (inx == -1) { relationships.add(new RelationshipDef(col1, getCol2(tds.get(1), true))); } else { indexes.add(new IndexDef(col1, getCol2(tds.get(1), false))); } } } } }
From source file:com.jnj.b2b.storefront.web.theme.StorefrontResourceBundleSource.java
/** * This implementation returns a SimpleTheme instance, holding a ResourceBundle-based MessageSource whose basename * corresponds to the given site name (prefixed by the configured "siteBasenamePrefix") which then delegates to a * ResourceBundle-based MessageSource whose basename corresponds to the theme name (prefixed by the configured * "themeBasenamePrefix") which in turn delegates to the {@link #getParentMessageSource()}. * /*from w w w. java 2 s. com*/ * <p> * SimpleTheme instances are cached per theme name. * * <p> * Uses reloadable MessageSources to reflect changes to the underlying files. Set the {@link #setCacheSeconds(int)} * to control how long the files should be cached for. * * @param themeName * the theme name * @see #setSiteBasenamePrefix * @see #setThemeBasenamePrefix */ @Override public Theme getTheme(final String themeName) { if (themeName == null) { return null; } synchronized (this.themeCache) { // Look for the theme in the cache { final Theme theme = this.themeCache.get(themeName); if (theme != null) { return theme; } } // Split the theme name into site and theme parts final String[] strings = splitThemeName(themeName); final String uiExperiencePart = strings[0]; final String sitePart = strings[1]; final String themePart = strings[2]; final String siteBasename = getBasenamePrefix() + getSitePrefix() + "-" + sitePart; final String themeBasename = getBasenamePrefix() + getThemePrefix() + "-" + themePart; final String uiExperienceCode = uiExperiencePart.toLowerCase(); final List<String> addOnNames = requiredAddOnsNameProvider .getAddOns(StringUtils.remove(appContext.getApplicationName(), "/")); // Build the messages sources from most general to most specific final MessageSource addOnBaseMessageSrouce = createAddOnMessageSource(addOnNames, getParentMessageSource(), getBasePrefix()); final MessageSource themeMessageSource = createMessageSource(themeBasename, addOnBaseMessageSrouce); final MessageSource addOnThemeMessageSource = createAddOnMessageSource(addOnNames, themeMessageSource, getThemePrefix(), themePart); final MessageSource themeUiExperienceMessageSource = createMessageSource( themeBasename + "-" + uiExperienceCode, addOnThemeMessageSource); final MessageSource addOnThemeUiMessageSource = createAddOnMessageSource(addOnNames, themeUiExperienceMessageSource, getThemePrefix(), themePart, uiExperienceCode); final MessageSource siteMessageSource = createMessageSource(siteBasename, addOnThemeUiMessageSource); final MessageSource addOnSiteMessageSource = createAddOnMessageSource(addOnNames, siteMessageSource, getSitePrefix(), sitePart); final MessageSource siteUiExperienceMessageSource = createMessageSource( siteBasename + "-" + uiExperienceCode, addOnSiteMessageSource); final MessageSource addOnSiteUiMessageSource = createAddOnMessageSource(addOnNames, siteUiExperienceMessageSource, getSitePrefix(), sitePart, uiExperienceCode); lastMessageSource = addOnSiteUiMessageSource; // Create the new theme final Theme theme = new SimpleTheme(themeName, addOnSiteUiMessageSource); this.themeCache.put(themeName, theme); if (LOG.isDebugEnabled()) { LOG.debug("Theme created: name '" + themeName + "', iteBasename [" + siteBasename + "], themeBasename [" + themeBasename + "]"); } return theme; } }
From source file:edu.stanford.base.batch.RawCollectionsExample.java
/** * @param subcat/*from w w w .ja v a 2 s.c o m*/ * @throws IOException * @throws HttpException * @throws JsonParseException * @throws URISyntaxException */ public static void pullSearsProducts(String subcat) throws IOException, HttpException, JsonParseException, URISyntaxException { StringBuffer reponse = new StringBuffer(); //http://api.developer.sears.com/v1/productsearch?apikey=09b9aeb25ff985a9c85d877f8a9c4dd9&store=Sears&verticalName=Appliances&categoryName=Refrigerators&searchType=category&productsOnly=1&contentType=json //String request = "http://api.developer.sears.com/v1/productsearch?apikey=09b9aeb25ff985a9c85d877f8a9c4dd9&store=Sears&verticalName=Appliances&categoryName=Refrigerators&subCategoryName=Side-by-Side+Refrigerators&searchType=subcategory&productsOnly=1&endIndex=1000&startIndex=1&contentType=json"; String request = "http://api.developer.sears.com/v1/productsearch?apikey=09b9aeb25ff985a9c85d877f8a9c4dd9&store=Sears&verticalName=Appliances&categoryName=Refrigerators&subCategoryName=" + subcat + "&searchType=subcategory&productsOnly=1&contentType=json&endIndex=1000&startIndex=1"; URI uri = new URI(request); URL url = uri.toURL(); //Compact+Refrigerators System.out.println(url); HttpClient client = new HttpClient(); GetMethod method = new GetMethod(request); // Send GET request int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + method.getStatusLine()); } InputStream rstream = null; // Get the response body rstream = method.getResponseBodyAsStream(); // Process the response from Yahoo! Web Services BufferedReader br = new BufferedReader(new InputStreamReader(rstream)); String line; while ((line = br.readLine()) != null) { reponse.append(line); System.out.println(line); } br.close(); Gson gson = new Gson(); /* // gson.registerTypeAdapter(Event.class, new MyInstanceCreator()); Collection collection = new ArrayList(); collection.add("hello"); collection.add(5); collection.add(new Event("GREETINGS", "guest")); String json2 = gson.toJson(collection); System.out.println("Using Gson.toJson() on a raw collection: " + json2);*/ JsonParser parser = new JsonParser(); //JsonArray array = parser.parse(json1).getAsJsonArray(); String products = StringUtils.remove(reponse.toString(), "{\"mercadoresult\":{\"products\":{\"product\":[true,"); //System.out.println(products); String productsList = StringUtils.substring(products, 0, StringUtils.indexOf(products, "productcount") - 3); // System.out.println(productsList); productsList = "[" + StringUtils.replaceOnce(productsList, "}}]]", "}]]"); //System.out.println(productsList); List<SearsProduct> prodList = new ArrayList<SearsProduct>(); // Reader reader = new InputStreamReader(productsList); Gson gson1 = new GsonBuilder().create(); JsonArray array1 = parser.parse(productsList).getAsJsonArray(); JsonArray prodArray = (JsonArray) array1.get(0); // prodList= gson1.fromJson(array1.get(2), ArrayList.class); for (JsonElement jsonElement : prodArray) { prodList.add(gson.fromJson(jsonElement, SearsProduct.class)); //System.out.println(gson.fromJson(jsonElement, SearsProduct.class)); } PullSearsProductsDAO pullSearsProductsDAO = new PullSearsProductsDAO(); try { pullSearsProductsDAO.pullAllProducts(prodList); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:cec.easyshop.storefront.controllers.misc.StoreSessionController.java
protected String getReturnRedirectUrlWithoutReferer(final HttpServletRequest request) { final String originalReferer = (String) request.getSession() .getAttribute(StorefrontFilter.ORIGINAL_REFERER); if (StringUtils.isNotBlank(originalReferer)) { return REDIRECT_PREFIX + originalReferer; }//www.java 2 s. c o m final String referer = StringUtils.remove(request.getRequestURL().toString(), request.getServletPath()); if (referer != null && !referer.isEmpty()) { return REDIRECT_PREFIX + referer; } return REDIRECT_PREFIX + '/'; }
From source file:com.razorfish.controllers.misc.StoreSessionController.java
protected String getReturnRedirectUrlForUrlEncoding(final HttpServletRequest request, final String old, final String current) { String referer = StringUtils.remove(request.getRequestURL().toString(), request.getServletPath()); if (!StringUtils.endsWith(referer, "/")) { referer = referer + "/"; }/*www. j a va 2s. c om*/ if (referer != null && !referer.isEmpty() && StringUtils.contains(referer, "/" + old + "/")) { return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old + "/", "/" + current + "/"); } return REDIRECT_PREFIX + referer; }
From source file:de.hybris.platform.acceleratorstorefrontcommons.controllers.pages.checkout.steps.AbstractCheckoutStepController.java
protected void setCheckoutStepLinksForModel(final Model model, final CheckoutStep checkoutStep) { model.addAttribute("previousStepUrl", StringUtils.remove(checkoutStep.previousStep(), REDIRECT_PREFIX)); model.addAttribute("nextStepUrl", StringUtils.remove(checkoutStep.nextStep(), REDIRECT_PREFIX)); model.addAttribute("currentStepUrl", StringUtils.remove(checkoutStep.currentStep(), REDIRECT_PREFIX)); model.addAttribute("progressBarId", checkoutStep.getProgressBarId()); }
From source file:jef.tools.string.RegexpUtils.java
/** * ?/* ww w . j a v a2 s. c om*/ * @param pattern ? * @param str * @param strict ?????? * @return ?null */ public static String[] getMatcherResult(String str, String regexp, boolean strict) { if (!strict) { String tmp = StringUtils.remove(str, "\\("); tmp = StringUtils.remove(str, "\\)"); if (tmp.indexOf('(') > -1 && tmp.indexOf(')') > -1) { //?? } else { regexp = "(" + regexp + ")";// } } Matcher m = getMatcher(str, regexp, strict); if (!m.matches()) return null; int n = m.groupCount(); if (n == 0) return new String[] { m.group() }; String[] result = new String[n]; for (int i = 1; i <= n; i++) { result[i - 1] = m.group(i); } return result; }
From source file:net.bpelunit.test.unit.TestSOAPEncoder.java
private String nl(String messageAsString) { return StringUtils.remove(messageAsString, '\r'); }
From source file:cec.easyshop.storefront.controllers.misc.StoreSessionController.java
protected String getReturnRedirectUrlForUrlEncoding(final HttpServletRequest request, final String old, final String current) { final String originalReferer = (String) request.getSession() .getAttribute(StorefrontFilter.ORIGINAL_REFERER); if (StringUtils.isNotBlank(originalReferer)) { return REDIRECT_PREFIX + StringUtils.replace(originalReferer, "/" + old + "/", "/" + current + "/"); }/*from w ww . j av a2 s.c o m*/ String referer = StringUtils.remove(request.getRequestURL().toString(), request.getServletPath()); if (!StringUtils.endsWith(referer, "/")) { referer = referer + "/"; } if (referer != null && !referer.isEmpty() && StringUtils.contains(referer, "/" + old + "/")) { return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old + "/", "/" + current + "/"); } return REDIRECT_PREFIX + referer; }
From source file:com.twinsoft.convertigo.beans.core.MobileApplication.java
public String getComputedApplicationId() { String applicationId = this.applicationId; if ("".equals(applicationId)) { applicationId = "com.convertigo.mobile." + getProject().getName(); } else {//from w w w. java2 s . com // The user can have setup an application ID that could be non valid: // application ID can only contains alpha numeric ASCII characters. String[] applicationIdParts = applicationId.split("\\."); for (int i = 0; i < applicationIdParts.length; i++) { applicationIdParts[i] = com.twinsoft.convertigo.engine.util.StringUtils .normalize(applicationIdParts[i]); applicationIdParts[i] = StringUtils.remove(applicationIdParts[i], "_"); } applicationId = com.twinsoft.convertigo.engine.util.StringUtils.join(applicationIdParts, "."); } return applicationId; }