2.17.2: 2011-06-17

net.sf.basedb.core
Class BlockInfo

java.lang.Object
  extended by net.sf.basedb.core.BlockInfo

public final class BlockInfo
extends Object

A BlockInfo object is used to represent the uniqe identifiers of an ArrayDesignBlock. It can either be the block number or the metagrid coordinates. If block number is used metagrid can be added but they are not used to identify an arraydesignblock and it is possible to create two blocks with the same metagrid as long as the blocknumbers are uniqe.

Version:
2.0
Author:
Enell, Nicklas
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Field Summary
private  int block
          The block number.
private  int metaGridX
          The X coordinate of the block.
private  int metaGridY
          The Y coordinate of the block.
 
Constructor Summary
BlockInfo(int metaGridX, int metaGridY)
          Create a new block info using the meta coordinates.
BlockInfo(int block, int metaGridX, int metaGridY)
          Create a new block info using meta coordinates.
 
Method Summary
 boolean equals(Object o)
          Check if this object is equal to another BlockInfo object.
 int getBlock()
          Get the block number.
 int getMetaGridX()
          Get the row or x meta coordinate.
 int getMetaGridY()
          Get the column or y meta coordinate.
 int hashCode()
          Calculate the hash code for the object.
 String toString()
          Get the coordinate as [number;metaGridX,metaGridY]
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

block

private final int block
The block number.


metaGridY

private final int metaGridY
The Y coordinate of the block.


metaGridX

private final int metaGridX
The X coordinate of the block.

Constructor Detail

BlockInfo

public BlockInfo(int metaGridX,
                 int metaGridY)
          throws InvalidDataException
Create a new block info using the meta coordinates. Block is set to 0.

Parameters:
metaGridX - The row or x meta coordinate
metaGridY - The column or y meta coordinate
Throws:
InvalidDataException - If any of the coordinates is 0 or negative

BlockInfo

public BlockInfo(int block,
                 int metaGridX,
                 int metaGridY)
          throws InvalidDataException
Create a new block info using meta coordinates.

Parameters:
block - The block number which must be greater or equal than 0
metaGridX - The row or x meta coordinate, use 0 if unknown
metaGridY - The column or y meta coordinate, use 0 if unknown
Throws:
InvalidDataException - If the block number is 0 or negative
Method Detail

equals

public final boolean equals(Object o)
Check if this object is equal to another BlockInfo object. They are equal if they have the same block number > 0, or the same meta coordinates.

Overrides:
equals in class Object

hashCode

public final int hashCode()
Calculate the hash code for the object.

Overrides:
hashCode in class Object

toString

public final String toString()
Get the coordinate as [number;metaGridX,metaGridY]

Overrides:
toString in class Object

getMetaGridX

public int getMetaGridX()
Get the row or x meta coordinate.


getMetaGridY

public int getMetaGridY()
Get the column or y meta coordinate.


getBlock

public int getBlock()
Get the block number. If the block number is 0 it is considerd unknown and meta coordinates are used instead.


2.17.2: 2011-06-17