/** * Special method that is called by Java deserialization process. Any HashCons'ed object should implement it, in order to make * sure that all equal objects are consolidated. */ private Object readResolve() { return findOrCreate(this.val); }
/** * New Atom containing last count bytes */ public final Atom right(int count) { return findOrCreate(val, val.length - count, count); }
/** * Special method that is called by Java deserialization process. Any HashCons'ed object should implement it, in order to make * sure that all equal objects are consolidated. */ private Object readResolve() { return findOrCreate(this.val); }
/** * New Atom containing first count bytes */ public final Atom left(int count) { return findOrCreate(val, 0, count); }
/** * New Atom containing last count bytes */ public final Atom right(int count) { return findOrCreate(val, val.length - count, count); }
/** * Return array descriptor corresponding to "this" array-element descriptor. this: array-element descriptor - something like "I" * or "Ljava/lang/Object;" * * @return array descriptor - something like "[I" or "[Ljava/lang/Object;" */ public final Atom arrayDescriptorFromElementDescriptor() { byte sig[] = new byte[1 + val.length]; sig[0] = (byte) '['; for (int i = 0, n = val.length; i < n; ++i) sig[i + 1] = val[i]; return findOrCreate(sig); }
/** * New Atom containing first count bytes */ public final Atom left(int count) { return findOrCreate(val, 0, count); }
public static synchronized Atom findOrCreate(ImmutableByteArray b) { if (b == null) { throw new IllegalArgumentException("b is null"); } return findOrCreate(b.b); }
public static synchronized Atom findOrCreate(ImmutableByteArray b, int start, int length) { if (b == null) { throw new IllegalArgumentException("b is null"); } return findOrCreate(b.b, start, length); }
/** * Parse "this" array descriptor to obtain descriptor for array's element type. this: array descriptor - something like "[I" * * @return array element descriptor - something like "I" */ public final Atom parseForArrayElementDescriptor() throws IllegalArgumentException { if (val.length == 0) { throw new IllegalArgumentException("empty atom is not an array"); } return findOrCreate(val, 1, val.length - 1); }
private static Atom concat(byte c, byte[] bs) { byte[] val = new byte[bs.length + 1]; val[0] = c; System.arraycopy(bs, 0, val, 1, bs.length); return findOrCreate(val); }
public static synchronized Atom findOrCreate(ImmutableByteArray b, int start, int length) { if (b == null) { throw new IllegalArgumentException("b is null"); } return findOrCreate(b.b, start, length); }
public static synchronized Atom findOrCreate(ImmutableByteArray b) { if (b == null) { throw new IllegalArgumentException("b is null"); } return findOrCreate(b.b); }
/** * Parse "this" array descriptor to obtain descriptor for array's element type. this: array descriptor - something like "[I" * * @return array element descriptor - something like "I" */ public final Atom parseForArrayElementDescriptor() throws IllegalArgumentException { if (val.length == 0) { throw new IllegalArgumentException("empty atom is not an array"); } return findOrCreate(val, 1, val.length - 1); }
private static Atom concat(byte c, byte[] bs) { byte[] val = new byte[bs.length + 1]; val[0] = c; System.arraycopy(bs, 0, val, 1, bs.length); return findOrCreate(val); }
/** * Find or create an atom. * * @param utf8 atom value, as utf8 encoded bytes * @return atom * @throws IllegalArgumentException if utf8 is null */ public static Atom findOrCreateUtf8Atom(byte[] utf8) { if (utf8 == null) { throw new IllegalArgumentException("utf8 is null"); } return findOrCreate(utf8); }
public static Atom concat(Atom ma, Atom mb) { if ((ma == null ) || (mb == null)) { throw new IllegalArgumentException("argument may not be null!"); } byte[] val = Arrays.copyOf(ma.val, ma.val.length + mb.val.length); System.arraycopy(mb.val, 0, val, ma.val.length, mb.val.length); return findOrCreate(val); }
public static Atom concat(Atom ma, Atom mb) { if ((ma == null ) || (mb == null)) { throw new IllegalArgumentException("argument may not be null!"); } byte[] val = Arrays.copyOf(ma.val, ma.val.length + mb.val.length); System.arraycopy(mb.val, 0, val, ma.val.length, mb.val.length); return findOrCreate(val); }
/** * Find or create an atom. * * @param str atom value, as string literal whose characters are unicode * @return atom */ public static Atom findOrCreateUnicodeAtom(String str) { byte[] utf8 = UTF8Convert.toUTF8(str); return findOrCreate(utf8); }
/** * Find or create an atom. * * @param str atom value, as string literal whose characters are unicode * @return atom */ public static Atom findOrCreateUnicodeAtom(String str) { byte[] utf8 = UTF8Convert.toUTF8(str); return findOrCreate(utf8); }