X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FTransformations.java;h=7fd3e10e7041efd6173dcc35832b94e67d0cbc46;hb=5b4ee8d862b98d127abb04c646017c184d005838;hp=212d36b2ef6c560d74c41f0adcf69a60b897e4e1;hpb=7ace7a8cf3173112717904aa825a7481dd0804e8;p=xmlrouter diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/Transformations.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/Transformations.java index 212d36b..7fd3e10 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/Transformations.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/Transformations.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.xmlrouter.impl; import java.util.ArrayList; @@ -23,32 +23,31 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; import org.wamblee.xmlrouter.common.Id; import org.wamblee.xmlrouter.config.Transformation; public class Transformations { - private AtomicInteger sequenceNumber; - private Map transformations; + private AtomicLong sequenceNumber; + private Map, Transformation> transformations; private List vertices; private TransformationPath[][] matrix; private Map> sequences; public Transformations() { - sequenceNumber = new AtomicInteger(1); - transformations = new LinkedHashMap(); + sequenceNumber = new AtomicLong(1); + transformations = new LinkedHashMap, Transformation>(); vertices = new ArrayList(); matrix = new TransformationPath[0][0]; } public Id addTransformation(Transformation aTransformation) { - int seqno = sequenceNumber.getAndIncrement(); + long seqno = sequenceNumber.getAndIncrement(); Id id = new Id(seqno); - transformations.put(seqno, - new RobustTransformation(id, aTransformation)); + transformations.put(id, new RobustTransformation(id, aTransformation)); computeTransformationSequences(); return id; } @@ -80,7 +79,7 @@ public class Transformations { */ public TransformationPath getPath(String aFrom, String aTo) { int i = vertices.indexOf(aFrom); - if (i == -1) { + if (i < 0) { if (aFrom.equals(aTo)) { return new TransformationPath(); } @@ -88,6 +87,9 @@ public class Transformations { } int j = vertices.indexOf(aTo); + if (j < 0) { + return null; + } return matrix[i][j]; } @@ -142,12 +144,16 @@ public class Transformations { } public void removeTransformation(Id aId) { - transformations.remove(aId.getId()); + transformations.remove(aId); computeTransformationSequences(); } - public Collection getTransformations() { - return Collections.unmodifiableCollection(transformations.values()); + public Collection> getTransformations() { + return Collections.unmodifiableCollection(transformations.keySet()); + } + + public Transformation getTransformation(Id aId) { + return transformations.get(aId); } @Override