Java 类org.simpleframework.xml.Element 实例源码

项目:Saiy-PS    文件:Pod.java   
public Pod(@Attribute(name = "error") final boolean error,
           @Attribute(name = "primary") final boolean primary,
           @Attribute(name = "title") final String title,
           @Attribute(name = "scanner") final String scanner,
           @Attribute(name = "id") final String id,
           @Attribute(name = "position") final long position,
           @Attribute(name = "numsubpods") final long numsubpods,
           @ElementList(inline = true, name = "subpods") final List<SubPod> subpods,
           @Element(name = "states") final States states,
           @Element(name = "infos") final Infos infos,
           @Element(name = "definitions", required = false) final Definitions definitions) {
    this.error = error;
    this.title = title;
    this.scanner = scanner;
    this.id = id;
    this.position = position;
    this.numsubpods = numsubpods;
    this.subpods = subpods;
    this.primary = primary;
    this.states = states;
    this.infos = infos;
    this.definitions = definitions;
}
项目:simplexml    文件:MethodScannerDefaultTest.java   
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));
}
项目:simplexml    文件:AnnotationFactory.java   
/**
 * This is used to create an annotation for the provided type.
 * Annotations created are used to match the type provided. So
 * an array of objects will have an <code>ElementArray</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
 * 
 * @return this returns the synthetic annotation to be used
 */
private Annotation getInstance(Class type) throws Exception {
   ClassLoader loader = getClassLoader();
   Class entry = type.getComponentType();

   if(type.isArray()) {
      if(isPrimitive(entry)) {
         return getInstance(loader, Element.class);
      }
      return getInstance(loader, ElementArray.class);
   }
   if(isPrimitive(type) && isAttribute()) {
      return getInstance(loader, Attribute.class);
   }
   return getInstance(loader, Element.class);
}
项目:simplexml    文件:PackageParserTest.java   
public void testParser() throws Exception {
   assertEquals("http://util.java/HashMap", parse(HashMap.class));
   assertEquals("http://simpleframework.org/xml/Element", parse(Element.class));
   assertEquals("http://simpleframework.org/xml/ElementList", parse(ElementList.class));
   assertEquals("http://w3c.org/dom/Node", parse(Node.class));
   assertEquals("http://simpleframework.org/xml/strategy/PackageParser", parse(PackageParser.class));

   assertEquals(HashMap.class, revert("http://util.java/HashMap"));
   assertEquals(Element.class, revert("http://simpleframework.org/xml/Element"));
   assertEquals(ElementList.class, revert("http://simpleframework.org/xml/ElementList"));
   assertEquals(Node.class, revert("http://w3c.org/dom/Node"));
   assertEquals(PackageParser.class, revert("http://simpleframework.org/xml/strategy/PackageParser"));

   long start = System.currentTimeMillis();
   for(int i = 0; i < ITERATIONS; i++) {
      fastParse(ElementList.class);
   }
   long fast = System.currentTimeMillis() - start;
   start = System.currentTimeMillis();
   for(int i = 0; i < ITERATIONS; i++) {
      parse(ElementList.class);
   }
   long normal = System.currentTimeMillis() - start;
   System.out.printf("fast=%sms normal=%sms diff=%s%n", fast, normal, normal / fast);
}
项目:anitrend-app    文件:Episode.java   
public Episode(@Element(name = "title")String title, @Element(name = "link")String link, @Element(name = "description")String description, @Element(name = "publisher", required = false)String publisher, @Element(name = "content")MediaContent content, @ElementList(name = "thumbnail", inline = true, required = false)List<Thumbnail> thumbnail) {
    this.title = title;
    this.link = link;
    this.description = description;
    this.publisher = publisher;
    this.content = content;
    this.thumbnail = thumbnail;
}
项目:anitrend-app    文件:Channel.java   
public Channel(@Element(name = "title")String title, @Path("link") @Text(required=false)String link, @Element(name = "description")String description, @Element(name = "copyright")String copyright, @ElementList(name = "episode", inline = true)List<Episode> episode) {
    this.title = title;
    this.link = link;
    this.description = description;
    this.copyright = copyright;
    this.episode = episode;
}
项目:Proyecto-DASI    文件:InfoCasoSimulacion.java   
public  InfoCasoSimulacion (@Element(name="identCaso")String casoId,@Element(name="identEscenario") String escenarioId){ 
 identCaso= casoId;
 identEscenario= escenarioId;
 infoRescateVictimas = new HashMap<String, InfoRescateVictima>();
 conjVictimasRescatadas= new TreeSet <InfoRescateVictima>() ;
 infoRobotVictimasSalvadas=new HashMap<String, VictimasSalvadas>();
 infoRobotVictimasAsignadas=new HashMap<String, Set<String>>();
 victimasRescatadasPorRobot = new VictimasSalvadas();
 identsVictimasRescatadas= new VictimasSalvadas();
}
项目:thingplug-sdk-android    文件:CSEBase.java   
@Element(required = false)

    /**
     * CSEBase constructor
     *
     * @param builder
     */
    private CSEBase(Builder builder) {
        super(builder);
    }
项目:thingplug-sdk-android    文件:CSEBase.java   
@Element(required = false)

    /**
     * CSEBase constructor
     *
     * @param builder
     */
    private CSEBase(Builder builder) {
        super(builder);
    }
项目:thingplug-sdk-android    文件:CSEBase.java   
@Element(required = false)

    /**
     * CSEBase constructor
     *
     * @param builder
     */
    private CSEBase(Builder builder) {
        super(builder);
    }
项目:Saiy-PS    文件:States.java   
public States(@Attribute(name = "count") final long count,
              @ElementList(inline = true, name = "state") final List<State> state,
              @Element(name = "statelist", required = false) final StateList stateList) {
    this.count = count;
    this.state = state;
    this.stateList = stateList;
}
项目:Saiy-PS    文件:SubPod.java   
public SubPod(@Element(name = "plaintext") final String plaintext,
              @Attribute(name = "title") final String title,
              @Element(name = "imagesource", required = false) final String imagesource) {
    this.plaintext = plaintext;
    this.title = title;
    this.imagesource = imagesource;
}
项目:Saiy-PS    文件:Warnings.java   
public Warnings(@Attribute(name = "count") final long count,
                @Element(name = "reinterpret", required = false) final Reinterpret reinterpret,
                @Element(name = "spellcheck", required = false) final SpellCheck spellcheck) {
    this.count = count;
    this.reinterpret = reinterpret;
    this.spellcheck = spellcheck;
}
项目:c2mon    文件:SourceCommandTag.java   
/**
 * Creates a SourceCommandTag from a DOM element. The provided element
 * MUST be a element CommandTag element.
 *
 * @param domElement The DOM element to use.
 * @return The created SourceCommandTag.
 */
public static SourceCommandTag fromConfigXML(final org.w3c.dom.Element domElement) {
    Long id = Long.valueOf(domElement.getAttribute("id"));
    String name = domElement.getAttribute("name");

    SourceCommandTag result = new SourceCommandTag(id, name);

    Node fieldNode = null;
    String fieldName = null;
    String fieldValueString = null;
    NodeList fields = domElement.getChildNodes();

    int fieldsCount = fields.getLength();

    for (int i = 0; i < fieldsCount; i++) {
        fieldNode = fields.item(i);

        if (fieldNode.getNodeType() == 1) {
            // extract name of the XML node
            fieldName = fieldNode.getNodeName();
            // extract contents of the XML node
            fieldValueString = fieldNode.getFirstChild().getNodeValue();

            if (fieldName.equals("source-timeout")) {
                result.sourceTimeout = Integer.parseInt(fieldValueString);
            }

            if (fieldName.equals("source-retries")) {
                result.sourceRetries = Integer.parseInt(fieldValueString);
            }

            if (fieldName.equals("HardwareAddress")) {
                result.hardwareAddress = HardwareAddressFactory.getInstance().fromConfigXML((org.w3c.dom.Element) fieldNode);
            }
        }
    }
    return result;
}
项目:code    文件:OObject.java   
public OObject(@Attribute(required = true, name = "O_id") String O_id, 
        @Element(required = true, name = "C") Type C,
        IDomain parent) {
    super();
    this.O_id = O_id;
    this.C = C;

    // parent is the parent domain of this
    this.parent = parent;

    // NOTE: would be hackish to do the following:
    // parentDomain.addObject(this);
}
项目:code    文件:ODFEdge.java   
public ODFEdge(@Element(required = true, name = "osrc") OObject osrc,
        @Element(required = true, name = "odst") OObject odst,
        @Element(required = true, name = "flow") OObject flow,
        @Attribute(required = true, name = "flag") EdgeFlag flag) {
    super(osrc, odst);
    this.flow = flow;
    this.flag = flag;
}
项目:code    文件:ODFEdge.java   
public ODFEdge(@Element(required = true, name = "osrc") OObject osrc,
        @Element(required = true, name = "odst") OObject odst,
        @Element(required = true, name = "flow") OObject flow,
        @Attribute(required = true, name = "flag") EdgeFlag flag,
        @Attribute(required = false, name = "hasFlow") boolean hasFlow,
        @Attribute(required = false, name = "flowType")String flowType ) {
    this(osrc, odst, flow, flag);
    this.hasFlow = hasFlow;
    this.flowType = flowType;
}
项目:code    文件:OCFEdge.java   
public OCFEdge(@Element(required = true, name = "osrc") OObject osrc,
        @Element(required = true, name = "odst") OObject odst,
        @Element(required = true, name = "control") String label) {
    super(osrc, odst);

    this.label = label;
}
项目:IA-AgentScape-Rover    文件:Scenario.java   
public Scenario(@Attribute(name="id") int id,@Element(name="width") int width,@Element(name="height") int height,
                @Element(name="resources") int resources,@Element(name="resourceDistribution") int resourceDist, @Element(name="energy") int energy,@Element(name="isCompetitive") boolean competitive) {
    this.id = id;
    this.width = width;
    this.height = height;
    this.rscount  =resources;
    this.rsDist = resourceDist;
    this.initialEnergy = energy;
    this.isCompetitive = competitive;
}
项目:simplexml    文件:UnionListConstructorInjectionTest.java   
@ElementUnion({
   @Element(name="login"),
   @Element(name="name"),
   @Element(name="user")
})
public String getName(){
   return name;
}
项目:simplexml    文件:UnionWithSameNamesAndDifferentPathsTest.java   
public Example(
      @Path("path[1]") @Element(name="b") String x, 
      @Path("path[2]") @Element(name="b") String y)
{
   this.y = y;
   this.x = x;
}
项目:simplexml    文件:ConstructorInjectionWithMissingValuesTest.java   
@SuppressWarnings("unused")
public ManyConstructorsWithMissingValues(
   @Element(name="a", required=false) String a,
   @Element(name="b", required=false) String b,
   @Element(name="c", required=false) String c)
{
   this.a = a;
   this.b = b;
   this.c = c;
   this.d = 10;
}
项目:simplexml    文件:PathWithTextAndElementTest.java   
private OtherPathWithTextAndElementExample(
      @Path("valuePath/path") @Attribute(name="name") String a,
      @Path("someOtherPath/path") @Element(name="name") String b,
      @Text String c) 
{
   this.a = a;
   this.b = b;
   this.c = c;
}
项目:simplexml    文件:MethodPartFactoryTest.java   
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()));
}
项目:simplexml    文件:ConstructorInjectionWithMissingValuesTest.java   
@SuppressWarnings("unused")
public ConstructorWithMissingValues(
   @Element(name="a", required=false) String a,
   @Element(name="b", required=false) String b,
   @Element(name="c", required=false) String c)
{
   this.a = a;
   this.b = b;
   this.c = c;
}
项目:simplexml    文件:NestedElementTest.java   
public NestedElementExample(
        @Element(name="city") String city,
        @Element(name="street") String street,
        @Element(name="mobile") String mobile,
        @Element(name="home") String home,
        @Attribute(name="area-code") int areaCode) 
{
   this.city=city;
   this.street=street;
   this.mobile=mobile;
   this.home=home;   
   this.areaCode = areaCode;
}
项目:simplexml    文件:PathWithConverterTest.java   
public ServerDetailsReference(
      @Element(name="primary") ServerDetails primary,
      @Element(name="secondary") ServerDetails secondary) 
{
   this.primary = primary;
   this.secondary = secondary;
}
项目:simplexml    文件:PathWithTextAndElementTest.java   
private PathWithTextAndElementExample(
      @Text String text,
      @Path("some/path") @Attribute(name="name") String value,
      @Path("some") @Element(name="name") String item) 
{
   this.item = item;
   this.value = value;
   this.text = text;
}
项目:simplexml    文件:PathInPathTest.java   
public PathInPathRoot(
      @Element(name="d") PathInPathEntry d,
      @Element(name="e") PathInPathEntry e) 
{
   this.d = d;
   this.e = e;
}
项目:simplexml    文件:UnionListTaskTest.java   
public Move(
      @Element(name="source") File source,
      @Element(name="destination") File destination)
{
   this.source = source;
   this.destination = destination;
}
项目:simplexml    文件:ConstructorInjectionAdjustmentFactorTest.java   
@SuppressWarnings("unused")
public ConstructorAdjustmentExample(
      @Element(name="a") String a,
      @Element(name="b") String b, 
      @Element(name="c") String c,
      @Element(name="d") String d)
{
   this.a = a;
   this.b = b;
   this.c = c;
   this.d = d;
   this.longestUsed = true;
}
项目:simplexml    文件:MethodScannerDefaultTest.java   
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));
}
项目:simplexml    文件:MissingPrefixTest.java   
public BlahBlah(
      @Element(name="x")String x, 
      @Element(name="y")int y, 
      @Element(name="z")long z) {
   this.x = x;
   this.y = y;
   this.z = z;

}
项目:simplexml    文件:ElementWithExplicitTypeTest.java   
public Example(
   @Element(name="string") Object string, 
   @Element(name="integer") Object integer, 
   @Element(name="bool") Object bool) 
{
   this.string = string;
   this.integer = integer;
   this.bool = bool;
}
项目:simplexml    文件:SignatureScannerTest.java   
public UnionExample(            
@ElementUnion({
   @Element(name="a", type=String.class),
   @Element(name="b", type=Integer.class),
   @Element(name="c", type=Long.class)
}) 
Object a) {}
项目:simplexml    文件:ConstructorInjectionWithMissingValuesTest.java   
@SuppressWarnings("unused")
public ManyConstructorsWithMissingValues(
   @Element(name="a", required=false) String a,
   @Element(name="b", required=false) String b)
{
   this.a = a;
   this.b = b;
   this.c = "Default C";
   this.d = 10;
}
项目:anitrend-app    文件:Rss.java   
public Rss(@Element(name = "channel") Channel channel) {
    this.channel = channel;
}
项目:Saiy-PS    文件:Info.java   
public Info(@Element(name = "link", required = false) final Link link,
            @Element(name = "units", required = false) final Units units) {
    this.link = link;
    this.units = units;
}
项目:Saiy-PS    文件:QueryResult.java   
public QueryResult(@Attribute(name = "datatypes") final String datatypes,
                   @Attribute(name = "success") final boolean success,
                   @Attribute(name = "nodata") final boolean noData,
                   @Attribute(name = "error") final boolean error,
                   @Attribute(name = "numpods") final int numpods,
                   @Attribute(name = "timedout") final String timedout,
                   @Attribute(name = "timedoutpods") final String timedoutpods,
                   @Attribute(name = "timing") final double timing,
                   @Attribute(name = "parsetimedout") final boolean parsetimedout,
                   @Attribute(name = "parsetiming") final double parsetiming,
                   @Attribute(name = "recalculate") final String recalculate,
                   @Attribute(name = "id") final String id,
                   @Attribute(name = "host") final String host,
                   @Attribute(name = "server") final int server,
                   @Attribute(name = "related") final String related,
                   @Attribute(name = "version") final double version,
                   @ElementList(inline = true, name = "pod") final List<Pod> pods,
                   @Element(name = "assumptions") final Assumptions assumptions,
                   @Element(name = "sources", required = false) final Sources sources,
                   @Element(name = "warnings", required = false) final Warnings warnings) {
    this.datatypes = datatypes;
    this.success = success;
    this.noData = noData;
    this.error = error;
    this.numpods = numpods;
    this.timedout = timedout;
    this.timedoutpods = timedoutpods;
    this.timing = timing;
    this.parsetimedout = parsetimedout;
    this.parsetiming = parsetiming;
    this.recalculate = recalculate;
    this.id = id;
    this.host = host;
    this.server = server;
    this.related = related;
    this.version = version;
    this.pods = pods;
    this.assumptions = assumptions;
    this.sources = sources;
    this.warnings = warnings;
}
项目:c2mon    文件:DataTagAddress.java   
public static DataTagAddress fromConfigXML(org.w3c.dom.Element element) {

    DataTagAddress result = new DataTagAddress();

    NodeList fields = element.getChildNodes();
    int fieldsCount = fields.getLength();

    for (int i = 0; i < fieldsCount; i++) {
      Node fieldNode = fields.item(i);
      String fieldName;
      String fieldValueString;

      if (fieldNode.getNodeType() == Node.ELEMENT_NODE) {
        fieldName = fieldNode.getNodeName();
        if (fieldName.equals("HardwareAddress")) {
          result.setHardwareAddress(HardwareAddressFactory.getInstance()
              .fromConfigXML((org.w3c.dom.Element) fieldNode));
        } else if (fieldName.equals("address-parameters")) {
          result.setAddressParameters((HashMap<String, String>) SimpleXMLParser.domNodeToMap(fieldNode));
        } else {
          fieldValueString = fieldNode.getFirstChild().getNodeValue();
          if (fieldName.equals("time-to-live")) {
            result.timeToLive = Integer.parseInt(fieldValueString);
          } else if (fieldName.equals("value-deadband-type")) {
            try {
              result.valueDeadbandType = Short.parseShort(fieldValueString);
            } catch (NumberFormatException nfe) {
              result.valueDeadbandType = DataTagDeadband.DEADBAND_NONE;
            }
          } else if (fieldName.equals("value-deadband")) {
            result.valueDeadband = Float.parseFloat(fieldValueString);
          } else if (fieldName.equals("time-deadband")) {
            result.timeDeadband = Integer.parseInt(fieldValueString);
          } else if (fieldName.equals("priority")) {
            result.priority = Integer.parseInt(fieldValueString);
          } else if (fieldName.equals("freshness-interval") && !fieldValueString.equals("null")) {
            result.freshnessInterval = Integer.parseInt(fieldValueString);
          } else if (fieldName.equals("guaranteed-delivery")) {
            result.guaranteedDelivery = fieldValueString.equals("true");
          }
        }
      }
    }
    return result;
  }