Java Code Examples for org.apache.commons.lang3.StringUtils#removeStart()
The following examples show how to use
org.apache.commons.lang3.StringUtils#removeStart() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: chassis File: ClasspathResourceServlet.java License: Apache License 2.0 | 6 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // figure out the real path String pathInfo = StringUtils.trimToEmpty(req.getPathInfo()); while (pathInfo.endsWith("/")) { pathInfo = StringUtils.removeEnd(pathInfo, "/"); } while (pathInfo.startsWith("/")) { pathInfo = StringUtils.removeStart(pathInfo, "/"); } if (StringUtils.isBlank(pathInfo)) { resp.sendRedirect(rootContextPath + "/" + welcomePage); } else { Resource resource = resourceLoader.getResource("classpath:" + classPathDirectory + req.getPathInfo()); if (resource.exists()) { StreamUtils.copy(resource.getInputStream(), resp.getOutputStream()); resp.setStatus(HttpServletResponse.SC_OK); } else { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } } }
Example 2
Source Project: archiva File: RemoteRepository.java License: Apache License 2.0 | 5 votes |
public void setCheckPath(String checkPath) { if (checkPath==null) { this.checkPath=""; } else if (checkPath.startsWith("/")) { this.checkPath = StringUtils.removeStart(checkPath, "/"); while(this.checkPath.startsWith("/")) { this.checkPath = StringUtils.removeStart(checkPath, "/"); } } else { this.checkPath = checkPath; } }
Example 3
Source Project: cyberduck File: TerminalHelpFormatter.java License: GNU General Public License v3.0 | 5 votes |
protected StringBuffer renderWrappedText(final StringBuffer sb, final int width, int nextLineTabStop, String text) { int pos = findWrapPos(text, width, 0); if(pos == -1) { sb.append(rtrim(text)); return sb; } sb.append(rtrim(text.substring(0, pos))).append(getNewLine()); if(nextLineTabStop >= width) { // stops infinite loop happening nextLineTabStop = 1; } // all following lines must be padded with nextLineTabStop space characters final String padding = createPadding(nextLineTabStop); while(true) { text = padding + StringUtils.removeStart(text.substring(pos), StringUtils.SPACE); pos = findWrapPos(text, width, 0); if(pos == -1) { sb.append(text); return sb; } if((text.length() > width) && (pos == nextLineTabStop - 1)) { pos = width; } sb.append(rtrim(text.substring(0, pos))).append(getNewLine()); } }
Example 4
Source Project: owltools File: PANTHERTree.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create an instance for the given path * * @param pFile path * @throws IOException */ public PANTHERTree (File pFile) throws IOException { if( pFile == null ){ throw new Error("No file was specified..."); } // String fileAsStr = FileUtils.readFileToString(pFile); String[] lines = StringUtils.split(fileAsStr, "\n"); // The first line is the tree in Newick-ish form, the rest is the annotation info // that needs to be parsed later on. if( lines.length < 3 ){ throw new Error("Does not look like a usable PANTHER tree file: " + pFile.getName()); }else{ // The human tree name. //treeLabel = StringUtils.lowerCase(StringUtils.removeStart(lines[0], "NAME=")); treeLabel = StringUtils.removeStart(lines[0], "NAME="); // The raw tree. treeStr = lines[1]; // The raw annotations associated with the tree. treeAnns = Arrays.copyOfRange(lines, 2, lines.length); if( treeAnns == null || treeStr == null || treeLabel == null || treeStr.equals("") || treeLabel.equals("") || treeAnns.length < 1 ){ throw new Error("It looks like a bad PANTHER tree file."); }else{ String filename = pFile.getName(); treeID = StringUtils.substringBefore(filename, "."); } } //LOG.info("Processing: " + getTreeName() + " with " + lines.length + " lines."); annotationSet = new HashSet<String>(); generateGraph(); // this must come before annotation processing readyAnnotationDataCache(); matchAnnotationsIntoGraph(); }
Example 5
Source Project: camel-kafka-connector File: CamelSinkTask.java License: Apache License 2.0 | 5 votes |
private void addHeader(Map<String, Object> map, Header singleHeader) { String camelHeaderKey = StringUtils.removeStart(singleHeader.key(), HEADER_CAMEL_PREFIX); Schema schema = singleHeader.schema(); if (schema.type().getName().equals(Schema.STRING_SCHEMA.type().getName())) { map.put(camelHeaderKey, (String)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.BOOLEAN_SCHEMA.type().getName())) { map.put(camelHeaderKey, (Boolean)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.INT32_SCHEMA.type().getName())) { map.put(camelHeaderKey, singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.BYTES_SCHEMA.type().getName())) { map.put(camelHeaderKey, (byte[])singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.FLOAT32_SCHEMA.type().getName())) { map.put(camelHeaderKey, (float)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.FLOAT64_SCHEMA.type().getName())) { map.put(camelHeaderKey, (double)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.INT16_SCHEMA.type().getName())) { map.put(camelHeaderKey, (short)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.INT64_SCHEMA.type().getName())) { map.put(camelHeaderKey, (long)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(Schema.INT8_SCHEMA.type().getName())) { map.put(camelHeaderKey, (byte)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(SchemaBuilder.map(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA).type().getName())) { map.put(camelHeaderKey, (Map<?, ?>)singleHeader.value()); } else if (schema.type().getName().equalsIgnoreCase(SchemaBuilder.array(Schema.STRING_SCHEMA).type().getName())) { map.put(camelHeaderKey, (List<?>)singleHeader.value()); } }
Example 6
Source Project: scoold File: ScooldUtils.java License: Apache License 2.0 | 5 votes |
private ParaObject checkApiAuth(HttpServletRequest req) { if (req.getRequestURI().equals(CONTEXT_PATH + "/api")) { return null; } String apiKeyJWT = StringUtils.removeStart(req.getHeader(HttpHeaders.AUTHORIZATION), "Bearer "); if (req.getRequestURI().equals(CONTEXT_PATH + "/api/stats") && isValidJWToken(apiKeyJWT)) { return API_USER; } else if (!isApiEnabled() || StringUtils.isBlank(apiKeyJWT) || !isValidJWToken(apiKeyJWT)) { throw new WebApplicationException(401); } return API_USER; }
Example 7
Source Project: hbase File: TestHdfsSnapshotHRegion.java License: Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { Configuration c = TEST_UTIL.getConfiguration(); c.setBoolean("dfs.support.append", true); TEST_UTIL.startMiniCluster(1); table = TEST_UTIL.createMultiRegionTable(TABLE_NAME, FAMILY); TEST_UTIL.loadTable(table, FAMILY); // setup the hdfssnapshots client = new DFSClient(TEST_UTIL.getDFSCluster().getURI(), TEST_UTIL.getConfiguration()); String fullUrIPath = TEST_UTIL.getDefaultRootDirPath().toString(); String uriString = TEST_UTIL.getTestFileSystem().getUri().toString(); baseDir = StringUtils.removeStart(fullUrIPath, uriString); client.allowSnapshot(baseDir); }
Example 8
Source Project: WeBASE-Front File: FrontUtils.java License: Apache License 2.0 | 5 votes |
/** * remove fist string. */ public static String removeFirstStr(String constant, String target) { if (StringUtils.isBlank(constant) || StringUtils.isBlank(target)) { return constant; } if (constant.startsWith(target)) { constant = StringUtils.removeStart(constant, target); } return constant; }
Example 9
Source Project: openemm File: ConfigService.java License: GNU Affero General Public License v3.0 | 5 votes |
private static Tuple<String, String> createHostProperty(Entry<String, String> propertyEntry) { String hostFunction = StringUtils.removeStart(propertyEntry.getKey(), "hostname-"); String hostName = propertyEntry.getValue(); String propertyName = String.format("host.%s.%s.ping", hostFunction, hostName); String reachable = "ERROR"; try { InetAddress address = InetAddress.getByName(hostName); reachable = address.isReachable(1000) ? "OK" : "ERROR"; } catch (IOException e) { logger.error("Cannot reach to host " + hostName, e); } return new Tuple<>(propertyName, reachable); }
Example 10
Source Project: JsoupXpath File: XValue.java License: Apache License 2.0 | 5 votes |
public XValue exprStr(){ this.isExprStr = true; String str = StringUtils.removeStart(String.valueOf(this.value),"'"); str = StringUtils.removeStart(str,"\""); str = StringUtils.removeEnd(str,"'"); this.value = StringUtils.removeEnd(str,"\""); return this; }
Example 11
Source Project: symbol-sdk-java File: RepositoryFactoryBase.java License: Apache License 2.0 | 5 votes |
protected ObservableSource<NetworkCurrency> getNetworkCurrency(String mosaicIdHex) { MosaicId mosaicId = new MosaicId( StringUtils.removeStart(mosaicIdHex.replace("'", "").substring(2), "0x")); return createMosaicRepository().getMosaic(mosaicId) .map(mosaicInfo -> new NetworkCurrencyBuilder(mosaicInfo.getMosaicId(), mosaicInfo.getDivisibility()).withTransferable(mosaicInfo.isTransferable()) .withSupplyMutable(mosaicInfo.isSupplyMutable())) .flatMap(builder -> createNamespaceRepository() .getMosaicsNames(Collections.singletonList(mosaicId)).map( names -> names.stream().filter(n -> n.getMosaicId().equals(mosaicId)) .findFirst() .map(name -> builder.withNamespaceId(getNamespaceId(names)).build()) .orElse(builder.build()))); }
Example 12
Source Project: bird-java File: QueryDescriptor.java License: MIT License | 5 votes |
public static String getDbFieldName(Field field) { TableField tableField = field.getAnnotation(TableField.class); String dbFieldName = tableField == null ? field.getName() : tableField.value(); if (StringUtils.startsWith(dbFieldName, "{") && StringUtils.endsWith(dbFieldName, "}")) { dbFieldName = StringUtils.removeStart(dbFieldName, "{"); dbFieldName = StringUtils.removeEnd(dbFieldName, "}"); } else { dbFieldName = StringUtils.wrapIfMissing(dbFieldName, '`'); } return dbFieldName; }
Example 13
Source Project: circus-train File: S3S3Copier.java License: Apache License 2.0 | 5 votes |
private void initialiseCopyJobsFromListing( AmazonS3URI sourceS3Uri, final AmazonS3URI targetS3Uri, ListObjectsRequest request, ObjectListing listing) { LOG .debug("Found objects to copy {}, for request {}/{}", listing.getObjectSummaries(), request.getBucketName(), request.getPrefix()); List<S3ObjectSummary> objectSummaries = listing.getObjectSummaries(); for (final S3ObjectSummary s3ObjectSummary : objectSummaries) { totalBytesToReplicate += s3ObjectSummary.getSize(); String fileName = StringUtils.removeStart(s3ObjectSummary.getKey(), sourceS3Uri.getKey()); final String targetKey = Strings.nullToEmpty(targetS3Uri.getKey()) + fileName; CopyObjectRequest copyObjectRequest = new CopyObjectRequest(s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey(), targetS3Uri.getBucket(), targetKey); if (s3s3CopierOptions.getCannedAcl() != null) { copyObjectRequest.withCannedAccessControlList(s3s3CopierOptions.getCannedAcl()); } applyObjectMetadata(copyObjectRequest); TransferStateChangeListener stateChangeListener = new BytesTransferStateChangeListener(s3ObjectSummary, targetS3Uri, targetKey); copyJobRequests.add(new CopyJobRequest(copyObjectRequest, stateChangeListener)); } }
Example 14
Source Project: sqlg File: PartitionTree.java License: MIT License | 5 votes |
private String fromExpression() { if (this.fromToIn != null && this.parentPartitionTree.partitionType.isRange()) { String tmp = this.fromToIn.substring("FOR VALUES FROM (".length()); String fromTo[] = tmp.split(" TO "); String from = fromTo[0].trim(); from = StringUtils.removeStart(from, "("); from = StringUtils.removeEnd(from, ")"); return from; } else { return null; } }
Example 15
Source Project: jackdaw File: NameBean.java License: Apache License 2.0 | 4 votes |
@Override public final String apply(final String input) { final String name = StringUtils.removeStart(StringUtils.removeEnd(input, MODEL), ABSTRACT); return StringUtils.equals(name, input) ? input + BEAN : name; }
Example 16
Source Project: synopsys-detect File: YarnLockParser.java License: Apache License 2.0 | 4 votes |
private String removeWrappingQuotes(String s) { return StringUtils.removeStart(StringUtils.removeEnd(s.trim(), "\""), "\""); }
Example 17
Source Project: DCMonitor File: EmitMetricsAnalyzer.java License: MIT License | 4 votes |
MetricFetcher(String name) { this.name = StringUtils.removeStart(StringUtils.removeEnd(name, "/"), "/"); this.accpetMetrics = Collections.singletonList(name); }
Example 18
Source Project: nexus-repository-p2 File: P2BrowseNodeGenerator.java License: Eclipse Public License 1.0 | 4 votes |
private String getRelativePath(final String fullUrl, final String remote) { return StringUtils.removeStart(fullUrl, remote); }
Example 19
Source Project: cloudsync File: Helper.java License: GNU General Public License v2.0 | 4 votes |
public static String trim(String text, final String character) { text = StringUtils.removeStart(text, character); text = StringUtils.removeEnd(text, character); return text; }
Example 20
Source Project: incubator-gobblin File: SlaEventSubmitter.java License: Apache License 2.0 | 2 votes |
/** * {@link SlaEventKeys} have a prefix of {@link SlaEventKeys#EVENT_GOBBLIN_STATE_PREFIX} to keep properties organized * in state. This method removes the prefix before submitting an Sla event. */ private String withoutPropertiesPrefix(String key) { return StringUtils.removeStart(key, SlaEventKeys.EVENT_GOBBLIN_STATE_PREFIX); }