commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Kendall" <matt_kend...@iname.com>
Subject [betwixt] Nested Mixed Content Lists
Date Tue, 22 May 2007 19:43:01 GMT
OK, so I have a really stupid question, but I've been banging my head
against it all day, so it's time to ask for some help. I have two
mixed content lists, one is a list of Matcher objects and each Matcher
list contains a list of Selector objects. Both Matcher and Selector
are abstract types. Matchers are contained in a Transform object. The
whole thing would look something like this:

public class Transform {
	private List<Matcher> matchers = new ArrayList<Matcher>();
	public void addMatcher(Matcher matcher) {
		matchers.add(matcher);
	}
	public List<Matcher> getMatchers() {
		return matchers;
	}
}

public abstract class Matcher {
	private List<Selector> selectors = new ArrayList<Selector>();

	protected abstract Set<Long> doSomething();

	public void addSelector(Selector selector) {
		selectors.add(selector);
	}

	public List<Selector> getSelectors() {
		return selectors;
	}
}

public abstract class Selector {
  public abstract void doSomething();
}

Now, reading the documentation, I found this little gem:

Transformer.betwixt
<info>
  <element name="transform">
    <element name="matchers">
      <element property="matchers" adder="addMatcher"/>
    </element>
    <addDefaults add-adders="false"/>
  </element>
</info>

And, naively, I also created:

AnInstanceOfMatcher.betwixt
<info>
  <element name="matcher">
    <element name="selectors">
      <element property="selectors" adder="addSelector"/>
    </element>
    <addDefaults add-adders="false"/>
  </element>
</info>

Using the latest betwixt 0.8 release this does not, sadly, give me
what I want. Just guessing, it looks like the name="matcher" attribute
from my AnInstanceOfMatcher.betwixt overrides the Transform.betwixt's
naming instructions. Here's my output:

<transform id="3">
  <matchers>
    <matcher id="4">
      <selectors>
	<PathFieldSelector id="5">
	  <path>table.*</path>
	</PathFieldSelector>
	<NamedFieldSelector id="6">
	  <name>table</name>
	</NamedFieldSelector>
      </selectors>
      <clazzName>java.util.HashMap</clazzName>
    </matcher>
  </matchers>
  <name>default</name>
</transform>

As you can see, the Selectors are named properly, but the type of the
Matcher remains a mystery. What is the proper way to map this?

Please note that I would prefer a strategy that doesn't require a lot
of extra attributes and elements. Once I get the actual mapping
working, I'll be toning down the complexity of the file so that it can
be easily edited by hand.

Thanks!
Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message