|
SASAX API - 1.5 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jp.ne.dti.lares.foozy.sasax.AbstractElement
Abstract implementation of Element interface.
This provides basic functionalities for
Element
implementations.
This is designed for "simple content"/"complex content" models of XML, not for "mixed content" model of it even though this may be also good for the later unexpectedly.
What you should do to define class(es) derived from this correctly are not only concretization of methods shown below:
accepts(ParseContext, String, String)
startElement(ParseContext, String, String, Attributes)
endElement(ParseContext, String, String)
but also invocation of below methods at appropriate places.
Constructor Summary | |
AbstractElement(Element parent)
Constructor. |
Method Summary | |
abstract boolean |
accepts(ParseContext context,
java.lang.String uri,
java.lang.String lName)
Examine whether specified name is acceptable or not. |
void |
addCleanup(java.lang.Runnable cleanup)
Add custom clean up procedure as Runnable . |
void |
addNotification(Notification notification)
Add custom notification procedure. |
Element |
characters(ParseContext context,
char[] chars,
int offset,
int length)
Receive notification of character data. |
void |
clear()
Reset state to re-use. |
abstract Element |
endElement(ParseContext context,
java.lang.String uri,
java.lang.String lName)
Receive notification of the end of an element. |
protected void |
ensureDetermined()
Ensure content determination. |
protected void |
fireElementStarted(ParseContext context,
org.xml.sax.Attributes attrs)
This notifies start of element. |
java.lang.String |
getAttribute(java.lang.String uri,
java.lang.String lName)
Get found attribute. |
Element |
getParent()
Get parent element of this. |
boolean |
hasNotification(Notification notification)
Remove custom notification procedure. |
static boolean |
hasXSINil(org.xml.sax.Attributes attrs)
Examine whether there is xsi:nil="true"
in specified attribute. |
Element |
ignorableWhitespace(ParseContext context,
char[] chars,
int offset,
int length)
Receive notification of ignorable whitespace in element content. |
boolean |
isDetermined()
Examine content of element is determined or not. |
protected void |
notifyDetermined()
Deprecated. by notifyDetermined(ParseContext) |
protected void |
notifyDetermined(ParseContext context)
Notify determination of element content. |
Element |
processingInstruction(ParseContext context,
java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
void |
removeNotification(Notification notification)
Remove custom notification procedure. |
protected void |
setDetermined(ParseContext context)
Set internal status as "determined". |
Element |
skippedEntity(ParseContext context,
java.lang.String name)
Receive notification of a skipped entity. |
abstract Element |
startElement(ParseContext context,
java.lang.String uri,
java.lang.String lName,
org.xml.sax.Attributes attrs)
Receive notification of the beginning of an element. |
void |
unwatchAttribute(java.lang.String uri,
java.lang.String lName)
Stop to watch specified attribute. |
void |
watchAttribute(java.lang.String uri,
java.lang.String lName)
Start to watch specified attribute. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbstractElement(Element parent)
parent
- of this element.Method Detail |
public final void addCleanup(java.lang.Runnable cleanup)
Runnable
.
This method adds specified Runnable
instance to
cleanup procedure list,
and invokes them at invocation of own
clear()
method.
This allows you to extend cleanup procedure unless method overriding with invocation of "super.cleanup()".
For example:
public class CustomElement extends AbstractElement // or other derived class { final private Runnable CLEANUP = new Runnable(){ public void run(){ // custom clean up procedure } }; // Constructor pubilc CustomElement(Element parent){ : : addCleanup(CLEANUP); CLEANUP.run(); } }
In above example,
"CLEANUP.run()
" is invoked
instead of clear()
,
because the later causes invocation of
all registrated cleanup procedures
but only custom class local cleanup is required in this situation
(base class cleanup procedures should be invoked
in their own constructors.).
cleanup
- procedure as Runnable
.public final void addNotification(Notification notification)
This method adds specified Notification
instance to
notification procedure list,
and they will be invoked by classes derived from this.
This allows you to extend target (instance) fuctionality unless defining class nor method overriding with invocation of one of "super".
notification
- encapsulated procedure.removeNotification(jp.ne.dti.lares.foozy.sasax.Notification)
,
hasNotification(jp.ne.dti.lares.foozy.sasax.Notification)
public final void removeNotification(Notification notification)
addNotification(jp.ne.dti.lares.foozy.sasax.Notification)
,
hasNotification(jp.ne.dti.lares.foozy.sasax.Notification)
public final boolean hasNotification(Notification notification)
addNotification(jp.ne.dti.lares.foozy.sasax.Notification)
,
removeNotification(jp.ne.dti.lares.foozy.sasax.Notification)
public final void watchAttribute(java.lang.String uri, java.lang.String lName)
This tells target element to watch specified attribute.
By invocation of this,
you can get attribute value
(which is specified at startElement()
)
by getAttribute()
after each element determination.
uri
- namespace, of watch target attributelName
- of watch target attributeunwatchAttribute(java.lang.String, java.lang.String)
public final void unwatchAttribute(java.lang.String uri, java.lang.String lName)
uri
- namespace, of watch target attributelName
- of watch target attributewatchAttribute(java.lang.String, java.lang.String)
public final java.lang.String getAttribute(java.lang.String uri, java.lang.String lName)
You can get value of specified attribute, if:
watchAttribute()
before, and
startElement()
In other words, returned value may be null, if:
watchAttribute()
yet, or
startElement()
Attribute values are held
from startElement()
until clear()
invocation on
corresponded element.
So, you can get appropriate value in elementEnded notification
.
uri
- namespace, of target attributelName
- of target attributepublic static boolean hasXSINil(org.xml.sax.Attributes attrs)
xsi:nil="true"
in specified attribute.
In this explanation, xsi
prefix means
"http://www.w3.org/2001/XMLSchema-instance
",
but this implementation does not require that
xsi
prefix is used for
http://www.w3.org/2001/XMLSchema-instance
namespace.
attrs
- to be looked up inprotected final void setDetermined(ParseContext context) throws org.xml.sax.SAXException
This sets internal status as determined,
then, invokes notifyDetermined(ParseContext)
and
Notification#elementEnded()
of registrated ones
to notify determination.
context
- of SAX document parsing.org.xml.sax.SAXException
- by notifyDetermined(ParseContext)
protected final void ensureDetermined()
IllegalStateExcepion
- if content is not determined.protected void notifyDetermined(ParseContext context) throws org.xml.sax.SAXException
This method is invoked after determination of element content,
which is notified by invocation of setDetermined(ParseContext)
,
and invokes notifyDetermined()
in default
for backward compatibility.
You can customize behavior to override this in derived class,
but should implement your custom logic
as Notification
, if you want re-use it.
org.xml.sax.SAXException
- if parsing should not be continued.addNotification(Notification)
protected void notifyDetermined() throws org.xml.sax.SAXException
notifyDetermined(ParseContext)
This method is invoked from notifyDetermined(ParseContext)
,
and does nothing in default.
You should override it instead of this.
org.xml.sax.SAXException
- if parsing should not be continued.protected final void fireElementStarted(ParseContext context, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
This invokes
Notification#elementStarted
of
registrated
ones.
Invocation of Notification#elementEnded()
is done in
setDetermined(ParseContext)
automaticaly,
but you should invoke this manualy
in your custom class which is derived from this.
context
- of SAX document parsing.attrs
- given by "startElement" SAX event.org.xml.sax.SAXException
- by Notification
public final void clear()
This invokes registrated procedures(as Runnable
)
one by one.
clear
in interface Element
addCleanup(Runnable)
public final Element getParent()
This returns the element specified at construction.
getParent
in interface Element
public abstract boolean accepts(ParseContext context, java.lang.String uri, java.lang.String lName)
This does not examine whether specified name is acceptable or not at invocation time but in initial condition.
accepts
in interface Element
context
- of SAX document parsing.uri
- given by "startElement" SAX event.lName
- given by "startElement" SAX event.Element.accepts(ParseContext, String, String)
public abstract Element startElement(ParseContext context, java.lang.String uri, java.lang.String lName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
startElement
in interface Element
context
- of SAX document parsing.uri
- given by "startElement" SAX event.lName
- given by "startElement" SAX event.attrs
- given by "startElement" SAX event.org.xml.sax.SAXException
- if parsing should not be continued.Element.startElement(ParseContext, String, String, Attributes)
public abstract Element endElement(ParseContext context, java.lang.String uri, java.lang.String lName) throws org.xml.sax.SAXException
endElement
in interface Element
context
- of SAX document parsing.uri
- given by "endElement" SAX event.lName
- given by "endElement" SAX event.org.xml.sax.SAXException
- if parsing should not be continued.Element.endElement(ParseContext, String, String)
public Element characters(ParseContext context, char[] chars, int offset, int length) throws org.xml.sax.SAXException
This implementation throws SAXException (SAXNotRecognizedException in fact) always.
characters
in interface Element
context
- of SAX document parsing.chars
- given by "characters" SAX eventoffset
- given by "characters" SAX eventlength
- given by "characters" SAX eventorg.xml.sax.SAXException
- if parsing should not be continued.Element.characters(ParseContext, char[], int, int)
public Element ignorableWhitespace(ParseContext context, char[] chars, int offset, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface Element
context
- of SAX document parsing.chars
- given by "ignorableWhitespace" SAX eventoffset
- given by "ignorableWhitespace" SAX eventlength
- given by "ignorableWhitespace" SAX eventorg.xml.sax.SAXException
- if parsing should not be continued.Element.ignorableWhitespace(ParseContext, char[], int, int)
public Element processingInstruction(ParseContext context, java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface Element
context
- of SAX document parsing.target
- given by "processingInstruction" SAX eventdata
- given by "processingInstruction" SAX eventorg.xml.sax.SAXException
- if parsing should not be continued.Element.processingInstruction(ParseContext, String, String)
public Element skippedEntity(ParseContext context, java.lang.String name) throws org.xml.sax.SAXException
skippedEntity
in interface Element
context
- of SAX document parsing.name
- given by "skippedEntity" SAX eventorg.xml.sax.SAXException
- if parsing should not be continued.Element.skippedEntity(ParseContext, String)
public boolean isDetermined()
This returns whether
setDetermined(ParseContext)
is invoked after last clear()
invocation or not.
isDetermined
in interface Element
|
SASAX API - 1.5 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |