01: /*
02: * JFolder, Copyright 2001-2006 Gary Steinmetz
03: *
04: * Distributable under LGPL license.
05: * See terms of license at gnu.org.
06: */
07:
08: package org.jfolder.common;
09:
10: //base classes
11: import java.io.PrintStream;
12: import java.io.PrintWriter;
13:
14: //project specific classes
15:
16: //other classes
17:
18: public class ImmutableByteArray {
19:
20: private byte value[] = null;
21:
22: private ImmutableByteArray(byte inValue[], boolean inClone) {
23: if (inClone) {
24: this .value = (byte[]) inValue.clone();
25: } else {
26: this .value = inValue;
27: }
28: }
29:
30: public final static ImmutableByteArray newInstance(byte inValue[],
31: boolean inClone) {
32: return new ImmutableByteArray(inValue, inClone);
33: }
34:
35: public final static ImmutableByteArray newInstance(byte inValue[]) {
36: return new ImmutableByteArray(inValue, true);
37: }
38:
39: public int getLength() {
40: return this .value.length;
41: }
42:
43: public byte getByte(int inIndex) {
44: return this .value[inIndex];
45: }
46:
47: public byte[] copyByteArray() {
48: return (byte[]) this .value.clone();
49: }
50:
51: public boolean equals(Object inObject) {
52:
53: boolean outValue = false;
54:
55: if (inObject != null && inObject instanceof ImmutableByteArray) {
56: ImmutableByteArray iba = (ImmutableByteArray) inObject;
57: outValue = this .value.equals(iba.value);
58: }
59:
60: return outValue;
61: }
62:
63: public int hashCode() {
64: return this.value.hashCode();
65: }
66:
67: }
|