本文整理汇总了Java中japa.parser.ast.body.FieldDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java FieldDeclaration类的具体用法?Java FieldDeclaration怎么用?Java FieldDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldDeclaration类属于japa.parser.ast.body包,在下文中一共展示了FieldDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: nodeContainsPkFields
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
private boolean nodeContainsPkFields(TypeDeclaration dclr, Collection<FieldDescriptor> pks) {
for (FieldDescriptor pk : pks) {
boolean contains = false;
for (FieldDeclaration field : ParserUtil.getFieldMembers(dclr.getMembers())) {
if (field.getVariables().get(0).getId().getName().equals(pk.getAttributeName())) {
contains = true;
break;
}
}
if (!contains) {
return false;
}
}
return true;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:IdClassResolver.java
示例2: resolve
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
@Override
public final 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 TypeDeclaration dclr = (TypeDeclaration) node.getParentNode();
final String name = dclr.getName();
final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
final String fullyQualifiedClass = pckg + "." + name;
final boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field),
descriptorRepositories);
if (mappedColumn) {
return getAnnotationNodes(fullyQualifiedClass, ParserUtil.getFieldName(field), mappedClass);
}
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:AbstractMappedFieldResolver.java
示例3: resolve
import japa.parser.ast.body.FieldDeclaration; //导入依赖的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
示例4: getTypeOrFieldNameForMsg
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
private String getTypeOrFieldNameForMsg(final BodyDeclaration n) {
if (n instanceof TypeDeclaration) {
return ((TypeDeclaration) n).getName();
} else if (n instanceof FieldDeclaration) {
final FieldDeclaration fd = (FieldDeclaration) n;
//this wont work for nested classes but we should be in nexted classes at this point
final CompilationUnit unit = getCompilationUnit(n);
final TypeDeclaration parent = unit.getTypes().get(0);
Collection<String> variableNames = new ArrayList<String>();
if (fd.getVariables() != null) {
for (VariableDeclarator vd : fd.getVariables()) {
variableNames.add(vd.getId().getName());
}
}
return variableNames.size() == 1 ?
parent.getName() + "." + variableNames.iterator().next() :
parent.getName() + "." + variableNames.toString();
}
return null;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:AnnotationHelper.java
示例5: deconstructMultiDeclarations
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
/**
* In Java variables can be defined like the following:
* int i, j, k;
*
* When mapping fields in xml this is not a problem. However when using annotation on a field,
* Each field should be defined separately. This helper will deconstruct these fields such
* that later AST analysis will not need to account for field defined on a separate line.
*/
public static void deconstructMultiDeclarations(Collection<FieldDeclaration> fields) {
for (FieldDeclaration field : fields) {
ClassOrInterfaceDeclaration parent = (ClassOrInterfaceDeclaration) field.getParentNode();
//these are chained together
if (field.getVariables().size() > 1) {
int index = parent.getMembers().indexOf(field);
parent.getMembers().remove(index);
List<FieldDeclaration> deconstructed = new ArrayList<FieldDeclaration>();
for (VariableDeclarator v : field.getVariables()) {
FieldDeclaration f = new FieldDeclaration(field.getModifiers(), field.getAnnotations(), field.getType(), Collections.singletonList(v));
f.setJavaDoc(field.getJavaDoc());
f.setComment(field.getComment());
f.setParentNode(field.getParentNode());
deconstructed.add(f);
}
parent.getMembers().addAll(index, deconstructed);
}
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:31,代码来源:ParserUtil.java
示例6: getDeclaration
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public static FieldDeclaration getDeclaration(CompilationUnit unit, Field field) {
TypeDeclaration typeDecl = getDeclaration(unit, field.getDeclaringClass());
if (typeDecl == null) {
return null;
}
for (BodyDeclaration decl : typeDecl.getMembers()) {
if (decl instanceof FieldDeclaration) {
FieldDeclaration fieldDecl = (FieldDeclaration) decl;
List<VariableDeclarator> variables = fieldDecl.getVariables();
if (variables.size() != 1) {
continue;
}
if (field.getName().equals(variables.get(0).getId().getName())) {
return fieldDecl;
}
}
}
return null;
}
开发者ID:jedwards1211,项目名称:breakout,代码行数:20,代码来源:JavaParserUtils.java
示例7: deconstructMultiDeclarations
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
/**
* In Java variables can be defined like the following:
* int i, j, k;
*
* When mapping fields in xml this is not a problem. However when using annotation on a field,
* Each field should be defined separately. This helper will deconstruct these fields such
* that later AST analysis will not need to account for field defined on a separate line.
*/
public static void deconstructMultiDeclarations(Collection<FieldDeclaration> fields) {
for (FieldDeclaration field : fields) {
ClassOrInterfaceDeclaration parent = (ClassOrInterfaceDeclaration) field.getParentNode();
//these are chained together
if (field.getVariables().size() > 1) {
int index = parent.getMembers().indexOf(field);
parent.getMembers().remove(index);
List<FieldDeclaration> deconstructed = new ArrayList<FieldDeclaration>();
for (VariableDeclarator v : field.getVariables()) {
FieldDeclaration f = new FieldDeclaration(field.getJavaDoc(), field.getModifiers(), field.getAnnotations(), field.getType(), Collections.singletonList(v));
f.setComment(field.getComment());
f.setParentNode(field.getParentNode());
deconstructed.add(f);
}
parent.getMembers().addAll(index, deconstructed);
}
}
}
开发者ID:kuali,项目名称:rice,代码行数:30,代码来源:ParserUtil.java
示例8: getAttributesNames
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
private LinkedList<String> getAttributesNames()
{
List<TypeDeclaration> types = compUnit.getTypes();
LinkedList<String> attNames = new LinkedList<String>();
if (types != null)
{
for (TypeDeclaration type : types)
{
List<BodyDeclaration> members = type.getMembers();
if (members != null)
for (BodyDeclaration member : members)
if (member instanceof FieldDeclaration)
{
FieldDeclaration t = (FieldDeclaration) member;
List<VariableDeclarator> variables = t.getVariables();
for (VariableDeclarator v : variables)
attNames.add(v.getId().getName());
}
}
}
return attNames;
}
开发者ID:gems-uff,项目名称:oceano,代码行数:25,代码来源:NumberOfAccessorMethods.java
示例9: visit
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public Boolean visit(FieldDeclaration n1, Node arg) {
FieldDeclaration n2 = (FieldDeclaration) arg;
// javadoc are checked at CompilationUnit
if (n1.getModifiers() != n2.getModifiers()) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return Boolean.FALSE;
}
if (!nodeEquals(n1.getType(), n2.getType())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getVariables(), n2.getVariables())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
开发者ID:rfw,项目名称:genja,代码行数:24,代码来源:EqualsVisitor.java
示例10: visit
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public void visit(FieldDeclaration n, Object arg) {
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
n.getType().accept(this, arg);
printer.print(" ");
for (Iterator<VariableDeclarator> i = n.getVariables().iterator(); i.hasNext();) {
VariableDeclarator var = i.next();
var.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
printer.print(";");
}
开发者ID:rfw,项目名称:genja,代码行数:18,代码来源:DumpVisitor.java
示例11: visit
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public Node visit(FieldDeclaration n, A arg) {
if (n.getJavaDoc() != null) {
n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
}
List<AnnotationExpr> annotations = n.getAnnotations();
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
}
removeNulls(annotations);
}
n.setType((Type) n.getType().accept(this, arg));
List<VariableDeclarator> variables = n.getVariables();
for (int i = 0; i < variables.size(); i++) {
variables.set(i, (VariableDeclarator) variables.get(i).accept(this, arg));
}
removeNulls(variables);
return n;
}
开发者ID:rfw,项目名称:genja,代码行数:20,代码来源:ModifierVisitorAdapter.java
示例12: changeMethods
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
private static void changeMethods(CompilationUnit cu, String rootClass) {
addImport(cu, rootClass);
String rootClassShort = rootClass
.substring(rootClass.lastIndexOf(".") + 1);
List<TypeDeclaration> types = cu.getTypes();
for (TypeDeclaration type : types) {
List<BodyDeclaration> members = type.getMembers();
for (BodyDeclaration member : members) {
if (member instanceof MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration) member;
if (isSetRootComponentMethod(method)) {
changeSetRootMethod(method, rootClassShort);
}
} else if (member instanceof FieldDeclaration) {
FieldDeclaration field = (FieldDeclaration) member;
if (isRootField(field)) {
changeRootField(field, rootClassShort);
}
}
}
}
}
开发者ID:ahn,项目名称:mideaas,代码行数:24,代码来源:JavaUtil.java
示例13: getField
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
private FieldDeclaration getField(String name) {
List<BodyDeclaration> members = getType().getMembers();
if (members==null) {
return null;
}
for (BodyDeclaration f : members) {
if (f instanceof FieldDeclaration) {
for (VariableDeclarator v : ((FieldDeclaration)f).getVariables()) {
if (name.equals(v.getId().getName())) {
return (FieldDeclaration) f;
}
}
}
}
return null;
}
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:ControllerCode.java
示例14: ensureClaraFieldExists
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public int[] ensureClaraFieldExists(String id, String className) {
List<TypeDeclaration> types = cu.getTypes();
for (TypeDeclaration type : types) {
List<BodyDeclaration> members = type.getMembers();
if (members==null) {
break;
}
for (BodyDeclaration member : members) {
if (member instanceof FieldDeclaration) {
FieldDeclaration field = (FieldDeclaration) member;
if (isClaraField(field, id, className)) {
return getMemberRowCol(field);
}
}
}
}
FieldDeclaration fd = addClaraField(id, className);
reparse();
String name = fd.getVariables().get(0).getId().getName();
int[] hmm = getFieldRowCol(name);
return hmm;
}
开发者ID:ahn,项目名称:mideaas,代码行数:27,代码来源:ControllerCode.java
示例15: isClaraField
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
private static boolean isClaraField(FieldDeclaration field, String id,
String className) {
if (field.getAnnotations()==null) {
return false;
}
for (AnnotationExpr ann : field.getAnnotations()) {
if ("UiField".equals(ann.getName().getName())) {
if (ann instanceof SingleMemberAnnotationExpr) {
SingleMemberAnnotationExpr smae = (SingleMemberAnnotationExpr)ann;
if (smae.getMemberValue() instanceof StringLiteralExpr) {
String v = ((StringLiteralExpr)smae.getMemberValue()).getValue();
if (id.equals(v)) {
return true;
}
}
}
}
}
return false;
}
开发者ID:ahn,项目名称:mideaas,代码行数:21,代码来源:ControllerCode.java
示例16: resolveType
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public static JClass resolveType(JClassContainer _package, String typeDefinition) {
try {
FieldDeclaration fieldDeclaration = (FieldDeclaration) JavaParser.parseBodyDeclaration(typeDefinition + " foo;");
ClassOrInterfaceType c = (ClassOrInterfaceType) ((ReferenceType) fieldDeclaration.getType()).getType();
return buildClass(_package, c, 0);
} catch (ParseException e) {
throw new GenerationException(e);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:TypeUtil.java
示例17: findFieldDeclaration
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public static FieldDeclaration findFieldDeclaration(String aFieldName, ClassOrInterfaceDeclaration aType) {
if (aType.getMembers() != null) {
for (BodyDeclaration theBody : aType.getMembers()) {
if (theBody instanceof FieldDeclaration) {
FieldDeclaration theField = (FieldDeclaration) theBody;
for (VariableDeclarator theDeclaration : theField.getVariables()) {
if (aFieldName.equals(theDeclaration.getId().getName())) {
return theField;
}
}
}
}
}
return null;
}
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:16,代码来源:OpenXavaASTHelper.java
示例18: getInstance
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public static JavaParserFieldMetadataBuilder getInstance(
final String declaredByMetadataId,
final FieldDeclaration fieldDeclaration,
final VariableDeclarator var,
final CompilationUnitServices compilationUnitServices,
final Set<JavaSymbolName> typeParameters) {
return new JavaParserFieldMetadataBuilder(declaredByMetadataId,
fieldDeclaration, var, compilationUnitServices, typeParameters);
}
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:10,代码来源:JavaParserFieldMetadataBuilder.java
示例19: removeField
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
public static void removeField(
final CompilationUnitServices compilationUnitServices,
final List<BodyDeclaration> members, final JavaSymbolName fieldName) {
Validate.notNull(compilationUnitServices,
"Flushable compilation unit services required");
Validate.notNull(members, "Members required");
Validate.notNull(fieldName, "Field name to remove is required");
// Locate the field
int i = -1;
int toDelete = -1;
for (final BodyDeclaration bd : members) {
i++;
if (bd instanceof FieldDeclaration) {
final FieldDeclaration fieldDeclaration = (FieldDeclaration) bd;
for (final VariableDeclarator var : fieldDeclaration
.getVariables()) {
if (var.getId().getName().equals(fieldName.getSymbolName())) {
toDelete = i;
break;
}
}
}
}
Validate.isTrue(toDelete > -1, "Could not locate field '%s' to delete",
fieldName);
// Do removal outside iteration of body declaration members, to avoid
// concurrent modification exceptions
members.remove(toDelete);
}
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:33,代码来源:JavaParserFieldMetadataBuilder.java
示例20: getFieldsOnNode
import japa.parser.ast.body.FieldDeclaration; //导入依赖的package包/类
private Collection<String> getFieldsOnNode(TypeDeclaration node, Collection<String> fields) {
final Collection<String> fieldsOnNode = new ArrayList<String>();
final Collection<FieldDeclaration> fds = ParserUtil.getFieldMembers(node.getMembers());
if (fields != null) {
for (FieldDeclaration f : fds) {
final String name = ParserUtil.getFieldName(f);
if (fields.contains(name)) {
fieldsOnNode.add(name);
}
}
}
return fieldsOnNode;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:CustomizerResolver.java
注:本文中的japa.parser.ast.body.FieldDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论