diff --git a/src/fr/inrialpes/exmo/align/impl/AlgebraRelation.java b/src/fr/inrialpes/exmo/align/impl/AlgebraRelation.java index 6381702b0781c76b0e34f4a190a6d4be20fe8eee..1113a08e1c5ad9d6806423eda83fa53bd7ac26f7 100644 --- a/src/fr/inrialpes/exmo/align/impl/AlgebraRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/AlgebraRelation.java @@ -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(); + + */ } diff --git a/src/fr/inrialpes/exmo/align/impl/BitSetAlgebraRelation.java b/src/fr/inrialpes/exmo/align/impl/BitSetAlgebraRelation.java index 328104bd5e62f105e1e225232fe1a0b93217e308..64aa3fb5aa55d708f1ebb26f1b0d589c9935adb2 100644 --- a/src/fr/inrialpes/exmo/align/impl/BitSetAlgebraRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/BitSetAlgebraRelation.java @@ -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(); + */ } diff --git a/src/fr/inrialpes/exmo/align/impl/rel/A16AlgebraRelation.java b/src/fr/inrialpes/exmo/align/impl/rel/A16AlgebraRelation.java index 772dfce322c8728ba422b576966fcbb89a5e3ba3..e6ea99bb7c79b9da800bf08e31f69f6968949d40 100644 --- a/src/fr/inrialpes/exmo/align/impl/rel/A16AlgebraRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/rel/A16AlgebraRelation.java @@ -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 { diff --git a/src/fr/inrialpes/exmo/align/impl/rel/A2AlgebraRelation.java b/src/fr/inrialpes/exmo/align/impl/rel/A2AlgebraRelation.java index b71412ea524776744d0daa133823152655258268..c0a5337b563e1ff3569681627ee78986d8c51806 100644 --- a/src/fr/inrialpes/exmo/align/impl/rel/A2AlgebraRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/rel/A2AlgebraRelation.java @@ -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; } - } diff --git a/src/fr/inrialpes/exmo/align/impl/rel/A5AlgebraRelation.java b/src/fr/inrialpes/exmo/align/impl/rel/A5AlgebraRelation.java index 2a103f890f757cda45485265e5e01708281cee7c..2c7cf0e52173745e0ef9a45685a644260ede1b73 100644 --- a/src/fr/inrialpes/exmo/align/impl/rel/A5AlgebraRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/rel/A5AlgebraRelation.java @@ -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; } - }