org.apache.commons.lang3.StringUtils#substringAfter ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#substringAfter ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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);
        }
    }
}
 
源代码2 项目: saluki   文件: GenericInvokeUtils.java
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;
}
 
源代码3 项目: OpenLRW   文件: AuthorizationUtils.java
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);
  }
}
 
源代码4 项目: Ffast-Java   文件: FStringUtil.java
/**
 * 将字符串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;
}
 
源代码5 项目: crud-intellij-plugin   文件: Field.java
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);
}
 
源代码6 项目: o2oa   文件: HttpToken.java
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;
}
 
源代码7 项目: spring-boot   文件: JpaUtils.java
/**
 * 根据 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);
    }
}
 
源代码8 项目: cuba   文件: MetadataTools.java
/**
 * 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;
}
 
源代码9 项目: rocketmq-all-4.1.0-incubating   文件: DynaCode.java
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;
}
 
源代码10 项目: MercuryTrade   文件: UpdateManager.java
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);
    }
}
 
源代码11 项目: uyuni   文件: RhelUtils.java
/**
 * 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();
}
 
源代码12 项目: OpenLRW   文件: DefaultClassIdConverter.java
@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;
}
 
源代码13 项目: MercuryTrade   文件: TradeOutMessagesInterceptor.java
@Override
public String trimString(String src) {
    return StringUtils.substringAfter(src, "@Para");
}
 
源代码14 项目: aceql-http   文件: ProxyLoader.java
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;
   }
 
源代码15 项目: MercuryTrade   文件: TradeOutMessagesInterceptor.java
@Override
public String trimString(String src) {
    return StringUtils.substringAfter(src, "@To");
}
 
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;
	}
 
源代码17 项目: g4proxy   文件: ClientToProxyConnection.java
/**
 * <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;
}
 
源代码18 项目: conductor   文件: QueueUtils.java
private static String getIsolationGroup(String queue) {
	return StringUtils.substringAfter(queue, QueueUtils.ISOLATION_SEPARATOR);
}
 
源代码19 项目: syncope   文件: FlowableUserRequestHandler.java
protected String getUserKey(final String procInstId) {
    String procBusinessKey = engine.getRuntimeService().createProcessInstanceQuery().
            processInstanceId(procInstId).singleResult().getBusinessKey();

    return StringUtils.substringAfter(procBusinessKey, ":");
}
 
源代码20 项目: confucius-commons   文件: JarUtils.java
/**
 * 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);
}
 
 同类方法