001    /**
002     * Copyright (C) 2010, Skype Limited
003     *
004     * All intellectual property rights, including but not limited to copyrights,
005     * trademarks and patents, as well as know how and trade secrets contained in,
006     * relating to, or arising from the internet telephony software of
007     * Skype Limited (including its affiliates, "Skype"), including without
008     * limitation this source code, Skype API and related material of such
009     * software proprietary to Skype and/or its licensors ("IP Rights") are and
010     * shall remain the exclusive property of Skype and/or its licensors.
011     * The recipient hereby acknowledges and agrees that any unauthorized use of
012     * the IP Rights is a violation of intellectual property laws.
013     *
014     * Skype reserves all rights and may take legal action against infringers of
015     * IP Rights.
016     *
017     * The recipient agrees not to remove, obscure, make illegible or alter any
018     * notices or indications of the IP Rights and/or Skype's rights and
019     * ownership thereof.
020     */
021    
022    package com.skype.ipc;
023    
024    import java.io.IOException;
025    import java.util.ArrayList;
026    
027    import com.skype.util.Log;
028    
029    
030    public class ResponseListElement extends AbstractDecoder
031    {
032            private static final String TAG="ResponseListElement";
033            public static final int INITIAL_LIST_SIZE=16;
034            private ArrayList<Object> items;
035            private int getindex;
036            
037            ResponseListElement(Transport in) throws IOException
038            {
039                    super(in);
040                    getindex=0;
041                    items=new ArrayList<Object>(INITIAL_LIST_SIZE);
042                    while(true)
043                    {
044                            int kind=ioTransport.read();
045                            // there are no tags in lists
046                            Object o=decodeOneOfKind(kind);
047                            if(o==null)
048                            {
049                                    //Log.d(TAG,"In list: Decoding returned null");
050                                    items.trimToSize();
051                                    return;
052                            }
053                            items.add(o);
054                            //Log.d(TAG,"In list: added parm of kind='"+kind+"'");                  
055                    }
056            }
057    
058            public Object GetNext()
059            {
060                    try
061                    {
062                            return items.get(getindex++);
063                    }
064                    catch(ArrayIndexOutOfBoundsException e)
065                    {
066                            Log.e(TAG,"GetNext() called even though there is no more items in list");
067                            return null;                    
068                    }
069            }
070    
071            public boolean HasMore()
072            {
073                    return(getindex<items.size());
074            }
075            
076    }