Hi,

On Wed, Nov 11, 2009 at 11:52 PM, Michael Wechner
<michael.wech...@wyona.com> wrote:
> do you have a concrete example?

The client code for the Map option is currently:

    Map<String, Object> context = new HashMap<String, Object>();
    context.put(Parser.class.getName(), parser);
    parser.parse(..., context);

The ParseContext version would look like this:

    ParserContext context = new ParseContext();
    context.set(Parser.class, parser);
    parser.parse(..., context);

The parser implementation code in DelegatingParser.parse() is now:

    Object parser = context.get(Parser.class.getName());
    if (parser instanceof Parser) {
        ((Parser) parser).parse(...);
    } else {
        new EmptyParser().parse(...);
    }

With the proposed ParseContext it would be:

    context.get(Parser.class, new EmptyParser()).parse(...);

BR,

Jukka Zitting

Reply via email to