當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。