• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FieldDeclaration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.mirror.declaration.FieldDeclaration的典型用法代码示例。如果您正苦于以下问题:Java FieldDeclaration类的具体用法?Java FieldDeclaration怎么用?Java FieldDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FieldDeclaration类属于com.sun.mirror.declaration包,在下文中一共展示了FieldDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getSchemaGenerator

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
private synchronized XmlSchemaGenerator<TypeMirror, TypeDeclaration, FieldDeclaration, MethodDeclaration> getSchemaGenerator() {
    if(xsdgen==null) {
        xsdgen = new XmlSchemaGenerator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>( types.getNavigator(), types );

        for (Map.Entry<QName, Reference> e : additionalElementDecls.entrySet()) {
            Reference value = e.getValue();
            if(value!=null) {
                NonElement<TypeMirror, TypeDeclaration> typeInfo = refMap.get(value);
                if(typeInfo==null)
                    throw new IllegalArgumentException(e.getValue()+" was not specified to JavaCompiler.bind");
                xsdgen.add(e.getKey(),!(value.type instanceof PrimitiveType),typeInfo);
            } else {
                xsdgen.add(e.getKey(),false,null);
            }
        }
    }
    return xsdgen;
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:19,代码来源:JAXBModelImpl.java


示例2: testFieldModifiers

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
private boolean testFieldModifiers(FieldDeclaration fieldDeclaration) {
    Collection<Modifier> modifiers = fieldDeclaration.getModifiers();

    // must not worry for private/protected. cannot be accessed from outside.
    if (modifiers.contains(Modifier.PROTECTED) || modifiers.contains(Modifier.PRIVATE))
        return true;

    // no public/package access without getters/setters for non final fields
    if (!fieldDeclaration.getModifiers().contains(Modifier.FINAL) &&
        !checkGettersSetters(fieldDeclaration.getSimpleName())) {
        reportWarning(fieldDeclaration, "The class declares the  " +
            (modifiers.contains(Modifier.PUBLIC) ? "public" : "package") + " field " +
            fieldDeclaration.getSimpleName() + ".\n" + ErrorMessages.NO_GETTERS_SETTERS_ERROR_MESSAGE);
        return false;
    }

    return true;
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:19,代码来源:ActiveObjectVisitorAPT.java


示例3: validateField

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
private static void validateField(FieldDeclaration field) {
	// Check if field is "public static final"
	Collection<Modifier> modifiers = field.getModifiers();
	if ( modifiers.size() != 3
	     || !modifiers.contains(Modifier.PUBLIC)
	     || !modifiers.contains(Modifier.STATIC)
	     || !modifiers.contains(Modifier.FINAL) ) {
		throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
	}

	// Check suported types (int, long, float, String)
	TypeMirror field_type = field.getType();
	if ( field_type instanceof PrimitiveType ) {
		PrimitiveType field_type_prim = (PrimitiveType)field_type;
		PrimitiveType.Kind field_kind = field_type_prim.getKind();
		if ( field_kind != PrimitiveType.Kind.INT
		     && field_kind != PrimitiveType.Kind.LONG
		     && field_kind != PrimitiveType.Kind.FLOAT
		     && field_kind != PrimitiveType.Kind.BYTE ) {
			throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long' or 'float'");
		}
	} else if ( "java.lang.String".equals(field_type.toString()) ) {
	} else {
		throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type or String");
	}

	Object field_value = field.getConstantValue();
	if ( field_value == null ) {
		throw new RuntimeException("Field " + field.getSimpleName() + " has no initial value");
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:FieldsGenerator.java


示例4: generateField

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
private static void generateField(PrintWriter writer, FieldDeclaration field, FieldDeclaration prev_field) {
	validateField(field);

	Object value = field.getConstantValue();
	String field_value_string;
	Class field_value_class = value.getClass();
	if ( field_value_class.equals(Integer.class) ) {
		field_value_string = "0x" + Integer.toHexString((Integer)field.getConstantValue()).toUpperCase();
	} else if ( field_value_class.equals(Long.class) ) {
		field_value_string = "0x" + Long.toHexString((Long)field.getConstantValue()).toUpperCase() + 'L';
	} else if ( field_value_class.equals(Float.class) ) {
		field_value_string = field.getConstantValue() + "f";
	} else if ( value.getClass().equals(Byte.class) ) {
		field_value_string = "0x" + Integer.toHexString((Byte)field.getConstantValue()).toUpperCase();
	} else if ( field_value_class.equals(String.class) ) {
		field_value_string = "\"" + field.getConstantValue() + "\"";
	} else {
		throw new RuntimeException("Field is of unexpected type. This means there is a bug in validateField().");
	}

	boolean hadDoc = prev_field != null && prev_field.getDocComment() != null;
	boolean hasDoc = field.getDocComment() != null;
	boolean newBatch = prev_field == null || !prev_field.getType().equals(field.getType()) || (!hadDoc && field.getDocComment() != null) || (hadDoc && hasDoc && !prev_field.getDocComment().equals(field.getDocComment()));

	// Print field declaration
	if ( newBatch ) {
		if ( prev_field != null )
			writer.println(";\n");

		Utils.printDocComment(writer, field);
		writer.print("\tpublic static final " + field.getType().toString() + " " + field.getSimpleName() + " = " + field_value_string);
	} else
		writer.print(",\n\t\t" + field.getSimpleName() + " = " + field_value_string);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:FieldsGenerator.java


示例5: generateFields

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public static void generateFields(PrintWriter writer, Collection<FieldDeclaration> fields) {
	if ( 0 < fields.size() ) {
		writer.println();
		FieldDeclaration prev_field = null;
		for ( FieldDeclaration field : fields ) {
			generateField(writer, field, prev_field);
			prev_field = field;
		}
		writer.println(";");
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:FieldsGenerator.java


示例6: bind

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public J2SJAXBModel bind(
    Collection<Reference> rootClasses,
    Map<QName,Reference> additionalElementDecls,
    String defaultNamespaceRemap,
    AnnotationProcessorEnvironment env) {

    ModelBuilder<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration> builder =
        new ModelBuilder<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>(
            InlineAnnotationReaderImpl.theInstance,
            new APTNavigator(env),
            Collections.<TypeDeclaration,TypeDeclaration>emptyMap(),
            defaultNamespaceRemap );

    builder.setErrorHandler(new ErrorHandlerImpl(env.getMessager()));

    for( Reference ref : rootClasses ) {
        TypeMirror t = ref.type;

        XmlJavaTypeAdapter xjta = ref.annotations.getAnnotation(XmlJavaTypeAdapter.class);
        XmlList xl = ref.annotations.getAnnotation(XmlList.class);

        builder.getTypeInfo(new Ref<TypeMirror,TypeDeclaration>(builder,t,xjta,xl));
    }

    TypeInfoSet r = builder.link();
    if(r==null)     return null;

    if(additionalElementDecls==null)
        additionalElementDecls = Collections.emptyMap();
    else {
        // fool proof check
        for (Map.Entry<QName, ? extends Reference> e : additionalElementDecls.entrySet()) {
            if(e.getKey()==null)
                throw new IllegalArgumentException("nulls in additionalElementDecls");
        }
    }
    return new JAXBModelImpl(r,builder.reader,rootClasses,new HashMap(additionalElementDecls));
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:39,代码来源:JavaCompilerImpl.java


示例7: getDeclaredField

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public FieldDeclaration getDeclaredField(TypeDeclaration clazz, String fieldName) {
    for( FieldDeclaration fd : clazz.getFields() ) {
        if(fd.getSimpleName().equals(fieldName))
            return fd;
    }
    return null;
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:8,代码来源:APTNavigator.java


示例8: visitClassDeclaration

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
@Override
public void visitClassDeclaration(ClassDeclaration classDeclaration) {

    _containingClass = classDeclaration;
    _containingClassMethods = classDeclaration.getMethods();

    testClassModifiers(classDeclaration);

    ConstructorCheckResult ccr = verifyConstructors(classDeclaration);

    if (!ccr.hasNoArgConstructor) {
        reportError(classDeclaration, ErrorMessages.NO_NOARG_CONSTRUCTOR_ERROR_MESSAGE);
    }

    if (ccr.isFinalNoArgConstructor) {
        reportError(classDeclaration, ErrorMessages.NO_NOARG_CONSTRUCTOR_CANNOT_BE_PRIVATE_MESSAGE);
    }

    //		if (!implementsSerializable(classDeclaration)) {
    //			reportWarning(classDeclaration, ErrorMessages.NO_SERIALIZABLE_ERROR_MESSAGE);
    //		}

    // super.visitClassDeclaration(classDeclaration);
    // visit the subcomponents of this class
    // this should have been already provided by the MirrorAPI. bad API, bad! :P
    final Collection<MethodDeclaration> methods = _containingClassMethods;
    for (MethodDeclaration methodDeclaration : methods) {
        methodDeclaration.accept(this);
    }

    final Collection<FieldDeclaration> fields = classDeclaration.getFields();
    for (FieldDeclaration fieldDeclaration : fields) {
        fieldDeclaration.accept(this);
    }

}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:37,代码来源:ActiveObjectVisitorAPT.java


示例9: applicableOnDeclaration

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public static boolean applicableOnDeclaration(ElementType applicableType, Declaration typeDeclaration) {

        if (typeDeclaration instanceof ClassDeclaration)
            return applicableType.equals(ElementType.TYPE);
        if (typeDeclaration instanceof MethodDeclaration)
            return applicableType.equals(ElementType.METHOD);
        if (typeDeclaration instanceof FieldDeclaration)
            return applicableType.equals(ElementType.FIELD);
        if (typeDeclaration instanceof ConstructorDeclaration)
            return applicableType.equals(ElementType.CONSTRUCTOR);
        // TODO add others when needed

        return false;
    }
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:15,代码来源:UtilsAPT.java


示例10: visitFieldDeclaration

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public void visitFieldDeclaration(FieldDeclaration d) {
	// no-op		
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:4,代码来源:SPClassVisitor.java


示例11: visitFieldDeclaration

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public void visitFieldDeclaration (FieldDeclaration fieldDeclaration)
{
}
 
开发者ID:coconut2015,项目名称:cookcc,代码行数:4,代码来源:ClassVisitor.java


示例12: JAXBModelImpl

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public JAXBModelImpl(TypeInfoSet<TypeMirror, TypeDeclaration, FieldDeclaration, MethodDeclaration> types,
                     AnnotationReader<TypeMirror, TypeDeclaration, FieldDeclaration, MethodDeclaration> reader,
                     Collection<Reference> rootClasses,
                     Map<QName, Reference> additionalElementDecls) {
    this.types = types;
    this.reader = reader;
    this.additionalElementDecls = additionalElementDecls;

    Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration> navigator = types.getNavigator();

    for( ClassInfo<TypeMirror,TypeDeclaration> i : types.beans().values() ) {
        classList.add(i.getName());
    }

    for(ArrayInfo<TypeMirror,TypeDeclaration> a : types.arrays().values()) {
        String javaName = navigator.getTypeName(a.getType());
        classList.add(javaName);
    }

    for( EnumLeafInfo<TypeMirror,TypeDeclaration> l : types.enums().values() ) {
        QName tn = l.getTypeName();
        if(tn!=null) {
            String javaName = navigator.getTypeName(l.getType());
            classList.add(javaName);
        }
    }

    for (Reference ref : rootClasses)
        refMap.put(ref,getXmlType(ref));

    // check for collision between "additional" ones and the ones given to JAXB
    // and eliminate duplication
    Iterator<Map.Entry<QName, Reference>> itr = additionalElementDecls.entrySet().iterator();
    while(itr.hasNext()) {
        Map.Entry<QName, Reference> entry = itr.next();
        if(entry.getValue()==null)      continue;

        NonElement<TypeMirror,TypeDeclaration> xt = getXmlType(entry.getValue());

        assert xt!=null;
        refMap.put(entry.getValue(),xt);
        if(xt instanceof ClassInfo) {
            ClassInfo<TypeMirror,TypeDeclaration> xct = (ClassInfo<TypeMirror,TypeDeclaration>) xt;
            Element<TypeMirror,TypeDeclaration> elem = xct.asElement();
            if(elem!=null && elem.getElementName().equals(entry.getKey())) {
                itr.remove();
                continue;
            }
        }
        ElementInfo<TypeMirror,TypeDeclaration> ei = types.getElementInfo(null,entry.getKey());
        if(ei!=null && ei.getContentType()==xt)
            itr.remove();
    }
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:55,代码来源:JAXBModelImpl.java


示例13: getDeclaredFields

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public Collection<FieldDeclaration> getDeclaredFields(TypeDeclaration c) {
    List<FieldDeclaration> l = new ArrayList<FieldDeclaration>(c.getFields());
    return sort(l);
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:5,代码来源:APTNavigator.java


示例14: getDeclaringClassForField

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public ClassDeclaration getDeclaringClassForField(FieldDeclaration f) {
    return (ClassDeclaration)f.getDeclaringType();
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:4,代码来源:APTNavigator.java


示例15: getFieldType

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public TypeMirror getFieldType(FieldDeclaration f) {
    return f.getType();
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:4,代码来源:APTNavigator.java


示例16: getFieldName

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public String getFieldName(FieldDeclaration f) {
    return f.getSimpleName();
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:4,代码来源:APTNavigator.java


示例17: getEnumConstants

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public FieldDeclaration[] getEnumConstants(TypeDeclaration clazz) {
    EnumDeclaration ed = (EnumDeclaration) clazz;
    Collection<EnumConstantDeclaration> constants = ed.getEnumConstants();
    return constants.toArray(new EnumConstantDeclaration[constants.size()]);
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:6,代码来源:APTNavigator.java


示例18: isTransient

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public boolean isTransient(FieldDeclaration f) {
    return f.getModifiers().contains(Modifier.TRANSIENT);
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:4,代码来源:APTNavigator.java


示例19: getFieldLocation

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public Location getFieldLocation(FieldDeclaration decl) {
    return getLocation(decl);
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:4,代码来源:APTNavigator.java


示例20: isStaticField

import com.sun.mirror.declaration.FieldDeclaration; //导入依赖的package包/类
public boolean isStaticField(FieldDeclaration f) {
    return hasModifier(f,Modifier.STATIC);
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:4,代码来源:APTNavigator.java



注:本文中的com.sun.mirror.declaration.FieldDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Earth类代码示例发布时间:2022-05-22
下一篇:
Java ReadWriteTransaction类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap