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


Java StringUtils.startsWithAny方法代码示例

本文整理汇总了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();
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:29,代码来源:BlurImageController.java

示例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;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:22,代码来源:AEMConfigurationProviderImpl.java

示例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;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:32,代码来源:PropertyUtils.java

示例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);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:34,代码来源:AddAllResourceContentPropertiesContextProcessor.java

示例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;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:21,代码来源:PropertyUtils.java

示例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());
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:43,代码来源:Callstacks.java

示例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());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:8,代码来源:MantaSession.java

示例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);
    }
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:39,代码来源:AddAllResourceContentPropertiesContextProcessor.java

示例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;
}
 
开发者ID:BlackCraze,项目名称:GameResourceBot,代码行数:47,代码来源:Commands.java

示例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());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:7,代码来源:MantaSession.java

示例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;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:54,代码来源:PageContentModelToJSONServlet.java

示例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());
}
 
开发者ID:6089555,项目名称:spring-boot-starter-dynamic-datasource,代码行数:11,代码来源:DataSourceAspect.java


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