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


Java ElementMap类代码示例

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


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

示例1: ComplicatedExample

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
public ComplicatedExample(
      @Path("x:path[1]") @ElementMap(name="a") Map<Key, Entry> map,
      @Path("x:path[2]") @ElementList(name="a") List<Entry> list,
      @Element(name="elementOne") String elementOne,
      @Element(name="elementTwo") String elementTwo,
      @Element(name="elementThree") String elementThree,
      @Text String text,
      @Path("x:path[2]/x:someOtherPath") @Attribute(name="attribute_one") String attribute_one,
      @Path("x:path[2]/x:someOtherPath") @Attribute(name="attribute_two") String attribute_two) 
{
   this.map = map;
   this.list = list;
   this.elementOne = elementOne;
   this.elementTwo = elementTwo;
   this.elementThree = elementThree;
   this.text = text;
   this.attribute_one = attribute_one;
   this.attribute_two = attribute_two;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:20,代码来源:UnionComplicatedPathMixTest.java

示例2: setAttributeMap

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/** For serialization only. */
@ElementMap(name = "attrs", key = "key", value = "value", attribute = true, required = false)
public void setAttributeMap(Map<String, ? extends Object> attributes) {
    Iterator<? extends Map.Entry<String, ?>> it = attributes.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, ? extends Object> e = it.next();
        if (e.getValue() != null)
            if (!(e.getValue() instanceof Serializable))
                throw new IllegalArgumentException("Not serializable: " + e.getValue().getClass());
    }
    super.setAttributes((Map<String, Serializable>) attributes);
}
 
开发者ID:shevek,项目名称:simple-xml-serializers,代码行数:13,代码来源:SimpleXmlInvocation.java

示例3: scan

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * This reflectively checks the annotation to determine the type 
 * of annotation it represents. If it represents an XML schema
 * annotation it is used to create a <code>Contact</code> which 
 * can be used to represent the field within the source object.
 * 
 * @param field the field that the annotation comes from
 * @param label the annotation used to model the XML schema
 * @param list this is the list of annotations on the field
 */
private void scan(Field field, Annotation label, Annotation[] list) {
   if(label instanceof Attribute) {
      process(field, label, list);
   }
   if(label instanceof ElementUnion) {
      process(field, label, list);
   }
   if(label instanceof ElementListUnion) {
      process(field, label, list);
   }
   if(label instanceof ElementMapUnion) {
      process(field, label, list);
   }
   if(label instanceof ElementList) {
      process(field, label, list);
   }     
   if(label instanceof ElementArray) {
      process(field, label, list);
   }
   if(label instanceof ElementMap) {
      process(field, label, list);
   }
   if(label instanceof Element) {
      process(field, label, list);
   }       
   if(label instanceof Version) {
      process(field, label, list);
   }
   if(label instanceof Text) {
      process(field, label, list);
   }
   if(label instanceof Transient) {
      remove(field, label);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:46,代码来源:FieldScanner.java

示例4: scan

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * This reflectively checks the annotation to determine the type 
 * of annotation it represents. If it represents an XML schema
 * annotation it is used to create a <code>Contact</code> which 
 * can be used to represent the method within the source object.
 * 
 * @param method the method that the annotation comes from
 * @param label the annotation used to model the XML schema
 * @param list this is the list of annotations on the method
 */ 
private void scan(Method method, Annotation label, Annotation[] list) throws Exception {
   if(label instanceof Attribute) {
      process(method, label, list);
   }
   if(label instanceof ElementUnion) {
      process(method, label, list);
   }
   if(label instanceof ElementListUnion) {
      process(method, label, list);
   }
   if(label instanceof ElementMapUnion) {
      process(method, label, list);
   }
   if(label instanceof ElementList) {
      process(method, label, list);
   }
   if(label instanceof ElementArray) {
      process(method, label, list);
   }
   if(label instanceof ElementMap) {
      process(method, label, list);
   }
   if(label instanceof Element) {
      process(method, label, list);
   }    
   if(label instanceof Version) {
      process(method, label, list);
   }
   if(label instanceof Text) {
      process(method, label, list);
   }
   if(label instanceof Transient) {
      remove(method, label, list);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:46,代码来源:MethodScanner.java

示例5: getBuilder

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * Creates an entry that is used to select the constructor for the
 * parameter. Each parameter must implement a constructor that takes 
 * a constructor, and annotation, and the index of the parameter. If
 * the annotation is not know this method throws an exception.
 * 
 * @param label the XML annotation used to create the parameter
 * 
 * @return this returns the entry used to create a constructor
 */
private ParameterBuilder getBuilder(Annotation label) throws Exception{      
   if(label instanceof Element) {
      return new ParameterBuilder(ElementParameter.class, Element.class);
   }
   if(label instanceof ElementList) {
      return new ParameterBuilder(ElementListParameter.class, ElementList.class);
   }
   if(label instanceof ElementArray) {
      return new ParameterBuilder(ElementArrayParameter.class, ElementArray.class);               
   }
   if(label instanceof ElementMapUnion) {
      return new ParameterBuilder(ElementMapUnionParameter.class, ElementMapUnion.class, ElementMap.class);
   }
   if(label instanceof ElementListUnion) {
      return new ParameterBuilder(ElementListUnionParameter.class, ElementListUnion.class, ElementList.class);
   }
   if(label instanceof ElementUnion) {
      return new ParameterBuilder(ElementUnionParameter.class, ElementUnion.class, Element.class);
   }
   if(label instanceof ElementMap) {
      return new ParameterBuilder(ElementMapParameter.class, ElementMap.class);
   }
   if(label instanceof Attribute) {
      return new ParameterBuilder(AttributeParameter.class, Attribute.class);
   }
   if(label instanceof Text) {
      return new ParameterBuilder(TextParameter.class, Text.class);
   }
   throw new PersistenceException("Annotation %s not supported", label);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:41,代码来源:ParameterFactory.java

示例6: getInstance

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * This is used to create an annotation for the provided type.
 * Annotations created are used to match the type provided. So
 * a <code>List</code> will have an <code>ElementList</code>
 * annotation for example. Matching the annotation to the
 * type ensures the best serialization for that type. 
 * 
 * @param type the type to create the annotation for
 * @param dependents these are the dependents for the type
 * 
 * @return this returns the synthetic annotation to be used
 */
public Annotation getInstance(Class type, Class[] dependents) throws Exception { 
   ClassLoader loader = getClassLoader();
   
   if(Map.class.isAssignableFrom(type)) {
      if(isPrimitiveKey(dependents) && isAttribute()) { 
         return getInstance(loader, ElementMap.class, true);
      }
      return getInstance(loader, ElementMap.class);
   }
   if(Collection.class.isAssignableFrom(type)) {
      return getInstance(loader, ElementList.class);
   }
   return getInstance(type);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:27,代码来源:AnnotationFactory.java

示例7: process

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * This is used to create <code>Parameter</code> objects which are
 * used to represent the parameters in a constructor. Each parameter
 * contains an annotation an the index it appears in.
 * 
 * @param label this is the annotation used for the parameter
 * @param ordinal this is the position the parameter appears at
 * 
 * @return this returns the parameters for the constructor
 */
private List<Parameter> process(Annotation label, int ordinal) throws Exception{
   if(label instanceof Attribute) {
      return create(label, ordinal);
   }
   if(label instanceof Element) {
      return create(label, ordinal);
   }
   if(label instanceof ElementList) {
      return create(label, ordinal);
   }     
   if(label instanceof ElementArray) {
      return create(label, ordinal);
   }
   if(label instanceof ElementMap) {
      return create(label, ordinal);
   }
   if(label instanceof ElementListUnion) {
      return union(label, ordinal);
   }     
   if(label instanceof ElementMapUnion) {
      return union(label, ordinal);
   }
   if(label instanceof ElementUnion) {
      return union(label, ordinal);
   }
   if(label instanceof Text) {
      return create(label, ordinal);
   }
   return emptyList();
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:41,代码来源:SignatureScanner.java

示例8: getBuilder

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * Creates an entry that is used to select the constructor for the
 * label. Each label must implement a constructor that takes a
 * contact and the specific XML annotation for that field. If the
 * annotation is not know this method throws an exception.
 * 
 * @param label the XML annotation used to create the label
 * 
 * @return this returns the entry used to create a constructor
 */
private LabelBuilder getBuilder(Annotation label) throws Exception{   
   if(label instanceof Element) {
      return new LabelBuilder(ElementLabel.class, Element.class);
   }
   if(label instanceof ElementList) {
      return new LabelBuilder(ElementListLabel.class, ElementList.class);
   }
   if(label instanceof ElementArray) {
      return new LabelBuilder(ElementArrayLabel.class, ElementArray.class);               
   }
   if(label instanceof ElementMap) {
      return new LabelBuilder(ElementMapLabel.class, ElementMap.class);
   }
   if(label instanceof ElementUnion) {
      return new LabelBuilder(ElementUnionLabel.class, ElementUnion.class, Element.class);
   }
   if(label instanceof ElementListUnion) {
      return new LabelBuilder(ElementListUnionLabel.class, ElementListUnion.class, ElementList.class);
   }
   if(label instanceof ElementMapUnion) {
      return new LabelBuilder(ElementMapUnionLabel.class, ElementMapUnion.class, ElementMap.class);
   }
   if(label instanceof Attribute) {
      return new LabelBuilder(AttributeLabel.class, Attribute.class);
   }
   if(label instanceof Version) {
      return new LabelBuilder(VersionLabel.class, Version.class);
   }
   if(label instanceof Text) {
      return new LabelBuilder(TextLabel.class, Text.class);
   }
   throw new PersistenceException("Annotation %s not supported", label);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:44,代码来源:LabelExtractor.java

示例9: process

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * This reflectively checks the annotation to determine the type 
 * of annotation it represents. If it represents an XML schema
 * annotation it is used to create a <code>Label</code> which can
 * be used to represent the field within the context object.
 * 
 * @param field the field that the annotation comes from
 * @param label the annotation used to model the XML schema
 * 
 * @throws Exception if there is more than one text annotation
 */   
public void process(Contact field, Annotation label) throws Exception {
   if(label instanceof Attribute) {
      process(field, label, attributes);
   }
   if(label instanceof ElementUnion) {
      union(field, label, elements);
   }
   if(label instanceof ElementListUnion) {
      union(field, label, elements);
   }
   if(label instanceof ElementMapUnion) {
      union(field, label, elements);
   }
   if(label instanceof ElementList) {
      process(field, label, elements);
   }
   if(label instanceof ElementArray) {
      process(field, label, elements);
   }
   if(label instanceof ElementMap) {
      process(field, label, elements);
   }
   if(label instanceof Element) {
      process(field, label, elements);
   }    
   if(label instanceof Version) {
      version(field, label);
   }
   if(label instanceof Text) {
      text(field, label);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:44,代码来源:StructureBuilder.java

示例10: ElementMapParameter

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**   
 * Constructor for the <code>ElementMapParameter</code> object.
 * This is used to create a parameter that can be used to 
 * determine a consistent name using the provided XML annotation.
 * 
 * @param factory this is the constructor the parameter is in
 * @param value this is the annotation used for the parameter
 * @param format this is the format used to style this parameter
 * @param index this is the index the parameter appears at
 */
public ElementMapParameter(Constructor factory, ElementMap value, Format format, int index) throws Exception {
   this.contact = new Contact(value, factory, index);
   this.label = new ElementMapLabel(contact, value, format);
   this.expression = label.getExpression();
   this.path = label.getPath();
   this.type = label.getType();
   this.name = label.getName();
   this.key = label.getKey();
   this.index = index;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:21,代码来源:ElementMapParameter.java

示例11: ElementMapLabel

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
/**
 * Constructor for the <code>ElementMapLabel</code> object. This
 * creates a label object, which can be used to convert an XML 
 * node to a <code>Map</code> of XML serializable objects.
 * 
 * @param contact this is the contact that this label represents
 * @param label the annotation that contains the schema details
 * @param format this is the format used to style this label
 */
public ElementMapLabel(Contact contact, ElementMap label, Format format) {
   this.detail = new Introspector(contact, this, format);
   this.decorator = new Qualifier(contact);
   this.entry = new Entry(contact, label);
   this.required = label.required();
   this.type = contact.getType();
   this.inline = label.inline();
   this.override = label.name();      
   this.data = label.data();
   this.format = format;
   this.label = label;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:22,代码来源:ElementMapLabel.java

示例12: getEntry

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
public Entry getEntry(Class type, String name) throws Exception {
   Contact contact = getContact(EntryTest.class, name);
   ElementMap label = getField(EntryTest.class, name).getAnnotation(ElementMap.class);
   Entry entry = new Entry(contact, label);
   
   return entry;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:8,代码来源:EntryTest.java

示例13: getAnnotation

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
public Annotation getAnnotation(Field field) {
   Annotation[] list = field.getDeclaredAnnotations();
   
   for(Annotation label : list) {
      if(label instanceof ElementMap) {
         return label;
      }
   }
   return null;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:11,代码来源:EntryTest.java

示例14: testHandler

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
@ElementArray
@ElementList
@ElementMap
@Element
public void testHandler() throws Exception {
   AnnotationHandler elementHandler = new AnnotationHandler(Element.class);
   Element element = getClass().getDeclaredMethod("testHandler").getAnnotation(Element.class);
   
   System.err.println(elementHandler);
   System.err.println(element);
   
   AnnotationHandler elementListHandler = new AnnotationHandler(ElementList.class);
   ElementList elementList = getClass().getDeclaredMethod("testHandler").getAnnotation(ElementList.class);
   
   System.err.println(elementListHandler);
   System.err.println(elementList);
   
   AnnotationHandler elementMapHandler = new AnnotationHandler(ElementMap.class);
   ElementMap elementMap = getClass().getDeclaredMethod("testHandler").getAnnotation(ElementMap.class);
   
   System.err.println(elementMapHandler);
   System.err.println(elementMap);
   
   AnnotationHandler elementArrayHandler = new AnnotationHandler(ElementArray.class);
   ElementArray elementArray = getClass().getDeclaredMethod("testHandler").getAnnotation(ElementArray.class);
   
   System.err.println(elementArrayHandler);
   System.err.println(elementArray);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:30,代码来源:AnnotationHandlerTest.java

示例15: testMethodPart

import org.simpleframework.xml.ElementMap; //导入依赖的package包/类
public void testMethodPart() throws Exception {
   assertTrue(Element.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("getInteger"), new Annotation[0]).getAnnotation().getClass()));
   assertTrue(Element.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("setInteger", int.class), new Annotation[0]).getAnnotation().getClass()));
   assertTrue(ElementMap.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("getMap"), new Annotation[0]).getAnnotation().getClass()));
   assertTrue(ElementMap.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("setMap", Map.class), new Annotation[0]).getAnnotation().getClass()));
   assertTrue(ElementList.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("getList"), new Annotation[0]).getAnnotation().getClass()));
   assertTrue(ElementList.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("setList", List.class), new Annotation[0]).getAnnotation().getClass()));
   assertTrue(ElementArray.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("getArray"), new Annotation[0]).getAnnotation().getClass()));
   assertTrue(ElementArray.class.isAssignableFrom(new MethodPartFactory(new DetailScanner(MethodPartFactoryTest.class), new Support()).getInstance(Bean.class.getMethod("setArray", String[].class), new Annotation[0]).getAnnotation().getClass()));
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:11,代码来源:MethodPartFactoryTest.java


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