Ila

org.topoweb.ila
Class State

java.lang.Object
  |
  +--org.topoweb.ila.State
All Implemented Interfaces:
NodeConstants, StateConstants
Direct Known Subclasses:
VisitedState

public class State
extends java.lang.Object
implements StateConstants, NodeConstants

The respresentation of the state of a node in an Ila system. Instances are immutable. This class may be subclassed, but the accessor methods defined here are final. This immutability allows us to enforce some minimum criteria for State instances. See the constructor for details.

Author:
Babak Farhang
See Also:
StateBuffer, Node.getState()

Field Summary
 
Fields inherited from interface org.topoweb.ila.StateConstants
NF, NK, NV, OK
 
Fields inherited from interface org.topoweb.ila.NodeConstants
BACK, FIRST_PAGE, FORE, LAST_PAGE, LINK_MASK, PAGE_MASK
 
Constructor Summary
State(int status, int versionId, long versionTimestamp, int syncVersionId, long syncVersionTimestamp, int forelinkCount, int coForelinkCount, long backlinkCount, long coBacklinkCount)
          Creates a new instance.
 
Method Summary
 long getCoLinkCount(int type)
          Returns the co-link count for the specified link type.
 long getLinkCount(int type)
          Returns the link count for the specified link type.
 int getStatus()
          Returns the status code for the instance.
 int getSyncVersionId()
          Returns the sync version ID for this instance.
 long getSyncVersionTimestamp()
          Returns the version timestamp for this instance.
 int getVersionId()
          Returns the version ID for this instance.
 long getVersionTimestamp()
          Returns the version timestamp for this instance.
static java.lang.String statusToString(int status)
          Returns a string representation of an integral status code as defined by StateConstants.
 boolean supercedes(State other)
          Does this instance supercede the other? Uses the version ID to determine which instance is more recent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

State

public State(int status,
             int versionId,
             long versionTimestamp,
             int syncVersionId,
             long syncVersionTimestamp,
             int forelinkCount,
             int coForelinkCount,
             long backlinkCount,
             long coBacklinkCount)
      throws java.lang.IllegalArgumentException
Creates a new instance.

Parameters:
status - the status, as defined by StateConstants
versionId - the version ID
versionTimestamp - the version timestamp
syncVersionId - the sync version ID
syncVersionTimestamp - the sync version timestamp
forelinkCount - the total number of forelinks
coForelinkCount - the total number of co--forelinks
backlinkCount - the total number of backlinks
coBacklinkCount - the total number of co-backlinks
Throws:
java.lang.IllegalArgumentException -
if status is neither of OK, or NF, or NV, or NK;
if either of backlinkCount, or coBacklinkCount, or forelinkCount, or coForelinkCount is < 0;
if status is not OK and either of forelinkCount, or coForelinkCount is > 0;
if status is NK and either of backlinkCount, or coBacklinkCount != 0;
if the syncVersionId supercedes the versionId (syncVersionId - versionId > 0);
if syncVersionTimestamp < 0;
if syncVersionTimestamp > versionTimestamp;
if coForelinkCount > forelinkCount;
if coBacklinkCount > backlinkCount
Method Detail

getStatus

public final int getStatus()
Returns the status code for the instance. The return value is either of the 4 values OK, or NF, or NV, or NK.

Returns:
the status of the instance
See Also:
StateConstants

statusToString

public static java.lang.String statusToString(int status)
                                       throws java.lang.IllegalArgumentException
Returns a string representation of an integral status code as defined by StateConstants. The string representations are just the constant names "OK", "NF", "NV", and "NK".

Parameters:
status - the status code
Returns:
the string representation of the givenstatus code
Throws:
java.lang.IllegalArgumentException - if the value of status is not defined by StateConstants
See Also:
StateConstants

getVersionId

public final int getVersionId()
Returns the version ID for this instance. Each time information about a node is updated in Ila, the version ID is bumped up by one. This version ID scheme allows us to determine which version of a node is more recent than another.

Returns:
the version ID

getVersionTimestamp

public final long getVersionTimestamp()
Returns the version timestamp for this instance. The value returned indicates the time (in UTC millis) when the version was first created.

Returns:
the version timestamp

getSyncVersionId

public final int getSyncVersionId()
Returns the sync version ID for this instance. Sync version ID indicates the version ID of the node when its information was last synchronized with the nodes it is linked to.

Returns:
the sync version ID

getSyncVersionTimestamp

public final long getSyncVersionTimestamp()
Returns the version timestamp for this instance. The value returned indicates the time (in UTC millis) when the sync version was first created.

Returns:
the sync version timestamp

supercedes

public final boolean supercedes(State other)
Does this instance supercede the other? Uses the version ID to determine which instance is more recent. The exact condition for supercession is
getVersionId() - other.getVersionId() > 0

Note:

Version IDs are signed integers. Consequently the above defintion makes some negative version ID values supercede large positive version ID values. This behavior is good: it creates a circular sequence of version IDs.

Parameters:
other - the other instance tested against
Returns:
true, if this instance supercedes the other; false, o.w.

getLinkCount

public final long getLinkCount(int type)
Returns the link count for the specified link type. The returned value is the total number of links for the specified type.

From this method's perspective, the value of type is always well defined, as only its first bit is examined.

Parameters:
type - the link type
Returns:
the forelink count, if (type & LINK_MASK) == FORE; the backlink count, o.w.

getCoLinkCount

public final long getCoLinkCount(int type)
Returns the co-link count for the specified link type. For any given link type, its co-links are a subset of the links for that type. We are not hammering down its exact meaning; it's supposed to indicate the number of links from nodes that are more-or-less administered by the same owner -- i.e., nodes that are probably cohorts of a given node. For a node representing an HTTP document, then, a co-link might be defined as a link to or from another document on the same server.

From this method's perspective, the value of type is always well defined, as only its first bit is examined.

Parameters:
type - the link type
Returns:
the co-forelink count, if (type & LINK_MASK) == FORE; the co-backlink count, o.w.

Ila

Copyright (C) 2002 Babak Farhang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.