/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Implementation of Name.Table that stores all names in a single shared
* byte array, expanding it as needed. This avoids the overhead incurred
* by using an array of bytes for each name.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
// maintain a freelist of recently used name tables for reuse.
if (t != null) {
return t;
}
}
return new SharedNameTable(names);
}
}
/** The hash table for names.
*/
/** The shared byte array holding all encountered names.
*/
public byte[] bytes;
/** The mask to be used for hashing
*/
private int hashMask;
/** The number of filled bytes in `names'.
*/
/** Allocator
* @param names The main name table
* @param hashSize the (constant) size to be used for the hash table
* needs to be a power of two.
* @param nameSize the initial size of the name table.
*/
super(names);
}
}
// System.err.println("doubling name buffer of length " + names.length + " to fit " + len + " chars");//DEBUG
}
while (n != null &&
(n.getByteLength() != nbytes ||
n = n.next;
}
if (n == null) {
n = new NameImpl(this);
hashes[h] = n;
if (nbytes == 0) {
this.nc++;
}
}
return n;
}
while (n != null &&
n = n.next;
}
if (n == null) {
// System.err.println("doubling name buffer of length + " + names.length + " to fit " + len + " bytes");//DEBUG
}
n = new NameImpl(this);
hashes[h] = n;
if (len == 0) {
this.nc++;
}
}
return n;
}
public void dispose() {
dispose(this);
}
/** The next name occupying the same hash bucket.
*/
/** The index where the bytes of this name are stored in the global name
* buffer `byte'.
*/
int index;
/** The number of bytes in this name.
*/
int length;
super(table);
}
public int getIndex() {
return index;
}
public int getByteLength() {
return length;
}
public byte getByteAt(int i) {
return getByteArray()[index + i];
}
public byte[] getByteArray() {
}
public int getByteOffset() {
return index;
}
/** Return the hash value of this name.
*/
public int hashCode() {
return index;
}
/** Is this name equal to other?
*/
return
else return false;
}
}
}