nars.entity
Class Stamp

java.lang.Object
  extended by nars.entity.Stamp
All Implemented Interfaces:
java.lang.Cloneable

public class Stamp
extends java.lang.Object
implements java.lang.Cloneable

Each Sentence has a get of serial numbers of a constant length attached. The input sentence gets a unique number. The derived sentences inherits from its parents, then cut at the length limit.


Field Summary
private  long creationTime
          creation time of the stamp
private static long current
          serial number, for the whole system
private  int length
          current stamp length
private  long[] list
          serial numbers
 
Constructor Summary
  Stamp()
          Generate a new stamp, with a new serial number, for input sentence
private Stamp(Stamp first, Stamp second)
          Generate a new stamp for derived sentence by merging the two from parents the first one is no shorter than the second
 
Method Summary
 boolean equals(java.lang.Object that)
          Check if two stamps contains the same set of numbers
(package private)  long get(int i)
          Get a number from the list by index, called in this class only
 long getCreationTime()
          Get the creationTime of the truth-value
 int hashCode()
          The hash code of Stamp
static void init()
          Initialize the stamp machenism of the system, called in Center
 int length()
          Return the length of the list
static Stamp make(Stamp first, Stamp second)
          Try to merge two Stamps, return null if have overlap
 TemporalValue orderWith(Stamp that)
          Compare two Stamps for their temporal order
(package private)  java.util.TreeSet<java.lang.Long> toSet()
          Convert the list into a set
 java.lang.String toString()
          Get a String form of the Stamp for display
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

current

private static long current
serial number, for the whole system


list

private long[] list
serial numbers


length

private int length
current stamp length


creationTime

private final long creationTime
creation time of the stamp

Constructor Detail

Stamp

public Stamp()
Generate a new stamp, with a new serial number, for input sentence


Stamp

private Stamp(Stamp first,
              Stamp second)
Generate a new stamp for derived sentence by merging the two from parents the first one is no shorter than the second

Parameters:
first - The first Stamp
second - The second Stamp
Method Detail

make

public static Stamp make(Stamp first,
                         Stamp second)
Try to merge two Stamps, return null if have overlap

Parameters:
first - The first Stamp
second - The second Stamp
Returns:
The merged Stamp, or null

init

public static void init()
Initialize the stamp machenism of the system, called in Center


length

public int length()
Return the length of the list

Returns:
Length of the Stamp

get

long get(int i)
Get a number from the list by index, called in this class only

Parameters:
i - The index
Returns:
The number at the index

toSet

java.util.TreeSet<java.lang.Long> toSet()
Convert the list into a set


equals

public boolean equals(java.lang.Object that)
Check if two stamps contains the same set of numbers

Overrides:
equals in class java.lang.Object
Parameters:
that - The Stamp to be compared
Returns:
Whether the two have contain the same elements

hashCode

public int hashCode()
The hash code of Stamp

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code

getCreationTime

public long getCreationTime()
Get the creationTime of the truth-value

Returns:
The creation time

orderWith

public TemporalValue orderWith(Stamp that)
Compare two Stamps for their temporal order

Parameters:
that - The Stamp to be compared
Returns:
The temporal order

toString

public java.lang.String toString()
Get a String form of the Stamp for display

Overrides:
toString in class java.lang.Object
Returns:
The Stamp as a String