forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1184 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
4a019723ce
commit
78011b53dc
Binary file not shown.
Binary file not shown.
@ -0,0 +1,100 @@
|
|||||||
|
package com.evolute.adt;
|
||||||
|
|
||||||
|
public class Pair<CARCLASS extends Object, CDRCLASS extends Object> implements Comparable<Pair<? extends CARCLASS,? extends CDRCLASS>>
|
||||||
|
{
|
||||||
|
|
||||||
|
private final CARCLASS left;
|
||||||
|
|
||||||
|
private final CDRCLASS right;
|
||||||
|
|
||||||
|
public Pair( CARCLASS leftValue, CDRCLASS rightValue )
|
||||||
|
{
|
||||||
|
this.left = leftValue;
|
||||||
|
this.right = rightValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CARCLASS getLeft()
|
||||||
|
{
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CDRCLASS getRight()
|
||||||
|
{
|
||||||
|
return right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
boolean result = obj != null;
|
||||||
|
if( result )
|
||||||
|
{
|
||||||
|
if( obj instanceof Pair )
|
||||||
|
{
|
||||||
|
result = ( left == null ? (((Pair) obj).left == null ) : (left.equals(((Pair) obj).left)) );
|
||||||
|
result &= ( right == null ? (((Pair) obj).right == null ) : (right.equals(((Pair) obj).right)) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Pair<? extends CARCLASS, ? extends CDRCLASS> pair)
|
||||||
|
{
|
||||||
|
int result = compare( left, pair == null ? null : pair.left );
|
||||||
|
if( result == 0 )
|
||||||
|
{
|
||||||
|
result = compare( right, pair == null ? null : pair.right );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private int compare( Object a, Object b )
|
||||||
|
{
|
||||||
|
int result = a == null ? (b == null ? 0 : -1 ) : ( b == null ? 1 : 0 );
|
||||||
|
if( a != null && b != null )
|
||||||
|
{
|
||||||
|
if( a.getClass().equals( b.getClass() ) && (a instanceof Comparable) )
|
||||||
|
{
|
||||||
|
((Comparable)a).compareTo(b);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = compare(a.toString(),b.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int result = super.hashCode();
|
||||||
|
if( left != null )
|
||||||
|
{
|
||||||
|
result = left.hashCode();
|
||||||
|
if( right != null )
|
||||||
|
{
|
||||||
|
result ^= right.hashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( right != null )
|
||||||
|
{
|
||||||
|
result = right.hashCode();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "<"+left+","+right+">";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.evolute.adt;
|
||||||
|
|
||||||
|
public class Range
|
||||||
|
{
|
||||||
|
|
||||||
|
private final int start;
|
||||||
|
|
||||||
|
private final int end;
|
||||||
|
|
||||||
|
private final int length;
|
||||||
|
|
||||||
|
public Range( int start, int end )
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.length = 1 + ( Math.max( Math.abs( start ), Math.abs( end ) ) - Math.min( Math.abs( start ), Math.abs( end ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStart()
|
||||||
|
{
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnd()
|
||||||
|
{
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The lenght of the range
|
||||||
|
* Examples:
|
||||||
|
* start:end > length
|
||||||
|
* 0:3 > 4
|
||||||
|
* -1:-1 > 1
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getLength()
|
||||||
|
{
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals( Object obj )
|
||||||
|
{
|
||||||
|
return (obj instanceof Range) && ((Range)obj).start == start && ((Range)obj).end == end;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return new Integer( start ).hashCode() ^ new Integer( end ).hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package siprp;
|
||||||
|
|
||||||
|
import com.evolute.modules.spellchecker.EvoSpellChecker;
|
||||||
|
import com.evolute.modules.spellchecker.EvoSpellChecker.Dictionary;
|
||||||
|
|
||||||
|
|
||||||
|
public class SpellChecker
|
||||||
|
{
|
||||||
|
|
||||||
|
private static SpellChecker instance = null;
|
||||||
|
|
||||||
|
private final EvoSpellChecker spellChecker;
|
||||||
|
|
||||||
|
private SpellChecker()
|
||||||
|
{
|
||||||
|
this.spellChecker = new EvoSpellChecker( Dictionary.PT_PT );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SpellChecker getInstance()
|
||||||
|
{
|
||||||
|
if( instance == null )
|
||||||
|
{
|
||||||
|
instance = new SpellChecker();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EvoSpellChecker getSpellChecker()
|
||||||
|
{
|
||||||
|
return spellChecker;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue