// 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: TBranch.java
package hep.rootio.reps;
import hep.rootio.*;
import hep.rootio.implementation.*;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Hashtable;
// Referenced classes of package hep.rootio.reps:
// TObjArray, TBasket
public class TBranch extends SpecificRootObject
{
public TBranch()
{
}
public void readMembers(RootInput in, int v)
throws IOException
{
super.readMembers(in, v);
raf = in.getRAF();
TObjArray leaves = (TObjArray)get("fLeaves");
if(leaves != null)
{
for(int i = 0; i < leaves.size(); i++)
{
Leaf leaf = (Leaf)leaves.elementAt(i);
leaf.setBranch(this);
}
}
}
Object getValue(Leaf leaf, int index)
throws IOException
{
int i = findBasketForIndex(index);
TBasket basket = getBasket(i);
int offsets[] = (int[])get("fBasketEntry");
return basket.getEntry(index, offsets[i], leaf);
}
public Object getEntry(int index)
throws IOException
{
TObjArray leaves = (TObjArray)get("fLeaves");
Leaf leaf = (Leaf)leaves.elementAt(0);
return getValue(leaf, index);
}
private int findBasketForIndex(int index)
{
int nEntries = ((Number)get("fEntryNumber")).intValue();
if(index < 0 || index >= nEntries)
throw new ArrayIndexOutOfBoundsException("index=" + index);
int entries[] = (int[])get("fBasketEntry");
int n = ((Integer)get("fWriteBasket")).intValue();
for(int i = 0; i < n; i++)
if(index >= entries[i] && index < entries[i + 1])
return i;
return n;
}
private TBasket getBasket(int index)
throws IOException
{
TObjArray baskets = (TObjArray)get("fBaskets");
TBasket basket = (TBasket)baskets.elementAt(index);
if(basket != null)
return basket;
int seek[] = (int[])get("fBasketSeek");
raf.seek(seek[index]);
basket = (TBasket)raf.readObject("TBasket");
int len = ((Integer)get("fEntryOffsetLen")).intValue();
if(len > 0)
basket.readEntryOffsets(len);
baskets.setElementAt(index, basket);
return basket;
}
public int getNEntries()
{
return ((Number)get("fEntries")).intValue();
}
public RootObjectRepresentation getBranchForName(String name)
{
if(map == null)
buildMap();
return (RootObjectRepresentation)map.get(name);
}
public RootObjectRepresentation getBranchForMangledName(String name)
{
if(map == null)
buildMap();
return (RootObjectRepresentation)mangledMap.get(name);
}
private void buildMap()
{
map = new Hashtable();
mangledMap = new Hashtable();
TObjArray branches = (TObjArray)get("fBranches");
int size = branches.size();
for(int i = 0; i < size; i++)
{
RootObjectRepresentation b = branches.elementAt(i);
String bName = b.get("fName").toString();
int pos = bName.indexOf('[');
if(pos > 0)
bName = bName.substring(0, pos);
pos = bName.indexOf('.');
if(pos > 0)
bName = bName.substring(pos + 1);
map.put(bName, b);
mangledMap.put(nameMangler.mangleMember(bName), b);
}
}
private RootRandomAccessFile raf;
private Hashtable map;
private Hashtable mangledMap;
private static final NameMangler nameMangler = NameMangler.instance();
}
Ads help maintain this website.