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:br.com.nordestefomento.jrimum.bopepo.campolivre.CampoLivreFactory.java
/** * Devolve um CampoLivre de acordo a partir de uma String. * /*from www .j a va2 s . c o m*/ * @param strCampoLivre * * @return Uma referncia para um ICampoLivre. * * @throws NullPointerException * @throws IllegalArgumentException */ public static CampoLivre create(String strCampoLivre) { CampoLivre campoLivre = null; ObjectUtil.checkNotNull(strCampoLivre); StringUtil.checkNotBlank(strCampoLivre, "O Campo Livre no deve ser vazio!"); strCampoLivre = StringUtils.strip(strCampoLivre); if (strCampoLivre.length() == CampoLivre.STRING_LENGTH) { if (StringUtils.remove(strCampoLivre, ' ').length() == CampoLivre.STRING_LENGTH) { if (StringUtils.isNumeric(strCampoLivre)) { campoLivre = new CampoLivre() { private static final long serialVersionUID = -7592488081807235080L; Field<String> campo = new Field<String>(StringUtils.EMPTY, STRING_LENGTH, Filler.ZERO_LEFT); public void read(String str) { campo.read(str); } public String write() { return campo.write(); } }; campoLivre.read(strCampoLivre); } else { IllegalArgumentException e = new IllegalArgumentException( "O Campo Livre [ " + strCampoLivre + " ] deve ser uma String numrica!"); log.error(StringUtils.EMPTY, e); throw e; } } else { IllegalArgumentException e = new IllegalArgumentException( "O Campo Livre [ " + strCampoLivre + " ] no deve conter espaos em branco!"); log.error(StringUtils.EMPTY, e); throw e; } } else { IllegalArgumentException e = new IllegalArgumentException("O tamanho do Campo Livre [ " + strCampoLivre + " ] deve ser igual a 25 e no [" + strCampoLivre.length() + "]!"); log.error(StringUtils.EMPTY, e); throw e; } return campoLivre; }
From source file:edu.ku.brc.specify.tools.datamodelgenerator.DataDict.java
/** * @param text/*from w w w. j a v a 2s. co m*/ * @return */ protected String getText(final String text) { String desc = StringUtils.replace(StringUtils.remove(text, '\n'), " ", " "); desc = StringUtils.replace(desc, " ", " "); desc = StringUtils.replace(desc, " ", " "); desc = StringEscapeUtils.escapeXml(desc); desc = StringUtils.replace(desc, "&apos;", "'"); desc = StringUtils.replace(desc, " ", " "); desc = StringUtils.replace(desc, " ", " "); if (StringUtils.isNotBlank(desc)) { return desc; } return ""; }
From source file:com.hangum.tadpole.engine.sql.parser.UpdateDeleteParser.java
/** * getObjectName//from w ww . j ava2 s. c om * * @param matcher * @param sql * @return */ private String getObjectName(Matcher matcher, String sql) { int intEndIndex = matcher.end(1); int intContentLength = matcher.group(1).length(); // if(logger.isDebugEnabled()) { // logger.debug("===DDL Parser======================================"); // logger.debug("SQL :" + sql); // logger.debug("object name: " + matcher.group(1)); // logger.debug("intContentLength : " + intContentLength ); // logger.debug("intEndIndex : " + intEndIndex ); // logger.debug("start index: " + (intEndIndex - intContentLength)); // logger.debug("===DDL Parser======================================"); // } String objctName = StringUtils.substring(sql, (intEndIndex - intContentLength), intEndIndex); objctName = StringUtils.remove(objctName, "\""); objctName = StringUtils.remove(objctName, "'"); objctName = StringUtils.remove(objctName, "`"); return objctName; }
From source file:net.bpelunit.framework.control.util.BPELUnitUtil.java
/** * Removes line breaks from a string/*from ww w . j a v a 2 s . co m*/ * * @param string * @return */ public static String removeSpaceLineBreaks(String string) { if (string == null) { return ""; } String v = string.trim(); v = StringUtils.remove(v, '\n'); v = StringUtils.remove(v, '\r'); v = StringUtils.remove(v, '\t'); return v; }
From source file:gov.nih.nci.cacis.sa.mirthconnect.SemanticAdapter.java
/** * AcceptSource operation accepts data from Clinical Source system and sends it to Mirth Connect for processing * /*from ww w. java 2 s . c om*/ * @param parameter caCISRequest * @return CaCISResponse * @throws AcceptSourceFault Web Service Fault */ @WebResult(name = "caCISResponse", targetNamespace = "http://cacis.nci.nih.gov", partName = "parameter") @WebMethod public CaCISResponse acceptSource( @WebParam(partName = "parameter", name = "caCISRequest", targetNamespace = "http://cacis.nci.nih.gov") CaCISRequest parameter) throws AcceptSourceFault { LOG.info("Executing operation acceptSource"); final CaCISResponse response = new CaCISResponse(); try { final String reqstr = getCaCISRequestxml(parameter); if (StringUtils.isEmpty(reqstr)) { throw new AcceptSourceFault("Error marshalling CaCISRequest!"); } String mcResponse = webServiceMessageReceiver.processData(reqstr); LOG.info("MC RESPONSE:" + mcResponse); if (mcResponse != null && (mcResponse.indexOf("Error") > -1 || mcResponse.indexOf("Exception") > -1 || mcResponse.indexOf("ERROR") > -1 || mcResponse.indexOf("error") > -1)) { mcResponse = StringUtils.remove(mcResponse, "SUCCESS:"); // throw new AcceptSourceFault("Error processing Data from Source System: " + mcResponse); throw new AcceptSourceFault(mcResponse); } response.setStatus(ResponseStatusType.SUCCESS); return response; // CHECKSTYLE:OFF } catch (Exception ex) { // CHECKSTYLE:ON LOG.error(ex); throw new AcceptSourceFault(ex.getMessage(), ex); } }
From source file:gov.nih.nci.cacis.ip.mirthconnect.CanonicalModelProcessor.java
/** * Method accepts canonical data for processing * /*from w w w. j av a2 s . c o m*/ * @param request CaCISRequest * @return response CaCISResponse * @throws AcceptCanonicalFault Fault * @throws */ @WebResult(name = "caCISResponse", targetNamespace = CACIS_NS, partName = "parameter") @WebMethod public gov.nih.nci.cacis.CaCISResponse acceptCanonical( @WebParam(partName = "parameter", name = "caCISRequest", targetNamespace = CACIS_NS) CaCISRequest request) throws AcceptCanonicalFault { final CaCISResponse response = new CaCISResponse(); final StringWriter sw = new StringWriter(); try { final JAXBContext jc = JAXBContext.newInstance(CaCISRequest.class); final Marshaller m = jc.createMarshaller(); final PrintWriter pw = new PrintWriter(sw); m.marshal(request, pw); response.setStatus(ResponseStatusType.SUCCESS); } catch (JAXBException jaxE) { throw new AcceptCanonicalFault("Error Marshalling object", jaxE); } try { String mcResponse = webServiceMessageReceiver.processData(sw.toString()); if (mcResponse != null && (mcResponse.indexOf("Error") > -1 || mcResponse.indexOf("Exception") > -1 || mcResponse.indexOf("ERROR") > -1 || mcResponse.indexOf("error") > -1)) { mcResponse = StringUtils.remove(mcResponse, "SUCCESS:"); String channelUid = StringUtils.substringBetween(mcResponse, "(", ")"); if (channelUid != null) { mcResponse = StringUtils.remove(mcResponse, "(" + channelUid + ")"); } throw new AcceptCanonicalFault( StringUtils.substring(mcResponse, StringUtils.lastIndexOf(mcResponse, ':'))); } response.setStatus(ResponseStatusType.SUCCESS); return response; // CHECKSTYLE:OFF } catch (Exception e) { // CHECKSTYLE:ON //throw new AcceptCanonicalFault("Error processing message!" + e.getMessage(), e); throw new AcceptCanonicalFault(e.getMessage(), e); } }
From source file:io.ecarf.core.utils.UsageParser.java
public UsageParser(String folder) throws Exception { super();//from ww w.j a v a2 s. c om boolean remote = folder.startsWith(GoogleMetaData.CLOUD_STORAGE_PREFIX); if (remote) { String bucket = StringUtils.remove(folder, GoogleMetaData.CLOUD_STORAGE_PREFIX); this.setUp(); List<StorageObject> objects = this.service.listCloudStorageObjects(bucket); for (StorageObject object : objects) { String name = object.getName(); if (name.endsWith(Constants.DOT_LOG)) { String localFile = FilenameUtils.getLocalFilePath(name); service.downloadObjectFromCloudStorage(name, localFile, bucket); this.files.add(localFile); } } } else { // local file DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() { public boolean accept(Path file) throws IOException { String filename = file.toString(); return filename.contains(USAGE_PREFIX); } }; Path dir = Paths.get(folder); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, filter)) { for (Path path : stream) { this.files.add(path.toString()); } } } }
From source file:edu.ku.brc.specify.toycode.mexconabio.AgentNames.java
private void parseForNames(final String nameStr) { String str = nameStr;//ww w. jav a 2 s.co m if (StringUtils.contains(str, '\"')) { str = StringUtils.remove(str, '\"'); } if (StringUtils.contains(str, ';')) { String[] toks = StringUtils.split(str, ';'); for (String s : toks) { parseForFirstLastName(s); } } else { parseForFirstLastName(str); /*String[] toks = str.split("^([-\\w]+)(?:(?:\\s?[,|&]\\s)([-\\w]+)\\s?)*(.*)"); //"((?:[^, &]+\\s*[,&]+\\s*)*[^, &]+)\\s+([^,&]+)"); for (String s : toks) { System.out.println(" ["+s+"]"); }*/ } System.out.println(); }
From source file:gobblin.data.management.copy.writer.TarArchiveInputStreamDataWriter.java
/** * Untars the passed in {@link FileAwareInputStream} to the task's staging directory. Uses the name of the root * {@link TarArchiveEntry} in the stream as the directory name for the untarred file. The method also commits the data * by moving the file from staging to output directory. * * @see gobblin.data.management.copy.writer.FileAwareInputStreamDataWriter#write(gobblin.data.management.copy.FileAwareInputStream) *///w w w . ja v a 2 s . c o m @Override public void writeImpl(InputStream inputStream, Path writeAt, CopyableFile copyableFile) throws IOException { this.closer.register(inputStream); TarArchiveInputStream tarIn = new TarArchiveInputStream(inputStream); final ReadableByteChannel inputChannel = Channels.newChannel(tarIn); TarArchiveEntry tarEntry; // flush the first entry in the tar, which is just the root directory tarEntry = tarIn.getNextTarEntry(); String tarEntryRootName = StringUtils.remove(tarEntry.getName(), Path.SEPARATOR); log.info("Unarchiving at " + writeAt); try { while ((tarEntry = tarIn.getNextTarEntry()) != null) { // the API tarEntry.getName() is misleading, it is actually the path of the tarEntry in the tar file String newTarEntryPath = tarEntry.getName().replace(tarEntryRootName, writeAt.getName()); Path tarEntryStagingPath = new Path(writeAt.getParent(), newTarEntryPath); if (tarEntry.isDirectory() && !this.fs.exists(tarEntryStagingPath)) { this.fs.mkdirs(tarEntryStagingPath); } else if (!tarEntry.isDirectory()) { FSDataOutputStream out = this.fs.create(tarEntryStagingPath, true); final WritableByteChannel outputChannel = Channels.newChannel(out); try { StreamCopier copier = new StreamCopier(inputChannel, outputChannel); if (isInstrumentationEnabled()) { copier.withCopySpeedMeter(this.copySpeedMeter); } this.bytesWritten.addAndGet(copier.copy()); if (isInstrumentationEnabled()) { log.info("File {}: copied {} bytes, average rate: {} B/s", copyableFile.getOrigin().getPath(), this.copySpeedMeter.getCount(), this.copySpeedMeter.getMeanRate()); } else { log.info("File {} copied.", copyableFile.getOrigin().getPath()); } } finally { out.close(); outputChannel.close(); } } } } finally { tarIn.close(); inputChannel.close(); inputStream.close(); } }
From source file:gobblin.util.PathUtils.java
/** * Removes all <code>extensions</code> from <code>path</code> if they exist. * * <pre>//w w w . j av a2 s. co m * PathUtils.removeExtention("file.txt", ".txt") = file * PathUtils.removeExtention("file.txt.gpg", ".txt", ".gpg") = file * PathUtils.removeExtention("file", ".txt") = file * PathUtils.removeExtention("file.txt", ".tar.gz") = file.txt * PathUtils.removeExtention("file.txt.gpg", ".txt") = file.gpg * PathUtils.removeExtention("file.txt.gpg", ".gpg") = file.txt * </pre> * * @param path in which the <code>extensions</code> need to be removed * @param extensions to be removed * * @return a new {@link Path} without <code>extensions</code> */ public static Path removeExtension(Path path, String... extensions) { String pathString = path.toString(); for (String extension : extensions) { pathString = StringUtils.remove(pathString, extension); } return new Path(pathString); }