A
Alan Gutierrez
I've got an framework for creating SAX handlers through the
composition of strategies. Don't like the names.
Here are the interfaces...
public interface Strategy {
void startDocument(StrategyContext strategyContext,
EventContext eventContext);
void startElement(StrategyContext strategyContext,
EventContext eventContext);
void characters(StrategyContext strategyContext,
EventContext eventContext);
// And so on...
}
/** Example of Event. */
public interface Characters extends Event {
char[] getCharacters();
int getStart();
int getLength();
}
public interface StrategyContext {
Strategy getStrategy();
List getStrategyContextStack();
StrategyContext getParentContext(); // shortcut, common question
Map getVariables();
}
public interface EventContext {
Event getEvent();
List getEventContextStack();
EventContext getParentContext(); // shortcut, common question
Map getVariables();
PrefixMappingSet getPrefixMappingSet();
}
...in the above example, the context interfaces wrap something that
is external to wrapped object.
When a Strategy is at work, it is on a stack of strategies. Only
when it is on the stack, does it have a parent, and the
associated variables.
So a StrategyContext, is a bucket into which to put a Strategy,
before putting it into a stack.
Similarly, an event only has a meaningful set of prefix
mappings when it is on a processing stack.
My question is, what is a better name for these interfaces?
I don't think StrategyBucket is any better, since the user's
focus insn't necessarily on the stack.
- EventContext < Event >
- EventState < Event >
- EventBox < Event >
- Event < Lexeme >
- StrategyContext < Strategy >
- StrategyState < Strategy >
- StrategyBox < Strategy >
- ParseContext < Strategy >
- Stream < Strategy >
- StreamContext < Strategy >
- Process < Strategy >
Thanks for your consideration.
Alan Gutierrez - (e-mail address removed)
composition of strategies. Don't like the names.
Here are the interfaces...
public interface Strategy {
void startDocument(StrategyContext strategyContext,
EventContext eventContext);
void startElement(StrategyContext strategyContext,
EventContext eventContext);
void characters(StrategyContext strategyContext,
EventContext eventContext);
// And so on...
}
/** Example of Event. */
public interface Characters extends Event {
char[] getCharacters();
int getStart();
int getLength();
}
public interface StrategyContext {
Strategy getStrategy();
List getStrategyContextStack();
StrategyContext getParentContext(); // shortcut, common question
Map getVariables();
}
public interface EventContext {
Event getEvent();
List getEventContextStack();
EventContext getParentContext(); // shortcut, common question
Map getVariables();
PrefixMappingSet getPrefixMappingSet();
}
...in the above example, the context interfaces wrap something that
is external to wrapped object.
When a Strategy is at work, it is on a stack of strategies. Only
when it is on the stack, does it have a parent, and the
associated variables.
So a StrategyContext, is a bucket into which to put a Strategy,
before putting it into a stack.
Similarly, an event only has a meaningful set of prefix
mappings when it is on a processing stack.
My question is, what is a better name for these interfaces?
I don't think StrategyBucket is any better, since the user's
focus insn't necessarily on the stack.
- EventContext < Event >
- EventState < Event >
- EventBox < Event >
- Event < Lexeme >
- StrategyContext < Strategy >
- StrategyState < Strategy >
- StrategyBox < Strategy >
- ParseContext < Strategy >
- Stream < Strategy >
- StreamContext < Strategy >
- Process < Strategy >
Thanks for your consideration.
Alan Gutierrez - (e-mail address removed)