Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 8a8f1d64 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- normalised getNoInfo/getInconsistent/getIdRelation and commented in interface and abstract

parent dcd7463d
No related branches found
No related tags found
No related merge requests found
......@@ -37,5 +37,17 @@ public interface AlgebraRelation<T extends BaseRelation> extends DisjunctiveRela
public AlgebraRelation<T> inverse();
/**
* They should be part of the interface...
* However, they are static
* Hence static properties are not available in interfaces...
public AlgebraRelation<T> getIdRelation();
public AlgebraRelation<T> getNoInfoRelation();
public AlgebraRelation<T> getInconsistentRelation();
*/
}
......@@ -81,5 +81,19 @@ public abstract class BitSetAlgebraRelation<T extends BaseRelation> extends BitS
*/
public abstract BitSetAlgebraRelation<T> inverse();
/**
* They should be part of the interface (AlgebraRelation)
* However, they are static
* Hence static properties are not available in interfaces...
*
* But they cannot be abstract either, because Java thinks abstract static has no meaning
* (which is true in general
public abstract static AlgebraRelation<T> getIdRelation();
public abstract static AlgebraRelation<T> getNoInfoRelation();
public abstract static AlgebraRelation<T> getInconsistentRelation();
*/
}
......@@ -82,13 +82,8 @@ public class A16AlgebraRelation extends BitSetAlgebraRelation<A16BaseRelation> {
declareRelation( A16BaseRelation.EN, A16BaseRelation.NE );
declareRelation( A16BaseRelation.EI, A16BaseRelation.IE );
compositionTable = new BitSet[size][size];
for( int i=0; i < size; i++ )
for( int j=0; j < size; j++ )
compositionTable[i][j] = new BitSet( size );
BitSet bs = new BitSet( size );
bs.set( 0 );
instance0 = new A16AlgebraRelation( bs );
initStructures();
// ---- EQ_N
o( A16BaseRelation.EQ_N, A16BaseRelation.EQ_N,
A16BaseRelation.EQ_N );
......@@ -320,11 +315,40 @@ public class A16AlgebraRelation extends BitSetAlgebraRelation<A16BaseRelation> {
protected static BitSet[][] compositionTable;
private static A16AlgebraRelation instance0;
private static A16AlgebraRelation fullSet;
private static A16AlgebraRelation emptySet;
protected BitSet createSet() {
return new BitSet( size );
}
protected static void protoinit() {
logger.trace( "Initialising algebra of relations" );
size = 0;
relations = new HashMap<String,A16BaseRelation>();
positions = new Vector<A16BaseRelation>();
}
protected static void initStructures() {
compositionTable = new BitSet[size][size];
for( int i=0; i < size; i++ )
for( int j=0; j < size; j++ )
compositionTable[i][j] = new BitSet( size );
BitSet bs = new BitSet( size );
bs.set( 0 );
instance0 = new A16AlgebraRelation( bs );
bs = new BitSet( size );
emptySet = new A16AlgebraRelation( bs );
bs = new BitSet( size );
bs.flip( 0, bs.size() );
fullSet = new A16AlgebraRelation( bs );
}
protected static void protofinalize() {
//if ( instance0 == null ) instance0 = new A16AlgebraRelation( new BitSet( size ) );
logger.trace( "Initialised algebra with {} relations", size );
}
public A16BaseRelation getRelation( String rel ) {
//return A16BaseRelation.valueOf( rel );
if ( size == -1) init();
......@@ -339,13 +363,6 @@ public class A16AlgebraRelation extends BitSetAlgebraRelation<A16BaseRelation> {
return compositionTable[s.index][t.index];
}
protected static void protoinit() {
logger.trace( "Initialising algebra of relations" );
size = 0;
relations = new HashMap<String,A16BaseRelation>();
positions = new Vector<A16BaseRelation>();
}
protected static void declareRelation( A16BaseRelation rel, A16BaseRelation inverse ) {
rel.init( size++, inverse );
relations.put( rel.relation, rel );
......@@ -353,11 +370,6 @@ public class A16AlgebraRelation extends BitSetAlgebraRelation<A16BaseRelation> {
logger.debug( "{} idx: {}, inv: {}", rel, rel.index, rel.inverse );
}
protected static void protofinalize() {
//if ( instance0 == null ) instance0 = new A16AlgebraRelation( new BitSet( size ) );
logger.trace( "Initialised algebra with {} relations", size );
}
protected static void setComposition( A16BaseRelation a, A16BaseRelation b, A16BaseRelation c ) {
compositionTable[a.index][b.index].set( c.index );
}
......@@ -401,11 +413,14 @@ public class A16AlgebraRelation extends BitSetAlgebraRelation<A16BaseRelation> {
return new A16AlgebraRelation( protomeet( drs ) );
}
public static A16AlgebraRelation getTopRelation() throws AlignmentException {
public static A16AlgebraRelation getInconsistentRelation() throws AlignmentException {
if ( size == -1 ) init();
BitSet bs = instance0.createSet();
bs.flip( 0, bs.size() );
return new A16AlgebraRelation( bs );
return emptySet;
}
public static A16AlgebraRelation getNoInfoRelation() throws AlignmentException {
if ( size == -1 ) init();
return fullSet;
}
public static A16AlgebraRelation getIdRelation() throws AlignmentException {
......
......@@ -69,13 +69,7 @@ public class A2AlgebraRelation extends BitSetAlgebraRelation<A2BaseRelation> {
protoinit();
declareRelation( A2BaseRelation.EQUIV, A2BaseRelation.EQUIV );
declareRelation( A2BaseRelation.DIFF, A2BaseRelation.DIFF );
compositionTable = new BitSet[size][size];
for( int i=0; i < size; i++ )
for( int j=0; j < size; j++ )
compositionTable[i][j] = new BitSet( size );
BitSet bs = new BitSet( size );
bs.set( 0 );
instance0 = new A2AlgebraRelation( bs );
initStructures();
/*
o( A2BaseRelation.EQUIV, A2BaseRelation.EQUIV, A2BaseRelation.EQUIV );
o( A2BaseRelation.EQUIV, A2BaseRelation.DIFF, A2BaseRelation.DIFF );
......@@ -102,11 +96,40 @@ public class A2AlgebraRelation extends BitSetAlgebraRelation<A2BaseRelation> {
protected static BitSet[][] compositionTable;
private static A2AlgebraRelation instance0;
private static A2AlgebraRelation fullSet;
private static A2AlgebraRelation emptySet;
protected BitSet createSet() {
return new BitSet( size );
}
protected static void protoinit() {
logger.trace( "Initialising algebra of relations" );
size = 0;
relations = new HashMap<String,A2BaseRelation>();
positions = new Vector<A2BaseRelation>();
}
protected static void initStructures() {
compositionTable = new BitSet[size][size];
for( int i=0; i < size; i++ )
for( int j=0; j < size; j++ )
compositionTable[i][j] = new BitSet( size );
BitSet bs = new BitSet( size );
bs.set( 0 );
instance0 = new A2AlgebraRelation( bs );
bs = new BitSet( size );
emptySet = new A2AlgebraRelation( bs );
bs = new BitSet( size );
bs.flip( 0, bs.size() );
fullSet = new A2AlgebraRelation( bs );
}
protected static void protofinalize() {
//if ( instance0 == null ) instance0 = new A2AlgebraRelation( new BitSet( size ) );
logger.trace( "Initialised algebra with {} relations", size );
}
public A2BaseRelation getRelation( String rel ) {
// This would rely on enum id (EQUIV) and not label ("=")
//return A2BaseRelation.valueOf( rel );
......@@ -122,13 +145,6 @@ public class A2AlgebraRelation extends BitSetAlgebraRelation<A2BaseRelation> {
return compositionTable[s.index][t.index];
}
protected static void protoinit() {
logger.trace( "Initialising algebra of relations" );
size = 0;
relations = new HashMap<String,A2BaseRelation>();
positions = new Vector<A2BaseRelation>();
}
protected static void declareRelation( A2BaseRelation rel, A2BaseRelation inverse ) {
rel.init( size++, inverse );
relations.put( rel.relation, rel );
......@@ -136,11 +152,6 @@ public class A2AlgebraRelation extends BitSetAlgebraRelation<A2BaseRelation> {
logger.debug( "{} idx: {}, inv: {}", rel, rel.index, rel.inverse );
}
protected static void protofinalize() {
//if ( instance0 == null ) instance0 = new A2AlgebraRelation( new BitSet( size ) );
logger.trace( "Initialised algebra with {} relations", size );
}
protected static void setComposition( A2BaseRelation a, A2BaseRelation b, A2BaseRelation c ) {
compositionTable[a.index][b.index].set( c.index );
}
......@@ -184,17 +195,19 @@ public class A2AlgebraRelation extends BitSetAlgebraRelation<A2BaseRelation> {
return new A2AlgebraRelation( protomeet( drs ) );
}
public static A2AlgebraRelation getTopRelation() throws AlignmentException {
public static A2AlgebraRelation getInconsistentRelation() throws AlignmentException {
if ( size == -1 ) init();
BitSet bs = instance0.createSet();
bs.flip( 0, bs.size() );
return new A2AlgebraRelation( bs );
return emptySet;
}
public static A2AlgebraRelation getNoInfoRelation() throws AlignmentException {
if ( size == -1 ) init();
return fullSet;
}
public static A2AlgebraRelation getIdRelation() throws AlignmentException {
if ( size == -1 ) init();
return instance0;
}
}
......@@ -72,13 +72,7 @@ public class A5AlgebraRelation extends BitSetAlgebraRelation<A5BaseRelation> {
declareRelation( A5BaseRelation.SUBSUMED, A5BaseRelation.SUBSUME );
declareRelation( A5BaseRelation.OVERLAP, A5BaseRelation.OVERLAP );
declareRelation( A5BaseRelation.DISJOINT, A5BaseRelation.DISJOINT );
compositionTable = new BitSet[size][size];
for( int i=0; i < size; i++ )
for( int j=0; j < size; j++ )
compositionTable[i][j] = new BitSet( size );
BitSet bs = new BitSet( size );
bs.set( 0 );
instance0 = new A5AlgebraRelation( bs );
initStructures();
// ---- EQUIV
o( A5BaseRelation.EQUIV, A5BaseRelation.EQUIV,
A5BaseRelation.EQUIV );
......@@ -151,11 +145,40 @@ public class A5AlgebraRelation extends BitSetAlgebraRelation<A5BaseRelation> {
protected static BitSet[][] compositionTable;
private static A5AlgebraRelation instance0;
private static A5AlgebraRelation emptySet;
private static A5AlgebraRelation fullSet;
protected BitSet createSet() {
return new BitSet( size );
}
protected static void protoinit() {
logger.trace( "Initialising algebra of relations" );
size = 0;
relations = new HashMap<String,A5BaseRelation>();
positions = new Vector<A5BaseRelation>();
}
protected static void initStructures() {
compositionTable = new BitSet[size][size];
for( int i=0; i < size; i++ )
for( int j=0; j < size; j++ )
compositionTable[i][j] = new BitSet( size );
BitSet bs = new BitSet( size );
bs.set( 0 );
instance0 = new A5AlgebraRelation( bs );
bs = new BitSet( size );
emptySet = new A5AlgebraRelation( bs );
bs = new BitSet( size );
bs.flip( 0, bs.size() );
fullSet = new A5AlgebraRelation( bs );
}
protected static void protofinalize() {
//if ( instance0 == null ) instance0 = new A5AlgebraRelation( new BitSet( size ) );
logger.trace( "Initialised algebra with {} relations", size );
}
public A5BaseRelation getRelation( String rel ) {
// This would rely on enum id (EQUIV) and not label ("=")
//return A5BaseRelation.valueOf( rel );
......@@ -171,13 +194,6 @@ public class A5AlgebraRelation extends BitSetAlgebraRelation<A5BaseRelation> {
return compositionTable[s.index][t.index];
}
protected static void protoinit() {
logger.trace( "Initialising algebra of relations" );
size = 0;
relations = new HashMap<String,A5BaseRelation>();
positions = new Vector<A5BaseRelation>();
}
protected static void declareRelation( A5BaseRelation rel, A5BaseRelation inverse ) {
rel.init( size++, inverse );
relations.put( rel.relation, rel );
......@@ -185,11 +201,6 @@ public class A5AlgebraRelation extends BitSetAlgebraRelation<A5BaseRelation> {
logger.debug( "{} idx: {}, inv: {}", rel, rel.index, rel.inverse );
}
protected static void protofinalize() {
//if ( instance0 == null ) instance0 = new A5AlgebraRelation( new BitSet( size ) );
logger.trace( "Initialised algebra with {} relations", size );
}
protected static void setComposition( A5BaseRelation a, A5BaseRelation b, A5BaseRelation c ) {
compositionTable[a.index][b.index].set( c.index );
}
......@@ -233,17 +244,19 @@ public class A5AlgebraRelation extends BitSetAlgebraRelation<A5BaseRelation> {
return new A5AlgebraRelation( protomeet( drs ) );
}
public static A5AlgebraRelation getTopRelation() throws AlignmentException {
public static A5AlgebraRelation getInconsistentRelation() throws AlignmentException {
if ( size == -1 ) init();
BitSet bs = instance0.createSet();
bs.flip( 0, bs.size() );
return new A5AlgebraRelation( bs );
return emptySet;
}
public static A5AlgebraRelation getNoInfoRelation() throws AlignmentException {
if ( size == -1 ) init();
return fullSet;
}
public static A5AlgebraRelation getIdRelation() throws AlignmentException {
if ( size == -1 ) init();
return instance0;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment