當前位置: 首頁>>代碼示例>>Java>>正文


Java JClassType.getFields方法代碼示例

本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.getFields方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.getFields方法的具體用法?Java JClassType.getFields怎麽用?Java JClassType.getFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.core.ext.typeinfo.JClassType的用法示例。


在下文中一共展示了JClassType.getFields方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processRelationClasses

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的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: composeBindMethod

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的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

示例3: getAllAnnotations

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的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

示例4: composeSyncMethod

import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
 * Generate method sync
 */
private void composeSyncMethod(TreeLogger logger, SourceWriter sourceWriter) {

	logger.log(TreeLogger.INFO, "");
	String line = "public void sync("
			+ 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);
		String type = field.getType().getQualifiedSourceName();
		String simType = field.getType().getSimpleSourceName();
		if ("java.lang.String".equals(type))
			line = " if( text.getText(\"" + name + "\") != null )obj.set" + Name
			+ "( text.getText(\"" + name + "\") );";
		else
			line = " if( text.getText(\"" + name + "\") != null )obj.set" + Name
			+ "( " + type + ".parse" + simType + "( text.getText(\"" + name
			+ "\")) );";

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

	}
	line = "}";

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

}
 
開發者ID:ICT-BDA,項目名稱:EasyML,代碼行數:51,代碼來源:TextBinderGenerator.java


注:本文中的com.google.gwt.core.ext.typeinfo.JClassType.getFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。