List of usage examples for org.apache.commons.lang StringUtils removeStart
public static String removeStart(String str, String remove)
Removes a substring only if it is at the begining of a source string, otherwise returns the source string.
From source file:com.adobe.acs.commons.quickly.Command.java
public Command(final String raw) { this.raw = StringUtils.stripToEmpty(raw); String opWithPunctuation = StringUtils .stripToEmpty(StringUtils.lowerCase(StringUtils.substringBefore(this.raw, " "))); int punctuationIndex = StringUtils.indexOfAny(opWithPunctuation, PUNCTUATIONS); if (punctuationIndex > 0) { this.punctuation = StringUtils.substring(opWithPunctuation, punctuationIndex).split("(?!^)"); this.operation = StringUtils.substring(opWithPunctuation, 0, punctuationIndex); } else {// w w w .java2 s . c o m this.punctuation = new String[] {}; this.operation = opWithPunctuation; } this.param = StringUtils.stripToEmpty(StringUtils.removeStart(this.raw, opWithPunctuation)); this.params = StringUtils.split(this.param); if (log.isTraceEnabled()) { log.trace("Raw: {}", this.raw); log.trace("Operation: {}", this.operation); log.trace("Punctuation: {}", Arrays.toString(this.punctuation)); log.trace("Param: {}", this.param); log.trace("Params: {}", Arrays.toString(this.params)); } }
From source file:com.hangum.tadpole.engine.sql.util.executer.procedure.MSSQLProcedureExecuter.java
/** * execute script// w w w .j a v a 2 s .co m */ public String getMakeExecuteScript() throws Exception { StringBuffer sbQuery = new StringBuffer(); if ("FUNCTION".equalsIgnoreCase(procedureDAO.getType())) { if (!"".equals(procedureDAO.getPackagename())) { sbQuery.append("SELECT " + procedureDAO.getPackagename() + "." + procedureDAO.getSysName() + "("); } else { sbQuery.append("SELECT " + procedureDAO.getSysName() + "("); } List<InOutParameterDAO> inList = getInParameters(); for (int i = 0; i < inList.size(); i++) { InOutParameterDAO inOutParameterDAO = inList.get(i); String name = StringUtils.removeStart(inOutParameterDAO.getName(), "@"); if (i == (inList.size() - 1)) sbQuery.append(String.format(":%s", name)); else sbQuery.append(String.format(":%s, ", name)); } sbQuery.append(");"); } else { // . if (!"".equals(procedureDAO.getPackagename())) { sbQuery.append( String.format("EXEC %s.%s ", procedureDAO.getPackagename(), procedureDAO.getSysName())); } else { sbQuery.append(String.format("EXEC %s ", procedureDAO.getSysName())); } // out List<InOutParameterDAO> inList = getInParameters(); for (int i = 0; i < inList.size(); i++) { InOutParameterDAO inOutParameterDAO = inList.get(i); String name = inOutParameterDAO.getName(); String nameVal = StringUtils.removeStart(inOutParameterDAO.getName(), "@"); if (i != (inList.size() - 1)) sbQuery.append(String.format("%s = :%s, ", name, nameVal)); else sbQuery.append(String.format("%s = :%s", name, nameVal)); } } if (logger.isDebugEnabled()) logger.debug("Execute Procedure query is\t " + sbQuery.toString()); return sbQuery.toString(); }
From source file:edu.mayo.cts2.framework.core.config.ConfigInitializerFactory.java
public void contextInitialized(ServletContextEvent sce) { try {/*from w ww . j a v a 2s . c o m*/ ConfigInitializer.initialize(StringUtils.removeStart(sce.getServletContext().getContextPath(), "/")); } catch (Cts2ConfigAlreadyInitializedException e) { throw new IllegalStateException(e); } }
From source file:info.magnolia.module.files.ModuleFileExtractorTransformer.java
@Override public String accept(String resourcePath) { final boolean thisIsAFileWeWant = resourcePath.startsWith("/mgnl-files/") && StringUtils.contains(resourcePath, "/" + moduleName + "/"); if (!thisIsAFileWeWant) { return null; }//from w w w.j av a2s. c o m final String relTargetPath = StringUtils.removeStart(resourcePath, "/mgnl-files/"); return Path.getAbsoluteFileSystemPath(relTargetPath); }
From source file:net.shopxx.plugin.ossStorage.OssStoragePlugin.java
@Override public void upload(String path, File file, String contentType) { PluginConfig pluginConfig = getPluginConfig(); if (pluginConfig != null) { String endpoint = pluginConfig.getAttribute("endpoint"); String accessId = pluginConfig.getAttribute("accessId"); String accessKey = pluginConfig.getAttribute("accessKey"); String bucketName = pluginConfig.getAttribute("bucketName"); InputStream inputStream = null; try {//from ww w . j a v a 2s . c o m inputStream = new BufferedInputStream(new FileInputStream(file)); OSSClient ossClient = new OSSClient(endpoint, accessId, accessKey); ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setContentType(contentType); objectMetadata.setContentLength(file.length()); ossClient.putObject(bucketName, StringUtils.removeStart(path, "/"), inputStream, objectMetadata); } catch (FileNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(inputStream); } } }
From source file:jenkins.plugins.git.traits.DiscoverOtherRefsTrait.java
@DataBoundConstructor public DiscoverOtherRefsTrait(String ref) { if (StringUtils.isEmpty(ref)) { throw new IllegalArgumentException("ref can not be empty"); }/*from ww w . ja v a 2 s . c o m*/ this.ref = StringUtils.removeStart(StringUtils.removeStart(ref, Constants.R_REFS), "/"); setDefaultNameMapping(); }
From source file:com.aqnote.shared.encrypt.cert.bc.loader.CaCertLoader.java
public synchronized static String getB64CaCrt() throws IOException { if (StringUtils.isBlank(b64CaCrt)) { ClassLoader classLoader = ClassLoaderUtil.getClassLoader(); InputStream is = classLoader.getResourceAsStream(CA_CRT_FILE); b64CaCrt = StreamUtil.stream2Bytes(is, StandardCharsets.UTF_8); b64CaCrt = StringUtils.removeStart(b64CaCrt, BEGIN_CERT); b64CaCrt = StringUtils.removeEnd(b64CaCrt, END_CERT); }/* w w w . j a v a 2 s. c o m*/ return b64CaCrt; }
From source file:com.temenos.interaction.core.web.RequestContextFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest servletRequest = (HttpServletRequest) request; String requestURI = servletRequest.getRequestURI(); requestURI = StringUtils.removeStart(requestURI, servletRequest.getContextPath() + servletRequest.getServletPath()); String baseURL = StringUtils.removeEnd(servletRequest.getRequestURL().toString(), requestURI); Map<String, List<String>> headersMap = new HashMap<>(); Enumeration<String> headerNames = servletRequest.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); List<String> valuesList = Collections.list(servletRequest.getHeaders(headerName)); headersMap.put(headerName, valuesList); }/*from ww w .jav a 2 s . c om*/ } RequestContext ctx; Principal userPrincipal = servletRequest.getUserPrincipal(); if (userPrincipal != null) { ctx = new RequestContext(baseURL, servletRequest.getRequestURI(), servletRequest.getHeader(RequestContext.HATEOAS_OPTIONS_HEADER), userPrincipal, headersMap); } else { ctx = new RequestContext(baseURL, servletRequest.getRequestURI(), servletRequest.getHeader(RequestContext.HATEOAS_OPTIONS_HEADER), headersMap); } RequestContext.setRequestContext(ctx); try { chain.doFilter(request, response); } finally { RequestContext.clearRequestContext(); } }
From source file:com.aqnote.shared.cryptology.cert.loader.CaCertLoader.java
public synchronized static String getB64RootCaCert() throws IOException { if (StringUtils.isBlank(b64RootCaCert)) { ClassLoader classLoader = ClassLoaderUtil.getClassLoader(); InputStream is = classLoader.getResourceAsStream(CA_Cert_FILE); b64RootCaCert = StreamUtil.stream2Bytes(is, StandardCharsets.UTF_8); b64RootCaCert = StringUtils.removeStart(b64RootCaCert, BEGIN_CERT); b64RootCaCert = StringUtils.removeEnd(b64RootCaCert, END_CERT); }/*from w w w . jav a2s . c o m*/ return b64RootCaCert; }
From source file:info.magnolia.cms.i18n.DefaultI18nContentSupport.java
@Override protected String toRawURI(String i18nURI, Locale locale) { //MAGNOLIA-2142 - make sure we strip language only when it is actually present String raw = StringUtils.removeStart(i18nURI, "/" + locale.toString() + "/"); // put back leading slash if removed while stripping language identifier return raw == null || raw.startsWith("/") ? raw : ("/" + raw); }