Java Code Examples for org.apache.commons.lang3.StringUtils#substringAfter()
The following examples show how to use
org.apache.commons.lang3.StringUtils#substringAfter() .
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 File: FStringUtil.java From Ffast-Java with MIT License | 6 votes |
/** * 将字符串source根据separator分割成字符串数组 * * @param source * @param separator * @return */ public static String[] split(String source, String separator) { String[] distArray = {}; if (source == null) { return null; } int i = 0; distArray = new String[StringUtils.countMatches(source, separator) + 1]; while (source.length() > 0) { String value = StringUtils.substringBefore(source, separator); distArray[i++] = StringUtils.isEmpty(value) ? null : value; source = StringUtils.substringAfter(source, separator); } if (distArray[distArray.length - 1] == null) {// 排除最后一个分隔符后放空 distArray[distArray.length - 1] = null; } return distArray; }
Example 2
Source File: ResolveWebSphereWebXmlRuleProvider.java From windup with Eclipse Public License 1.0 | 6 votes |
private void processBinding(EnvironmentReferenceService envRefService, JNDIResourceService jndiResourceService, Set<ProjectModel> applications, Element resourceRef, String tagName) { String jndiLocation = $(resourceRef).attr("jndiName"); String resourceId = $(resourceRef).child(tagName).attr("href"); resourceId = StringUtils.substringAfter(resourceId, "WEB-INF/web.xml#"); if (StringUtils.isBlank(resourceId)) { LOG.info("Issue Element: " + $(resourceRef).toString()); return; } if (StringUtils.isNotBlank(jndiLocation)) { JNDIResourceModel resource = jndiResourceService.createUnique(applications, jndiLocation); LOG.info("JNDI: " + jndiLocation + " Resource: " + resourceId); // now, look up the resource for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.REFERENCE_ID, resourceId)) { LOG.info(" - Associating JNDI: " + jndiLocation + " Resource: " + ref); envRefService.associateEnvironmentToJndi(resource, ref); } } }
Example 3
Source File: AuthorizationUtils.java From OpenLRW with Educational Community License v2.0 | 6 votes |
private static String getSecretBasic(String authorizationHeader) { StringTokenizer st = new StringTokenizer(authorizationHeader); if (st.hasMoreTokens()) { String basic = st.nextToken(); if (basic.equalsIgnoreCase("Basic") || basic.equalsIgnoreCase("Base64")) { try { String credentials = new String(Base64.decodeBase64(st.nextToken()), "UTF-8"); return StringUtils.substringAfter(credentials, ":"); } catch (UnsupportedEncodingException e) { throw new Error("Couldn't retrieve key", e); } } else { throw new Error("Couldn't retrieve key from header: " + authorizationHeader); } } else { throw new Error("Couldn't retrieve key from header: " + authorizationHeader); } }
Example 4
Source File: GenericInvokeUtils.java From saluki with Apache License 2.0 | 6 votes |
private static Object generateMapType(ServiceDefinition def, TypeDefinition td, MetadataType metadataType, Set<String> resolvedTypes) { String keyType = StringUtils.substringAfter(td.getType(), "<"); keyType = StringUtils.substringBefore(keyType, ","); keyType = StringUtils.strip(keyType); keyType = StringUtils.isNotEmpty(keyType) ? keyType : "java.lang.Object"; Object key = generateType(def, keyType, metadataType, resolvedTypes); String valueType = StringUtils.substringAfter(td.getType(), ","); valueType = StringUtils.substringBefore(valueType, ">"); valueType = StringUtils.strip(valueType); valueType = StringUtils.isNotEmpty(valueType) ? valueType : "java.lang.Object"; Object value = generateType(def, valueType, metadataType, resolvedTypes); Map<Object, Object> map = new HashMap<>(); map.put(key, value); return map; }
Example 5
Source File: RhelUtils.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Parse the /etc/redhat|centos-release * @param releaseFile the content of the release file * @return the parsed content of the release file */ public static Optional<ReleaseFile> parseReleaseFile(String releaseFile) { Matcher matcher = RHEL_RELEASE_MATCHER.matcher(releaseFile); if (matcher.matches()) { String name = matcher.group(1).replaceAll("(?i)linux", "").replaceAll(" ", ""); String majorVersion = StringUtils.substringBefore(matcher.group(2), "."); String minorVersion = StringUtils.substringAfter(matcher.group(2), "."); String release = matcher.group(3); return Optional.of(new ReleaseFile(name, majorVersion, minorVersion, release)); } return Optional.empty(); }
Example 6
Source File: Field.java From crud-intellij-plugin with Apache License 2.0 | 5 votes |
public String getName() { String str = columnName; if (StringUtils.startsWith(columnName, "is_")) { str = StringUtils.substringAfter(columnName, "is_"); } return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, str); }
Example 7
Source File: UpdateManager.java From MercuryTrade with MIT License | 5 votes |
public void doUpdate() { try { String path = StringUtils.substringAfter(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath(), "/"); logger.debug("Execute local updater, source path: {}", path); if (new File(JAR_FILE_PATH).exists()) { Runtime.getRuntime().exec("java -jar " + LOCAL_UPDATER_PATH + " " + "\"" + path + "\""); System.exit(0); } } catch (Exception e1) { logger.error("Error while execute local-updater: ", e1); } }
Example 8
Source File: DynaCode.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public static String getClassName(String code) { String className = StringUtils.substringBefore(code, "{"); if (StringUtils.isBlank(className)) { return className; } if (StringUtils.contains(code, " class ")) { className = StringUtils.substringAfter(className, " class "); if (StringUtils.contains(className, " extends ")) { className = StringUtils.substringBefore(className, " extends ").trim(); } else if (StringUtils.contains(className, " implements ")) { className = StringUtils.trim(StringUtils.substringBefore(className, " implements ")); } else { className = StringUtils.trim(className); } } else if (StringUtils.contains(code, " interface ")) { className = StringUtils.substringAfter(className, " interface "); if (StringUtils.contains(className, " extends ")) { className = StringUtils.substringBefore(className, " extends ").trim(); } else { className = StringUtils.trim(className); } } else if (StringUtils.contains(code, " enum ")) { className = StringUtils.trim(StringUtils.substringAfter(className, " enum ")); } else { return StringUtils.EMPTY; } return className; }
Example 9
Source File: MetadataTools.java From cuba with Apache License 2.0 | 5 votes |
/** * Return a collection of properties included into entity's name pattern (see {@link NamePattern}). * * @param metaClass entity metaclass * @param useOriginal if true, and if the given metaclass doesn't define a {@link NamePattern} and if it is an * extended entity, this method tries to find a name pattern in an original entity * @return collection of the name pattern properties */ @Nonnull public Collection<MetaProperty> getNamePatternProperties(MetaClass metaClass, boolean useOriginal) { Collection<MetaProperty> properties = new ArrayList<>(); String pattern = (String) getMetaAnnotationAttributes(metaClass.getAnnotations(), NamePattern.class).get("value"); if (pattern == null && useOriginal) { MetaClass original = metadata.getExtendedEntities().getOriginalMetaClass(metaClass); if (original != null) { pattern = (String) getMetaAnnotationAttributes(original.getAnnotations(), NamePattern.class).get("value"); } } if (!StringUtils.isBlank(pattern)) { String value = StringUtils.substringAfter(pattern, "|"); String[] fields = StringUtils.splitPreserveAllTokens(value, ","); for (String field : fields) { String fieldName = StringUtils.trim(field); MetaProperty property = metaClass.getProperty(fieldName); if (property != null) { properties.add(metaClass.getProperty(fieldName)); } else { throw new DevelopmentException( String.format("Property '%s' is not found in %s", field, metaClass.toString()), "NamePattern", pattern); } } } return properties; }
Example 10
Source File: JpaUtils.java From spring-boot with Apache License 2.0 | 5 votes |
/** * 根据 jqgrid 传过来的排序信息,构造排序所需要的 Sort * * @param order * @return */ private static Sort getJqGirdSort(Order order) { if (order.getProperty() == null || order.getProperty().isEmpty()) { log.info("排序字段为 null 或 空"); return null; } //排序字段 if (!order.getProperty().contains(",")) { //未分组 return createSort(order.getDirection().toString(), order.getProperty()); } else { //分组,grouping:true 时 String[] arrays = StringUtils.removeEnd(order.getProperty().trim(), ",").split(","); //传来的排序请求字符串,形如 sidx =name asc, herf desc,实际经过参数对应后变成字符串 name asc, herf desc, //arrays = {[name asc],[herf desc]} List<Sort.Order> orders = Lists.newArrayList(); List<String> unique = Lists.newArrayList(); //为了避免同一个属性,重复添加。此情况发生在 grouping:true 时,没有进一步测试。 for (String s : arrays) { //拼接所有的排序请求。 String propertyT = StringUtils.substringBefore(s.trim(), " "); if (unique.contains(propertyT)) continue; unique.add(propertyT); String directionT = StringUtils.substringAfter(s.trim(), " "); orders.add(createOrder(directionT, propertyT)); } return createSort(orders); } }
Example 11
Source File: HttpToken.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String domain(HttpServletRequest request) throws Exception { String str = request.getServerName(); if (StringUtils.contains(str, ".")) { Pattern pattern = Pattern.compile(RegularExpression_IP); Matcher matcher = pattern.matcher(str); if (!matcher.find()) { if (StringUtils.equalsIgnoreCase(DomainTools.getMainDomain(str), str)) { return str; } else { return "." + StringUtils.substringAfter(str, "."); } } } return str; }
Example 12
Source File: ProxyLoader.java From aceql-http with GNU Lesser General Public License v2.1 | 4 votes |
public Proxy getProxy() throws IOException, URISyntaxException { if (FrameworkSystemUtil.isAndroid()) { return null; } System.setProperty("java.net.useSystemProxies", "true"); List<Proxy> proxies = ProxySelector.getDefault() .select(new URI("http://www.google.com/")); if (proxies != null && proxies.size() >= 1) { System.out.println("Loading proxy file info..."); if (proxies.get(0).type().equals(Proxy.Type.DIRECT)) { return null; } File file = new File(NEOTUNNEL_TXT); if (file.exists()) { String proxyValues = FileUtils.readFileToString(file, Charset.defaultCharset()); String username = StringUtils.substringBefore(proxyValues, " "); String password = StringUtils.substringAfter(proxyValues, " "); username = username.trim(); password = password.trim(); proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8080)); passwordAuthentication = new PasswordAuthentication(username, password.toCharArray()); System.out.println("USING PROXY WITH AUTHENTICATION: " + proxy + " / " + username + " " + password); } else { throw new FileNotFoundException( "proxy values not found. No file " + file); } } return proxy; }
Example 13
Source File: TradeOutMessagesInterceptor.java From MercuryTrade with MIT License | 4 votes |
@Override public String trimString(String src) { return StringUtils.substringAfter(src, "@To"); }
Example 14
Source File: OntologyGeneralSolrDocumentLoader.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private SolrInputDocument collectClass(OWLGraphWrapper graph, OWLClass c) { String def = graph.getDef(c); String com = graph.getComment(c); String syns = StringUtils.join(graph.getOBOSynonymStrings(c, null), " "); String subs = StringUtils.join(graph.getSubsets(c), " "); ArrayList<String> alt_pps = new ArrayList<String>(); alt_pps.add("alt_id"); String alts = StringUtils.join(graph.getAnnotationPropertyValues(c, alt_pps), " "); ArrayList<String> rep_pps = new ArrayList<String>(); rep_pps.add("replaced_by"); String reps = StringUtils.join(graph.getAnnotationPropertyValues(c, rep_pps), " "); ArrayList<String> con_pps = new ArrayList<String>(); con_pps.add("consider"); String cons = StringUtils.join(graph.getAnnotationPropertyValues(c, con_pps), " "); // Okay, pull out all of the variations on the ID for what people might expect in the ontology. String gid = graph.getIdentifier(c); String gid_no_namespace = StringUtils.substringAfter(gid, ":"); String gid_no_namespace_or_leading_zeros = StringUtils.stripStart(gid_no_namespace, "0"); // All together now. ArrayList<String> all = new ArrayList<String>(); all.add(gid_no_namespace); all.add(gid_no_namespace_or_leading_zeros); all.add(def); all.add(com); all.add(syns); all.add(subs); all.add(alts); all.add(reps); all.add(cons); // Watch out for "id" collision! SolrInputDocument general_doc = new SolrInputDocument(); general_doc.addField("id", "general_ontology_class_" + gid); general_doc.addField("entity", graph.getIdentifier(c)); general_doc.addField("entity_label", graph.getLabel(c)); general_doc.addField("document_category", "general"); general_doc.addField("category", "ontology_class"); general_doc.addField("general_blob", StringUtils.join(all, " ")); return general_doc; }
Example 15
Source File: ClientToProxyConnection.java From g4proxy with Apache License 2.0 | 4 votes |
/** * <p> * Checks whether the given HttpRequest requires authentication. * </p> * * <p> * If the request contains credentials, these are checked. * </p> * * <p> * If authentication is still required, either because no credentials were * provided or the credentials were wrong, this writes a 407 response to the * client. * </p> * * @param request * @return */ private boolean authenticationRequired(HttpRequest request) { if (authenticated.get()) { return false; } final ProxyAuthenticator authenticator = proxyServer .getProxyAuthenticator(); if (authenticator == null) return false; if (!request.headers().contains(HttpHeaders.Names.PROXY_AUTHORIZATION)) { writeAuthenticationRequired(authenticator.getRealm()); return true; } List<String> values = request.headers().getAll( HttpHeaders.Names.PROXY_AUTHORIZATION); String fullValue = values.iterator().next(); String value = StringUtils.substringAfter(fullValue, "Basic ").trim(); byte[] decodedValue = BaseEncoding.base64().decode(value); String decodedString = new String(decodedValue, Charset.forName("UTF-8")); String userName = StringUtils.substringBefore(decodedString, ":"); String password = StringUtils.substringAfter(decodedString, ":"); if (!authenticator.authenticate(userName, password)) { writeAuthenticationRequired(authenticator.getRealm()); return true; } LOG.debug("Got proxy authorization!"); // We need to remove the header before sending the request on. String authentication = request.headers().get( HttpHeaders.Names.PROXY_AUTHORIZATION); LOG.debug(authentication); request.headers().remove(HttpHeaders.Names.PROXY_AUTHORIZATION); authenticated.set(true); return false; }
Example 16
Source File: QueueUtils.java From conductor with Apache License 2.0 | 4 votes |
private static String getIsolationGroup(String queue) { return StringUtils.substringAfter(queue, QueueUtils.ISOLATION_SEPARATOR); }
Example 17
Source File: FlowableUserRequestHandler.java From syncope with Apache License 2.0 | 4 votes |
protected String getUserKey(final String procInstId) { String procBusinessKey = engine.getRuntimeService().createProcessInstanceQuery(). processInstanceId(procInstId).singleResult().getBusinessKey(); return StringUtils.substringAfter(procBusinessKey, ":"); }
Example 18
Source File: TradeOutMessagesInterceptor.java From MercuryTrade with MIT License | 4 votes |
@Override public String trimString(String src) { return StringUtils.substringAfter(src, "@Para"); }
Example 19
Source File: DefaultClassIdConverter.java From OpenLRW with Educational Community License v2.0 | 4 votes |
@Override public String convert(Tenant tenant, Event event) { Group group = event.getGroup(); if (group == null) { return null; } // temporary fix for NCSU issue, will be resolved soon if (group.getCourseNumber() != null && group.getId() != null && group.getId().contains("ncsu.edu")) { return group.getCourseNumber(); } String convertedClassId = null, groupId = null; String groupType = group.getType(); if (isCourseSection(groupType)) { groupId = group.getId(); } else { groupId = findCourseSectionId(group.getSubOrganizationOf()); } if (StringUtils.isBlank(groupId)) { return null; } if (StringUtils.startsWith(groupId, "http")) { Map<String, String> tenantMetadata = tenant.getMetadata(); if (tenantMetadata != null && !tenantMetadata.isEmpty()) { String tenantClassPrefix = tenantMetadata.get(Vocabulary.TENANT_CLASS_PREFIX); if (StringUtils.isNotBlank(tenantClassPrefix)) { String classIdAfterPrefix = StringUtils.substringAfter(groupId, tenantClassPrefix); if (StringUtils.startsWith(classIdAfterPrefix, "/")) { convertedClassId = StringUtils.substringAfter(classIdAfterPrefix, "/"); } else { convertedClassId = classIdAfterPrefix; } } } else { convertedClassId = StringUtils.substringAfterLast(groupId, "/"); } } else { convertedClassId = groupId; } return convertedClassId; }
Example 20
Source File: JarUtils.java From confucius-commons with Apache License 2.0 | 3 votes |
/** * Resolve Relative path from Jar URL * * @param jarURL * {@link URL} of {@link JarFile} or {@link JarEntry} * @return Non-null * @throws NullPointerException * see {@link #assertJarURLProtocol(URL)} * @throws IllegalArgumentException * see {@link #assertJarURLProtocol(URL)} * @version 1.0.0 * @since 1.0.0 2012-3-20 下午02:37:25 */ @Nonnull public static String resolveRelativePath(URL jarURL) throws NullPointerException, IllegalArgumentException { assertJarURLProtocol(jarURL); String form = jarURL.toExternalForm(); String relativePath = StringUtils.substringAfter(form, SeparatorConstants.ARCHIVE_ENTITY); relativePath = URLUtils.resolvePath(relativePath); return URLUtils.decode(relativePath); }