本文整理汇总了Java中com.buschmais.jqassistant.core.scanner.api.Scanner类的典型用法代码示例。如果您正苦于以下问题:Java Scanner类的具体用法?Java Scanner怎么用?Java Scanner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Scanner类属于com.buschmais.jqassistant.core.scanner.api包,在下文中一共展示了Scanner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public void execute(MavenProject mavenProject, Store store) throws MojoExecutionException, MojoFailureException {
ScannerConfiguration configuration = new ScannerConfiguration();
configuration.setContinueOnError(continueOnError);
ScannerContext scannerContext = new ScannerContextImpl(store);
ScannerPluginRepository scannerPluginRepository = pluginRepositoryProvider.getScannerPluginRepository();
Map<String, ScannerPlugin<?, ?>> scannerPlugins;
try {
scannerPlugins = scannerPluginRepository.getScannerPlugins(scannerContext, getPluginProperties());
} catch (PluginRepositoryException e) {
throw new MojoExecutionException("Cannot determine scanner plugins.", e);
}
ScopePluginRepository scopePluginRepository = pluginRepositoryProvider.getScopePluginRepository();
Scanner scanner = new ScannerImpl(configuration, scannerContext, scannerPlugins, scopePluginRepository.getScopes());
store.beginTransaction();
try {
scanner.scan(mavenProject, mavenProject.getFile().getAbsolutePath(), MavenScope.PROJECT);
} finally {
store.commitTransaction();
}
}
开发者ID:buschmais,项目名称:jqa-maven-plugin,代码行数:22,代码来源:ScanMojo.java
示例2: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public ManifestFileDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
try (InputStream stream = item.createStream()) {
Manifest manifest = new Manifest(stream);
ScannerContext context = scanner.getContext();
Store store = context.getStore();
FileDescriptor fileDescriptor = context.getCurrentDescriptor();
ManifestFileDescriptor manifestFileDescriptor = store.addDescriptorType(fileDescriptor, ManifestFileDescriptor.class);
ManifestSectionDescriptor mainSectionDescriptor = store.create(ManifestSectionDescriptor.class);
mainSectionDescriptor.setName(SECTION_MAIN);
manifestFileDescriptor.setMainSection(mainSectionDescriptor);
readSection(manifest.getMainAttributes(), mainSectionDescriptor, store);
for (Map.Entry<String, Attributes> sectionEntry : manifest.getEntries().entrySet()) {
ManifestSectionDescriptor sectionDescriptor = store.create(ManifestSectionDescriptor.class);
sectionDescriptor.setName(sectionEntry.getKey());
readSection(sectionEntry.getValue(), sectionDescriptor, store);
manifestFileDescriptor.getManifestSections().add(sectionDescriptor);
}
return manifestFileDescriptor;
}
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:22,代码来源:ManifestFileScannerPlugin.java
示例3: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public ClassFileDescriptor scan(FileResource file, String path, Scope scope, final Scanner scanner) throws IOException {
final FileDescriptor fileDescriptor = scanner.getContext().getCurrentDescriptor();
VisitorHelper visitorHelper = new VisitorHelper(scanner.getContext(), classModelConfiguration);
final ClassVisitor visitor = new ClassVisitor(fileDescriptor, visitorHelper);
ClassFileDescriptor classFileDescriptor;
try (InputStream stream = file.createStream()) {
classFileDescriptor = MD5DigestDelegate.getInstance().digest(stream, new MD5DigestDelegate.DigestOperation<ClassFileDescriptor>() {
@Override
public ClassFileDescriptor execute(InputStream inputStream) throws IOException {
new ClassReader(inputStream).accept(visitor, 0);
return visitor.getTypeDescriptor();
}
});
classFileDescriptor.setValid(true);
} catch (RuntimeException e) {
LOGGER.warn("Cannot scan class '" + path + "'.", e);
classFileDescriptor = visitor.getTypeDescriptor();
if (classFileDescriptor == null) {
classFileDescriptor = scanner.getContext().getStore().addDescriptorType(fileDescriptor, ClassFileDescriptor.class);
}
classFileDescriptor.setValid(false);
}
return classFileDescriptor;
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:26,代码来源:ClassFileScannerPlugin.java
示例4: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public PropertyFileDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
ScannerContext context = scanner.getContext();
Store store = context.getStore();
FileDescriptor fileDescriptor = context.getCurrentDescriptor();
PropertyFileDescriptor propertyFileDescriptor = store.addDescriptorType(fileDescriptor, PropertyFileDescriptor.class);
Properties properties = new Properties();
try (InputStream stream = item.createStream()) {
properties.load(stream);
} catch (IllegalArgumentException e) {
LOGGER.warn("Cannot load properties from '" + path + "': " + e.getMessage());
}
for (String name : properties.stringPropertyNames()) {
String value = properties.getProperty(name);
PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
propertyDescriptor.setName(name);
propertyDescriptor.setValue(value);
propertyFileDescriptor.getProperties().add(propertyDescriptor);
}
return propertyFileDescriptor;
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:22,代码来源:PropertyFileScannerPlugin.java
示例5: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public ServiceLoaderDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
Matcher matcher = PATTERN.matcher(path);
if (!matcher.matches()) {
throw new IOException("Cannot match path name: " + path);
}
String serviceInterface = matcher.group(2);
ScannerContext context = scanner.getContext();
FileDescriptor fileDescriptor = context.getCurrentDescriptor();
ServiceLoaderDescriptor serviceLoaderDescriptor = context.getStore().addDescriptorType(fileDescriptor, ServiceLoaderDescriptor.class);
TypeDescriptor interfaceTypeDescriptor = getTypeDescriptor(serviceInterface, context);
serviceLoaderDescriptor.setType(interfaceTypeDescriptor);
try (InputStream stream = item.createStream()) {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
String serviceImplementation;
while ((serviceImplementation = reader.readLine()) != null) {
if (!isEmptyOrComment(serviceImplementation)) {
TypeDescriptor implementationTypeDescriptor = getTypeDescriptor(serviceImplementation, context);
serviceLoaderDescriptor.getContains().add(implementationTypeDescriptor);
}
}
}
return serviceLoaderDescriptor;
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:26,代码来源:ServiceLoaderFileScannerPlugin.java
示例6: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public PackageDescriptor scan(DirectoryResource item, String path, Scope scope, Scanner scanner) throws IOException {
ScannerContext context = scanner.getContext();
DirectoryDescriptor directoryDescriptor = context.getCurrentDescriptor();
PackageDescriptor descriptor = context.getStore().addDescriptorType(directoryDescriptor, PackageDescriptor.class);
String packageName = path.substring(1).replaceAll("/", ".");
String name;
int separatorIndex = packageName.lastIndexOf('.');
if (separatorIndex != -1) {
name = packageName.substring(separatorIndex + 1);
} else {
name = packageName;
}
descriptor.setName(name);
descriptor.setFullQualifiedName(packageName);
return descriptor;
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:18,代码来源:PackageDirectoryScannerPlugin.java
示例7: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public PropertyFileDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
ScannerContext context = scanner.getContext();
Store store = context.getStore();
FileDescriptor fileDescriptor = context.getCurrentDescriptor();
Class<XmlPropertyFileDescriptor> descriptorType = XmlPropertyFileDescriptor.class;
PropertyFileDescriptor propertyFileDescriptor = store.addDescriptorType(fileDescriptor, descriptorType);
Properties properties = new Properties();
try (InputStream stream = item.createStream()) {
properties.loadFromXML(stream);
} catch (IllegalArgumentException e) {
LOGGER.warn("Cannot load properties from '" + path + "': " + e.getMessage());
}
for (String name : properties.stringPropertyNames()) {
String value = properties.getProperty(name);
PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
propertyDescriptor.setName(name);
propertyDescriptor.setValue(value);
propertyFileDescriptor.getProperties().add(propertyDescriptor);
}
return propertyFileDescriptor;
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:24,代码来源:XmlPropertyFileScannerPlugin.java
示例8: execute
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
/**
* Executes the given scan operation.
*
* @param artifactId
* The artifact id of the artifact to push on the context.
* @param operation
* The operation.
*/
protected List<? extends FileDescriptor> execute(String artifactId, ScanClassPathOperation operation) {
Scanner scanner = getScanner();
ScannerContext context = scanner.getContext();
store.beginTransaction();
JavaArtifactFileDescriptor artifact = getArtifactDescriptor(artifactId);
artifact.setFullQualifiedName(artifactId);
context.push(JavaArtifactFileDescriptor.class, artifact);
ContainerFileResolver fileResolverStrategy = new ContainerFileResolver(artifact);
context.push(FileResolver.class, fileResolverStrategy);
List<? extends FileDescriptor> descriptors = execute(artifact, operation, scanner);
for (FileDescriptor descriptor : descriptors) {
fileResolverStrategy.put(descriptor.getFileName(), descriptor);
}
context.pop(JavaArtifactFileDescriptor.class);
context.pop(FileResolver.class);
fileResolverStrategy.flush();
store.commitTransaction();
return descriptors;
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:30,代码来源:AbstractJavaPluginIT.java
示例9: invalidDescriptor
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
/**
* Verifies that any files not representing service descriptors are ignored.
*
* @throws java.io.IOException
* If the test fails.
*/
@Test
public void invalidDescriptor() throws IOException {
File file = getClassesDirectory(ServiceLoaderIT.class);
final File propsFile = new File(file, "META-INF/test.properties");
final String path = "META-INF/services/test.properties";
store.beginTransaction();
JavaClassesDirectoryDescriptor artifactDescriptor = getArtifactDescriptor("a1");
execute(artifactDescriptor, new ScanClassPathOperation() {
@Override
public List<FileDescriptor> scan(JavaArtifactFileDescriptor artifact, Scanner scanner) {
return singletonList(scanner.<File, FileDescriptor>scan(propsFile, path, JavaScope.CLASSPATH));
}
}, getScanner());
List<ServiceLoaderDescriptor> s = query("MATCH (s:ServiceLoader:Properties:File) RETURN s").getColumn("s");
assertThat(s.size(), equalTo(1));
ServiceLoaderDescriptor serviceLoaderDescriptor = s.get(0);
assertThat(serviceLoaderDescriptor.getFileName(), equalTo(path));
store.commitTransaction();
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:26,代码来源:ServiceLoaderIT.java
示例10: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public PlaintextFileDescriptor scan(final FileResource item, final String path, final Scope scope, final Scanner scanner) throws IOException {
final Store store = scanner.getContext().getStore();
final PlaintextFileDescriptor plaintextFileDescriptor = store.create(PlaintextFileDescriptor.class);
plaintextFileDescriptor.setFileName(path);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(item.createStream()))) {
final PlaintextLineParser pumlLineParser = new PlaintextLineParser(store, plaintextFileDescriptor);
String line;
while ((line = reader.readLine()) != null) {
pumlLineParser.parseLine(line);
}
}
return plaintextFileDescriptor;
}
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:17,代码来源:PlaintextFileScannerPlugin.java
示例11: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public PlantUmlFileDescriptor scan(final FileResource item, final String path, final Scope scope, final Scanner scanner) throws IOException {
final Store store = scanner.getContext().getStore();
final PlantUmlFileDescriptor plantUmlFileDescriptor = store.create(PlantUmlFileDescriptor.class);
plantUmlFileDescriptor.setFileName(path);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(item.createStream()))) {
final PumlLineParser pumlLineParser = new PumlLineParser(store, plantUmlFileDescriptor, path.endsWith(".puml") ? ParsingState.ACCEPTING : ParsingState.IGNORING);
String line;
while ((line = reader.readLine()) != null) {
pumlLineParser.parseLine(line);
}
}
return plantUmlFileDescriptor;
}
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:17,代码来源:PlantUmlFileScannerPlugin.java
示例12: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public CustomDescriptor scan(FileResource item, String path, Scope scope, Scanner scanner) throws IOException {
ClassFileDescriptor descriptor = scanner.getContext().peek(ClassFileDescriptor.class);
String value = (String) getProperties().get(PROPERTY_VALUE);
LOGGER.info("Using custom plugin to scan " + path + ", setting value to " + value);
CustomDescriptor customDescriptor = scanner.getContext().getStore().migrate(descriptor, CustomDescriptor.class);
customDescriptor.setValue(value);
return customDescriptor;
}
开发者ID:buschmais,项目名称:jqa-maven-plugin,代码行数:10,代码来源:CustomScannerPlugin.java
示例13: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public ClassFileDescriptor scan(final Class<?> item, String path, Scope scope, Scanner scanner) throws IOException {
final String fileName = "/" + item.getName().replace('.', '/') + ".class";
AbstractFileResource fileResource = new AbstractFileResource() {
@Override
public InputStream createStream() throws IOException {
return item.getResourceAsStream(fileName);
}
};
return scanner.scan(fileResource, fileName, scope);
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:12,代码来源:ClassTypeScannerPlugin.java
示例14: scanClasses
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
/**
* Scans the given classes.
*
* @param artifactId
* The id of the containing artifact.
* @param classes
* The classes.
* @throws IOException
* If scanning fails.
*/
protected void scanClasses(String artifactId, final Class<?>... classes) throws IOException {
execute(artifactId, new ScanClassPathOperation() {
@Override
public List<FileDescriptor> scan(JavaArtifactFileDescriptor artifact, Scanner scanner) {
List<FileDescriptor> result = new ArrayList<>();
for (Class<?> item : classes) {
FileDescriptor fileDescriptor = scanner.scan(item, item.getName(), JavaScope.CLASSPATH);
result.add(fileDescriptor);
}
return result;
}
});
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:24,代码来源:AbstractJavaPluginIT.java
示例15: scanClassPathResources
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
protected void scanClassPathResources(final Scope scope, String artifactId, final String... resources) throws IOException {
final File directory = getClassesDirectory(this.getClass());
execute(artifactId, new ScanClassPathOperation() {
@Override
public List<FileDescriptor> scan(JavaArtifactFileDescriptor artifact, Scanner scanner) {
List<FileDescriptor> result = new ArrayList<>();
for (String resource : resources) {
File file = new File(directory, resource);
FileDescriptor fileDescriptor = scanner.scan(file, resource, scope);
result.add(fileDescriptor);
}
return result;
}
});
}
开发者ID:buschmais,项目名称:jqa-java-plugin,代码行数:16,代码来源:AbstractJavaPluginIT.java
示例16: start
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public final Collection<Injectable<?>> start(GraphDatabaseService graphDatabaseService, Configuration config) {
Set<Injectable<?>> injectables = new HashSet<>();
PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(AbstractPluginInitializer.class.getClassLoader());
try {
ScopePluginRepository scopePluginRepository = new ScopePluginRepositoryImpl(pluginConfigurationReader);
injectables.add(new SimpleInjectable<>(scopePluginRepository, ScopePluginRepository.class));
ScannerPluginRepository scannerPluginRepository = new ScannerPluginRepositoryImpl(pluginConfigurationReader);
injectables.add(new SimpleInjectable<>(scannerPluginRepository, ScannerPluginRepository.class));
ModelPluginRepository modelPluginRepository = new ModelPluginRepositoryImpl(pluginConfigurationReader);
injectables.add(new SimpleInjectable<>(modelPluginRepository, ModelPluginRepository.class));
store = new GraphDbStore(graphDatabaseService);
store.start(modelPluginRepository.getDescriptorTypes());
injectables.add(new SimpleInjectable<>(store, Store.class));
ScannerContext context = new ScannerContextImpl(store);
List<ScannerPlugin<?, ?>> scannerPlugins = scannerPluginRepository.getScannerPlugins(context, Collections.<String, Object> emptyMap());
Scanner scanner = new ScannerImpl(context, scannerPlugins, scopePluginRepository.getScopes());
injectables.add(new SimpleInjectable<>(scanner, Scanner.class));
} catch (PluginRepositoryException e) {
throw new RuntimeException("Setting up plugin repositories failed.", e);
}
injectables.addAll(getInjectables(store, config));
return injectables;
}
开发者ID:buschmais,项目名称:jqassistant-server,代码行数:33,代码来源:AbstractPluginInitializer.java
示例17: execute
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public Descriptor execute(Scanner scanner) throws IOException {
String url = artifactCoordinates.getRepositoryUrl();
ScannerContext context = scanner.getContext();
ArtifactProvider artifactProvider = getArtifactProvider(url, getMavenRepoDescriptor(url, context.getStore()));
try {
context.push(ArtifactProvider.class, artifactProvider);
context.push(ArtifactResolver.class, new MavenArtifactResolver());
ArtifactInfo info = createArtifactInfo();
return scanner.scan(info, info.toString(), MavenScope.REPOSITORY);
} finally {
context.pop(ArtifactResolver.class);
context.pop(ArtifactProvider.class);
}
}
开发者ID:buschmais,项目名称:jqassistant-server,代码行数:16,代码来源:ScanArtifactJob.java
示例18: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public JavaSourceDescriptor scan(final FileResource item, final String path, final Scope scope, final Scanner scanner) throws IOException {
final Store store = scanner.getContext().getStore();
final JavaSourceFileDescriptor javaSourceFileDescriptor = store.create(JavaSourceFileDescriptor.class);
javaSourceFileDescriptor.setFileName(path);
importStream(store, item.createStream(), path);
return javaSourceFileDescriptor;
}
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:9,代码来源:JavaparserScannerPlugin.java
示例19: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public GitRepositoryDescriptor scan(final FileResource item, final String path, final Scope scope, final Scanner scanner) throws IOException {
counter++;
// This is called with path = "/HEAD" since this is the only "accepted" file
LOGGER.debug ("Scanning Git directory '{}' (call with path: '{}')", item.getFile(), path);
Store store = scanner.getContext().getStore();
final GitRepositoryDescriptor gitRepositoryDescriptor = store.create(GitRepositoryDescriptor.class);
initGitDescriptor(gitRepositoryDescriptor, item.getFile());
new GitRepositoryScanner(store, gitRepositoryDescriptor, range).scanGitRepo();
return gitRepositoryDescriptor;
}
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:15,代码来源:GitScannerPlugin.java
示例20: scan
import com.buschmais.jqassistant.core.scanner.api.Scanner; //导入依赖的package包/类
@Override
public CppClangAstDescriptor scan(final FileResource item, final String path, final Scope scope, final Scanner scanner) throws IOException {
LOGGER.debug("Cpp scans path "+path);
Store store = scanner.getContext().getStore();
final CppClangAstDescriptor cppClangAstDescriptor = store.create(CppClangAstDescriptor.class);
cppClangAstDescriptor.setFileName(path);
new CppAstParser().readStream(store, item.createStream());
return cppClangAstDescriptor;
}
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:10,代码来源:CppScannerPlugin.java
注:本文中的com.buschmais.jqassistant.core.scanner.api.Scanner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论