Not exactly sure what you are looking for, but...

Yes, the signature for the collection add-method currently has to take an Object. Not too much of a pain, really. Just cast it to your particular class type and call the real method.

As to whether or not that will change in future releases, I don't know. Perhaps there is something in the jira on it.


On Dec 21, 2004, at 7:11 PM, David Ezzio wrote:

Would love a response.

David Ezzio wrote:
Hi,
Still wondering about this.  Will JiBX do what I want it to do?
David
David Ezzio wrote:
Hi,

I still don't have the answer to my question. I am hoping that a change to the binding specification file will correct the problem that I am dealing with, but I don't know what the change should be.

I get the error message during enhancement, when the enhancer looks for a method Route.addFlight(Object). I would think it would be simple enough for it to look for Route.addFlight(Flight), but it doesn't.

TIA,

David

David Ezzio wrote:

Hi,

I've got JiBX working with a modified version of the TimeSchedule example. But I've got one issue that I would like some help with. All of my collection add methods must take an Object parameter type, when I would like them to take the element's type.

For example, here's what the relevant portions of the metadata look like:

<mapping class="jxml.Route" name="route" >
  <collection item-type="jxml.Flight" iter-method="iterateFlights"
      add-method="addFlight" />
  <value ident="ref" style="attribute" name="from"
      get-method="getFrom" set-method="setFrom" />
  <value ident="ref" style="attribute" name="to" get-method="getTo"
      set-method="setTo" />
</mapping>
<mapping class="jxml.Flight" name="flight" >
  <value ident="ref" name="carrier" style="attribute"
      get-method="getCarrier" set-method="setCarrier" />
  <value name="number" style="attribute" get-method="getNumber"
      set-method="setNumber" />
  <value name="depart" style="attribute" get-method="getDepart"
      set-method="setDepart"/>
  <value name="arrive" style="attribute" get-method="getArrive"
      set-method="setArrive" />
</mapping>

Here's what the data file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<schedule>
<carriers>
<carrier code="NL">
<url>http://www.northleft.com</url>
<name>Northleft Airlines</name>
</carrier>
<carrier code="CL">
<url>http://www.classyskylines.com</url>
<name>Classy Skylines</name>
</carrier>
</carriers>
<airports>
<airport code="BOS">
<location>Boston, MA</location>
<name>Logan International Airport</name>
</airport>
<airport code="SEA">
<location>Seattle, WA</location>
<name>Seattle-Tacoma International Airport</name>
</airport>
<airport code="LAX">
<location>Los Angeles, CA</location>
<name>Los Angeles International Airport</name>
</airport>
</airports>
<routes>
<route from="BOS" to="SEA">
<flight carrier="CL" number="796" depart="4:12a" arrive="1:26a"/>
<flight carrier="NL" number="328" depart="2:54a" arrive="1:29a"/>
<flight carrier="CL" number="401" depart="4:12a" arrive="1:25a"/>
</route>
<route from="SEA" to="BOS">
<flight carrier="CL" number="634" depart="7:43a" arrive="9:13a"/>
<flight carrier="NL" number="508" depart="4:38p" arrive="6:12p"/>
<flight carrier="CL" number="687" depart="1:38p" arrive="3:08p"/>
</route>
</routes>
</schedule>


And here's what the relevant portion of the Route class looks like:

package jxml;

public class Route
   {
   private Airport from;
   private Airport to;
   private ArrayList flightList = new ArrayList();

   public Route(ArrayList flightList, Airport from, Airport to)
      { ... }

   public void addFlight(Flight flight)
      { ... }

   public Iterator iterateFlights()
      { ... }

   public Airport getFrom()
      { ... }

   public void setFrom(Airport from)
      { ... }

   public Airport getTo()
      { ... }

   public void setTo(Airport to)
      { ... }

   protected Route()
      { ... }
   }

If I enhance as is, I get the following error message:

org.jibx.runtime.JiBXException: Add method addFlight not found in collection type jxml.Route at tag "collection"(line 26, col 95, in jxml/binding.xml)
at org.jibx.runtime.impl.UnmarshallingContext.throwStartTagException(Un marshallingContext.java:2725)
at org.jibx.binding.def.BindingBuilder.unmarshalStructure(BindingBuilde r.java:1153)
at org.jibx.binding.def.BindingBuilder.unmarshalStructureChildren(Bindi ngBuilder.java:837)
at org.jibx.binding.def.BindingBuilder.unmarshalMapping(BindingBuilder. java:1531)
at org.jibx.binding.def.BindingBuilder.unmarshalMappings(BindingBuilder .java:963)
at org.jibx.binding.def.BindingBuilder.unmarshalBindingDefinition(Bindi ngBuilder.java:1597)
at org.jibx.binding.Utility.loadBinding(Utility.java:228)
at org.jibx.binding.Utility.loadFileBinding(Utility.java:254)
at org.jibx.binding.Compile.compile(Compile.java:291)
at org.jibx.binding.Compile.main(Compile.java:367)


On the other hand, if I change the parameter of addFlight to "Object flight" everything is fine.

Is it possible to configure so that the parameter type of addFlight is Flight?

Thanks,

David Ezzio



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users








-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users





-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


Linus Kamb
[EMAIL PROTECTED]
(206) 547-0393 x106



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to