本文整理匯總了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?
}
}
示例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);
}
示例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;
}
示例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);
}