// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   TObjArray.java

package hep.rootio.reps;

import hep.rootio.RootInput;
import hep.rootio.RootObjectRepresentation;
import hep.rootio.implementation.AbstractRootObject;
import hep.rootio.implementation.HollowRootObject;
import hep.rootio.implementation.SpecificRootObject;

import java.io.DataInput;
import java.io.IOException;
import java.io.PrintStream;
import java.util.AbstractList;

public class TObjArray extends SpecificRootObject
{
    private class TObjArrayProxy extends AbstractList
        implements hep.rootio.interfaces.TObjArray
    {

        public int size()
        {
            return TObjArray.this.size();
        }

        public Object get(int index)
        {
            return array[index] != null ? array[index].getProxy() : null;
        }

        public int getLowerBound()
        {
            return lowerBound;
        }

        public int getUpperBound()
        {
            return (lowerBound + array.length) - 1;
        }

        public Object getElementAt(int index)
        {
            return get(index - lowerBound);
        }

        private TObjArrayProxy()
        {
        }

    }


    public TObjArray()
    {
    }

    public void readMembers(RootInput in, int v)
        throws IOException
    {
        if(v > 3)
            throw new IOException("Version mismatch TObjArray: " + v);
        if(v > 2)
            put("fobject", in.readObject("TObject"));
        if(v > 1)
            put("fname", in.readObject("TString"));
        int nobjects = in.readInt();
        put("fLowerBound", lowerBound = in.readInt());
        array = new RootObjectRepresentation[nobjects];
        for(int i = 0; i < nobjects; i++)
            array[i] = in.readObjectRef();

        put("fArray", array);
    }

    public void read(RootInput in)
        throws IOException
    {
        try
        {
            int v = in.readVersion(this);
            readMembers(in, v);
            in.checkLength(this);
        }
        catch(IOException x)
        {
            System.err.println("Error occured while reading " + getRootClass());
            dump();
            throw x;
        }
    }

    public Object createProxy()
    {
        return new TObjArrayProxy();
    }

    RootObjectRepresentation elementAt(int index)
    {
        RootObjectRepresentation array[] = (RootObjectRepresentation[])get("fArray");
        return array[index];
    }

    int size()
    {
        int n;
        for(n = array.length; n > 0 && array[n - 1] == null; n--);
        return n;
    }

    void setElementAt(int index, RootObjectRepresentation value)
    {
        RootObjectRepresentation array[] = (RootObjectRepresentation[])get("fArray");
        array[index] = value;
    }

    private RootObjectRepresentation array[];
    private int lowerBound;


}

 

Ads help maintain this website.