本文整理汇总了Java中japa.parser.ast.ImportDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java ImportDeclaration类的具体用法?Java ImportDeclaration怎么用?Java ImportDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImportDeclaration类属于japa.parser.ast包,在下文中一共展示了ImportDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: Fact
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
public Fact(File file, CompilationUnit compilationUnit) throws FileNotFoundException {
if (compilationUnit.getPackage() != null)
packageName = compilationUnit.getPackage().getName().toString().replace("package", "");
comment = extractTopComment(file);
imports = new HashSet<String>();
if (compilationUnit.getImports() != null)
for (ImportDeclaration imp : compilationUnit.getImports()) {
String str = imp.getName().toString();
if (!imp.isAsterisk())
str = str.substring(0, str.lastIndexOf("."));
imports.add(str);
}
declarations = new ArrayList<Declaration>();
if (compilationUnit.getTypes() != null)
for (TypeDeclaration decl : compilationUnit.getTypes()) {
if (decl instanceof ClassOrInterfaceDeclaration)
declarations.add(new Declaration(decl));
}
}
开发者ID:amritbhat786,项目名称:DocIT,代码行数:23,代码来源:Fact.java
示例2: importParametersForType
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
public static ReferenceType importParametersForType(
final JavaType targetType, final List<ImportDeclaration> imports,
final JavaType typeToImport) {
Validate.notNull(targetType, "Target type is required");
Validate.notNull(imports, "Compilation unit imports required");
Validate.notNull(typeToImport, "Java type to import is required");
final ClassOrInterfaceType cit = getClassOrInterfaceType(importTypeIfRequired(
targetType, imports, typeToImport));
// Add any type arguments presented for the return type
if (typeToImport.getParameters().size() > 0) {
final List<Type> typeArgs = new ArrayList<Type>();
cit.setTypeArgs(typeArgs);
for (final JavaType parameter : typeToImport
.getParameters()) {
typeArgs.add(JavaParserUtils.importParametersForType(
targetType,
imports, parameter));
}
}
return new ReferenceType(cit);
}
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:24,代码来源:JavaParserUtils.java
示例3: getCompilationUnitContents
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
public final String getCompilationUnitContents(
final ClassOrInterfaceTypeDetails cid) {
Validate.notNull(cid, "Class or interface type details are required");
// Create a compilation unit to store the type to be created
final CompilationUnit compilationUnit = new CompilationUnit();
// NB: this import list is replaced at the end of this method by a
// sorted version
compilationUnit.setImports(new ArrayList<ImportDeclaration>());
if (!cid.getName().isDefaultPackage()) {
compilationUnit.setPackage(new PackageDeclaration(ASTHelper
.createNameExpr(cid.getName().getPackage()
.getFullyQualifiedPackageName())));
}
// Add the class of interface declaration to the compilation unit
final List<TypeDeclaration> types = new ArrayList<TypeDeclaration>();
compilationUnit.setTypes(types);
updateOutput(compilationUnit, null, cid, null);
return compilationUnit.toString();
}
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:25,代码来源:JavaParserTypeParsingService.java
示例4: getDefaultCompilationUnitServices
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
private CompilationUnitServices getDefaultCompilationUnitServices() {
return new CompilationUnitServices() {
public JavaPackage getCompilationUnitPackage() {
return compilationUnitPackage;
}
public JavaType getEnclosingTypeName() {
return name;
}
public List<ImportDeclaration> getImports() {
return imports;
}
public List<TypeDeclaration> getInnerTypes() {
return innerTypes;
}
public PhysicalTypeCategory getPhysicalTypeCategory() {
return physicalTypeCategory;
}
};
}
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:24,代码来源:JavaParserClassOrInterfaceTypeDetailsBuilder.java
示例5: getAnnotationNodes
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final Class<?> fc = ResolverUtil.getType(enclosingClass, fieldName);
final String columnType = fd.getColumnType();
if (isLob(columnType)) {
if (isValidFieldType(fc)) {
return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
} else {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " is not a valid field type for the @Lob annotation, must be one of " + VALID_TYPES_STR);
}
}
return null;
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:21,代码来源:LobResolver.java
示例6: getAnnotationNodes
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final Class<?> fc = ResolverUtil.getType(enclosingClass, fieldName);
if (isEnum(fc)) {
final Comment fixme = new BlockComment("\nFIXME:\n" +
"Enums must be annotated with the @Enumerated annotation.\n " +
"The @Enumerated annotation should set the EnumType.\n" +
"If the EnumType is not set, then the Enumerated annotation is defaulted to EnumType.ORDINAL.\n" +
"This conversion program cannot tell whether EnumType.ORDINAL is the appropriate EnumType.");
AnnotationExpr enumerated = new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("value", new NameExpr("EnumType."))));
enumerated.setComment(fixme);
return new NodeData(enumerated, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false)));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:EnumeratedResolver.java
示例7: resolve
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
if (!(node instanceof ClassOrInterfaceDeclaration)) {
throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
}
final TypeDeclaration dclr = (TypeDeclaration) node;
if (!(dclr.getParentNode() instanceof CompilationUnit)) {
//handling nested classes
return null;
}
final String name = dclr.getName();
final Collection<FieldDescriptor> primaryKeyDescriptors = getPrimaryKeyDescriptors(mappedClass);
if (primaryKeyDescriptors != null && primaryKeyDescriptors.size() > 1 && nodeContainsPkFields(dclr,
primaryKeyDescriptors)) {
final NodeAndImports<ClassOrInterfaceDeclaration> primaryKeyClass = createPrimaryKeyClass(name, primaryKeyDescriptors);
final String pkClassName = primaryKeyClass.node.getName();
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr(name + "." + pkClassName + ".class")),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), primaryKeyClass.imprts, primaryKeyClass.node);
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:IdClassResolver.java
示例8: getAnnotationNodes
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final boolean autoInc = fd.isAutoIncrement();
final String seqName = fd.getSequenceName();
if (autoInc && StringUtils.isBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to true but sequenceName is blank.");
}
if (!autoInc && StringUtils.isNotBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to false but sequenceName is " + seqName + ".");
}
if (autoInc || StringUtils.isNotBlank(seqName)) {
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? seqName.toUpperCase() : seqName)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:PortableSequenceGeneratorResolver.java
示例9: resolve
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
if (!(node instanceof ClassOrInterfaceDeclaration)) {
throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
}
final TypeDeclaration dclr = (TypeDeclaration) node;
if (!(dclr.getParentNode() instanceof CompilationUnit)) {
//handling nested classes
return null;
}
final String name = dclr.getName();
final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
final String enclosingClass = pckg + "." + name;
final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
if (cd != null) {
return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:EntityResolver.java
示例10: resolve
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
if (!(node instanceof ClassOrInterfaceDeclaration)) {
throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
}
final TypeDeclaration dclr = (TypeDeclaration) node;
if (!(dclr.getParentNode() instanceof CompilationUnit)) {
//handling nested classes
return null;
}
final String name = dclr.getName();
final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
final String enclosingClass = pckg + "." + name;
if (!enclosingClass.equals(mappedClass)) {
return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:MappedSuperClassResolver.java
示例11: getAnnotationNodes
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
/** gets the annotation but also adds an import in the process if a Convert annotation is required. */
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final CollectionDescriptor cld = OjbUtil.findCollectionDescriptor(mappedClass, fieldName, descriptorRepositories);
if (cld != null) {
Collection<FieldHelper> orderBy = cld.getOrderBy();
if (orderBy != null && !orderBy.isEmpty()) {
String orderByStr = "";
for (FieldHelper fh : orderBy) {
orderByStr += fh.name + (fh.isAscending ? "" : " DESC") + ", ";
}
orderByStr = orderByStr.replaceAll(", $", "");
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new StringLiteralExpr(orderByStr)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:OrderByResolver.java
示例12: getAnnotationNodes
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final boolean autoInc = fd.isAutoIncrement();
final String seqName = fd.getSequenceName();
if (autoInc && StringUtils.isBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to true but sequenceName is blank.");
}
if (!autoInc && StringUtils.isNotBlank(seqName)) {
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to false but sequenceName is " + seqName + ".");
}
if (autoInc || StringUtils.isNotBlank(seqName)) {
return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("generator", new StringLiteralExpr(upperCaseTableName ? seqName.toUpperCase() : seqName)))),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:GeneratedValueResolver.java
示例13: resolve
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
if (!(node instanceof ClassOrInterfaceDeclaration)) {
throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
}
final TypeDeclaration dclr = (TypeDeclaration) node;
if (!(dclr.getParentNode() instanceof CompilationUnit)) {
//handling nested classes
return null;
}
final String name = dclr.getName();
final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
final String enclosingClass = pckg + "." + name;
final Collection<String> customizedFieldsOnNode = getFieldsOnNode(dclr, getCustomizedFields(mappedClass));
if (customizedFieldsOnNode == null || customizedFieldsOnNode.isEmpty()) {
LOG.info(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " has no customized fields");
return null;
}
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("CreateCustomizerFor" + customizedFieldsOnNode.toString())),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:CustomizerResolver.java
示例14: resolve
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
if (!(node instanceof FieldDeclaration)) {
throw new IllegalArgumentException("this annotation belongs only on FieldDeclaration");
}
final FieldDeclaration field = (FieldDeclaration) node;
if (ResolverUtil.canFieldBeAnnotated(field)) {
final boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field),
descriptorRepositories);
if (!mappedColumn) {
return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:TransientResolver.java
示例15: getAnnotationNodes
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final List<Expression> joinColumns = getJoinColumns(enclosingClass, fieldName, mappedClass);
if (joinColumns != null && joinColumns.size() > 1) {
final Comment fixme = new BlockComment("\nFIXME: JPA_CONVERSION\n"
+ "For compound primary keys, make sure the join columns are in the correct order.\n");
AnnotationExpr
annotation = new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new ArrayInitializerExpr(joinColumns));
annotation.setComment(fixme);
return new NodeData(annotation,
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Arrays.asList(
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PrimaryKeyJoinColumnResolver.PACKAGE),PrimaryKeyJoinColumnResolver.SIMPLE_NAME), false, false)
, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(JoinColumnResolver.PACKAGE),JoinColumnResolver.SIMPLE_NAME), false, false)
));
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:JoinColumnsResolver.java
示例16: imported
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
private boolean imported(List<ImportDeclaration> imports, String fullyQualifiedName) {
final String packageName = ClassUtils.getPackageName(fullyQualifiedName);
for (final ImportDeclaration i : imports) {
if (!i.isStatic()) {
final String importName = i.getName().toString();
if (i.isAsterisk()) {
if (packageName.equals(importName)) {
if ( LOG.isDebugEnabled() ) {
LOG.debug("found import " + packageName + ".* on " + getTypeNameForMsg(i) + ".");
}
return true;
}
} else {
if (fullyQualifiedName.equals(importName)) {
if ( LOG.isDebugEnabled() ) {
LOG.debug("found import " + fullyQualifiedName + " on " + getTypeNameForMsg(i) + ".");
}
return true;
}
}
}
}
return false;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:AnnotationHelper.java
示例17: visit
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
@Override
public void visit(ImportDeclaration n, Object arg)
{ String name = n.getName().toString();
// s'agit-il d'une classe du jeu ?
if(name.startsWith(GAME_PACKAGE))
{ // s'agit-il d'une classe de l'API ?
if(!(name.startsWith(apiPackage) && !name.startsWith(packPackage))
// s'agit-il d'une autre classe de l'agent ?
&& !name.startsWith(agentPackage)
// s'agit-il de la classe AiMain de l'agent ?
&& !name.equals(agentClass)
// s'agit-il d'une classe du jeu autorisée ?
&& !ALLOWED_CLASSES.contains(name))
{ int line = n.getBeginLine();
printErr("Erreur ligne "+line+" : le package ou la classe importé(e) ("+name+") n'est pas autorisé(e) pour cet agent.");
errorCount++;
}
}
}
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:21,代码来源:AiVisitor.java
示例18: visit
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
public R visit(CompilationUnit n, A arg) {
if (n.getPackage() != null) {
n.getPackage().accept(this, arg);
}
if (n.getImports() != null) {
for (ImportDeclaration i : n.getImports()) {
i.accept(this, arg);
}
}
if (n.getTypes() != null) {
for (TypeDeclaration typeDeclaration : n.getTypes()) {
typeDeclaration.accept(this, arg);
}
}
return null;
}
开发者ID:rfw,项目名称:genja,代码行数:17,代码来源:GenericVisitorAdapter.java
示例19: visit
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
public void visit(CompilationUnit n, Object arg) {
if (n.getPackage() != null) {
n.getPackage().accept(this, arg);
}
if (n.getImports() != null) {
for (ImportDeclaration i : n.getImports()) {
i.accept(this, arg);
}
printer.printLn();
}
if (n.getTypes() != null) {
for (Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext();) {
i.next().accept(this, arg);
printer.printLn();
if (i.hasNext()) {
printer.printLn();
}
}
}
}
开发者ID:rfw,项目名称:genja,代码行数:21,代码来源:DumpVisitor.java
示例20: visit
import japa.parser.ast.ImportDeclaration; //导入依赖的package包/类
public Node visit(CompilationUnit n, A arg) {
if (n.getPackage() != null) {
n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg));
}
List<ImportDeclaration> imports = n.getImports();
if (imports != null) {
for (int i = 0; i < imports.size(); i++) {
imports.set(i, (ImportDeclaration) imports.get(i).accept(this, arg));
}
removeNulls(imports);
}
List<TypeDeclaration> types = n.getTypes();
if (types != null) {
for (int i = 0; i < types.size(); i++) {
types.set(i, (TypeDeclaration) types.get(i).accept(this, arg));
}
removeNulls(types);
}
return n;
}
开发者ID:rfw,项目名称:genja,代码行数:21,代码来源:ModifierVisitorAdapter.java
注:本文中的japa.parser.ast.ImportDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论