it.unimi.dsi.webgraph.labelling
Class AbstractIntLabel

java.lang.Object
  extended by it.unimi.dsi.webgraph.labelling.AbstractLabel
      extended by it.unimi.dsi.webgraph.labelling.AbstractIntLabel
All Implemented Interfaces:
FlyweightPrototype<Label>, Label
Direct Known Subclasses:
FixedWidthIntLabel, GammaCodedIntLabel

public abstract class AbstractIntLabel
extends AbstractLabel
implements Label

An abstract (single-attribute) integer label.

This class provides basic methods for a label holding an integer. Concrete implementations may impose further requirements on the integer.

Implementing subclasses must provide constructors, Label.copy(), Label.fromBitStream(it.unimi.dsi.io.InputBitStream, int), Label.toBitStream(it.unimi.dsi.io.OutputBitStream, int) and possibly override toString().


Field Summary
protected  String key
          The key of the attribute represented by this label.
 int value
          The value of the attribute represented by this label.
 
Constructor Summary
AbstractIntLabel(String key, int value)
          Creates an int label with given key and value.
 
Method Summary
 String[] attributeKeys()
          All attribute keys (in arbitrary order).
 Class<?>[] attributeTypes()
          The types of all attributes in the same order as they are returned by Label.attributeKeys().
 boolean equals(Object x)
           
 Object get()
          The value associated to the well-known attribute.
 Object get(String key)
          The value associated to the attribute with given key.
 double getDouble()
          The value associated to the well-known attribute, provided that the latter has a type that fits a double.
 double getDouble(String key)
          The value associated to the attribute with given key, provided that the latter has a type that fits a double.
 float getFloat()
          The value associated to the well-known attribute, provided that the latter has a type that fits a float.
 float getFloat(String key)
          The value associated to the attribute with given key, provided that the latter has a type that fits a float.
 int getInt()
          The value associated to the well-known attribute, provided that the latter has a type that fits a int.
 int getInt(String key)
          The value associated to the attribute with given key, provided that the latter has a type that fits a int.
 long getLong()
          The value associated to the well-known attribute, provided that the latter has a type that fits a long.
 long getLong(String key)
          The value associated to the attribute with given key, provided that the latter has a type that fits a long.
 int hashCode()
           
 String toString()
           
 String wellKnownAttributeKey()
          Returns the well-known attribute key.
 
Methods inherited from class it.unimi.dsi.webgraph.labelling.AbstractLabel
getBoolean, getBoolean, getByte, getByte, getChar, getChar, getShort, getShort
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.webgraph.labelling.Label
copy, fixedWidth, fromBitStream, getBoolean, getBoolean, getByte, getByte, getChar, getChar, getShort, getShort, toBitStream, toSpec
 

Field Detail

key

protected final String key
The key of the attribute represented by this label.


value

public int value
The value of the attribute represented by this label.

Constructor Detail

AbstractIntLabel

public AbstractIntLabel(String key,
                        int value)
Creates an int label with given key and value.

Parameters:
key - the (only) key of this label.
value - the value of this label.
Method Detail

wellKnownAttributeKey

public String wellKnownAttributeKey()
Description copied from interface: Label
Returns the well-known attribute key.

Specified by:
wellKnownAttributeKey in interface Label
Returns:
the well-known attribute key.

attributeKeys

public String[] attributeKeys()
Description copied from interface: Label
All attribute keys (in arbitrary order).

Specified by:
attributeKeys in interface Label
Returns:
the keys of all attributes.

attributeTypes

public Class<?>[] attributeTypes()
Description copied from interface: Label
The types of all attributes in the same order as they are returned by Label.attributeKeys().

Specified by:
attributeTypes in interface Label
Returns:
the type of all attributes.

get

public Object get(String key)
Description copied from interface: Label
The value associated to the attribute with given key.

Specified by:
get in interface Label
Parameters:
key - the attribute key.
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getInt

public int getInt(String key)
Description copied from interface: Label
The value associated to the attribute with given key, provided that the latter has a type that fits a int. Otherwise, an IllegalArgumentException is thrown.

Specified by:
getInt in interface Label
Overrides:
getInt in class AbstractLabel
Parameters:
key - the attribute key.
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getLong

public long getLong(String key)
Description copied from interface: Label
The value associated to the attribute with given key, provided that the latter has a type that fits a long. Otherwise, an IllegalArgumentException is thrown.

Specified by:
getLong in interface Label
Overrides:
getLong in class AbstractLabel
Parameters:
key - the attribute key.
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getFloat

public float getFloat(String key)
Description copied from interface: Label
The value associated to the attribute with given key, provided that the latter has a type that fits a float. Otherwise, an IllegalArgumentException is thrown.

Specified by:
getFloat in interface Label
Overrides:
getFloat in class AbstractLabel
Parameters:
key - the attribute key.
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getDouble

public double getDouble(String key)
Description copied from interface: Label
The value associated to the attribute with given key, provided that the latter has a type that fits a double. Otherwise, an IllegalArgumentException is thrown.

Specified by:
getDouble in interface Label
Overrides:
getDouble in class AbstractLabel
Parameters:
key - the attribute key.
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

get

public Object get()
Description copied from interface: Label
The value associated to the well-known attribute.

Specified by:
get in interface Label
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getInt

public int getInt()
Description copied from interface: Label
The value associated to the well-known attribute, provided that the latter has a type that fits a int. Otherwise, an IllegalArgumentException is thrown.

Specified by:
getInt in interface Label
Overrides:
getInt in class AbstractLabel
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getLong

public long getLong()
Description copied from interface: Label
The value associated to the well-known attribute, provided that the latter has a type that fits a long. Otherwise, an IllegalArgumentException is thrown.

Specified by:
getLong in interface Label
Overrides:
getLong in class AbstractLabel
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getFloat

public float getFloat()
Description copied from interface: Label
The value associated to the well-known attribute, provided that the latter has a type that fits a float.

Specified by:
getFloat in interface Label
Overrides:
getFloat in class AbstractLabel
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

getDouble

public double getDouble()
Description copied from interface: Label
The value associated to the well-known attribute, provided that the latter has a type that fits a double. Otherwise, an IllegalArgumentException is thrown.

Specified by:
getDouble in interface Label
Overrides:
getDouble in class AbstractLabel
Returns:
the attribute value; if the attribute type is primitive, it is wrapped suitably.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object x)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object