当前位置: 首页>>代码示例>>Java>>正文


Java JField类代码示例

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


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

示例1: processRelationClasses

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
private void processRelationClasses(List<JClassType> types, JClassType classType){
	if (classType.getSuperclass() != null){
		processRelationClasses(types, classType.getSuperclass());
		addClassIfNotExists(types, classType.getSuperclass());
	}
	
	for (JClassType type : classType.getImplementedInterfaces()){
		addClassIfNotExists(types, type);
	}
	
	for (JField field : classType.getFields()) {
		addClassIfNotExists(types, field.getType().isClassOrInterface());
	}
	
	for (JMethod method : classType.getMethods()){
		if (method.getReturnType() != null)
			addClassIfNotExists(types, method.getReturnType().isClassOrInterface());
		
		//TODO How about parameters?
	}
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:SourceVisitor.java

示例2: getAnnotation

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
private Annotation getAnnotation(final PropertyDescriptor ppropertyDescription,
    final boolean useField, final Class<? extends Annotation> expectedAnnotationClass) {
  Annotation annotation = null;
  if (useField) {
    final JField field = this.beanType.findField(ppropertyDescription.getPropertyName());
    if (field.getEnclosingType().equals(this.beanType)) {
      annotation = field.getAnnotation(expectedAnnotationClass);
    }
  } else {
    final JMethod method = this.beanType.findMethod(asGetter(ppropertyDescription), NO_ARGS);
    if (method.getEnclosingType().equals(this.beanType)) {
      annotation = method.getAnnotation(expectedAnnotationClass);
    }
  }
  return annotation;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:17,代码来源:GwtSpecificValidatorCreator.java

示例3: writeFieldWrapperMethod

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
private void writeFieldWrapperMethod(final SourceWriter sw, final JField field) {
  this.writeUnsafeNativeLongIfNeeded(sw, field.getType());

  // private native fieldType _fieldName(com.example.Bean object) /*-{
  sw.print("private native ");

  sw.print(field.getType().getQualifiedSourceName());
  sw.print(" ");
  sw.print(this.toWrapperName(field));
  sw.print("(");
  sw.print(field.getEnclosingType().getQualifiedSourceName());
  sw.println(" object) /*-{");
  sw.indent();

  // return [email protected]::myMethod();
  sw.print("return [email protected]");
  sw.print(field.getEnclosingType().getQualifiedSourceName());
  sw.print("::" + field.getName());
  sw.println(";");

  // }-*/;
  sw.outdent();
  sw.println("}-*/;");
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:25,代码来源:GwtSpecificValidatorCreator.java

示例4: getElementType

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
JType getElementType(final PropertyDescriptor ppropertyDescriptor, final boolean puseField) {
  if (puseField) {
    final JField field =
        this.findRecursiveField(this.jclass, ppropertyDescriptor.getPropertyName());
    if (field == null) {
      return null;
    }
    return field.getType();
  } else {
    final JMethod method = this.findRecursiveMethod(this.jclass,
        GwtSpecificValidatorCreator.asGetter(ppropertyDescriptor),
        GwtSpecificValidatorCreator.NO_ARGS);
    if (method == null) {
      return null;
    }
    return method.getReturnType();
  }
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:19,代码来源:BeanHelper.java

示例5: getFieldModifier

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
private String getFieldModifier( JField field )
{
	ModifierBuilder mb = new ModifierBuilder();
	if( field.isPrivate() )
		mb.append( "2" );//"java.lang.reflect.Modifier.PRIVATE" );
	if( field.isProtected() )
		mb.append( "4" );//"java.lang.reflect.Modifier.PROTECTED" );
	if( field.isPublic() )
		mb.append( "1" );//"java.lang.reflect.Modifier.PUBLIC" );

	if( field.isStatic() )
		mb.append( "8" );//"java.lang.reflect.Modifier.STATIC" );
	if( field.isTransient() )
		mb.append( "128" );//"java.lang.reflect.Modifier.TRANSIENT" );
	if( field.isVolatile() )
		mb.append( "64" );//"java.lang.reflect.Modifier.VOLATILE" );
	if( field.isFinal() )
		mb.append( "16" );//"java.lang.reflect.Modifier.FINAL" );

	return mb.toString();
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:22,代码来源:ClazzInfoBuilder.java

示例6: InitializeFormCreator

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
public InitializeFormCreator(JField modelField) {
	this.modelField = modelField;
	this.fieldType = modelField.getType();

	Initialize initializeAnnotation = modelField.getAnnotation(Initialize.class);
	this.constantClassName = initializeAnnotation.constantsClass();
	if (ConstantsWithLookup.class.equals(this.constantClassName)) {
		this.constantClassName = null;
	}
	if (this.fieldType instanceof JParameterizedType) {
		JParameterizedType paramType = (JParameterizedType) this.fieldType;
		this.beanType = paramType.getTypeArgs()[0];
	} else {
		throw new RuntimeException("modelField can not be injected as Model");
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:17,代码来源:InitializeFormCreator.java

示例7: InjectServiceCreator

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
public InjectServiceCreator(JType viewType, JField serviceField) {
	this.viewType = viewType;
	this.serviceField = serviceField;

	this.serviceName = serviceField.getType().getQualifiedSourceName();

	Class fieldClass;
	try {
		fieldClass = this.getClass().getClassLoader().loadClass(serviceField.getType().getQualifiedBinaryName());
		if (ServiceProxy.class.isAssignableFrom(fieldClass)) {
			this.declareProxy = false;
			this.proxyTypeName = serviceField.getType().getQualifiedSourceName();
		} else {
			this.proxyTypeName = "_" + serviceField.getName() + "ServiceProxy";
		}
	} catch (ClassNotFoundException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:20,代码来源:InjectServiceCreator.java

示例8: listFields

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
public static Collection<JField> listFields(JClassType type, Class<? extends Annotation> annotationClass) {
	Collection<JField> methodAnnoted = Lists.newArrayList();
	JField[] fields = type.getFields();
	for (JField field : fields) {
		Annotation annotation = field.getAnnotation(annotationClass);
		if (annotation != null) {
			methodAnnoted.add(field);
		}
	}
	// Recurse to superclass
	JClassType superclass = type.getSuperclass();
	if (superclass != null) {
		methodAnnoted.addAll(InjectCreatorUtil.listFields(superclass, annotationClass));
	}

	return methodAnnoted;
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:18,代码来源:InjectCreatorUtil.java

示例9: createSingleImport

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
private void createSingleImport(XMLElement elem, JClassType enclosingType,
    String rawFieldName, String constantName)
    throws UnableToCompleteException {
  JField field = enclosingType.findField(constantName);
  if (field == null) {
    writer.die(elem, "Unable to locate a field named %s in %s", constantName,
        enclosingType.getQualifiedSourceName());
  } else if (!field.isStatic()) {
    writer.die(elem, "Field %s in type %s is not static", constantName,
        enclosingType.getQualifiedSourceName());
  }

  JType importType = field.getType();
  JClassType fieldType;
  if (importType instanceof JPrimitiveType) {
    fieldType = oracle.findType(((JPrimitiveType) importType).getQualifiedBoxedSourceName());
  } else {
    fieldType = (JClassType) importType;
  }

  FieldWriter fieldWriter = fieldManager.registerField(fieldType,
      constantName);
  fieldWriter.setInitializer(rawFieldName);
}
 
开发者ID:ahome-it,项目名称:ahome-core,代码行数:25,代码来源:UiBinderParser.java

示例10: isFieldAutoDetected

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
private static boolean isFieldAutoDetected( RebindConfiguration configuration, PropertyAccessors propertyAccessors, BeanInfo info ) {
    if ( !propertyAccessors.getField().isPresent() ) {
        return false;
    }

    for ( Class<? extends Annotation> annotation : AUTO_DISCOVERY_ANNOTATIONS ) {
        if ( propertyAccessors.isAnnotationPresentOnField( annotation ) ) {
            return true;
        }
    }

    JField field = propertyAccessors.getField().get();

    JsonAutoDetect.Visibility visibility = info.getFieldVisibility();
    if ( Visibility.DEFAULT == visibility ) {
        visibility = configuration.getDefaultFieldVisibility();
    }
    return isAutoDetected( visibility, field.isPrivate(), field.isProtected(), field.isPublic(), field
            .isDefaultAccess() );
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:21,代码来源:PropertyProcessor.java

示例11: parseFields

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
private static void parseFields( TreeLogger logger, JClassType type, Map<String, PropertyAccessorsBuilder> propertiesMap,
                                 boolean mixin ) {
    if ( type.getQualifiedSourceName().equals( "java.lang.Object" ) ) {
        return;
    }

    for ( JField field : type.getFields() ) {
        if ( field.isStatic() ) {
            continue;
        }

        String fieldName = field.getName();
        PropertyAccessorsBuilder property = propertiesMap.get( fieldName );
        if ( null == property ) {
            property = new PropertyAccessorsBuilder( fieldName );
            propertiesMap.put( fieldName, property );
        }
        if ( property.getField().isPresent() && !mixin ) {
            // we found an other field with the same name on a superclass. we ignore it
            logger.log( Type.INFO, "A field with the same name as '" + field
                    .getName() + "' has already been found on child class" );
        } else {
            property.addField( field, mixin );
        }
    }
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:27,代码来源:PropertyParser.java

示例12: FieldAccessor

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
/**
 * <p>Constructor for FieldAccessor.</p>
 *
 * @param propertyName a {@link java.lang.String} object.
 * @param samePackage a boolean.
 * @param fieldAutoDetect a boolean.
 * @param fieldAutoDetect a boolean.
 * @param field a {@link com.google.gwt.thirdparty.guava.common.base.Optional} object.
 * @param methodAutoDetect a boolean.
 * @param methodAutoDetect a boolean.
 * @param method a {@link com.google.gwt.thirdparty.guava.common.base.Optional} object.
 */
protected FieldAccessor( String propertyName, boolean samePackage, boolean fieldAutoDetect, Optional<JField> field,
                         boolean methodAutoDetect, Optional<JMethod> method ) {
    Preconditions.checkNotNull( propertyName );
    Preconditions.checkArgument( field.isPresent() || method.isPresent(), "At least one of the field or method must be given" );

    this.propertyName = propertyName;
    this.samePackage = samePackage;
    this.field = field;
    this.method = method;

    // We first test if we can use the method
    if ( method.isPresent() && (methodAutoDetect || !fieldAutoDetect || !field.isPresent()) ) {
        useMethod = true;
    }
    // else use the field
    else {
        useMethod = false;
    }
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:32,代码来源:FieldAccessor.java

示例13: composeBindMethod

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
/**
 * Generate method bind
 */
private void composeBindMethod(TreeLogger logger, SourceWriter sourceWriter) {

	logger.log(TreeLogger.INFO, "");
	String line = "public void bind("
			+ parameterizedType1.getQualifiedSourceName() + " text, "
			+ parameterizedType2.getQualifiedSourceName() + " obj){";
	sourceWriter.println(line);
	logger.log(TreeLogger.INFO, line);

	line = "  System.out.println(\"Implement it now:)\");";
	sourceWriter.println(line);
	logger.log(TreeLogger.INFO, line);

	ArrayList<JField> fields = new ArrayList<JField>();

	JClassType curtype = parameterizedType2;
	do {

		for (JField filed : curtype.getFields()) {
			fields.add(filed);
		}
		curtype = curtype.getSuperclass();
	} while (!curtype.getName().equals("Object"));

	for (JField field : fields) {
		String name = field.getName();
		String Name = name.substring(0, 1).toUpperCase() + name.substring(1);
		line = " text.setText(\"" + name + "\", obj.get" + Name
				+ "().toString() );";
		sourceWriter.println(line);
		logger.log(TreeLogger.INFO, line);

	}
	line = "}";

	sourceWriter.println(line);
	logger.log(TreeLogger.INFO, line);

}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:43,代码来源:TextBinderGenerator.java

示例14: findField

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
/**
 * Find a field, if not found in current classtype, then search it in supper classs
 * @param classType
 * @param fieldName
 * @return
 */
public static JField findField(JClassType classType, String fieldName){
  JField result = null;
   JClassType parent = classType;
   while (parent != null){
     result = parent.findField(fieldName);
     if (result != null)
       return result;
     
     parent = parent.getSuperclass();
   }
   
   return null;
 }
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:GenUtils.java

示例15: getAllAnnotations

import com.google.gwt.core.ext.typeinfo.JField; //导入依赖的package包/类
/**
 * Get All annotations from classType
 * NOTE: This is ordered by ParentClass to DevidedClass
 * The parentclass's annotation comes first
 * @param <T>
 * @param classType
 * @param annotationClass
 * @return
 */
public static <T extends Annotation> Map<Object, T> getAllAnnotations(JClassType classType, Class<T> annotationClass){
	Map<Object, T> results = new HashMap<Object, T>();
	
	JClassType parent = classType.getSuperclass();
	if (parent != null){
		results.putAll(getAllAnnotations(parent, annotationClass));
	}
	
	T a = classType.getAnnotation(annotationClass);
	if (a != null){
		results.put(classType, a);
	}
	
	for (JField field : classType.getFields()){
		a = field.getAnnotation(annotationClass);
		if (a != null)
			results.put(field, a);
	}
	
	for (JMethod method : classType.getMethods()){
		a = method.getAnnotation(annotationClass);
		if (a != null)
			results.put(method, a);
	}

	return results;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:37,代码来源:GenUtils.java


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