org.h2.pagestore

## Class Page

- java.lang.Object
- - org.h2.util.CacheObject
  - - org.h2.pagestore.Page

All Implemented Interfaces:
  java.lang.Comparable<CacheObject>

Direct Known Subclasses:
  PageBtree, PageDataLeaf, PageDataNode, PageDataOverflow, PageFreeList, PageStreamData, PageStreamTrunk

    public abstract class Page
    extends CacheObject

A page. Format:

- 0-3: parent page id (0 for root)
- 4-4: page type
- page-type specific data

### Field Summary

Fields
`protected long` `changeCount` When this page was changed the last time.
`static int` `FLAG_LAST` This is the last page of a chain.
`static int` `TYPE_BTREE_LEAF` A b-tree leaf page (without overflow: + FLAG_LAST).
`static int` `TYPE_BTREE_NODE` A b-tree node page (never has overflow pages).
`static int` `TYPE_DATA_LEAF` A data leaf page (without overflow: + FLAG_LAST).
`static int` `TYPE_DATA_NODE` A data node page (never has overflow pages).
`static int` `TYPE_DATA_OVERFLOW` A data overflow page (the last page: + FLAG_LAST).
`static int` `TYPE_EMPTY` An empty page.
`static int` `TYPE_FREE_LIST` A page containing a list of free pages (the last page: + FLAG_LAST).
`static int` `TYPE_STREAM_DATA` A stream data page.
`static int` `TYPE_STREAM_TRUNK` A stream trunk page.

### Fields inherited from class org.h2.util.CacheObject

`cacheChained, cacheNext, cachePrevious`

### Constructor Summary

Constructors
Constructor and Description
`Page()`

### Method Summary

Methods
`protected static void` `add(int[] array, int from, int to, int x)` Add a value to a subset of the array.
`boolean` `canMove()` If this page can be moved.
`protected static int[]` `insert(int[] old, int oldSize, int pos, int x)` Insert a value in an array.
`protected static long[]` `insert(long[] old, int oldSize, int pos, long x)` Insert a value in an array.
`static <T> T[]` `insert(T[] old, int oldSize, int pos, T x)` Insert a value in an array.
`abstract void` `moveTo(Session session, int newPos)` Copy the data to a new location, change the parent to point to the new location, and free up the current page.
`protected static int[]` `remove(int[] old, int oldSize, int pos)` Delete a value in an array.
`protected static long[]` `remove(long[] old, int oldSize, int pos)` Delete a value in an array.
`static <T> T[]` `remove(T[] old, int oldSize, int pos)` Delete a value in an array.
`abstract void` `write()` Write the page.

### Methods inherited from class org.h2.util.CacheObject

`canRemove, compareTo, getMemory, getPos, isChanged, isStream, setChanged, setPos`

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

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

### Field Detail

#### FLAG_LAST

    public static final int FLAG_LAST

This is the last page of a chain.

See Also:
  Constant Field Values

#### TYPE_EMPTY

    public static final int TYPE_EMPTY

An empty page.

See Also:
  Constant Field Values

#### TYPE_DATA_LEAF

    public static final int TYPE_DATA_LEAF

A data leaf page (without overflow: + FLAG_LAST).

See Also:
  Constant Field Values

#### TYPE_DATA_NODE

    public static final int TYPE_DATA_NODE

A data node page (never has overflow pages).

See Also:
  Constant Field Values

#### TYPE_DATA_OVERFLOW

    public static final int TYPE_DATA_OVERFLOW

A data overflow page (the last page: + FLAG_LAST).

See Also:
  Constant Field Values

#### TYPE_BTREE_LEAF

    public static final int TYPE_BTREE_LEAF

A b-tree leaf page (without overflow: + FLAG_LAST).

See Also:
  Constant Field Values

#### TYPE_BTREE_NODE

    public static final int TYPE_BTREE_NODE

A b-tree node page (never has overflow pages).

See Also:
  Constant Field Values

#### TYPE_FREE_LIST

    public static final int TYPE_FREE_LIST

A page containing a list of free pages (the last page: + FLAG_LAST).

See Also:
  Constant Field Values

#### TYPE_STREAM_TRUNK

    public static final int TYPE_STREAM_TRUNK

A stream trunk page.

See Also:
  Constant Field Values

#### TYPE_STREAM_DATA

    public static final int TYPE_STREAM_DATA

A stream data page.

See Also:
  Constant Field Values

#### changeCount

    protected long changeCount

When this page was changed the last time.

### Constructor Detail

#### Page

    public Page()

### Method Detail

#### moveTo

    public abstract void moveTo(Session session,
              int newPos)

Copy the data to a new location, change the parent to point to the new location, and free up the current page.

Parameters:
  `session` - the session
  `newPos` - the new position

#### write

    public abstract void write()

Write the page.

#### insert

    public static <T> T[] insert(T[] old,
                 int oldSize,
                 int pos,
                 T x)

Insert a value in an array. A new array is created if required.

Parameters:
  `old` - the old array
  `oldSize` - the old size
  `pos` - the position
  `x` - the value to insert
Returns:
  the (new) array

#### remove

    public static <T> T[] remove(T[] old,
                 int oldSize,
                 int pos)

Delete a value in an array. A new array is created if required.

Parameters:
  `old` - the old array
  `oldSize` - the old size
  `pos` - the position
Returns:
  the (new) array

#### insert

    protected static long[] insert(long[] old,
                int oldSize,
                int pos,
                long x)

Insert a value in an array. A new array is created if required.

Parameters:
  `old` - the old array
  `oldSize` - the old size
  `pos` - the position
  `x` - the value to insert
Returns:
  the (new) array

#### remove

    protected static long[] remove(long[] old,
                int oldSize,
                int pos)

Delete a value in an array. A new array is created if required.

Parameters:
  `old` - the old array
  `oldSize` - the old size
  `pos` - the position
Returns:
  the (new) array

#### insert

    protected static int[] insert(int[] old,
               int oldSize,
               int pos,
               int x)

Insert a value in an array. A new array is created if required.

Parameters:
  `old` - the old array
  `oldSize` - the old size
  `pos` - the position
  `x` - the value to insert
Returns:
  the (new) array

#### remove

    protected static int[] remove(int[] old,
               int oldSize,
               int pos)

Delete a value in an array. A new array is created if required.

Parameters:
  `old` - the old array
  `oldSize` - the old size
  `pos` - the position
Returns:
  the (new) array

#### add

    protected static void add(int[] array,
           int from,
           int to,
           int x)

Add a value to a subset of the array.

Parameters:
  `array` - the array
  `from` - the index of the first element (including)
  `to` - the index of the last element (excluding)
  `x` - the value to add

#### canMove

    public boolean canMove()

If this page can be moved. Transaction log and free-list pages can not.

Returns:
  true if moving is allowed