/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/**
* An Extremely Fast Tagged Attribute Read-only File Reader
* Created on October 12, 2005
*
* @author Chandan
*/
public class EftarFileReader {
private final RandomAccessFile f;
private boolean isOpen;
public class FNode {
public long offset;
public long hash;
public int childOffset;
public int numChildren;
public int tagOffset;
offset = f.getFilePointer();
//System.err.println("offset " + offset);
try {
childOffset = f.readUnsignedShort();
numChildren = f.readUnsignedShort();
tagOffset = f.readUnsignedShort();
} catch (EOFException e) {
numChildren = 0;
tagOffset = 0;
}
//System.err.println("offset " + offset + " num children " + numChildren + " tagOff " + tagOffset);
}
this.childOffset = childOffset;
this.numChildren = num;
}
return null;
}
}
//System.err.printf(" Searching [%x] in %5d elem from %x\n", hash, len, start);
int b = 0;
int e = len;
while (b <= e) {
int m = (b + e) / 2;
b = m + 1;
e = m - 1;
} else {
return new FNode(mhash, f.getFilePointer() - 8l, f.readUnsignedShort(), f.readUnsignedShort(), f.readUnsignedShort());
}
}
return null;
}
if (tagOffset == 0) {
return null;
}
byte[] tagString;
if (childOffset == 0) {
tagString = new byte[numChildren];
} else {
}
if (len == -1) {
throw new EOFException();
}
}
try {
} catch (EOFException e) { // NOPMD
// ignore
} catch (IOException e) {
}
}
}
}
isOpen = true;
}
f.seek(0);
return n;
}
n = next;
}
if (!toks.hasMoreElements()) {
return next;
}
return null;
}
}
}
return null;
}
f.seek(0);
long tagOffset = 0;
int tagLength = 0;
while (toks.hasMoreTokens()) {
continue;
}
break;
}
} else {
}
}
n = next;
}
if (tagOffset != 0) {
if (len == -1) {
throw new EOFException();
}
}
return "";
}
/**
* Check, whether this instance has been already closed.
* @return {@code true} if closed.
*/
public boolean isClosed() {
return !isOpen;
}
public void close() {
if (isOpen) {
isOpen = false;
}
}
}