List of usage examples for org.apache.commons.lang3 StringUtils remove
public static String remove(final String str, final char remove)
Removes all occurrences of a character from within the source string.
A null source string will return null .
From source file:org.ligoj.app.plugin.prov.aws.in.ProvAwsPriceImportResource.java
/** * Build a new instance price type from the CSV line. */// w w w.j a va2s . c o m private ProvInstancePriceTerm newInstancePriceTerm(final UpdateContext context, final AwsEc2Price csvPrice) { final ProvInstancePriceTerm term = new ProvInstancePriceTerm(); term.setNode(context.getNode()); term.setCode(csvPrice.getOfferTermCode()); // Build the name from the leasing, purchase option and offering class final String name = StringUtils.trimToNull(StringUtils.removeAll( StringUtils.replaceAll(csvPrice.getPurchaseOption(), "([a-z])Upfront", "$1 Upfront"), "No\\s*Upfront")); term.setName(Arrays .stream(new String[] { csvPrice.getTermType(), StringUtils.replace(csvPrice.getLeaseContractLength(), " ", ""), name, StringUtils.trimToNull(StringUtils.remove(csvPrice.getOfferingClass(), "standard")) }) .filter(Objects::nonNull).collect(Collectors.joining(", "))); // Handle leasing final Matcher matcher = LEASING_TIME .matcher(StringUtils.defaultIfBlank(csvPrice.getLeaseContractLength(), "")); if (matcher.find()) { // Convert years to months term.setPeriod(Integer.parseInt(matcher.group(1)) * 12); } iptRepository.saveAndFlush(term); return term; }
From source file:org.mapreduce.martin.mapreducewordcount.algorithms.Mapping.java
/** * For cleaning a word to ensure that /*from ww w . j a va2s . co m*/ * @param word * @return */ public String cleanWord(String word) { String[] delimiters = { "\n", " ", " ", "\r", ".", "," }; for (String del : delimiters) { word = StringUtils.remove(word, del).trim(); } return word; }
From source file:org.neo4art.importer.wikipedia.parser.util.WikipediaInfoboxParserUtils.java
/** * @param input/*from www . j a v a 2 s . c om*/ * @return */ public static String getTextFromLink(String input) { String result = null; if (StringUtils.isNotBlank(input)) { result = input; result = StringUtils.remove(result, "[["); result = StringUtils.remove(result, "]]"); if (StringUtils.indexOf(result, "|") != -1) { result = StringUtils.substring(result, 0, StringUtils.indexOf(result, "|")); } result = StringUtils.trim(result); } return result; }
From source file:org.neo4art.importer.wikipedia.parser.util.WikipediaInfoboxParserUtils.java
/** * // ww w . j av a 2 s . c o m * @param input * @return * @throws MalformedURLException */ public static URL parseAsURL(String input) throws MalformedURLException { URL result = null; if (!StringUtils.isBlank(input)) { String temp = input; temp = StringUtils.remove(temp, "{"); temp = StringUtils.remove(temp, "}"); if (StringUtils.indexOf(temp, "[") != -1) { temp = StringUtils.remove(temp, "["); temp = StringUtils.remove(temp, "]"); if (StringUtils.indexOf(temp, " ") != -1) { temp = StringUtils.substring(temp, 0, StringUtils.indexOf(temp, " ")); } } temp = StringUtils.remove(temp, "URL|"); temp = StringUtils.replace(temp, " ", "_"); if (!StringUtils.startsWith(temp, "http")) { if (StringUtils.startsWith(temp, "www")) { temp = "http://" + temp; } else { temp = "https://en.wikipedia.org/wiki/File:" + temp; } } temp = StringUtils.removeEnd(temp, "|"); result = new URL(temp); } return result; }
From source file:org.neo4art.importer.wikipedia.parser.util.WikipediaInfoboxParserUtils.java
/** * @param input//from w w w. j a v a 2s. c om * @return */ public static List<String> asListOfStrings(String input) { List<String> result = null; if (StringUtils.isNotBlank(input)) { result = new ArrayList<String>(); String[] movements = StringUtils.split(input, ","); for (String movement : movements) { movement = StringUtils.trim(movement); movement = StringUtils.remove(movement, "[["); movement = StringUtils.remove(movement, "]]"); result.add(StringUtils.trim(movement)); } } return result; }
From source file:org.noroomattheinn.visibletesla.NotifierController.java
private void notifyUser(Map<String, String> contextSpecific, MessageTarget target) { String addr = target.getActiveEmail(); String lower = addr.toLowerCase(); // Don't muck with the original addr. // URLs are case sensitive if (lower.startsWith("http://") || lower.startsWith("https://")) { (new HTTPAsyncGet(addr)).exec(); }//from w w w . ja v a 2 s . com if (lower.startsWith("command:")) { String command = StringUtils.remove(addr, "command:"); String args = target.getSubject(); if (args != null) args = (new MessageTemplate(args)).getMessage(app.api, vtVehicle, contextSpecific); String stdin = target.getMessage(); if (stdin != null) stdin = (new MessageTemplate(stdin)).getMessage(app.api, vtVehicle, contextSpecific); ThreadManager.get().launchExternal(command, args, stdin, 60 * 1000); logger.info("Executing external command for notification: " + command); } else { MessageTemplate mt = new MessageTemplate(target.getActiveMsg()); MessageTemplate st = new MessageTemplate(target.getActiveSubj()); MailGun.get().send(addr, st.getMessage(app.api, vtVehicle, contextSpecific), mt.getMessage(app.api, vtVehicle, contextSpecific)); } }
From source file:org.opensilk.music.plugin.upnp.UpnpServiceService.java
@Override protected UpnpServiceConfiguration createConfiguration() { return new AndroidUpnpServiceConfiguration() { @Override// w w w . j a v a 2s. c o m public ServiceType[] getExclusiveServiceTypes() { return new ServiceType[] { new UDAServiceType("ContentDirectory", 1) }; } @Override protected SOAPActionProcessor createSOAPActionProcessor() { return new RecoveringSOAPActionProcessorImpl() { @Override @DebugLog public void readBody(ActionResponseMessage responseMsg, ActionInvocation actionInvocation) throws UnsupportedDataException { try { super.readBody(responseMsg, actionInvocation); } catch (Exception e) { //Hack for X_GetFeatureList embedding this in the body String fixedBody = StringUtils.remove(getMessageBody(responseMsg), "<?xml version=\"1.0\" encoding=\"utf-8\"?>"); responseMsg.setBody(fixedBody); super.readBody(responseMsg, actionInvocation); } } }; } @Override public int getRegistryMaintenanceIntervalMillis() { return 10000; } }; }
From source file:org.owasp.webgoat.controller.Start.java
private String getRole() { Collection<GrantedAuthority> authorities = (Collection<GrantedAuthority>) SecurityContextHolder.getContext() .getAuthentication().getAuthorities(); String role = "N/A"; for (GrantedAuthority authority : authorities) { authority.getAuthority();/*from www . jav a2 s.c om*/ role = authority.getAuthority(); role = StringUtils.lowerCase(role); role = StringUtils.remove(role, "role_"); break; } return role; }
From source file:org.pepstock.jem.gwt.server.services.NodesManager.java
/** * Returns the HAZELCAST cluster status which is the list of all members.<br> * This is a sampl output format:<br> * <code>/*from ww w . j a v a 2 s.c o m*/ * Members [2] { Member [127.0.0.1]:5710 this Member [127.0.0.1]:5711 } * </code> * * @param node node where execute a future task to get top command * @return content file in String * @throws ServiceMessageException if exception occurs */ public String displayCluster(NodeInfoBean node) throws ServiceMessageException { // checks if the user is authorized to performs commands // if not, this method throws an exception checkAuthorization(new StringPermission(Permissions.ADMINISTRATION_NODES_COMMANDS)); // gets hzelcast cluster Cluster cluster = getInstance().getCluster(); // scans all members creating a stringbuilder // with HC format StringBuilder result = new StringBuilder("Members [").append(cluster.getMembers().size()).append("] {") .append("\n"); for (Member member : cluster.getMembers()) { // adds dinamically the label "this" // based on node passed as argument String memberString = StringUtils.remove(member.toString(), " this"); if (node.getKey().equals(member.getUuid())) { memberString = memberString + " this"; } result.append(" ").append(memberString).append("\n"); } result.append("}\n"); return result.toString(); }
From source file:org.pepstock.jem.jppf.JPPFUtil.java
/** * Parses address, port and load JPPF properties to connect to JPPF. * @param props JPPF properties to load//from w w w.j a v a2 s . c om * @param addressParm address to parse * @throws JPPFMessageException if address is not valid */ public static void loadTypedProperties(TypedProperties props, String addressParm) throws JPPFMessageException { // parses addresses (comma separated) String address = StringUtils.remove(addressParm, " "); String[] addresses = StringUtils.split(address, ","); if (addresses != null && addresses.length > 0) { // calculate JPPF.DRIVERS properties StringBuilder drivers = new StringBuilder(); for (int i = 0; i < addresses.length; i++) { // parses address. FORMAT: [host|ipaddress]:[port] if (addresses[i].contains(":")) { String host = StringUtils.substringBefore(addresses[i], ":"); String port = StringUtils.substringAfter(addresses[i], ":"); // drivers is named with counter String driver = Keys.JEM_JPPF_DRIVER_PREFIX + i; props.setProperty(driver + Keys.JEM_JPPF_PORT_SUFFIX, port); props.setProperty(driver + Keys.JEM_JPPF_SERVER_SUFFIX, host); // drivers are defined blank separated drivers.append(driver).append(" "); } else { throw new JPPFMessageException(JPPFMessage.JEMJ008E, addresses[i]); } } // sets drivers props.setProperty(Keys.JEM_JPPF_DRIVERS, drivers.toString()); } }