Mapping ArrayList in java to Actionscript Problem

Hi Guys,
This is wrecking my head. Had this issue for the last two days and cannot for the life of me understand why. I have a service defined as with the following method;
public List getIngredients(){
          List list = null;
          List ingredientList = new ArrayList();
          SandwichDAOFactory fac = SandwichDAOFactory.getDAOFactory(1);
          IngredientDAO ingDao = fac.getIngredientDao();
          IngredientDTO ingDTO = new IngredientDTO();
          Ingredient ing = new Ingredient();
          list = ingDao.getAllIngredients();
          for (Iterator it=list.iterator(); it.hasNext();) {
               ing = (Ingredient) it.next();
               ingDTO.setIngredientID(ing.getIngredientID());
               ingDTO.setName(ing.getName());
               ingDTO.setPrice(ing.getPrice());
               ingDTO.setDescription(ing.getDescription());
               ingDTO.setType(ing.getDescription());
              ingredientList.add(ingDTO);
          System.out.println("Calling Service");
          System.out.println(list.toString());
          return list;
Now I have defined a remotes object in my flex app;
I call this service method when I first load the application;
retrievalService.getAllIngredients();
then handle the result as follows;
private function getAllIngredientsResultHandler(event:ResultEvent):void
                 ingredientsListData =  event.result as ArrayCollection;
                 var arrList:Array = event.result as Array;
                 trace("event.result.toString = "+event.result);
                 trace("ingredientsListData = "+ingredientsListData);
                trace("arrList = "+arrList);
I would expect to see the object references delimited in some way for all the trace methods. But when I run the example I get the following output;
event.result.toString = [object IngredientDTO],[object IngredientDTO],[object IngredientDTO],[object IngredientDTO],[object IngredientDTO]
ingredientsListData = null
arrList = null
I dont understand why this is happening. Surely the variables should contain the same info. I did some debugging and found that the event.result object did in fact contain the data as an ArrayCollection. In addition all the elements were objects of the type IngredientDTO and contained all the relevant fields and data. So again I don't understand for the life of me why its not working.
Can you not caste an ArrayList in java to an Array or an ArrayCollection?
Its like the data isn't being mapped or cast properlu from the ArrayList in java to either the Array or the ArrayCollection in actionscript.
This is driving me insane. Has anyone else had this problem and lived to tell the tale?

I figured it out. Silly, silly mistake. I was using the wrong import declaration.
import flex.messaging.io.ArrayList;
instead of
import java.util.ArrayList;
Silly silly...

Similar Messages

  • BlazeDS Java to ActionScript

    Hello, I am trying to send certain data types from a Java
    back-end through BlazeDS to my Flex clients. I wrote a ant script
    that takes JAXWS generated types and converts them into
    ActionScript types. One problem that I am facing is that the Seq
    classes are not being translated. What I mean is that JAXWS classes
    that contain List get wrapped into a class name ClassBSeq which
    contains a List<T> object. From the Java back-end I send the
    JAXWS types in a List to BlazeDS. The List contain a Seq classes
    that have List<t>. It seems on the client side that the main
    List gets translated but any List after that are null. Seems like
    it translated the top level List but no other List after that. Is
    there a way to tell the channel, in this case a
    StreamingAMFChannel, to transverse the object being translated?
    Here some code to help with my explanation.
    The Java Type:
    package handjam.gmiContainer;
    import java.util.List;
    public class GMIContainer {
    public List dataObjects;
    public String methodName;
    public GMIContainer() {
    public void setMethodName(String methodName) {
    this.methodName=methodName;
    public void setDataObjects(List dataObjects) {
    this.dataObjects=dataObjects;
    The ActionScript Type:
    package generated.handjam.gmiContainer
    import flash.utils.*;
    import mx.collections.ArrayCollection;
    [Bindable]
    [RemoteClass(alias="handjam.gmiContainer.GMIContainer")]
    public class GMIContainer
    private var _dataObjects:ArrayCollection;
    private var _methodName:String;
    public function GMIContainer()
    public function get dataObjects():ArrayCollection {
    return _dataObjects;
    public function get methodName():String {
    return _methodName;
    public function set
    dataObjects(dataObjects:ArrayCollection):void {
    trace("Setting the dataObject from Java = " + dataObjects);
    this._dataObjects=dataObjects;
    public function set methodName(methodName:String):void {
    trace("Setting the methods Name from Java = " + methodName);
    this._methodName=methodName;
    Code setting the List:
    GMIContainer container = new GMIContainer();
    List data = new ArrayList();
    data.add(id);
    data.add(mapItems);
    mapItems is a MapItemTypeSeq Java Type
    package mil.army.monmouth.webmap.data;
    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.XmlType;
    * Array of MapItemType
    * <p>Java class for MapItemTypeSeq complex type.
    * <p>The following schema fragment specifies the
    expected content contained within this class.
    * <pre>
    * &lt;complexType name="MapItemTypeSeq">
    * &lt;complexContent>
    * &lt;restriction base="{
    http://www.w3.org/2001/XMLSchema}anyType">
    * &lt;sequence>
    * &lt;element name="mapItems" type="{
    http://www.gmiweb.com/schema/mapdata}MapItemType"
    maxOccurs="unbounded" minOccurs="0"/>
    * &lt;/sequence>
    * &lt;/restriction>
    * &lt;/complexContent>
    * &lt;/complexType>
    * </pre>
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "MapItemTypeSeq", propOrder = {
    "mapItems"
    public class MapItemTypeSeq {
    protected List<MapItemType> mapItems;
    * Gets the value of the mapItems property.
    * <p>
    * 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 mapItems property.
    * <p>
    * For example, to add a new item, do as follows:
    * <pre>
    * getMapItems().add(newItem);
    * </pre>
    * <p>
    * Objects of the following type(s) are allowed in the list
    * {@link MapItemType }
    public List<MapItemType> getMapItems() {
    if (mapItems == null) {
    mapItems = new ArrayList<MapItemType>();
    return this.mapItems;
    Here is what the JAXWS Java class look like:
    package mil.army.monmouth.webmap.data {
    import flash.utils.*;
    import mx.collections.ArrayCollection;
    [Bindable]
    [RemoteClass(alias="mil.army.monmouth.webmap.data.MapItemTypeSeq")]
    public class MapItemTypeSeq {
    public var _mapItems:ArrayCollection;
    public function get mapItems():ArrayCollection {
    return _mapItems;
    public function set mapItems(mapItems:ArrayCollection):void
    this._mapItems=mapItems;
    when the message comes to my client the flashlog.txt tells me
    something like this.
    GMIContainer => MapItemTypeSeq
    _mapItems = (null)
    mapItems = null
    Has anyone else ran into this issue with complicated data
    objects? All examples I have seen uses very simple
    data types.
    Thanks for your help,
    dk

    Hi Martin. The way that AMF serialization/deserialization works for BlazeDS is the same regardless of which service is being used, so yes that code will work for messaging as well. On the server, the serialization/deserialization of messages happens at the endpoint. For an incoming message for example, the endpoint deserializes the message and then hands it off to the MessageBroker which decides which service/destination to deliver the message to.
    That was a good question. Thanks for asking it. Lots of people are used to doing custom serialization/deserialization with the RPC services (RemoteObject/RemotingService) but I'm not sure everyone realizes they can do this for messaging as well.
    -Alex

  • How to execute an ABAP Mapping after a Java Mapping

    Hi, i have found a Bug in XI and SAP said to me that the only solution is to execute an ABAP mapping after my java mapping.
    I have an IDOC to FILE scenario
    Could anyone orient me on what do i have to configure, so after my java mapping i can execute an abap mapping ?.
    Do i have to use process integration?
    thanks
    Mariano.

    i have developed a Java mapping originally, but XI has a bug. When you do not write anything to the outputStream XI instead of writing an emtpy file writes a file containing one byte ( 0x00 ) and this is a problem.
    SAP said to me that they will not fix this issue so they recomend me to create an abap mapping after my java mapping that will send no information if it receives this byte (0x00) and if not it will write all the information as received.
    My doubt regarding putting several mappings in the interface mapping configuration is this...
    Actual configuration:
    SOURCE MSG A -> ORIGINAL MAPPING -> TARGET MSG B
    Proposed configuration
    SOURCE. MSG A -> ORIGINAL MAPPING -> TARGET MSG B
    SOURCE. MSG A -> PATCH MAPPING -> TARGET MSG B
    I dont understand what receives de "patch mapping" it receives the structure from TARGET MSG B?
    regards
    mariano

  • Java Server Threading Problems

    Cross-posted at: http://www.java-forums.org/networking/41574-server-threading-confusion.html with no answers as of this edit.
    I'm very new to networking in java, and it's been a few months since I last did any major programming. I decided to try out networking, and I'm beginning to get a feel for it, but I've jumped in to trying to make a server for a multiplayer game, and I've gotten a bit stuck about how to do it, specifically on how to use threads to take care of my clients, and still be able to keep track of the threads so I can have the server send out info to them about where characters are, when the threads should close because someone wants to log out, etc.
    If anyone could help me out that would be awesome :D
    Here's some code:
    import java.net.*;
    import java.io.*;
    public class GameThread extends Thread // this is the actual thread class I made
      public Socket socket;
      public DataInputStream in;
      public DataOutputStream out; // a socket and two I/O streams for sending ints
      public GameThread(Socket socket) // typical constructor for getting socket
        try
          this.socket = socket;
          in = new DataInputStream(socket.getInputStream());
          out = new DataOutputStream(socket.getOutputStream());
        catch(Exception e)
          e.printStackTrace();
      public Socket getSocket() // I don't believe this is ever used. Ignore it.
        return socket;
      public void print() // Used to make sure the thread is active/knows about the socket
        System.out.println("GameThread says: " + socket);
      public void run()
        while(true)
    }Here's the class I use to manage the threads, or, at least, where I attempt to do so.
    import java.io.*;
    import java.util.ArrayList;
    import java.net.*;
    public class Threader
      public ArrayList clients;
      public ArrayList<GameThread> threads; // GameThread is the thread class above
      public Threader()
        threads = new ArrayList<GameThread>(); //constructor for this arraylist
      public void updateClientCount(ArrayList<Socket> clients) // this method works
        this.clients = clients; // it's not the problem.
      public void openThreads() //Here's probably where problems begin
        if(clients.size() > threads.size()) // this is to make the threads arraylist
          int f = clients.size()-threads.size();//equal length compared to clients arraylist
          while(f > 1)
         threads.add(null);
         f--;
        if(clients.size() < threads.size()) //same as above, just if threads is bigger
          threads.subList(clients.size(),(threads.size()-1)).clear();
        for(int h=0;h<clients.size();h++) //Here: for each client spot
          if(threads.get(h) == null) //Threads is tested in that spot to see if there's
          {              // A thread there
         GameThread gt = new GameThread((Socket)clients.get(h));
         threads.add(gt); //and if there isn't then it makes one
         gt.start(); // and starts it, but I guess this isn't happening as I want
          } // it to because in the method below none of the GameThreads print socket info
      public void print() //used to make sure the Threader/GameThread(s) is getting the info
        for(int y = 0;y<clients.size();y++)
          System.out.println("Threader says: " + clients.get(y));
        for(int x = 0;x<threads.size();x++)
          threads.get(x).print();
    }If anyone could help me find what is going on, or maybe (probably) I'm going about making a server wrong (I have another class with a serversocket and all, but I don't believe there are any bugs in it so it isn't included in here), so if I could get help that would be awesome.
    Thanks guys!
    Edited by: 848780 on Mar 30, 2011 8:55 PM
    Edited by: 848780 on Mar 30, 2011 11:55 PM

    Your thread management is back to front. All you need is a new thread per client, started every time you accept a new Socket. When you do that, if you want to manage them, enter the new thread into a collection, and when it exits remove it. But you normally don't need to keep track of client threads. You may want to keep track of client Sockets, in which case you should maintain a collection of Sockets on the same basis.

  • Sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loop

    sir i have given lot of effort but i am not able to solve my problem either with notifiers or with occurence fn,probably i do not know how to use these synchronisation tools.

    sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loopHi Sam,
    I want to pass along a couple of tips that will get you more and better response on this list.
    1) There is an un-written rule that says more "stars" is better than just one star. Giving a one star rating will probably eliminate that responder from individuals that are willing to anser your question.
    2) If someone gives you an answer that meets your needs, reply to that answer and say that it worked.
    3) If someone suggests that you look at an example, DO IT! LV comes with a wonderful set of examples that demonstate almost all of the core functionality of LV. Familiarity with all of the LV examples will get you through about 80% of the Certified LabVIEW Developer exam.
    4) If you have a question first search the examples for something tha
    t may help you. If you can not find an example that is exactly what you want, find one that is close and post a question along the lines of "I want to do something similar to example X, how can I modify it to do Y".
    5) Some of the greatest LabVIEW minds offer there services and advice for free on this exchange. If you treat them good, they can get you through almost every challenge that can be encountered in LV.
    6) If English is not your native language, post your question in the language you favor. There is probably someone around that can help. "We're big, we're bad, we're international!"
    Trying to help,
    Welcome to the forum!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Writing message mapping function in Java in integration repository

    Hi XI Pundits,
    I am new to XI. I was working on Message mapping in intergration repository.
    To map the source messages to target messages, we do graphical kind of mapping like drag and drop.
    There are some functions aavilable at the bottom like concatehate, trim and etc. which we use if we need to modify the source message and map to target.
    But in case we face a situation when we don't find the function which suits our requirement, I guess we need to write a new function. We can write these new function using Java only.
    Can someone throw some light on this ?
    <b>What do we do to invoke java editor in integartion reposity to write mapping function in java ?
    Can someone give an example of snippet of code ?</b>
    Thanks.

    Hi Tushar,
    Go thro this help link. You will get all info about User defined function.
    http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm
    To get more understanding on mapping go thro this link(PDF File)
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9202d890-0201-0010-1588-adb5e89a6638
    Hope this helps.
    regards,
    P.Venkat
    Message was edited by: Venkataramanan

  • Re-use message mapping from within java mapping?

    Hi there,                                                                               
    I have a question regarding java mapping. What I would like to do is to re-use an existing message mapping from within java mapping.
    Technicaly, message mapping is perfomed by com.sap.aii.mappingtool.tf3.AMappingProgram.execute, right? I would like to call that mapping program for a specifc message mapping from within my java mapping.
    Pseudo java code would look like this:
    public void execute(InputStream in, OutputStream out)
      throws StreamTransformationException {
    com.sap.aii.mappingtool.tf3.AMappingProgram.execute(in,out,'SomeMessageMapping');
    SomeMessageMapping is a message mapping that is defined in the integration repository.
    Is it possible? If so, could you provide me with some details?
    Thank you and best regards,
    Wolfgang

    Hi Wolfgang,
    very interesting idea?
    I would activa a dummy message mapping. than I would have a look in the file directory of the java-stack and try to find out the name of the *.class or *.jar file.
    On the other hand you could generate a tpz-transport-file an unpack this file, to explore the name of the *.class or *.jar
    Unfortunately I do not have access to the file system. So I can't explore the name.
    Regards Mario

  • Retrive message mapping error from java class

    Hi,
    I'm trying to create a scenario that if exist an error in the message mapping step this error will be inserted in a Ztable. I'm thinking in to call to the message mapping from a java class to catch the exception and this java class will be used in the interface mapping.
    Is it possible? If yes, How to call the message mapping from java code?
    Exists other possible solution?
    I need to do it because we want store all mapping errors in a Ztable. (Customer requeriment)
    Thanks, in advance
    Jose Manuel

    you can throw generic exceptions from the message mapping like this - /people/michal.krawczyk2/blog/2007/04/26/xipi-throwing-generic-exceptions-from-any-type-of-mapping
    you can then decide how to handle these exceptions

  • Re   Java Stored Procedure Problem

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

  • "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7"

    I'm in the process of publishing the following note (134280.1), titled "How to Resolve ORA-29532 Java 2
    Permission Problems in RDBMS 8.1.6 and 8.1.7".
    It will be accessible from Oracle Support's "Metalink" site.
    "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7".
    Problem Description
    Periodically an application running in the Enterprise Java Engine
    (EJE) formerly known as the "Oracle 8i JVM", "the JSERVER component", or
    the "Aurora JVM" will fail with a "java 2" permissions error having the
    following format :
    Note : Message shown below have been reformatted for easier readability.
    java.sql.SQLException: ORA-29532: Java call terminated by uncaught Java exception:
    usually followed by a detailed error message similar to one of the following
    messages :
    Example # 1
    java.security.AccessControlException: the Permission
    (java.net.SocketPermission hostname resolve)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Example # 2
    java.security.AccessControlException: the Permission
    (java.util.PropertyPermission * read,write)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Example # 3
    java.security.AccessControlException: the Permission
    (java.io.FilePermission \matt1.gif read)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Explanation
    The java 2 permission stated in line # 2 of each of the above "Examples"
    has not been granted to the user specified in line 4 of the above "Examples".
    Solution Description
    The methodology to solve this issue is identical for all java 2 permissions
    cases.
    1) Format a call "dbms_java.grant_permission" procedure as described below.
    2) Logon as SYS or SYSTEM
    3) Issue the TWO commands shown below
    4) Logoff as SYS or SYSTEM
    5) Retry your application
    For Example # 1
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.net.SocketPermission',
    'hostname',
    'resolve');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    For Example # 2
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.util.PropertyPermission',
    'read,write');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    For Example # 3
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.io.FilePermission',
    '\matt1.gif',
    'read');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    References
    For more details on java 2 permissions and security within the EJE, review
    Chapter 5, in the Java Developer's Guide. entitled,
    "Security For Oracle8i Java Applications"
    The RDBMS 8.1.7 version can be found at :
    http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/index.htm

    Hi, Don,
    I solved the problem of security exception I mentioned at java procedure topic as following:
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.SecurityException
    I tried to use your solution as following:
    call dbms_java.grant_permission('SDE', 'java.net.SocketPermission', 'ORCL.COHPA.UCF.EDU','resolve');
    but SQL*plus gave me a error message:
    invalid collumn.
    What's the problem?
    However, I call a grant command as following:
    SQL> grant JAVASYSPRIV to sde;
    and then that exception is gone. What's the difference between dbms_java.grant_permission and grant command?
    Thanks
    Bing
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by don -- oracle support:
    I'm in the process of publishing the following note (134280.1), titled "How to Resolve ORA-29532 Java 2
    Permission Problems in RDBMS 8.1.6 and 8.1.7".
    It will be accessible from Oracle Support's "Metalink" site.
    "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7".
    Problem Description
    <HR></BLOCKQUOTE>
    null

  • Calling a already existing mapping from a java mapping

    Hi.
    Is it possible to get a reference to an existing graphical mapping in a new java mapping or new user defined function?
    Rod

    Hi,
    If you have the mapping to run one after another and you need the output of mapping1 as input of mapping2 then you can add this in Interface mapping one after the other with required Message Interface.
    Don't know if you can refer to a standard Graphical mapping in a Java mapping?
    Regards
    Vijaya

  • Why the Error in ArrayList Program : java.util.NoSuchElementException

    import java.util.List;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.ListIterator;
    import java.util.Collections;
    import java.util.Random;
    public class ArrayListDoubt {
        public static void main(String[] args) {
    //        ArrayList Creation
            List arraylistA = new ArrayList();
            List arraylistB = new ArrayList();
    //        Adding elements to the ArrayList
            for (int i = 0; i < 5; i++) {
                arraylistA.add(new Integer(i));
            arraylistB.add("beginner");
            arraylistB.add("java");
            arraylistB.add("tutorial");
            arraylistB.add(".");
            arraylistB.add("com");
            arraylistB.add("java");
            arraylistB.add("site");
    // Iterating through the ArrayList to display the Contents.
            Iterator i1 = arraylistA.iterator();
            System.out.print("ArrayList arraylistA --> ");
            while (i1.hasNext()) {
                System.out.print(i1.next()+ " , ");
            System.out.println();
            System.out.print("ArrayList arraylistA --> ");
            for (int j=0; j < arraylistA.size(); j++) {
                System.out.print(arraylistA.get(j)+ " , ");
            System.out.println();
            Iterator i2 = arraylistB.iterator();
            System.out.println("ArrayList arraylistB --> ");
            while (i2.hasNext()) {
                System.out.print(i2.next()+ " , ");
            System.out.println();
            System.out.println("Using ListIterator to retireve ArrayList Elements");
            System.out.println();
            ListIterator li = arraylistA.listIterator();
    //       next(), hasPrevious(), hasNext(), hasNext() nextIndex() can be used with a
    //        ListIterator interface implementation
            System.out.println("ArrayList arraylistA --> ");
            while (li.hasNext()) {
                 System.out.print(i1.next()+ " , ");
    Output
    ArrayList arraylistA --> 0 , 1 , 2 , 3 , 4 ,
    ArrayList arraylistA --> 0 , 1 , 2 , 3 , 4 ,
    ArrayList arraylistB -->
    beginner , java , tutorial , . , com , java , site ,
    Using ListIterator to retireve ArrayList Elements
    ArrayList arraylistA -->
    Exception in thread "main" java.util.NoSuchElementException
         at java.util.AbstractList$Itr.next(AbstractList.java:427)
         at ArrayListDoubt.main(ArrayListDoubt.java:58)

    System.out.println("Using ListIterator to
    retireve ArrayList Elements");
    System.out.println();
    ListIterator li = arraylistA.listIterator();
    next(), hasPrevious(), hasNext(), hasNext()
    nextIndex() can be used with a
    /        ListIterator interface implementation
    System.out.println("ArrayList arraylistA -->
    while (li.hasNext()) {
         System.out.print(i1.next()+ " , ");
    }I think you mean to call the next()-method of the ListIterator li, but instead call i1, which is an already used Iterator.
    Where you want to iterate with ListIterator, change this line
    System.out.print(i1.next()+ " , ");to this
    System.out.print(li.next()+ " , ");and it works

  • Private static ArrayList within java.util.Arrays

    I was recently reviewing the code in java.util.Arrays (class version 1.45 - Java version 1.4.1). Beginning on line 2289 is a private static class named ArrayList. I'm completely baffled as to why the author created this slimmed-down private class (which would be, incidentally, returned by the Arrays.asList(Object[] a) method) rather than use the public class java.util.ArrayList. Can anyone offer an explanation?
    Thanks,
    John

    from JDK JAVADoc:
    asList
    public static List asList(Object[] a)
    Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray. The returned list is serializable.
    So the private ArrayList extends java.util.ArrayList, and any changes made this list does not affect the internal Object[].... in other words can not be changed.

  • Having problems mapping Java to ActionScript objects

    I am building a service that returns  a custom object tree to AS3 client over RPC call. Consider a couple of java classes, the TestObject  contains a list of TestInnerObject classes:
    public class TestObject
        public int id = 123;
        public String title = "Test object title";
        public List <String> stringList = new ArrayList<String>();
        public List <TestInnerObject> objectList = new ArrayList<TestInnerObject>();
        public TestObject()
            stringList.add("First string in the list");
            stringList.add("Second string in the list");
            objectList.add(new TestInnerObject(456));
            objectList.add(new TestInnerObject(789));
    public class TestInnerObject
        public int id = 0;
        public String title = "Test inner object title";
        public List <String> stringList = new ArrayList<String>();
        public TestInnerObject(int id)
            this.id = id;
    To work with them on the client a have a couple of the counterpart AS3 classes:
    [Bindable]
    [RemoteClass(alias="test.TestObject")]
    public class TestObject
         public var id:int;
         public var title:String;
         public var stringList:ArrayCollection;
         public var objectList:ArrayCollection;
         public function TestObject()
    [Bindable]
    [RemoteClass(alias="test.TestInnerObject")]
    public class TestInnerObject
         public var id:int;
         public var title:String;
         public var stringList:ArrayCollection;
         public function TestInnerObject()
    My understanding is that such a setup should return result deserialized into objects of TestObject.as and TestInnerObject.as types but I am getting plain AS3 objects that have all the fields but I can not cast them to the required types. This is hardly the optimal way to work with response.
    Could somone clarify what should be fixed?
    Thanks

    Adrian,
    Thanks for the feedback. I added Serializable interface to java classes and confirmed that the package is correct. I am still having the same problem though. Here is the result handler code. May be I am doing something wrong here? When I access result objects as Objects I can get the fields and transfer them to the proper classes (commented lines) but it's hardly efficient. As soon as I try to cast the result I am getting an error.
    private function onResult(result:AcknowledgeMessage):void
               //result.body contains the actual data
                trace("RPC Ok");
                trace(result.body);
                trace(result.body.id);
                trace(result.body.title);
                trace("");
                var testObject:TestObject = result.body as TestObject;
                //var testObject:TestObject = new TestObject();
                //testObject.id = result.body.id;
                //testObject.title = result.body.title;
                //testObject.stringList = result.body.stringList;
                //testObject.objectList = result.body.objectList;
                trace(testObject);
                trace("TestObject id: " + testObject.id);
                trace("TestObject title: " + testObject.title);
                trace("TestObject stringList: " + testObject.stringList);
                for each (var inner:TestInnerObject in testObject.objectList)
                    trace("Inner id: " + inner.id + " Inner tittle: " + inner.title);

  • Mapped windows drive -  Java performance problem

    I have a mapped windows drive to which I am writing files sized from few kbs to GBs, Now I am facing performance problem.
    Time for writing to local drive file with 4 MB - 1.6 seconds.
    Time for writing to mapped drive : 31 seconds.
    Please give me the ways to improve the mapped drive file access.
    Note I am using buffered streams and all , I am primarly expecting some thing from windows side.
    Renjith.

    I am copying the file from local drive to a mapped drive.
    ovxFileName = filename.substring(attachmentsFolder.length() + 1);
                   BufferedInputStream reader = new BufferedInputStream(
                             new FileInputStream(filename));
                   BufferedOutputStream writer = new BufferedOutputStream(
                             new FileOutputStream(commonLocationForOVX + File.separator
                                       + ovxFileName));
                   String str = "";
                   TimerUtility timer = new TimerUtility();
                   timer.startTimer();
                   int val = 0;
                   while ((val = reader.read()) != -1) {
                        writer.write(val);
                   writer.close();
                   reader.close();
                   timer.stopTimer();

Maybe you are looking for

  • Corrupted files

    Right my laptop isn't working. I formatted my hard drive and went to re-install WinXP. The problem being that at 56% installation,the battery on my laptop cut out. Now I can't even get the files installed by XP off my hard drive.They only show up on

  • RSEOUT00 run sends duplicate IDOCs causing duplicate payments

    We are using RSEOUT00 to send out payments to vendor using PAYEXT type. Program is run in background job mode on daily basis. Occasionally, 1 IDOC out of couple of hundred gives error and then program starts from the beginning and send out all IDOCs

  • RenderForm does not generate the form

    I wrote a servlet which renders a form in the doGet method. I created a simple form to test my java code if it works fine. My form(xdp file) only consists of a simple text. When I call the servlet from the address bar of my browser, http://host:8080/

  • DVDs and virtual drives sometimes don't mount

    After a long (so far untimed) time without restarting, my G5 will not recognize an inserted DVD. If I restart, all is well. Likewise, after a long period without restart, my PGP encrypted disks will not show up on the desktop; after a restart, all is

  • I need a shell script to move latest archivelogs from one server to another server..

    Hi,      I need a shell script to move latest archivelogs from one server to another server.. Thanks&Regards, Vel