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


Java StringUtils.startsWith方法代码示例

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


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

示例1: scrapLinksForSearchJSoup

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void scrapLinksForSearchJSoup(String keyWord, int cityId) {
	// log("crawling for keyword : " + keyWord + " and city: " +cityId);
	String url = QuoraConstants.getUrl(keyWord, cityId);
	Document doc = getDocument(url);

	Elements els = doc.select("div.g");

	for (Element el : els) {
		String quoraUrl = el.getElementsByTag("cite").text();
		quoraUrl = StringUtils.replace(quoraUrl, " ", "");
		if (!StringUtils.startsWith(quoraUrl, "http")) {
			quoraUrl = "http://" + quoraUrl;
		}
		if (!uniqueQuoraLinks.contains(quoraUrl)) {
			crawlQuoraPage(quoraUrl, true);
		}
	}
}
 
开发者ID:thekosmix,项目名称:Quora-Marketing,代码行数:19,代码来源:QuoraCrawler.java

示例2: toHTML

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Converts the specified markdown text to HTML.
 *
 * @param markdownText
 *            the specified markdown text
 * @return converted HTML, returns {@code null} if the specified markdown
 *         text is "" or {@code null}, returns "Markdown error" if exception
 */
public static String toHTML(final String markdownText) {
	if (StringUtils.isBlank(markdownText)) {
		return "";
	}

	final PegDownProcessor pegDownProcessor = new PegDownProcessor(
			Extensions.ALL_OPTIONALS | Extensions.ALL_WITH_OPTIONALS, 5000);
	String ret = pegDownProcessor.markdownToHtml(markdownText);

	if (!StringUtils.startsWith(ret, "<p>")) {
		ret = "<p>" + ret + "</p>";
	}

	return ret;
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:24,代码来源:Markdowns.java

示例3: postHandle

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
	Long long1 = (Long) request.getAttribute(EXECUTE_TIME_ATTRIBUTE_NAME);
	if (long1 == null) {
		Long long2 = (Long) request.getAttribute(START_TIME_ATTRIBUTE_NAME);
		Long long3 = Long.valueOf(System.currentTimeMillis());
		long1 = Long.valueOf(long3.longValue() - long2.longValue());
		request.setAttribute(START_TIME_ATTRIBUTE_NAME, long2);
	}
	if (modelAndView != null) {
		String s = modelAndView.getViewName();
		if (!StringUtils.startsWith(s, "redirect:"))
			modelAndView.addObject(EXECUTE_TIME_ATTRIBUTE_NAME, long1);
	}
	if (logger.isDebugEnabled()) {
		logger.debug((new StringBuilder("[")).append(handler).append("] executeTime: ").append(long1).append("ms").toString());
	}
}
 
开发者ID:wz12406,项目名称:accumulate,代码行数:19,代码来源:ExecuteTimeInterceptor.java

示例4: resolveAbsolutePathToPattern

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String resolveAbsolutePathToPattern(String path, String projectSlingPrefix, String projectName, String currentPatternPath) {
    if (StringUtils.startsWith(path, projectSlingPrefix + PatternLabConstants.SLASH + projectName)
            || StringUtils.startsWith(path, projectSlingPrefix + PatternLabConstants.SLASH + projectName)) {
        return path;
    } else if (StringUtils.startsWith(path, projectName)) {
        return PatternLabConstants.SLASH + projectSlingPrefix + PatternLabConstants.SLASH + path;
    }
    String[] pathElements = StringUtils.split(path, PatternLabConstants.SLASH);
    StringBuilder absolutePath = new StringBuilder(StringUtils.substringBeforeLast(currentPatternPath, PatternLabConstants.SLASH));
    for (String pathElement : pathElements) {
        if (StringUtils.equals(pathElement, FILESYSTEM_BACK_PATH)) {
            absolutePath = new StringBuilder(StringUtils.substringBeforeLast(currentPatternPath, PatternLabConstants.SLASH));
        } else {
            absolutePath.append(PatternLabConstants.SLASH).append(pathElement);
        }
    }

    return absolutePath.toString();
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:20,代码来源:HtlScriptParser.java

示例5: annotationToObject

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 注解到对象复制,只复制能匹配上的方法。
 * @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) {
					// 忽略所有设置失败方法
				}
			}
		}
	}
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:28,代码来源:ObjectUtils.java

示例6: asFile

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 兼容无前缀, classpath://, file:// 的情况获取文件
 * 
 * 如果以classpath:// 定义的文件不存在会抛出IllegalArgumentException异常,以file://定义的则不会
 */
public static File asFile(String generalPath) throws IOException {
	if (StringUtils.startsWith(generalPath, CLASSPATH_PREFIX)) {
		String resourceName = StringUtils.substringAfter(generalPath, CLASSPATH_PREFIX);
		return getFileByURL(ResourceUtil.asUrl(resourceName));
	}
	try {
		// try URL
		return getFileByURL(new URL(generalPath));
	} catch (MalformedURLException ex) {
		// no URL -> treat as file path
		return new File(generalPath);
	}
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:19,代码来源:URLResourceUtil.java

示例7: convert

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String convert(Tenant tenant, Event event) {
  
  String convertedUserId = null;
  
  Agent agent = event.getAgent();
  String agentId = agent.getId();
  
  if (StringUtils.isNotBlank(agentId)
      && StringUtils.startsWith(agentId, "http")) {
    Map<String, String> tenantMetadata = tenant.getMetadata();
    if (tenantMetadata != null && !tenantMetadata.isEmpty()) {
      String tenantUserPrefix = tenantMetadata.get(Vocabulary.TENANT_USER_PREFIX);
      if (StringUtils.isNotBlank(tenantUserPrefix)) {
        String agentIdAfterPrefix = StringUtils.substringAfter(agentId, tenantUserPrefix);
        if (StringUtils.startsWith(agentIdAfterPrefix, "/")) {
          convertedUserId = StringUtils.substringAfter(agentIdAfterPrefix, "/");
        }
        else {
          convertedUserId = agentIdAfterPrefix;
        }
      }
    }
    else {
      convertedUserId = StringUtils.substringAfterLast(agentId, "/");
    }
  }
  else {
    convertedUserId = agentId;
  }
  
  return convertedUserId;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:OpenLRW,代码行数:34,代码来源:DefaultUserIdConverter.java

示例8: fileExistsInBucket

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static boolean fileExistsInBucket(String filenamePrefix) {
	try {
		ObjectListing ol = S3.listObjects(properties.getProperty(S3_BUCKET_NAME));
		List<S3ObjectSummary> objects = ol.getObjectSummaries();
		for (S3ObjectSummary os : objects) {
			if (StringUtils.startsWith(os.getKey(), filenamePrefix)) {
				LOG.info("Found file {} from S3 bucket.", filenamePrefix);
				return true;
			}
		}
	} catch (AmazonServiceException e) {
		LOG.error("Exception occured when checking if file exists in S3.", e);
	}
	return false;
}
 
开发者ID:villeau,项目名称:pprxmtr,代码行数:16,代码来源:S3.java

示例9: getS3KeyFromBucket

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String getS3KeyFromBucket(String filenamePrefix) {
	try {
		ObjectListing ol = S3.listObjects(properties.getProperty(S3_BUCKET_NAME));
		List<S3ObjectSummary> objects = ol.getObjectSummaries();
		for (S3ObjectSummary os : objects) {
			if (StringUtils.startsWith(os.getKey(), filenamePrefix)) {
				LOG.info("Found file {} from S3 bucket.", filenamePrefix);
				return os.getKey();
			}
		}
	} catch (AmazonServiceException e) {
		LOG.error("Exception occured when checking if file exists in S3.", e);
	}
	return StringUtils.EMPTY;
}
 
开发者ID:villeau,项目名称:pprxmtr,代码行数:16,代码来源:S3.java

示例10: replaceWithSysPropUserHome

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String[] replaceWithSysPropUserHome(final String[] pathArray) {
    if (ArrayUtils.isEmpty(pathArray)) {
        return pathArray;
    }
    final String SYS_PROP_USER_HOME = System.getProperty("user.home");
    for (int index = 0; index < pathArray.length; index++) {
        if (StringUtils.startsWith(pathArray[index], "~")) {
            pathArray[index] = StringUtils.replaceOnce(pathArray[index], "~", SYS_PROP_USER_HOME);
        }
    }
    return pathArray;
}
 
开发者ID:alibaba,项目名称:jvm-sandbox,代码行数:13,代码来源:CoreConfigure.java

示例11: retrieveJsonDataFilesInFolder

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private List<String> retrieveJsonDataFilesInFolder(Resource filesParentResource, String name) {
    final List<String> patternJsonDataFiles = Lists.newArrayList();
    final Iterator<Resource> children = filesParentResource.listChildren();
    while (children.hasNext()) {
        final Resource childResource = children.next();
        final String childResourceName = childResource.getName();
        if (StringUtils.startsWith(childResourceName, name) && StringUtils.endsWith(childResourceName, PatternLabConstants.DATA_EXT)) {
            patternJsonDataFiles.add(childResourceName);
        }
    }
    return patternJsonDataFiles;
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:13,代码来源:PatternPatternCategoryFactoryImpl.java

示例12: getMime

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String getMime(final String filename) {
    if(StringUtils.startsWith(filename, "._")) {
        return DEFAULT_CONTENT_TYPE;
    }
    // Reads from mime.types in classpath
    return types.getMimetype(StringUtils.lowerCase(filename));
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:9,代码来源:MappingMimeTypeService.java

示例13: getPath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String getPath(String path) {
    if (StringUtils.isBlank(path)) {
        path = StringUtils.EMPTY;
    }
    if (!StringUtils.startsWith(path, Constants.Path.ROOT)) {
        path = Constants.Path.ROOT + path;
    }
    if (StringUtils.isNotBlank(Config.getContextPath())
            && !StringUtils.startsWith(path, Config.getContextPath())) {
        path = Config.getContextPath() + path;
    }
    return path;
}
 
开发者ID:wittyLuzhishen,项目名称:EasyPackage,代码行数:14,代码来源:PathUtil.java

示例14: extractTokenFromHeader

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public String extractTokenFromHeader(HttpServletRequest req) {
    String token = null;
    String header = req.getHeader(JWT_TOKEN_HEADER);
    if (!StringUtils.isEmpty(header)) {
        if (StringUtils.startsWith(header.trim(), "Bearer")) {
            token = StringUtils.remove(header, "Bearer").trim();
        }
    }
    return token;
}
 
开发者ID:kinota,项目名称:kinota-server,代码行数:11,代码来源:JwtTokenUtil.java

示例15: getEdgeColor

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public Color getEdgeColor(final DiagramEdge edge) {
    final String edgeType = edge.getRelationship().toString();

    if (StringUtils.isBlank(edgeType) || "OK".equalsIgnoreCase(edgeType)) {
        return new JBColor(
            new Color(9, 128, 0),
            new Color(9, 128, 0)
        );
    }

    if ("NOK".equalsIgnoreCase(edgeType) || "ERROR".equalsIgnoreCase(edgeType) || "FAIL".equalsIgnoreCase(edgeType)) {
        return new JBColor(
            new Color(161, 49, 42),
            new Color(161, 49, 42)
        );
    }

    final String timeoutLabel = HybrisI18NBundleUtils.message("hybris.business.process.timeout");

    if (StringUtils.startsWith(edgeType, timeoutLabel)) {
        return new JBColor(
            new Color(161, 49, 42),
            new Color(161, 49, 42)
        );
    }

    return new JBColor(
        new Color(71, 71, 71),
        new Color(155, 158, 161)
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:33,代码来源:BpDiagramColorManagerIml.java


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