本文整理汇总了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;
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}