Code Search for Developers
 
 
  

WootId.java from PeerWriter at Krugle


Show WootId.java syntax highlighted

package fr.loria.ecoo.wooki.woot.core;

import java.io.Serializable;

/**
 * @author molli
 */
public class WootId implements Comparable, Serializable {
	private String siteId;

	private int localClock;

	// id of beginning
	public static final WootId bwid = new WootId("-1", -1);

	// id of end char
	public static final WootId ewid = new WootId("-2", -2);

	// constructor
	public WootId(String siteId, int localClock) {
		this.siteId = siteId;
		this.localClock = localClock;
	}

	// getters
	public int getLocalClock() {
		return localClock;
	}

	public String getSiteid() {
		return siteId;
	}

	// setters
	public void setLocalClock(int i) {
		localClock = i;
	}

	public void setSiteId(String id) {
		this.siteId = id;
	}

	// methods
	public int compareTo(Object o) {
		WootId id = (WootId) o;
		if (this == bwid) {
			return -1;
		}
		if (this == ewid) {
			return 1;
		}
		if (id == bwid) {
			return 1;
		}
		if (id == ewid) {
			return -1;
		}
		if (this.siteId.equals(id.siteId)) {
			return this.localClock - id.localClock;
		} else {
			return this.siteId.compareTo(id.siteId);
		}
	}

	public boolean equals(Object o) {
		// assert o instanceof WootId;
		if (!(o instanceof WootId))
			return false;
		WootId wid = (WootId) o;
		return this.siteId.equals(wid.siteId) && this.localClock == wid.localClock;
	}

	public String toString() {
		return "(wid " + siteId + "," + localClock + ")";
	}
}




See more files for this project here

PeerWriter

PeerWriter is a collaborative text editor. Multiple peers can edit the same document while they see overall changes in real-time. PeerWriter is based on a decentralized infrastructure, using a non-locking concurrency protocol ensuring global consistency.

Project homepage: http://sourceforge.net/projects/peerwriter
Programming language(s): Java,XML
License: gpl2

  Pool.java
  WootId.java
  WootPage.java
  WootRow.java