/* The contents of this file are subject to the AMP Open Community License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License on the AMP web site (http://www.tibet.iteso.mx/Guatemala/). Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific terms governing rights and limitations under the License. The Initial Developer of this software is Andres Montano Pellegrini. Portions created by Andres Montano Pellegrini are Copyright 2001 Andres Montano Pellegrini. All Rights Reserved. Contributor(s): ______________________________________. */ package org.thdl.tib.scanner; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; /** Specifies a subset of dictionaries among a set of dictionaries. Supports a maximum of 30 dictionaries. Unlike @BitDictionarySource, it provides the infrastructure to group definitions from various dictionaries. @author Andrés Montano Pellegrini */ public class ByteDictionarySource extends DictionarySource { //private BitDictionarySource dicts[]; private BitDictionarySource dicts[]; private boolean hasBrother; /** Last bit of word; 1 if there are more brothers.*/ private static final int lastBit = 64; private static final int allDicts=lastBit-1; public ByteDictionarySource() { dicts = null; hasBrother = false; } public ByteDictionarySource(BitDictionarySource dicts[], boolean hasBrother) { this.dicts = dicts; this.hasBrother = hasBrother; } public void insertDef(BitDictionarySource newDef, int n) { int i; BitDictionarySource newDicts[] = new BitDictionarySource[dicts.length+1]; for (i=0; i0) { hasBrother = true; n = n & allDicts; } else hasBrother = false; if (n==0) { dicts = null; return; } dicts = new BitDictionarySource[n]; for (i=0; i< dicts.length; i++) { dicts[i] = new BitDictionarySource(); do { n = (int) raf.readByte(); dicts[i].add(n & allDicts); } while((n & lastBit)>0); } } public boolean hasBrothers() { return this.hasBrother; } public boolean contains(int dict) { int i; if (dicts==null) return false; for (i=0; i=defTags.length) return null; tag = defTags[source[0]]; } for (i=1; i=defTags.length) return null; tag += defTags[source[i]]; } } return tag; } }