# ClassMap

## Content

# Class: ClassMap

Represents the value of the **ClassMap** entry of the structure tree: a dictionary that maps
name objects designating attribute classes to the corresponding collections of attribute
objects ([AttrCollection](AttrCollection)). See the PDF specification for details.

Keys are PDF names (plain JS strings); values are [AttrCollection](AttrCollection) objects.

Obtain it from [StructTreeRoot#classMap](StructTreeRoot#classmap).

## Extends

- [`ObjectBase`](ObjectBase)

## Accessors

### count

#### Get Signature

```ts
get count(): number;
```

Gets the number of entries in the map.

##### Returns

`number`

***

### id

#### Get Signature

```ts
get id(): number;
```

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`ObjectBase`](ObjectBase).[`id`](ObjectBase#id)

***

### om

#### Get Signature

```ts
get om(): ObjectManager;
```

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](ObjectBase#om)

## Methods

### clear()

```ts
clear(): void;
```

Removes all entries from the map.

#### Returns

`void`

***

### contains()

```ts
contains(key): boolean;
```

Determines whether the map contains the specified key.

#### Parameters

##### key

`string`

The attribute class name to check.

#### Returns

`boolean`

true if the key is present, false otherwise.

***

### entries()

```ts
entries(): [string, AttrCollection][];
```

Gets the array of key/value pairs in the map.

#### Returns

\[`string`, [`AttrCollection`](AttrCollection)\][]

***

### free()

```ts
free(): void;
```

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](ObjectBase#free)

***

### get()

```ts
get(key): AttrCollection;
```

Gets the collection of attribute objects mapped to the specified key.

#### Parameters

##### key

`string`

The attribute class name.

#### Returns

[`AttrCollection`](AttrCollection)

The mapped [AttrCollection](AttrCollection), or `undefined` if the key is not present.

***

### getOrCreate()

```ts
getOrCreate(key): AttrCollection;
```

Gets the collection of attribute objects mapped to the specified key, creating and storing
an empty [AttrCollection](AttrCollection) if the key is not yet present.

#### Parameters

##### key

`string`

The attribute class name.

#### Returns

[`AttrCollection`](AttrCollection)

The [AttrCollection](AttrCollection) mapped to the key.

***

### keys()

```ts
keys(): string[];
```

Gets the array of keys (the attribute class names).

#### Returns

`string`[]

***

### rebind()

```ts
rebind(omTo): void;
```

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### remove()

```ts
remove(key): boolean;
```

Removes the entry with the specified key.

#### Parameters

##### key

`string`

The attribute class name to remove.

#### Returns

`boolean`

true if the entry was actually removed, false otherwise.

***

### set()

```ts
set(key, value): void;
```

Maps the specified attribute class name to a collection of attribute objects.

#### Parameters

##### key

`string`

The attribute class name.

##### value

[`AttrCollection`](AttrCollection)

The [AttrCollection](AttrCollection) to map to the key.

#### Returns

`void`
