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

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

源代码1 项目: synopsys-detect   文件: GradleReportLineParser.java
private int parseTreeLevel(final String line) {
    if (StringUtils.startsWithAny(line, TREE_LEVEL_TERMINALS)) {
        return 0;
    }

    String modifiedLine = DetectableStringUtils.removeEvery(line, TREE_LEVEL_TERMINALS);

    if (!modifiedLine.startsWith("|") && modifiedLine.startsWith(" ")) {
        modifiedLine = "|" + modifiedLine;
    }
    modifiedLine = modifiedLine.replace("     ", "    |");
    modifiedLine = modifiedLine.replace("||", "|");
    if (modifiedLine.endsWith("|")) {
        modifiedLine = modifiedLine.substring(0, modifiedLine.length() - 5);
    }
    final int matches = StringUtils.countMatches(modifiedLine, "|");

    return matches;
}
 
源代码2 项目: fw-cloud-framework   文件: MsgHandler.java
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context,
		WxMpService weixinService, WxSessionManager sessionManager) {

	if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
		// TODO 可以选择将消息保存到本地
	}

	// 当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
	try {
		if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服")
				&& weixinService.getKefuService().kfOnlineList().getKfOnlineList().size() > 0) { return WxMpXmlOutMessage
				.TRANSFER_CUSTOMER_SERVICE().fromUser(wxMessage.getToUser()).toUser(
						wxMessage.getFromUser()).build(); }
	} catch (WxErrorException e) {
		e.printStackTrace();
	}

	// TODO 组装回复消息
	String content = "收到信息内容:" + JsonUtils.toJson(wxMessage);

	return new TextBuilder().build(content, wxMessage, weixinService);

}
 
源代码3 项目: o2oa   文件: LanguageProcessingHelper.java
private boolean skip(Item o) {
	if ((StringUtils.length(o.getValue()) > 1) && (!StringUtils.startsWithAny(o.getValue(), SKIP_START_WITH))
			&& (!StringUtils.endsWithAny(o.getValue(), SKIP_END_WITH))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "b"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "c"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "d"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "e"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "f"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "h"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "k"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "o"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "p"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "q"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "r"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "u"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "w")) && (!label_skip_m(o))) {
		return false;
	}
	return true;
}
 
源代码4 项目: o2oa   文件: LanguageProcessingHelper.java
private boolean skip(Item o) {
	if ((StringUtils.length(o.getValue()) > 1) && (!StringUtils.startsWithAny(o.getValue(), SKIP_START_WITH))
			&& (!StringUtils.endsWithAny(o.getValue(), SKIP_END_WITH))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "b"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "c"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "d"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "e"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "f"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "h"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "k"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "o"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "p"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "q"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "r"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "u"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "w")) && (!label_skip_m(o))) {
		return false;
	}
	return true;
}
 
源代码5 项目: JuniperBot   文件: BlurImageController.java
@RequestMapping(value = "/blur", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<InputStreamResource> blur(@RequestParam("source") String sourceUrl) {
    if (!StringUtils.startsWithAny(sourceUrl, ALLOWED_PREFIX)) {
        return ResponseEntity.badRequest().build();
    }

    String hash = DigestUtils.sha1Hex(sourceUrl);

    try {
        ImageInfo info = readCached(hash);
        if (info == null) {
            info = renderImage(sourceUrl);
            saveCached(hash, info);
        }
        return ResponseEntity.ok()
                .contentLength(info.contentLength)
                .contentType(MediaType.IMAGE_JPEG)
                .body(new InputStreamResource(info.inputStream));
    } catch (IOException e) {
        // fall down
    }
    return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
 
源代码6 项目: codeway_service   文件: JsonUtil.java
/**
 * 判断是否json串
 * @param jsonStr JSON字符串
 * @return java对象
 */
public static synchronized boolean isJson(String jsonStr) {
	try {
		return StringUtils.startsWithAny(jsonStr, "{", "[");
	} catch (Exception e) {
           LogBack.error(JACKSON_ERROR, e.getMessage());
		return false;
	}
}
 
源代码7 项目: levelup-java-examples   文件: StringStartsWith.java
@Test
public void string_starts_with_any_apache_commons() {

	boolean startsWithHttpProtocol = StringUtils
			.startsWithAny("http://www.leveluplunch.com", new String[] {
					"http", "https" });

	assertTrue(startsWithHttpProtocol);
}
 
源代码8 项目: yshopmall   文件: MsgHandler.java
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
                                Map<String, Object> context, WxMpService weixinService,
                                WxSessionManager sessionManager) {

    if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
        //TODO 可以选择将消息保存到本地
    }

    //当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
    try {
        if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服")
            && weixinService.getKefuService().kfOnlineList()
            .getKfOnlineList().size() > 0) {
            return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE()
                .fromUser(wxMessage.getToUser())
                .toUser(wxMessage.getFromUser()).build();
        }
    } catch (WxErrorException e) {
        e.printStackTrace();
    }

    //TODO 组装回复消息
    String content = "yshop收到信息内容:" + wxMessage.getContent();

    return new TextBuilder().build(content, wxMessage, weixinService);

}
 
源代码9 项目: sakai   文件: SimpleRSSPreferencesValidator.java
@Override
protected boolean isValidScheme(String url) {
	
	//check if url starts with one of the schemes
	if(StringUtils.startsWithAny(url, schemes)) {
		return true;
	} 
	return false;
	
}
 
@Override
public String toModelImport(String name) {
    String modelImport;
    if (StringUtils.startsWithAny(name,"import", "from")) {
        modelImport = name;
    } else {
        modelImport = "from ";
        if (!"".equals(modelPackage())) {
            modelImport += modelPackage() + ".";
        }
        modelImport += toModelFilename(name)+ " import " + name;
    }
    return modelImport;
}
 
@Override
public String toModelImport(String name) {
    String modelImport;
    if (StringUtils.startsWithAny(name,"import", "from")) {
        modelImport = name;
    } else {
        modelImport = "from ";
        if (!"".equals(modelPackage())) {
            modelImport += modelPackage() + ".";
        }
        modelImport += toModelFilename(name)+ " import " + name;
    }
    return modelImport;
}
 
源代码12 项目: openapi-generator   文件: PythonClientCodegen.java
@Override
public String toModelImport(String name) {
    String modelImport;
    if (StringUtils.startsWithAny(name, "import", "from")) {
        modelImport = name;
    } else {
        modelImport = "from ";
        if (!"".equals(modelPackage())) {
            modelImport += modelPackage() + ".";
        }
        modelImport += toModelFilename(name) + " import " + name;
    }
    return modelImport;
}
 
@Override
public String toModelImport(String name) {
    String modelImport;
    if (StringUtils.startsWithAny(name, "import", "from")) {
        modelImport = name;
    } else {
        modelImport = "from ";
        if (!"".equals(modelPackage())) {
            modelImport += modelPackage() + ".";
        }
        modelImport += toModelFilename(name) + " import " + name;
    }
    return modelImport;
}
 
源代码14 项目: sakai   文件: SimpleRSSPreferencesValidator.java
@Override
protected boolean isValidScheme(String url) {
	
	//check if url starts with one of the schemes
	if(StringUtils.startsWithAny(url, schemes)) {
		return true;
	} 
	return false;
	
}
 
源代码15 项目: sdb-mall   文件: MsgHandler.java
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
                                Map<String, Object> context, WxMpService weixinService,
                                WxSessionManager sessionManager) {

    if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
        //TODO 可以选择将消息保存到本地
    }

    //当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
    try {
        if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服")
            && weixinService.getKefuService().kfOnlineList()
            .getKfOnlineList().size() > 0) {
            return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE()
                .fromUser(wxMessage.getToUser())
                .toUser(wxMessage.getFromUser()).build();
        }
    } catch (WxErrorException e) {
        e.printStackTrace();
    }

    //TODO 组装回复消息
    String content = "收到信息内容:" + JsonUtils.toJson(wxMessage);

    return new TextBuilder().build(content, wxMessage, weixinService);

}
 
源代码16 项目: cyberduck   文件: MantaSession.java
protected boolean isUserWritable(final MantaObject object) {
    final MantaAccountHomeInfo account = new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath());
    return StringUtils.startsWithAny(
        object.getPath(),
        account.getAccountPublicRoot().getAbsolute(),
        account.getAccountPrivateRoot().getAbsolute());
}
 
源代码17 项目: app-engine   文件: DataBaseAdvisor.java
@Before("execution(* com.appengine..*Dao.*(..))")
public void beforMethod(JoinPoint joinPoint) {
    String methodName = joinPoint.getSignature().getName();
    RequestContext rc = ThreadLocalContext.getRequestContext();

    if (StringUtils.startsWithAny(methodName, writeMethodPrefixs)) {
        rc.setShouldReadMasterDB(true);
    } else if (StringUtils.startsWithAny(methodName, queryMethodPrefixs)) {
        rc.setShouldReadMasterDB(false);
    } else {
        log.warn("cannot found handle db method for methodName is: " + methodName);
        rc.setShouldReadMasterDB(true);
    }
}
 
源代码18 项目: ghidra   文件: QueryOpinionService.java
static boolean secondaryAttributeMatches(String eFlagsDecimalString, String attribute) {

		// eFlagDecimalString is the elf e_flags value, as a decimal string
		// sa is the secondary attribute string from the opinion file,
		// and it must start with "0x" or "0b"
		if (attribute == null) {
			return false;
		}

		if (!StringUtils.startsWithAny(attribute.toLowerCase(), "0x", "0b")) {
			return false;
		}

		int eFlagsInt = Integer.parseInt(eFlagsDecimalString);
		String eFlagsBinaryString = Integer.toBinaryString(eFlagsInt);
		if (eFlagsBinaryString == null) {
			return false;
		}

		eFlagsBinaryString = StringUtils.leftPad(eFlagsBinaryString, 32, "0");
		String eFlagsHexString = Integer.toHexString(eFlagsInt);
		eFlagsHexString = StringUtils.leftPad(eFlagsHexString, 8, "0");

		// Remove '_' and whitespace from the attribute string
		String cleaned = attribute.replace("_", "").replaceAll("\\s+", "").trim();
		String prefix = cleaned.substring(0, 2);
		String value = cleaned.substring(2);
		if (prefix.toLowerCase().startsWith("0x")) {

			// It's a hex string
			value = StringUtils.leftPad(value, 8, "0");
			return value.equals(eFlagsHexString);
		}

		// It's a binary string
		value = StringUtils.leftPad(value, 32, "0");
		for (int i = 0; i < 32; i++) {
			char c = value.charAt(i);
			if (c == '.') { // wildcard
				continue;
			}

			if (eFlagsBinaryString.charAt(i) != c) {
				return false;
			}
		}

		return true;
	}
 
源代码19 项目: cyberduck   文件: MantaSession.java
protected boolean isWorldReadable(final MantaObject object) {
    final MantaAccountHomeInfo accountHomeInfo = new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath());
    return StringUtils.startsWithAny(
        object.getPath(),
        accountHomeInfo.getAccountPublicRoot().getAbsolute());
}
 
源代码20 项目: more-lambdas-java   文件: StackTraceProviderJdk8.java
/**
 * at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 * at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 * at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 * at java.lang.reflect.Method.invoke(Method.java:498)
 */
private boolean isReflection(String stackClassName) {
    return StringUtils.startsWithAny(stackClassName, REFLECTION_PREFIXES);
}
 
 同类方法