1 package org.wamblee.xmlrouter.impl;
3 import java.util.ArrayList;
6 import org.wamblee.xmlrouter.config.Transformation;
8 public class TransformationPath {
10 private List<Transformation> transformations;
12 public TransformationPath() {
13 transformations = new ArrayList<Transformation>();
16 public TransformationPath(Transformation aTransformation) {
18 transformations.add(aTransformation);
21 public TransformationPath(List<Transformation> aTransformations) {
23 transformations.addAll(aTransformations);
26 public TransformationPath appendPath(TransformationPath aSequence) {
27 if (transformations.isEmpty()) {
28 return new TransformationPath(aSequence.transformations);
30 if (aSequence.transformations.isEmpty()) {
32 return new TransformationPath(transformations);
35 if (!getToType().equals(aSequence.getFromType())) {
36 throw new RuntimeException(
37 "error concatening sequence, destination of first differs from source of second");
39 List<Transformation> t = new ArrayList<Transformation>(transformations);
40 t.addAll(aSequence.transformations);
41 return new TransformationPath(t);
45 return transformations.size();
48 public String getFromType() {
49 if (transformations.isEmpty()) {
52 return transformations.get(0).getFromType();
55 public String getToType() {
56 if (transformations.isEmpty()) {
59 return transformations.get(transformations.size() - 1).getToType();
62 public List<Transformation> getTransformations() {
63 return transformations;
67 public String toString() {
68 StringBuffer buf = new StringBuffer();
69 buf.append("TransformationPath(");
70 for (int i = 0; i < transformations.size(); i++) {
74 buf.append(transformations.get(i).toString());
77 return buf.toString();