当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.indexOf方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.indexOf方法的具体用法?Java StringUtils.indexOf怎么用?Java StringUtils.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.indexOf方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractUsername

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Extracts the username from the specified DN. If the username cannot be extracted because the CN is in an unrecognized format, the entire CN is returned. If the CN cannot be extracted because
 * the DN is in an unrecognized format, the entire DN is returned.
 *
 * @param dn the dn to extract the username from
 * @return the exatracted username
 */
public static String extractUsername(String dn) {
    String username = dn;

    // ensure the dn is specified
    if (StringUtils.isNotBlank(dn)) {
        // determine the separate
        final String separator = StringUtils.indexOfIgnoreCase(dn, "/cn=") > 0 ? "/" : ",";

        // attempt to locate the cd
        final String cnPattern = "cn=";
        final int cnIndex = StringUtils.indexOfIgnoreCase(dn, cnPattern);
        if (cnIndex >= 0) {
            int separatorIndex = StringUtils.indexOf(dn, separator, cnIndex);
            if (separatorIndex > 0) {
                username = StringUtils.substring(dn, cnIndex + cnPattern.length(), separatorIndex);
            } else {
                username = StringUtils.substring(dn, cnIndex + cnPattern.length());
            }
        }
    }

    return username;
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:31,代码来源:CertificateUtils.java

示例2: buildURL

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private GrpcURL buildURL(ConsulService service) {
  try {
    for (String tag : service.getTags()) {
      if (StringUtils.indexOf(tag, Constants.PROVIDERS_CATEGORY) != -1) {
        String toUrlPath = StringUtils.substringAfter(tag, Constants.PROVIDERS_CATEGORY);
        GrpcURL salukiUrl = GrpcURL.valueOf(GrpcURL.decode(toUrlPath));
        return salukiUrl;
      }
    }
  } catch (Exception e) {
    log.error("convert consul service to url fail! service:" + service, e);
  }
  return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:15,代码来源:ConsulRegistry.java

示例3: rmXSSDangerousCharacters

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String rmXSSDangerousCharacters(String script, String[] xss) {// 移除存在XSS攻击威胁的字符串

			if (null == xss || xss.length == 0) {
				return script;
			}

			for (String remove : xss) {

				if (StringUtils.isBlank(remove)) {
					continue;
				}

				if (StringUtils.indexOf(script, remove) < 0) {
					continue;
				}

				if (remove.length() == 1) {
					script = StringUtils.remove(script, remove.charAt(0));
					log.warn('[' + remove + "]已移除");
					continue;
				}

				Pattern p = Pattern.compile(remove, Pattern.CASE_INSENSITIVE);
				Matcher m = p.matcher(script);

				while (m.find()) {
					String st = m.group();
					script = StringUtils.remove(script, remove);
					log.warn('[' + st + "]已移除");
				}

			}

			return script;
		}
 
开发者ID:Fetax,项目名称:Fetax-AI,代码行数:36,代码来源:XSSFilter.java

示例4: normalizePath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 在Windows环境里,兼容Windows上的路径分割符,将 '/' 转回 '\'
 */
public static String normalizePath(String path) {
	if (Platforms.FILE_PATH_SEPARATOR_CHAR == Platforms.WINDOWS_FILE_PATH_SEPARATOR_CHAR
			&& StringUtils.indexOf(path, Platforms.LINUX_FILE_PATH_SEPARATOR_CHAR) != -1) {
		return StringUtils.replaceChars(path, Platforms.LINUX_FILE_PATH_SEPARATOR_CHAR,
				Platforms.WINDOWS_FILE_PATH_SEPARATOR_CHAR);
	}
	return path;

}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:13,代码来源:FilePathUtil.java

示例5: getSubstring

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getSubstring(String start, String end) {
    int first = StringUtils.indexOf(logicRepresentation, start);
    int second = StringUtils.indexOf(logicRepresentation, end);
    return StringUtils.substring(logicRepresentation, first + 1, second);
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:6,代码来源:LogicTupleEvent.java

示例6: handleIndex

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected int handleIndex(CharSequence str, CharSequence searchStr, int startPos) {
    return StringUtils.indexOf(str, searchStr, startPos);
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:5,代码来源:IndexOf.java

示例7: toCsvString

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Parse fields as csv string,
 */
public static String toCsvString(Object... elements) {
	StringBuilder line = new StringBuilder();
	int last = elements.length - 1;
	for (int i = 0; i < elements.length; i++) {
		if (elements[i] == null) {
			if (i != last) {
				line.append(FIELD_SEPARATOR);
			}
			continue;
		}
		String field = elements[i].toString();

		// check for special cases
		int ndx = field.indexOf(FIELD_SEPARATOR);
		if (ndx == -1) {
			ndx = field.indexOf(FIELD_QUOTE);
		}
		if (ndx == -1 && (field.startsWith(SPACE) || field.endsWith(SPACE))) {
			ndx = 1;
		}
		if (ndx == -1) {
			ndx = StringUtils.indexOf(field, SPECIAL_CHARS);
		}

		// add field
		if (ndx != -1) {
			line.append(FIELD_QUOTE);
		}
		field = StringUtils.replace(field, QUOTE, DOUBLE_QUOTE);
		line.append(field);
		if (ndx != -1) {
			line.append(FIELD_QUOTE);
		}

		// last
		if (i != last) {
			line.append(FIELD_SEPARATOR);
		}
	}
	return line.toString();
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:45,代码来源:CsvUtil.java


注:本文中的org.apache.commons.lang3.StringUtils.indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。