本文整理匯總了Java中org.apache.commons.lang3.StringUtils.startsWithAny方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.startsWithAny方法的具體用法?Java StringUtils.startsWithAny怎麽用?Java StringUtils.startsWithAny使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.startsWithAny方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: blur
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@RequestMapping(value = "/blur", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<InputStreamResource> blur(@RequestParam("source") String sourceUrl, HttpServletResponse response) {
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);
if (info != null) {
saveCached(hash, info);
}
}
if (info != null) {
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();
}
示例2: getNodePropertiesMap
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private Map<String, InertProperty> getNodePropertiesMap(
Node node,
Map<String, InertProperty> propsMap,
String propertyPrefix) throws Exception {
NodeIterator nodeIterator = node.getNodes();
while (nodeIterator.hasNext()) {
Node childNode = nodeIterator.nextNode();
String childNodePropertyPrefix = propertyPrefix + childNode.getName() + DOT;
getNodePropertiesMap(childNode, propsMap, childNodePropertyPrefix);
}
//add properties to map
PropertyIterator props = node.getProperties();
while (props.hasNext()) {
InertProperty property = new InertProperty(props.nextProperty());
if (!StringUtils.startsWithAny(property.name(), RESERVED_SYSTEM_NAME_PREFIXES)) {
propsMap.put(propertyPrefix + property.name(), property);
}
}
return propsMap;
}
示例3: propsToMap
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Takes an Iterator properties and turns it into map.
*
* @param properties This is a list of Iterator Properties
* @param ignoreSystemNames This is a boolean value to whether ignore system names
* @param renderContext A renderContext object
* @param resource A resource object
* @param ignoreSystemNames A boolean flag indicating if systems names should be ignored
* @return content This is a list of Objects of Property
* @throws Exception
*/
public static Map<String, Object> propsToMap(
Iterator properties,
RenderContext renderContext,
Resource resource,
boolean ignoreSystemNames)
throws Exception {
Map<String, Object> content = new JSONObject();
while (properties.hasNext()) {
Property property = (Property) properties.next(); // This is required so we can take any kind of Iterator, not just PropertyIterator
String propertyName = property.getName();
if (ignoreSystemNames && StringUtils.startsWithAny(propertyName, RESERVED_SYSTEM_NAME_PREFIXES))
continue;
if (property.getType() == (PropertyType.WEAKREFERENCE)) {
content.put(propertyName, resolveReference(property, renderContext, resource));
} else {
content.put(propertyName, distill(property));
}
}
return content;
}
示例4: process
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)
throws ProcessException {
try {
SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
Resource resource = request.getResource();
Map<String, Object> content = new HashMap<>();
if (resource != null) {
Node node = resource.adaptTo(Node.class);
if (node != null) {
String componentContentId = DigestUtils.md5Hex(resource.getPath());
content.put(XK_CONTENT_ID_CP, componentContentId);
Map<String, Object> propsMap = propsToMap(node.getProperties());
for (String propertyName : propsMap.keySet()) {
if (!StringUtils.startsWithAny(propertyName, RESERVED_SYSTEM_NAME_PREFIXES)) {
content.put(propertyName, propsMap.get(propertyName));
}
}
content.put(ID, DigestUtils.md5Hex(resource.getPath()));
} else {
// the resource doesn't exist so we clear the content
content.clear();
}
} else {
content.put(XK_CONTENT_ID_CP, "_NONE");
}
content.put(PATH, resource.getPath());
content.put(NAME, resource.getName());
contentModel.set(RESOURCE_CONTENT_KEY, content);
} catch (Exception e) {
throw new ProcessException(e);
}
}
示例5: propsToMap
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Takes an Iterator properties and turns it into map.
*
* @param properties This is a list of Iterator Properties
* @param ignoreSystemNames This is a boolean value to whether ignore system names
* @return content This is a list of Objects of Property
* @throws Exception
*/
public static Map<String, Object> propsToMap(Iterator properties, boolean ignoreSystemNames)
throws Exception {
Map<String, Object> content = new JSONObject();
while (properties.hasNext()) {
Property property = (Property) properties.next(); // This is required so we can take any kind of Iterator, not just PropertyIterator
String propertyName = property.getName();
if (ignoreSystemNames && StringUtils.startsWithAny(propertyName, RESERVED_SYSTEM_NAME_PREFIXES))
continue;
content.put(property.getName(), distill(property));
}
return content;
}
示例6: printCallstack
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Prints call stack with the specified logging level.
*
* @param logLevel
* the specified logging level
* @param carePackages
* the specified packages to print, for example,
* ["org.b3log.latke", "org.b3log.solo"], {@code null} to care
* nothing
* @param exceptablePackages
* the specified packages to skip, for example, ["com.sun",
* "java.io", "org.b3log.solo.filter"], {@code null} to skip
* nothing
*/
public static void printCallstack(final String[] carePackages, final String[] exceptablePackages) {
final Throwable throwable = new Throwable();
final StackTraceElement[] stackElements = throwable.getStackTrace();
if (null == stackElements) {
logger.warn("Empty call stack");
return;
}
final StringBuilder stackBuilder = new StringBuilder("CallStack [").append(SoloConstant.LINE_SEPARATOR);
for (int i = 1; i < stackElements.length; i++) {
final String stackElemClassName = stackElements[i].getClassName();
if (!StringUtils.startsWithAny(stackElemClassName, carePackages)
|| StringUtils.startsWithAny(stackElemClassName, exceptablePackages)) {
continue;
}
stackBuilder.append(" [className=").append(stackElements[i].getClassName()).append(", fileName=")
.append(stackElements[i].getFileName()).append(", lineNumber=")
.append(stackElements[i].getLineNumber()).append(", methodName=")
.append(stackElements[i].getMethodName()).append(']').append(SoloConstant.LINE_SEPARATOR);
}
stackBuilder.append("], full depth [").append(stackElements.length).append("]");
logger.info(stackBuilder.toString());
}
示例7: isUserWritable
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
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());
}
示例8: process
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)throws ProcessException {
try {
Map<String, Object> content = new HashMap<>();
Resource resource = (Resource) executionContext.get(JAHIA_RESOURCE);
RenderContext renderContext = (RenderContext) executionContext.get(JAHIA_RENDER_CONTEXT);
if (resource != null) {
Node node = resource.getNode();
if (node != null) {
String componentContentId = DigestUtils.md5Hex(resource.getPath());
content.put(XK_CONTENT_ID_CP, componentContentId);
Map<String, Object> propsMap = PropertyUtils.propsToMap(
node.getProperties(), renderContext, resource);
for (String propertyName : propsMap.keySet()) {
if (!StringUtils.startsWithAny(propertyName, RESERVED_SYSTEM_NAME_PREFIXES)) {
content.put(propertyName, propsMap.get(propertyName));
}
}
content.put(ID, DigestUtils.md5Hex(resource.getPath()));
content.put(JCR_NODE_UUID,node.getIdentifier());
} else {
// the resource doesn't exist so we clear the content
content.clear();
}
} else {
content.put(XK_CONTENT_ID_CP, "_NONE");
}
content.put(PATH, resource.getPath());
content.put(NAME, resource.getNode().getName());
contentModel.set(RESOURCE_CONTENT_KEY, content);
} catch (Exception e) {
LOG.error("DANTA Exception: "+e.getMessage(),e);
throw new ProcessException(e);
}
}
示例9: getTargetStockTypes
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private static List<StockType> getTargetStockTypes(Scanner scanner, Message message,
String operation) {
Locale locale = getResponseLocale(message);
List<StockType> stockTypes = new ArrayList<>();
List<String> unknownStockTypes = new ArrayList<>();
List<String> inputNames = new ArrayList<>();
while (scanner.hasNext()) {
String next = scanner.next();
boolean groupStart = StringUtils.startsWithAny(next, "\"", "\'");
if (!groupStart) {
inputNames.add(next);
} else {
StringBuilder buffer = new StringBuilder(next);
boolean groupEnd = false;
while (scanner.hasNext() && !groupEnd) {
next = scanner.next();
groupEnd = StringUtils.endsWithAny(next, "\"", "\'");
buffer.append(" ");
buffer.append(next);
}
buffer.deleteCharAt(0);
buffer.deleteCharAt(buffer.length() - 1);
inputNames.add(buffer.toString());
}
}
for (String inputName : inputNames) {
try {
// may throws IllegalArgumentException if there is no
String key = Resource.getItemKey(inputName, locale);
Optional<StockType> stockOpt = getStockTypeDao().findByKey(key);
if (!stockOpt.isPresent()) {
unknownStockTypes.add(inputName);
} else {
stockTypes.add(stockOpt.get());
}
} catch (Exception e) {
unknownStockTypes.add(inputName);
}
}
if (!unknownStockTypes.isEmpty()) {
String msg = String.format(Resource.getString("GROUP_UNKNOWN_TYPE", locale),
unknownStockTypes.toString());
Speaker.err(message, msg);
}
return stockTypes;
}
示例10: isWorldReadable
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
protected boolean isWorldReadable(final MantaObject object) {
final MantaAccountHomeInfo accountHomeInfo = new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath());
return StringUtils.startsWithAny(
object.getPath(),
accountHomeInfo.getAccountPublicRoot().getAbsolute());
}
示例11: doExecute
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public ActionResult doExecute(HttpServletRequest request, RenderContext renderContext, Resource resource,
JCRSessionWrapper session, Map<String, List<String>> parameters,
URLResolver urlResolver) throws Exception {
JSONObject filteredContentMap = new JSONObject();
final HttpServletResponse response = renderContext.getResponse();
try {
View view = null;
if ( resource.getNode() != null && resource.getNode().getPrimaryNodeType() != null &&
StringUtils.startsWithAny(resource.getNode().getPrimaryNodeType().getName(),
LIST_TEMPLATE_OPTION_TYPES) ){
view = JahiaUtils.resolveTemplateResourceView(request, resource, renderContext);
// Set view in the request since the view is needed by the contentModelFactoryService service
request.setAttribute(JAHIA_SCRIPT_VIEW, view);
}
if (view != null) {
TemplateContentModel templateContentModel = (TemplateContentModel)
contentModelFactoryService.getContentModel(request, response, renderContext, resource);
boolean clientAccessible =
(Boolean) templateContentModel.get(CONFIG_PROPERTIES_KEY + DOT + XK_CLIENT_ACCESSIBLE_CP);
if (clientAccessible) {
// get list of contexts
Configuration configuration = configurationProvider.getFor(view);
Collection<String> props = configuration.asStrings(XK_CLIENT_MODEL_PROPERTIES_CP, Mode.MERGE);
String[] contexts = props.toArray(new String[0]);
// get content model json with the XK_CLIENT_MODEL_PROPERTIES_CP contexts
filteredContentMap = templateContentModel.toJSONObject(contexts);
// add component id
String componentContentId = DigestUtils.md5Hex(resource.getPath());
filteredContentMap.put(XK_CONTENT_ID_CP, componentContentId);
}
// add component list with clientaccessible as true on the resource page
filteredContentMap.put(PAGE_COMPONENT_RESOURCE_LIST_AN, getComponentList(
resource, request, response, renderContext));
}
} catch (Exception ew) {
throw new ServletException(ew);
}
response.setContentType(SERVER_RESPONSE_CONTENT_TYPE);
response.getWriter().write( filteredContentMap.toString() );
return ActionResult.OK;
}
示例12: isSlave
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 判斷是否為讀庫
*
* @param methodName
* @return
*/
private Boolean isSlave(String methodName) {
// 方法名以query、find、get開頭的方法名走從庫
return StringUtils.startsWithAny(methodName, getSlaveMethodStart());
}