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

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

源代码1 项目: mylizzie   文件: PhoenixGoAnalyzer.java
/**
 * Process the lines in leelaz's output. Example: info move D16 visits 7 winrate 4704 pv D16 Q16 D4
 *
 * @param line an output line
 */
private void processEngineOutputLine(String line) {
    String trimmed = StringUtils.trim(line);
    if (!StringUtils.startsWith(trimmed, "info")) {
        return;
    }

    final MutableList<MoveData> currentBestMoves = parseMoveDataLine(trimmed);
    if (CollectionUtils.isEmpty(currentBestMoves)) {
        return;
    }

    if (System.currentTimeMillis() - lastBestMoveUpdatedTime < 100) {
        return;
    }

    notificationExecutor.execute(() -> observers.bestMovesUpdated(currentBestMoves));
    lastBestMoveUpdatedTime = System.currentTimeMillis();
}
 
源代码2 项目: para   文件: SecurityUtils.java
/**
 * @param request HTTP request
 * @return the appid if it's present in either the 'state' or 'appid' query parameters
 */
public static String getAppidFromAuthRequest(HttpServletRequest request) {
	String appid1 = request.getParameter("state");
	String appid2 = request.getParameter(Config._APPID);
	if (StringUtils.isBlank(appid1) && StringUtils.isBlank(appid2)) {
		if (StringUtils.startsWith(request.getRequestURI(), SAMLAuthFilter.SAML_ACTION + "/")) {
			return StringUtils.trimToNull(request.getRequestURI().substring(SAMLAuthFilter.SAML_ACTION.length() + 1));
		} else {
			return null;
		}
	} else if (!StringUtils.isBlank(appid1)) {
		return StringUtils.trimToNull(appid1);
	} else {
		return StringUtils.trimToNull(appid2);
	}
}
 
源代码3 项目: mylizzie   文件: OfficialLeelazAnalyzerV1.java
/**
 * Process the lines in leelaz's output. Example: info move D16 visits 7 winrate 4704 pv D16 Q16 D4
 *
 * @param line an output line
 */
private void processEngineOutputLine(String line) {
    if (!StringUtils.startsWith(line, "info")) {
        return;
    }

    MoveData moveData = parseMoveDataLine(line);
    if (moveData == null) {
        return;
    }

    if (System.currentTimeMillis() - startPonderTime > Lizzie.optionSetting.getMaxAnalysisTime() * MILLISECONDS_IN_SECOND) {
        // we have pondered for enough time. pause pondering
        notificationExecutor.execute(this::pauseAnalyzing);
    }

    bestMoves.put(moveData.getCoordinate(), moveData);

    final List<MoveData> currentBestMoves = bestMoves.toSortedList(Comparator.comparingInt(MoveData::getPlayouts).reversed());
    notificationExecutor.execute(() -> observers.bestMovesUpdated(currentBestMoves));
}
 
源代码4 项目: webanno   文件: UrlImporter.java
private Optional<Import> tryResolveUrl(URI base, String url)
{
    final Optional<Import> newImport;
    if (StringUtils.startsWith(url, WEBJARS_SCHEME)) {
        newImport = resolveWebJarsDependency(url);
    }
    else if (StringUtils.startsWith(url, CLASSPATH_SCHEME)) {
        newImport = resolveClasspathDependency(url);
    }
    else if (StringUtils.startsWith(url, WEB_CONTEXT_SCHEME)) {
        newImport = resolveWebContextDependency(url);
    }
    else if (scopeClass != null && StringUtils.startsWith(url, PACKAGE_SCHEME)) {
        newImport = resolvePackageDependency(url);
    }
    else {
        newImport = resolveLocalDependency(base, url);
    }

    return newImport;
}
 
源代码5 项目: FEBS-Cloud   文件: DataPermissionInterceptor.java
private Boolean shouldFilter(MappedStatement mappedStatement, DataPermission dataPermission) {
    if (dataPermission != null) {
        String methodName = StringUtils.substringAfterLast(mappedStatement.getId(), ".");
        String methodPrefix = dataPermission.methodPrefix();
        if (StringUtils.isNotBlank(methodPrefix) && StringUtils.startsWith(methodName, methodPrefix)) {
            return Boolean.TRUE;
        }
        String[] methods = dataPermission.methods();
        for (String method : methods) {
            if (StringUtils.equals(method, methodName)) {
                return Boolean.TRUE;
            }
        }
    }
    return Boolean.FALSE;
}
 
源代码6 项目: p4ic4idea   文件: P4JavaExceptions.java
/**
 * Rethrowing checked exceptions but it's not required catch statement
 *
 * @apiNote after jdk1.8
 */
@SuppressWarnings("unchecked")
private static <E extends Throwable> void throwAsUnchecked(Exception exception) {
    String version = System.getProperty("java.version");
    if (StringUtils.startsWith(version, "1.7")) {
        throwAsUncheckedInJava7(exception);
    } else {
        /*
        * FIXME: if p4java upgrade to java 8, change to
        * <pre>
        *     throwAsUncheckedAfterJava8(exception);
        * </pre>
        *
         */
        getUnsafe().throwException(exception);
    }
}
 
源代码7 项目: super-cloudops   文件: SerializeUtils.java
/**
 * Annotate to object copying, only copy the methods that match.
 * 
 * @param annotation
 * @param object
 */
public static void annotationToObject(Object annotation, Object object) {
	if (annotation != null && object != null) {
		Class<?> annotationClass = annotation.getClass();
		Class<?> objectClass = object.getClass();
		if (objectClass != null) {
			for (Method m : objectClass.getMethods()) {
				if (StringUtils.startsWith(m.getName(), "set")) {
					try {
						String s = StringUtils.uncapitalize(StringUtils.substring(m.getName(), 3));
						Object obj = annotationClass.getMethod(s).invoke(annotation);
						if (obj != null && !"".equals(obj.toString())) {
							if (object == null) {
								object = objectClass.newInstance();
							}
							m.invoke(object, obj);
						}
					} catch (Exception e) {
						// 忽略所有设置失败方法
					}
				}
			}
		}
	}
}
 
源代码8 项目: easyweb   文件: ObjectUtils.java
/**
 * 注解到对象复制,只复制能匹配上的方法。
 * @param annotation
 * @param object
 */
public static void annotationToObject(Object annotation, Object object){
	if (annotation != null){
		Class<?> annotationClass = annotation.getClass();
		if (null == object) {
			return;
		}
		Class<?> objectClass = object.getClass();
		for (Method m : objectClass.getMethods()){
			if (StringUtils.startsWith(m.getName(), "set")){
				try {
					String s = StringUtils.uncapitalize(StringUtils.substring(m.getName(), 3));
					Object obj = annotationClass.getMethod(s).invoke(annotation);
					if (obj != null && !"".equals(obj.toString())){
						m.invoke(object, obj);
					}
				} catch (Exception e) {
					// 忽略所有设置失败方法
				}
			}
		}
	}
}
 
源代码9 项目: analysis-model   文件: IntelParser.java
@Override
protected Optional<Issue> createIssue(final Matcher matcher, final IssueBuilder builder) {
    String category = StringUtils.capitalize(matcher.group(5));

    Severity priority;
    if (StringUtils.startsWith(category, "Remark") || StringUtils.startsWith(category, "Message")) {
        priority = Severity.WARNING_LOW;
    }
    else if (StringUtils.startsWith(category, "Error")) {
        priority = Severity.WARNING_HIGH;
    }
    else {
        priority = Severity.WARNING_NORMAL;
    }

    return builder.setFileName(matcher.group(2))
            .setLineStart(matcher.group(3))
            .setColumnStart(matcher.group(4))
            .setCategory(category)
            .setMessage(matcher.group(6))
            .setSeverity(priority)
            .buildOptional();
}
 
源代码10 项目: o2oa   文件: FilterEntry.java
private String compareValue(Runtime runtime) {
	if (StringUtils.startsWith(this.value, "@")) {
		if ((!StringUtils.equals(this.value, DEFINE_TIME)) && (!StringUtils.equals(this.value, DEFINE_DATE))
				&& (!StringUtils.equals(this.value, DEFINE_MONTH))
				&& (!StringUtils.equals(this.value, DEFINE_SEASON))
				&& (!StringUtils.equals(this.value, DEFINE_YEAR))
				&& (!StringUtils.equals(this.value, DEFINE_PERSON))
				&& (!StringUtils.equals(this.value, DEFINE_IDENTITYLIST))
				&& (!StringUtils.equals(this.value, DEFINE_UNITALLLIST))
				&& (!StringUtils.equals(this.value, DEFINE_UNITLIST))) {
			String key = StringUtils.substring(this.value, 1);
			return Objects.toString(runtime.parameter.get(key), "");
		}
	}
	return this.value;
}
 
源代码11 项目: frpMgr   文件: JsonMapper.java
/**
 * JSON字符串转换为 List<Map<String, Object>>
 */
public static List<Map<String, Object>> fromJsonForMapList(String jsonString){
	List<Map<String, Object>> result = ListUtils.newArrayList();
	if (StringUtils.startsWith(jsonString, "{")){
		Map<String, Object> map = fromJson(jsonString, Map.class);
		if (map != null){
			result.add(map);
		}
	}else if (StringUtils.startsWith(jsonString, "[")){
		List<Map<String, Object>> list = fromJson(jsonString, List.class);
		if (list != null){
			result = list;
		}
	}
	return result;
}
 
源代码12 项目: windup   文件: TestJavaApplicationOverviewUtil.java
/**
 * Returns the xpath full path of the given element. E.g something like /html/body/div[2]/p
 * 
 * @param driver
 * @param element
 * @return
 */
private String getElementXPath(WebDriver driver, WebElement element)
{
    String xpath = (String) ((JavascriptExecutor) driver).executeScript(
                "gPt=function(c){if(c.id!==''){return'id(\"'+c.id+'\")'}if(c===document.body){return c.tagName}var a=0;var e=c.parentNode.childNodes;for(var b=0;b<e.length;b++){var d=e[b];if(d===c){return gPt(c.parentNode)+'/'+c.tagName+'['+(a+1)+']'}if(d.nodeType===1&&d.tagName===c.tagName){a++}}};return gPt(arguments[0]).toLowerCase();",
                element);
    if (!StringUtils.startsWith(xpath, "id(\""))
        xpath = "/html/" + xpath;
    return xpath;
}
 
/**
 * Determines which attributes are selected based on the passed in node
 * name.
 *
 * @param parent the parent node pointer
 * @param name the name of the selected attribute
 * @return a list with the selected attributes
 */
private List<String> createAttributeDataList(
        final ConfigurationNodePointer<T> parent, final QName name)
{
    final List<String> result = new ArrayList<>();
    if (!WILDCARD.equals(name.getName()))
    {
        addAttributeData(parent, result, qualifiedName(name));
    }
    else
    {
        final Set<String> names =
                new LinkedHashSet<>(parent.getNodeHandler()
                        .getAttributes(parent.getConfigurationNode()));
        final String prefix =
                name.getPrefix() != null ? prefixName(name.getPrefix(),
                        null) : null;
        for (final String n : names)
        {
            if (prefix == null || StringUtils.startsWith(n, prefix))
            {
                addAttributeData(parent, result, n);
            }
        }
    }

    return result;
}
 
源代码14 项目: o2oa   文件: CipherConnectionAction.java
public static String trim(String uri) {
	if (StringUtils.isEmpty(uri)) {
		return "";
	}
	if (StringUtils.startsWith(uri, "/jaxrs/")) {
		return StringUtils.substringAfter(uri, "/jaxrs/");
	}
	if (StringUtils.startsWith(uri, "/")) {
		return StringUtils.substringAfter(uri, "/");
	}
	return uri;
}
 
源代码15 项目: incubator-atlas   文件: DiscoveryREST.java
private String escapeTypeName(String typeName) {
    String ret;

    if (StringUtils.startsWith(typeName, "`") && StringUtils.endsWith(typeName, "`")) {
        ret = typeName;
    } else {
        ret = String.format("`%s`", typeName);
    }

    return ret;
}
 
源代码16 项目: archiva   文件: DefaultWagonFactory.java
@Override
public Wagon getWagon( WagonFactoryRequest wagonFactoryRequest )
    throws WagonFactoryException
{
    try
    {
        String protocol = StringUtils.startsWith( wagonFactoryRequest.getProtocol(), "wagon#" )
            ? wagonFactoryRequest.getProtocol()
            : "wagon#" + wagonFactoryRequest.getProtocol();

        // if it's a ntlm proxy we have to lookup the wagon light which support thats
        // wagon http client doesn't support that
        if ( wagonFactoryRequest.getNetworkProxy() != null && wagonFactoryRequest.getNetworkProxy().isUseNtlm() )
        {
            protocol = protocol + "-ntlm";
        }

        Wagon wagon = applicationContext.getBean( protocol, Wagon.class );
        wagon.addTransferListener( debugTransferListener );
        configureUserAgent( wagon, wagonFactoryRequest );
        return wagon;
    }
    catch ( BeansException e )
    {
        throw new WagonFactoryException( e.getMessage(), e );
    }
}
 
源代码17 项目: flowable-engine   文件: TestRuleBean.java
public boolean startsWith(Object input, String value) {
    return StringUtils.startsWith(input.toString(), value);
}
 
源代码18 项目: torrssen2   文件: DownloadService.java
public long create(DownloadList download) {
    long ret = 0L;

    String app = settingService.getDownloadApp();
    if(StringUtils.equals(app, "DOWNLOAD_STATION")) {
        String[] paths = StringUtils.split(download.getDownloadPath(), "/");

        if(paths.length > 1) {
            StringBuffer path = new StringBuffer();
            String name = null;
            for(int i = 0; i < paths.length; i++) {
                if(i < paths.length -1) {
                    path.append("/" + paths[i]);
                } else {
                    name = paths[i];
                }
            }
            fileStationService.createFolder(path.toString(), name);
        }
        if(downloadStationService.create(download.getUri(), download.getDownloadPath())) {
            for(DownloadList down: downloadStationService.list()) {
                if(StringUtils.equals(download.getUri(), down.getUri())) {
                    ret = down.getId();
                    download.setDbid(down.getDbid());
                }
            }
        }
    } else if(StringUtils.equals(app, "TRANSMISSION")) {
        if (StringUtils.startsWith(download.getUri(), "magnet")
            || StringUtils.equalsIgnoreCase(FilenameUtils.getExtension(download.getUri()), "torrent")) {
            ret = (long)transmissionService.torrentAdd(download.getUri(), download.getDownloadPath());
        } else {
            Optional<DownloadList> optionalSeq = downloadListRepository.findTopByOrderByIdDesc();
            if (optionalSeq.isPresent()) {
                Long id = optionalSeq.get().getId() + 100L;                    
                log.debug("id: " + id);
                ret = id;
            } else {
                ret = 100L;
            }
            download.setId(ret);
            httpDownloadService.createTransmission(download);
        }
        
    }

    if(ret > 0L) {
        download.setId(ret);
        downloadListRepository.save(download);
    }

    if(download.getAuto()) {
        WatchList watchList = new WatchList();
        watchList.setTitle(download.getRssTitle());
        watchList.setDownloadPath(download.getDownloadPath());
        if(!StringUtils.equals(download.getRssReleaseGroup(), "OTHERS")) {
            watchList.setReleaseGroup(download.getRssReleaseGroup());
        }
        
        watchListRepository.save(watchList);
    }

    return ret;
}
 
源代码19 项目: analysis-model   文件: EclipseParser.java
/**
 * Sets the issue's category to {@code Javadoc} if the message starts with {@value #JAVADOC_PREFIX}, {@code Other}
 * otherwise. Unlike {@link #extractMessage(IssueBuilder, String)}, the {@code message} is assumed to be cleaned-up.
 * 
 * @param builder
 *     IssueBuilder to populate.
 * @param message
 *     issue to examine.
 */
static void extractCategory(final IssueBuilder builder, final String message) {
    if (StringUtils.startsWith(message, JAVADOC_PREFIX)) {
        builder.setCategory(Categories.JAVADOC);
    }
    else {
        builder.setCategory(Categories.OTHER);
    }
}
 
源代码20 项目: Asqatasun   文件: PageAuditSetUpFormValidator.java
/**
 * @param url 
 * @return whether the current Url starts with a file prefix
 */
public boolean hasUrlFilePrefix(String url) {
    return StringUtils.startsWith(url, TgolKeyStore.FILE_PREFIX);
}
 
 同类方法