Package org.eclipse.m2m.atl.emftvm.impl.resource

## Class ConstantPool

- java.lang.Object
- - org.eclipse.m2m.atl.emftvm.impl.resource.ConstantPool

    public class ConstantPool
    extends java.lang.Object

Constant pool implementation for binary EMFTVM file format.

### Nested Class Summary

Nested Classes
`class` `ConstantPool.CreateConstantsSwitch` Creates constant pool entries for EMFTVM elements.

### Field Summary

Fields
`protected ConstantPool.CreateConstantsSwitch` `createConstants`

### Constructor Summary

Constructors
`ConstantPool()` Creates a new `ConstantPool`.
`ConstantPool​(int size)` Creates a new `ConstantPool`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `add​(java.lang.Object value)` Adds
`void` `createConstants​(Module module)` Creates a constant table for the given module.
`java.lang.Object` `get​(int i)` Returns the constant at index
`int` `indexOf​(java.lang.Object value)` Returns the index of
`void` `read​(java.io.DataInputStream in)` Reads constant table from
`int` `size()` Returns the size of the constant pool.
`void` `write​(java.io.DataOutputStream out)` Writes constant pool to

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### createConstants

    protected ConstantPool.CreateConstantsSwitch createConstants

### Constructor Detail

#### ConstantPool

    public ConstantPool()

Creates a new `ConstantPool`.

#### ConstantPool

    public ConstantPool​(int size)

Creates a new `ConstantPool`.

Parameters:
  `size` - the initial pool size

### Method Detail

#### get

    public java.lang.Object get​(int i)

Returns the constant at index

    i

.

Parameters:
  `i` - the constant index
Returns:
  the constant, or `null`

#### indexOf

    public int indexOf​(java.lang.Object value)
                throws java.lang.IllegalArgumentException

Returns the index of

    value

in the constant pool.

Parameters:
  `value` - the value to look up
Returns:
  the index of value in the constant pool
Throws:
  `java.lang.IllegalArgumentException` - if value not found

#### size

    public int size()

Returns the size of the constant pool.

Returns:
  The size of the constant pool

#### add

    public void add​(java.lang.Object value)

Adds

    value

to the constant pool, if necessary.

Parameters:
  `value` - the value to add

#### read

    public void read​(java.io.DataInputStream in)
              throws java.io.IOException

Reads constant table from

    in

.

Parameters:
  `in` - the input stream
Throws:
  `java.io.IOException`

#### createConstants

    public void createConstants​(Module module)

Creates a constant table for the given module.

Parameters:
  `module` - the module

#### write

    public void write​(java.io.DataOutputStream out)
               throws java.io.IOException

Writes constant pool to

    out

.

Parameters:
  `out` - the output stream
Throws:
  `java.io.IOException`