com.cburch.editor.util
Class Positions

java.lang.Object
  extended by com.cburch.editor.util.Positions

public class Positions
extends java.lang.Object

This class is a collection exclusively of class members that are helpful in dealing with javax.swing.text's Position class.

Version:
0.1 2005-05-31
Author:
Carl Burch

Method Summary
static javax.swing.text.Position createDummy(int offset)
          Creates and returns a Position object that is not associated with any Document.
static java.util.Comparator<javax.swing.text.Position> getComparator()
          Returns a comparator that compares two positions' offsets.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getComparator

public static java.util.Comparator<javax.swing.text.Position> getComparator()
Returns a comparator that compares two positions' offsets. When two distinct Position objects are at the same offset, the comparator will return a zero value. This is technically erroneous, because two positions may be different at one invocation and later, due to edits in the document, become the same.

Returns:
the comparator.

createDummy

public static javax.swing.text.Position createDummy(int offset)
Creates and returns a Position object that is not associated with any Document. As a result, the associated position does not change.

Parameters:
offset - the offset of the returned position.
Returns:
a Position object wrapped around the given offset.