本文整理汇总了Java中org.simpleframework.xml.Root类的典型用法代码示例。如果您正苦于以下问题:Java Root类的具体用法?Java Root怎么用?Java Root使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Root类属于org.simpleframework.xml包,在下文中一共展示了Root类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This method is used to extract the annotations associated with
* the type. Annotations extracted include the <code>Root</code>
* annotation and the <code>Namespace</code> annotation as well as
* other annotations that are used to describe the type.
*
* @param type this is the type to extract the annotations from
*/
private void extract(Class type) {
for(Annotation label : labels) {
if(label instanceof Namespace) {
namespace(label);
}
if(label instanceof NamespaceList) {
scope(label);
}
if(label instanceof Root) {
root(label);
}
if(label instanceof Order) {
order(label);
}
if(label instanceof Default) {
access(label);
}
}
}
示例2: root
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This is used to set the optional <code>Root</code> annotation for
* the class. The root can only be set once, so if a super type also
* has a root annotation define it must be ignored.
*
* @param label this is the label used to define the root
*/
private void root(Annotation label) {
if(label != null) {
Root value = (Root)label;
String real = type.getSimpleName();
String text = real;
if(value != null) {
text = value.name();
if(isEmpty(text)) {
text = Reflector.getName(real);
}
strict = value.strict();
root = value;
name = text;
}
}
}
示例3: testMixedAnnotations
import org.simpleframework.xml.Root; //导入依赖的package包/类
public void testMixedAnnotations() throws Exception {
Map<String, Contact> map = getContacts(MixedAnnotations.class);
assertEquals(map.size(), 3);
assertFalse(map.get("name").isReadOnly());
assertFalse(map.get("value").isReadOnly());
assertFalse(map.get("list").isReadOnly());
assertEquals(String.class, map.get("name").getType());
assertEquals(int.class, map.get("value").getType());
assertEquals(List.class, map.get("list").getType());
assertEquals(Element.class, map.get("name").getAnnotation().annotationType());
assertEquals(Attribute.class, map.get("value").getAnnotation().annotationType());
assertEquals(ElementList.class, map.get("list").getAnnotation().annotationType());
assertEquals(Element.class, map.get("name").getAnnotation(Element.class).annotationType());
assertEquals(Attribute.class, map.get("value").getAnnotation(Attribute.class).annotationType());
assertEquals(ElementList.class, map.get("list").getAnnotation(ElementList.class).annotationType());
assertNull(map.get("name").getAnnotation(Root.class));
assertNull(map.get("value").getAnnotation(Root.class));
assertNull(map.get("list").getAnnotation(Root.class));
}
示例4: testMixedAnnotationsWithNoDefaults
import org.simpleframework.xml.Root; //导入依赖的package包/类
public void testMixedAnnotationsWithNoDefaults() throws Exception {
Map<String, Contact> map = getContacts(MixedAnnotations.class);
assertEquals(map.size(), 4);
assertFalse(map.get("name").isReadOnly());
assertFalse(map.get("value").isReadOnly());
assertEquals(int.class, map.get("value").getType());
assertEquals(String.class, map.get("name").getType());
assertEquals(Attribute.class, map.get("name").getAnnotation().annotationType());
assertEquals(Element.class, map.get("value").getAnnotation().annotationType());
assertEquals(Attribute.class, map.get("name").getAnnotation(Attribute.class).annotationType());
assertEquals(Element.class, map.get("value").getAnnotation(Element.class).annotationType());
assertNull(map.get("name").getAnnotation(Root.class));
assertNull(map.get("value").getAnnotation(Root.class));
}
示例5: getConvert
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This method is used to scan the provided <code>Type</code> for
* an annotation. If the <code>Type</code> represents a field or
* method then the annotation can be taken directly from that
* field or method. If however the type represents a class then
* the class itself must contain the annotation.
*
* @param real the type that represents the field or method
*
* @return this returns the annotation on the field or method
*/
private Convert getConvert(Class real) throws Exception {
Convert convert = getAnnotation(real, Convert.class);
if(convert != null) {
Root root = getAnnotation(real, Root.class);
if(root == null) {
throw new ConvertException("Root annotation required for %s", real);
}
}
return convert;
}
示例6: getRoot
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This will acquire the name of the <code>Root</code> annotation
* for the specified class. This will traverse the inheritance
* hierarchy looking for the root annotation, when it is found it
* is used to acquire a name for the XML element it represents.
*
* @param real the actual type of the object being searched
* @param type this is the type to acquire the root name with
*
* @return the root name for the specified type if it exists
*/
private String getRoot(Class<?> real, Class<?> type) {
String name = type.getSimpleName();
Root root = type.getAnnotation(Root.class);
if(root != null) {
String text = root.name();
if(!isEmpty(text)) {
return text;
}
return Reflector.getName(name);
}
return null;
}
示例7: testExtendedAnnotations
import org.simpleframework.xml.Root; //导入依赖的package包/类
public void testExtendedAnnotations() throws Exception {
Map<String, Contact> map = getContacts(ExtendedAnnotations.class);
assertFalse(map.get("array").isReadOnly());
assertFalse(map.get("map").isReadOnly());
assertFalse(map.get("name").isReadOnly());
assertFalse(map.get("value").isReadOnly());
assertEquals(String[].class, map.get("array").getType());
assertEquals(Map.class, map.get("map").getType());
assertEquals(int.class, map.get("value").getType());
assertEquals(String.class, map.get("name").getType());
assertEquals(Attribute.class, map.get("name").getAnnotation().annotationType());
assertEquals(Element.class, map.get("value").getAnnotation().annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation().annotationType());
assertEquals(Element.class, map.get("array").getAnnotation().annotationType());
assertEquals(Attribute.class, map.get("name").getAnnotation(Attribute.class).annotationType());
assertEquals(Element.class, map.get("value").getAnnotation(Element.class).annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation(ElementMap.class).annotationType());
assertEquals(Element.class, map.get("array").getAnnotation(Element.class).annotationType());
assertNull(map.get("name").getAnnotation(Root.class));
assertNull(map.get("value").getAnnotation(Root.class));
assertNull(map.get("map").getAnnotation(Root.class));
assertNull(map.get("array").getAnnotation(Root.class));
}
示例8: testMixedAnnotations
import org.simpleframework.xml.Root; //导入依赖的package包/类
public void testMixedAnnotations() throws Exception {
Map<String, Contact> map = getContacts(MixedAnnotations.class);
assertFalse(map.get("array").isReadOnly());
assertFalse(map.get("map").isReadOnly());
assertFalse(map.get("name").isReadOnly());
assertFalse(map.get("value").isReadOnly());
assertEquals(String[].class, map.get("array").getType());
assertEquals(Map.class, map.get("map").getType());
assertEquals(int.class, map.get("value").getType());
assertEquals(String.class, map.get("name").getType());
assertEquals(Attribute.class, map.get("name").getAnnotation().annotationType());
assertEquals(Element.class, map.get("value").getAnnotation().annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation().annotationType());
assertEquals(ElementArray.class, map.get("array").getAnnotation().annotationType());
assertEquals(Attribute.class, map.get("name").getAnnotation(Attribute.class).annotationType());
assertEquals(Element.class, map.get("value").getAnnotation(Element.class).annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation(ElementMap.class).annotationType());
assertEquals(ElementArray.class, map.get("array").getAnnotation(ElementArray.class).annotationType());
assertNull(map.get("name").getAnnotation(Root.class));
assertNull(map.get("value").getAnnotation(Root.class));
assertNull(map.get("map").getAnnotation(Root.class));
assertNull(map.get("array").getAnnotation(Root.class));
}
示例9: testNoAnnotations
import org.simpleframework.xml.Root; //导入依赖的package包/类
public void testNoAnnotations() throws Exception {
Map<String, Contact> map = getContacts(NoAnnotations.class);
assertFalse(map.get("name").isReadOnly());
assertFalse(map.get("value").isReadOnly());
assertFalse(map.get("date").isReadOnly());
assertFalse(map.get("locale").isReadOnly());
assertFalse(map.get("array").isReadOnly());
assertFalse(map.get("list").isReadOnly());
assertFalse(map.get("map").isReadOnly());
assertEquals(String.class, map.get("name").getType());
assertEquals(int.class, map.get("value").getType());
assertEquals(Date.class, map.get("date").getType());
assertEquals(Locale.class, map.get("locale").getType());
assertEquals(int[].class, map.get("array").getType());
assertEquals(List.class, map.get("list").getType());
assertEquals(Map.class, map.get("map").getType());
assertEquals(Element.class, map.get("name").getAnnotation().annotationType());
assertEquals(Element.class, map.get("value").getAnnotation().annotationType());
assertEquals(Element.class, map.get("date").getAnnotation().annotationType());
assertEquals(Element.class, map.get("locale").getAnnotation().annotationType());
assertEquals(Element.class, map.get("array").getAnnotation().annotationType());
assertEquals(ElementArray.class, map.get("strings").getAnnotation().annotationType());
assertEquals(ElementList.class, map.get("list").getAnnotation().annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation().annotationType());
assertEquals(Element.class, map.get("name").getAnnotation(Element.class).annotationType());
assertEquals(Element.class, map.get("value").getAnnotation(Element.class).annotationType());
assertEquals(Element.class, map.get("date").getAnnotation(Element.class).annotationType());
assertEquals(Element.class, map.get("locale").getAnnotation(Element.class).annotationType());
assertEquals(Element.class, map.get("array").getAnnotation(Element.class).annotationType());
assertEquals(ElementArray.class, map.get("strings").getAnnotation(ElementArray.class).annotationType());
assertEquals(ElementList.class, map.get("list").getAnnotation(ElementList.class).annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation(ElementMap.class).annotationType());
assertNull(map.get("name").getAnnotation(Root.class));
assertNull(map.get("value").getAnnotation(Root.class));
assertNull(map.get("date").getAnnotation(Root.class));
assertNull(map.get("locale").getAnnotation(Root.class));
assertNull(map.get("array").getAnnotation(Root.class));
assertNull(map.get("strings").getAnnotation(Root.class));
assertNull(map.get("list").getAnnotation(Root.class));
assertNull(map.get("map").getAnnotation(Root.class));
}
示例10: testNoAnnotations
import org.simpleframework.xml.Root; //导入依赖的package包/类
public void testNoAnnotations() throws Exception {
Map<String, Contact> map = getContacts(NoAnnotations.class);
assertFalse(map.get("date").isReadOnly());
assertFalse(map.get("customer").isReadOnly());
assertFalse(map.get("name").isReadOnly());
assertFalse(map.get("price").isReadOnly());
assertFalse(map.get("list").isReadOnly());
assertFalse(map.get("map").isReadOnly());
assertFalse(map.get("array").isReadOnly());
assertEquals(Date.class, map.get("date").getType());
assertEquals(String.class, map.get("customer").getType());
assertEquals(String.class, map.get("name").getType());
assertEquals(int.class, map.get("price").getType());
assertEquals(List.class, map.get("list").getType());
assertEquals(Map.class, map.get("map").getType());
assertEquals(String[].class, map.get("array").getType());
assertEquals(Element.class, map.get("date").getAnnotation().annotationType());
assertEquals(Element.class, map.get("customer").getAnnotation().annotationType());
assertEquals(Element.class, map.get("name").getAnnotation().annotationType());
assertEquals(Element.class, map.get("price").getAnnotation().annotationType());
assertEquals(ElementList.class, map.get("list").getAnnotation().annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation().annotationType());
assertEquals(ElementArray.class, map.get("array").getAnnotation().annotationType());
assertEquals(Element.class, map.get("date").getAnnotation(Element.class).annotationType());
assertEquals(Element.class, map.get("customer").getAnnotation(Element.class).annotationType());
assertEquals(Element.class, map.get("name").getAnnotation(Element.class).annotationType());
assertEquals(Element.class, map.get("price").getAnnotation(Element.class).annotationType());
assertEquals(ElementList.class, map.get("list").getAnnotation(ElementList.class).annotationType());
assertEquals(ElementMap.class, map.get("map").getAnnotation(ElementMap.class).annotationType());
assertEquals(ElementArray.class, map.get("array").getAnnotation(ElementArray.class).annotationType());
assertNull(map.get("date").getAnnotation(Root.class));
assertNull(map.get("customer").getAnnotation(Root.class));
assertNull(map.get("name").getAnnotation(Root.class));
assertNull(map.get("price").getAnnotation(Root.class));
assertNull(map.get("list").getAnnotation(Root.class));
assertNull(map.get("map").getAnnotation(Root.class));
assertNull(map.get("array").getAnnotation(Root.class));
}
示例11: canWrite
import org.simpleframework.xml.Root; //导入依赖的package包/类
@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
return clazz.isAnnotationPresent(Root.class) && canWrite(mediaType);
}
示例12: getRoot
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This returns the <code>Root</code> annotation for the class.
* The root determines the type of deserialization that is to
* be performed and also contains the name of the root element.
*
* @return this returns the name of the object being scanned
*/
public Root getRoot() {
return detail.getRoot();
}
示例13: getRoot
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This returns the <code>Root</code> annotation for the class.
* The root determines the type of deserialization that is to
* be performed and also contains the name of the root element.
*
* @return this returns the name of the object being scanned
*/
public Root getRoot() {
return root;
}
示例14: getRoot
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This returns the <code>Root</code> annotation for the class.
* The root determines the type of deserialization that is to
* be performed and also contains the name of the root element.
*
* @return this returns the name of the object being scanned
*/
Root getRoot();
示例15: getRoot
import org.simpleframework.xml.Root; //导入依赖的package包/类
/**
* This returns the root of the class processed by this scanner.
* The root determines the type of deserialization that is to
* be performed and also contains the name of the root element.
*
* @return this returns the name of the object being scanned
*/
public Root getRoot() {
return root;
}