MAP | PageMixer Documents > Design Note > Concrete base class |
This section explains the reason
to design Token
class
as one bound to HTML tag characteristics.
In this document, abbreviated class names are used. Complete names are shown below.
Notation | Full name |
---|---|
Filter | jp.ne.dti.lares.foozy.pagemixer.mixer.Filter |
Symbol | jp.ne.dti.lares.foozy.pagemixer.Symbol |
Token | jp.ne.dti.lares.foozy.pagemixer.Token |
In Object-Oriented-Design, base class is designed as abstract and generic one, which does not have any derived class specific methods.
For example,
neither javax.swing.JComponent
,
its base class java.awt.Container
,
or java.awt.Component
have
getUnitIncrement(int)
method,
whih is specific to javax.swing.JScrollBar
.
The way of thinking described above makes base classes robust against for changes and re-useful.
At first,
Token
class is designed as generic one
in PageMixer framework.
It had only getName()
and isNamedAs(Symbol)
at that time.
But it causes belows:
instanceof
invocations to examine what given token is
Invocation of instanceof
and casting cost so much
because almost all Filter
s(*Watcher
s, in fact)
want to know whether given Token
is of start/end tag or not,
and has specified attribute or not.
So, for performance reason,
it is natural
to define in Token
class below examination methods,
which depends on HTML tag Token
specific characteristics.
isStart()
isEnd()
isEmpty()
findAttribute(Symbol name)
findAttributes(Symbol name)
getAttributes()
MAP | PageMixer Documents > Design Note > Concrete base class |