From 40c926ee11c43ef8f7e42607f3c4fdef3555b8be Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Tue, 26 Nov 2013 05:45:58 +0000 Subject: [PATCH] in progress --- .../AdjactantDirectedBinaryDomainCombination.java | 4 +++- .../surfacing/BasicBinaryDomainCombination.java | 24 +++++++++++++------- .../surfacing/DirectedBinaryDomainCombination.java | 4 +++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/forester/java/src/org/forester/surfacing/AdjactantDirectedBinaryDomainCombination.java b/forester/java/src/org/forester/surfacing/AdjactantDirectedBinaryDomainCombination.java index 619e8f6..7ec6cb4 100644 --- a/forester/java/src/org/forester/surfacing/AdjactantDirectedBinaryDomainCombination.java +++ b/forester/java/src/org/forester/surfacing/AdjactantDirectedBinaryDomainCombination.java @@ -37,7 +37,9 @@ public class AdjactantDirectedBinaryDomainCombination extends BasicBinaryDomainC } // _id0 = n_terminal; // _id1 = c_terminal; - _data = n_terminal + SEPARATOR + c_terminal; + // _data = n_terminal + SEPARATOR + c_terminal; + _id0 = getId( n_terminal ); + _id1 = getId( c_terminal ); } public static AdjactantDirectedBinaryDomainCombination createInstance( final String ids ) { diff --git a/forester/java/src/org/forester/surfacing/BasicBinaryDomainCombination.java b/forester/java/src/org/forester/surfacing/BasicBinaryDomainCombination.java index 35ce62f..2b2a0cc 100644 --- a/forester/java/src/org/forester/surfacing/BasicBinaryDomainCombination.java +++ b/forester/java/src/org/forester/surfacing/BasicBinaryDomainCombination.java @@ -42,9 +42,11 @@ public class BasicBinaryDomainCombination implements BinaryDomainCombination { public static short getId( final String id ) { if ( !str2id.containsKey( id ) ) { - if ( count > ...) error - id2str.put( count, id ); - str2id.put( id, count ); + if ( count >= Short.MAX_VALUE ) { + throw new RuntimeException( "too many domain ids!" ); + } + id2str.put( count, id ); + str2id.put( id, count ); ++count; } return str2id.get( id ) ; @@ -62,15 +64,19 @@ public class BasicBinaryDomainCombination implements BinaryDomainCombination { throw new IllegalArgumentException( "ill formatted domain id: " + id0 + ", " + id1 ); } if ( id0.toLowerCase().compareTo( id1.toLowerCase() ) < 0 ) { - // _data = id0 + SEPARATOR + id1; + _id0 = getId( id0 ); + _id1 = getId( id1 ); } else { // _data = id1 + SEPARATOR + id0; + _id0 = getId( id1 ); + _id1 = getId( id0 ); } } BasicBinaryDomainCombination() { - _data = null; + _id0 = -1; + _id1 = -1; } @Override @@ -111,12 +117,14 @@ public class BasicBinaryDomainCombination implements BinaryDomainCombination { @Override public String getId0() { - return _data.substring( 0, _data.indexOf( SEPARATOR ) ); + //return _data.substring( 0, _data.indexOf( SEPARATOR ) ); + return getStr( _id0 ); } @Override public String getId1() { - return _data.substring( _data.indexOf( SEPARATOR ) + 1 ); + //return _data.substring( _data.indexOf( SEPARATOR ) + 1 ); + return getStr( _id1 ); } @Override @@ -174,7 +182,7 @@ public class BasicBinaryDomainCombination implements BinaryDomainCombination { } private String getAsStr() { - return _data; + return getId0() + SEPARATOR + getId1(); } public static BinaryDomainCombination createInstance( final String ids ) { diff --git a/forester/java/src/org/forester/surfacing/DirectedBinaryDomainCombination.java b/forester/java/src/org/forester/surfacing/DirectedBinaryDomainCombination.java index dac4464..68e570d 100644 --- a/forester/java/src/org/forester/surfacing/DirectedBinaryDomainCombination.java +++ b/forester/java/src/org/forester/surfacing/DirectedBinaryDomainCombination.java @@ -37,7 +37,9 @@ public class DirectedBinaryDomainCombination extends BasicBinaryDomainCombinatio } //_id0 = n_terminal; //_id1 = c_terminal; - _data = n_terminal + SEPARATOR + c_terminal; + // _data = n_terminal + SEPARATOR + c_terminal; + _id0 = getId( n_terminal ); + _id1 = getId( c_terminal ); } public static BinaryDomainCombination createInstance( final String ids ) { -- 1.7.10.2