Extracting Particular Object

How Do I define values to this class

import java.util.ArrayList;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlElement;

import javax.xml.bind.annotation.XmlElements;

import javax.xml.bind.annotation.XmlType;

/**

*

Java class for ResourceReservation complex type.

*

*

The following schema fragment specifies the expected content contained within this class.

*

* <pre>

* <complexType name="ResourceReservation">

*<complexContent>

*<restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*<sequence maxOccurs="unbounded">

* <element name="Info" type="{urn:http://1}nfo"/>

* <element name="ResourceStatus" type="{urn:http://1}ResourceStatus"/>

*</sequence>

*</restriction>

*</complexContent>

* </complexType>

* </pre>

*

*

*/

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "ResourceReservation", propOrder = {

"infoAndResourceStatus"

})

public class ResourceReservation {

@XmlElements({

@XmlElement(name = "ResourceStatus", required = true, type = ResourceStatus.class),

@XmlElement(name = "Info", required = true, type = Info.class)

})

protected List<Object> infoAndResourceStatus;

/**

* Gets the value of the infoAndResourceStatus property.

*

*

* This accessor method returns a reference to the live list,

* not a snapshot. Therefore any modification you make to the

* returned list will be present inside the JAXB object.

* This is why there is not a <CODE>set</CODE> method for the infoAndResourceStatus property.

*

*

* For example, to add a new item, do as follows:

* <pre>

*getInfoAndResourceStatus().add(newItem);

* </pre>

*

*

*

* Objects of the following type(s) are allowed in the list

* {@link ResourceStatus }

* {@link Info }

*

*

*/

public List<Object> getInfoAndResourceStatus() {

if (infoAndResourceStatus == null) {

infoAndResourceStatus = new ArrayList<Object>();

}

return this.infoAndResourceStatus;

}

}

I mean we do

ResourceReservation RR=new ResourceReservation();

RR.infoAndResourceStatus.add(e);

but what should e be. And how do I define it, because it is constuting 2 classes ResourceStatus and Info

[2678 byte] By [SandScrappera] at [2007-11-27 11:55:55]
# 1

It is better that you define either a superclass Foo for ResourceStatus and Info, or an interface Foo that will be implemented by ResourceStatus and Info (it depends on what you'll do with them). Then you declare a List<Foo> infoAndResourceStatus.

But if ResourceStatus and Info have nothing in common it would be better to have a List for each of them.

Just a general advice, I don't know anything about your project.

java_knighta at 2007-7-29 19:04:41 > top of Java-index,Java Essentials,New To Java...
# 2

> How Do I define values to this class

be more specific...what values? and post code without all your commenting out please

mark07a at 2007-7-29 19:04:41 > top of Java-index,Java Essentials,New To Java...
# 3

That code looks suspiciously like it has been compiled using XJC from JAXB?

If so tweak your XML Schema so on recompiling it you get distinct collections of both Info and ResourceStatus rather than one combined list

c0demonk3ya at 2007-7-29 19:04:41 > top of Java-index,Java Essentials,New To Java...