Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ix.util.lisp
Class ObjectHash

    java.lang.Object
      ix.util.lisp.ObjectHash

    public class ObjectHash

extends java.lang.Object

Provides re-readable (within a JVM) names for objects.

The names have the form "{" class-name "-" hash-value "}", where the hash-value is obtained by calling `hash(Object)`. These names are used by `Lisp.printToString(Object)` and by `Lisp.readFromString(String)` and `LispReader`s in general, but they use a particular ObjectHash object that is private to the `Lisp` class.

Note that ordinary, strong references are used. Objects that have been given to `hash(Object)` will therefore not be garbage collected. This is to ensure that hash-names in strings will work even if no other reference to the object exists. Indeed, the only ref might be the user's memory of some output that contained a hash-name. The user can type in the same hash-name and get back the object.

The class-name part of hash-names is not checked. It is there only to make the names more meaningful.

Field Summary
`protected java.util.List` | `hashToObject`
`protected EqMap` | `objectToHash`

Constructor Summary
`ObjectHash()`

Method Summary
`int` | `hash(java.lang.Object obj)` Maps an object to an int that can be given to `unhash(int)` to get back the same (==) object.
`java.lang.String` | `hashName(java.lang.Object obj)` Returns a name of the form "{" class-name "-" hash-value "}", where the hash-value is obtained by calling `hash(Object)`.
`static void` | `main(java.lang.String[] argv)` Test loop
`java.lang.Object` | `parseHashName(java.lang.String name)` The inverse of `hashName(Object)`.
`java.lang.Object` | `unhash(int h)` The inverse of `hash(Object)`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### objectToHash

    protected EqMap objectToHash

### hashToObject

    protected java.util.List hashToObject

Constructor Detail

### ObjectHash

    public ObjectHash()

Method Detail

### hash

    public int hash(java.lang.Object obj)

  Maps an object to an int that can be given to `unhash(int)` to get back the same (==) object.

### unhash

    public java.lang.Object unhash(int h)

  The inverse of `hash(Object)`.

### hashName

    public java.lang.String hashName(java.lang.Object obj)

  Returns a name of the form "{" class-name "-" hash-value "}", where the hash-value is obtained by calling `hash(Object)`.

### parseHashName

    public java.lang.Object parseHashName(java.lang.String name)

  The inverse of `hashName(Object)`.

  Throws:
    `java.lang.IllegalArgumentException` - if a valid object hash value cannot be found in the name.

### main

    public static void main(java.lang.String[] argv)

  Test loop

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD