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


Java CommonUtils.getUriByFilename方法代码示例

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


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

示例1: convert

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public Object convert(Class type, Object value) {
    final String url = value.toString();
    URI result = null;

    if (!CommonUtils.isBlank(url)) {
        try {
            result = CommonUtils.getUriByFilename(url);
        }
        catch (CheckstyleException ex) {
            throw new IllegalArgumentException(ex);
        }
    }

    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:AutomaticBean.java

示例2: testExternalResourceIsSavedInCache

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@Test
public void testExternalResourceIsSavedInCache() throws Exception {
    final Configuration config = new DefaultConfiguration("myName");
    final String filePath = temporaryFolder.newFile().getPath();
    final PropertyCacheFile cache = new PropertyCacheFile(config, filePath);

    cache.load();

    final Set<String> resources = new HashSet<String>();
    final String pathToResource = getPath("InputPropertyCacheFileExternal.properties");
    resources.add(pathToResource);
    cache.putExternalResources(resources);

    final MessageDigest digest = MessageDigest.getInstance("SHA-1");
    final URI uri = CommonUtils.getUriByFilename(pathToResource);
    final byte[] input =
            ByteStreams.toByteArray(new BufferedInputStream(uri.toURL().openStream()));
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(out);
    oos.writeObject(input);
    digest.update(out.toByteArray());
    final String expected = BaseEncoding.base16().upperCase().encode(digest.digest());

    assertEquals("Hashes are not equal", expected,
            cache.get("module-resource*?:" + pathToResource));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:PropertyCacheFileTest.java

示例3: loadConfiguration

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Returns the module configurations in a specified file.
 *
 * @param config location of config file, can be either a URL or a filename
 * @param overridePropsResolver overriding properties
 * @param ignoredModulesOptions {@code OMIT} if modules with severity
 *            'ignore' should be omitted, {@code EXECUTE} otherwise
 * @param threadModeSettings the thread mode configuration
 * @return the check configurations
 * @throws CheckstyleException if an error occurs
 */
public static Configuration loadConfiguration(String config,
                                              PropertyResolver overridePropsResolver,
                                              IgnoredModulesOptions ignoredModulesOptions,
                                              ThreadModeSettings threadModeSettings)
        throws CheckstyleException {
    // figure out if this is a File or a URL
    final URI uri = CommonUtils.getUriByFilename(config);
    final InputSource source = new InputSource(uri.toString());
    return loadConfiguration(source, overridePropsResolver,
            ignoredModulesOptions, threadModeSettings);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:ConfigurationLoader.java

示例4: loadExternalResource

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Loads the content of external resource.
 * @param location external resource location.
 * @return array of bytes which represents the content of external resource in binary form.
 * @throws CheckstyleException if error while loading occurs.
 */
private static byte[] loadExternalResource(String location) throws CheckstyleException {
    final byte[] content;
    final URI uri = CommonUtils.getUriByFilename(location);

    try {
        content = ByteStreams.toByteArray(new BufferedInputStream(uri.toURL().openStream()));
    }
    catch (IOException ex) {
        throw new CheckstyleException("Unable to load external resource file " + location, ex);
    }

    return content;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:PropertyCacheFile.java

示例5: loadSuppressions

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Returns the suppression filters in a specified file.
 * @param filename name of the suppressions file.
 * @return the filter chain of suppression elements specified in the file.
 * @throws CheckstyleException if an error occurs.
 */
public static FilterSet loadSuppressions(String filename)
        throws CheckstyleException {
    // figure out if this is a File or a URL
    final URI uri = CommonUtils.getUriByFilename(filename);
    final InputSource source = new InputSource(uri.toString());
    return loadSuppressions(source, filename);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:SuppressionsLoader.java

示例6: loadXpathSuppressions

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Returns the suppression {@code TreeWalker} filters in a specified file.
 * @param filename name of the suppressions file.
 * @return the set of xpath suppression elements specified in the file.
 * @throws CheckstyleException if an error occurs.
 */
public static Set<TreeWalkerFilter> loadXpathSuppressions(String filename)
        throws CheckstyleException {
    // figure out if this is a File or a URL
    final URI uri = CommonUtils.getUriByFilename(filename);
    final InputSource source = new InputSource(uri.toString());
    return loadXpathSuppressions(source, filename);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:SuppressionsLoader.java


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