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


Java DefaultType类代码示例

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


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

示例1: extract

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This is used to scan all the fields of the class in order to
 * determine if it should have a default annotation. If the field
 * should have a default XML annotation then it is added to the
 * list of contacts to be used to form the class schema.
 * 
 * @param detail this is the detail to have its fields scanned
 * @param access this is the default access type for the class
 */
private void extract(Detail detail, DefaultType access) throws Exception {
   List<FieldDetail> fields = detail.getFields();
   
   if(access == FIELD) {
      for(FieldDetail entry : fields) {
         Annotation[] list = entry.getAnnotations();
         Field field = entry.getField();
         Class real = field.getType();
         
         if(!isStatic(field) && !isTransient(field)) {
            process(field, real, list);
         }
      }   
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:25,代码来源:FieldScanner.java

示例2: extract

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This is used to scan all the methods of the class in order to
 * determine if it should have a default annotation. If the method
 * should have a default XML annotation then it is added to the
 * list of contacts to be used to form the class schema.
 * 
 * @param detail this is the detail to have its methods scanned
 * @param access this is the default access type for the class
 */
private void extract(Detail detail, DefaultType access) throws Exception {
   List<MethodDetail> methods = detail.getMethods();

   if(access == PROPERTY) {
      for(MethodDetail entry : methods) {
         Annotation[] list = entry.getAnnotations();
         Method method = entry.getMethod();
         Class value = factory.getType(method);
         
         if(value != null) {
            process(method, list);
         }
      }  
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:25,代码来源:MethodScanner.java

示例3: DetailScanner

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * Constructor for the <code>DetailScanner</code> object. This is
 * used to create a detail object from a type. All of the methods
 * fields and annotations are extracted so that they can be used
 * many times over without the need to process them again.
 * 
 * @param type this is the type to scan for various details
 * @param override this is the override used for this detail
 */
public DetailScanner(Class type, DefaultType override) {
   this.methods = new LinkedList<MethodDetail>();
   this.fields = new LinkedList<FieldDetail>();
   this.labels = type.getDeclaredAnnotations();
   this.override = override;
   this.strict = true;
   this.type = type;
   this.scan(type);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:19,代码来源:DetailScanner.java

示例4: scan

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This method is used to scan the class hierarchy for each class
 * in order to extract fields that contain XML annotations. If
 * the field is annotated it is converted to a contact so that
 * it can be used during serialization and deserialization.
 * 
 * @param detail this contains the details for the class scanned
 */
private void scan(Detail detail) throws Exception {
   DefaultType override = detail.getOverride();
   DefaultType access = detail.getAccess();
   Class base = detail.getSuper();
   
   if(base != null) {
      extend(base, override);
   }
   extract(detail, access);
   extract(detail);
   build();
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:21,代码来源:FieldScanner.java

示例5: scan

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This method is used to scan the class hierarchy for each class
 * in order to extract methods that contain XML annotations. If
 * a method is annotated it is converted to a contact so that
 * it can be used during serialization and deserialization.
 * 
 * @param detail this contains the details for the class scanned
 */
private void scan(Detail detail) throws Exception {
   DefaultType override = detail.getOverride();
   DefaultType access = detail.getAccess();
   Class base = detail.getSuper();

   if(base != null) {
      extend(base, override);
   }
   extract(detail, access);
   extract(detail);
   build();
   validate();
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:22,代码来源:MethodScanner.java

示例6: field

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This is used to acquire the contacts for the annotated fields 
 * within the specified class. The field contacts are added to
 * either the attributes or elements map depending on annotation.
 * 
 * @param detail this contains the details for the class scanned
 */    
private void field(Detail detail) throws Exception {
   Class type = detail.getType();
   DefaultType access = detail.getOverride();
   ContactList list = support.getFields(type, access);
   
   for(Contact contact : list) {
      Annotation label = contact.getAnnotation();
      
      if(label != null) {
         builder.process(contact, label);
      }
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:21,代码来源:ObjectScanner.java

示例7: method

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This is used to acquire the contacts for the annotated fields 
 * within the specified class. The field contacts are added to
 * either the attributes or elements map depending on annotation.
 * 
 * @param detail this contains the details for the class scanned
 */ 
private void method(Detail detail) throws Exception {
   Class type = detail.getType();
   DefaultType access = detail.getOverride();
   ContactList list = support.getMethods(type, access);
   
   for(Contact contact : list) {
      Annotation label = contact.getAnnotation();
      
      if(label != null) {
         builder.process(contact, label);
      }
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:21,代码来源:ObjectScanner.java

示例8: scan

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * Scan the fields and methods such that the given class is scanned 
 * first then all super classes up to the root <code>Object</code>. 
 * All fields and methods from the most specialized classes override 
 * fields and methods from higher up the inheritance hierarchy. This
 * means that annotated details can be overridden.
 * 
 * @param detail contains the methods and fields to be examined
 */   
private void scan(Detail detail) throws Exception {
   DefaultType access = detail.getOverride();
   Class type = detail.getType();

   while(type != null) {
      Detail value = support.getDetail(type, access);

      namespace(value);
      method(value);
      definition(value);
      type = value.getSuper();
   }      
   commit(detail); 
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:24,代码来源:ClassScanner.java

示例9: testScanner

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
public void testScanner() throws Exception {
   DetailScanner scanner = new DetailScanner(DetailExample.class);
   
   assertEquals(scanner.getNamespace(), null);
   assertEquals(scanner.getNamespaceList().value().length, 2);
   assertEquals(scanner.getNamespaceList().value()[0].reference(), "http://x.com/");
   assertEquals(scanner.getNamespaceList().value()[0].prefix(), "x");
   assertEquals(scanner.getNamespaceList().value()[1].reference(), "http://y.com/");
   assertEquals(scanner.getNamespaceList().value()[1].prefix(), "y");
   assertEquals(scanner.getNamespaceList().value().length, 2);
   assertEquals(scanner.getRoot().name(), "detail");
   assertEquals(scanner.getAccess(), DefaultType.FIELD);
   assertEquals(scanner.getMethods().size(), 3);
   assertEquals(scanner.getFields().size(), 1);
   assertEquals(scanner.getFields().get(0).getName(), "value");
   assertTrue(Arrays.asList(scanner.getMethods().get(0).getName(), 
                            scanner.getMethods().get(1).getName(),
                             scanner.getMethods().get(2).getName()).containsAll(Arrays.asList("validate", "getValue", "setValue")));
   
   for(MethodDetail detail : scanner.getMethods()) {
      if(detail.getName().equals("validate")) {
         assertEquals(detail.getAnnotations().length, 1);
         assertEquals(detail.getAnnotations()[0].annotationType(), Validate.class);
      }
   }
   assertTrue(scanner.getMethods() == scanner.getMethods());
   assertTrue(scanner.getNamespaceList() == scanner.getNamespaceList());
   assertTrue(scanner.getRoot() == scanner.getRoot());
   assertTrue(scanner.getAccess() == scanner.getAccess());
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:31,代码来源:DetailScannerTest.java

示例10: getDetail

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
public Detail getDetail(Class type, DefaultType access) {
   if(access != null) {
      return defaults.getDetail(type);   
   }
   return details.getDetail(type);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:7,代码来源:Support.java

示例11: getAccess

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This returns the <code>Default</code> annotation access type
 * that has been specified by this. If no default annotation has
 * been declared on the type then this will return null.
 * 
 * @return this returns the default access type for this type
 */
public DefaultType getAccess() {
   if(override != null) {
      return override;
   }
   return access;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:14,代码来源:DetailScanner.java

示例12: extend

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This method is used to extend the provided class. Extending a
 * class in this way basically means that the fields that have
 * been scanned in the specific class will be added to this. Doing
 * this improves the performance of classes within a hierarchy.
 * 
 * @param base the class to inherit scanned fields from
 * @param access this is the access type used for the super type
 */
private void extend(Class base, DefaultType access) throws Exception {
   ContactList list = support.getFields(base, access);
   
   if(list != null) {
      addAll(list);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:17,代码来源:FieldScanner.java

示例13: extend

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This method is used to extend the provided class. Extending a
 * class in this way basically means that the fields that have
 * been scanned in the specific class will be added to this. Doing
 * this improves the performance of classes within a hierarchy.
 * 
 * @param base the class to inherit scanned fields from
 * @param access this is the access type used for the super type
 */
private void extend(Class base, DefaultType access) throws Exception {
   ContactList list = support.getMethods(base, access);
   
   for(Contact contact : list) {
      process((MethodContact)contact);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:17,代码来源:MethodScanner.java

示例14: DetailExtractor

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * Constructor for the <code>DetailExtractor</code> object. This
 * is used to extract various details for a class, such as the
 * method and field details as well as the annotations used on
 * the class. The primary purpose for this is to create cachable
 * values that reduce the amount of reflection required.
 * 
 * @param support this contains various support functions
 * @param override this is the override used for details created
 */
public DetailExtractor(Support support, DefaultType override) {
   this.methods = new ConcurrentCache<ContactList>();
   this.fields = new ConcurrentCache<ContactList>();
   this.details = new ConcurrentCache<Detail>();
   this.override = override;
   this.support = support;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:18,代码来源:DetailExtractor.java

示例15: getFields

import org.simpleframework.xml.DefaultType; //导入依赖的package包/类
/**
 * This is used to acquire a list of <code>Contact</code> objects
 * that represent the annotated fields in a type. The entire
 * class hierarchy is scanned for annotated fields. Caching of
 * the contact list is done to increase performance.
 * 
 * @param type this is the type to scan for annotated fields
 * @param access this is the access type to use for the fields
 * 
 * @return this returns a list of the annotated fields
 */
public ContactList getFields(Class type, DefaultType access) throws Exception {
   if(access != null) {
      return defaults.getFields(type);
   }
   return details.getFields(type);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:18,代码来源:Support.java


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