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