Class RedefinableDeclState
- All Implemented Interfaces:
ExpressionOwner
,ContentHandler
- Direct Known Subclasses:
AttributeGroupState
,ComplexTypeDeclState
,GroupState
When this state is used under states other than RedefineState, this class doesn't do anything. When used under RedefineState, this class does several tricks to make redefinition easy.
Redefinition is done in the following steps.
Step.1
First, say redefinition of declaration "ABC" is found, "ABC" has already defined once and it is
- referenced from
ReferenceContainer
by name, and - referenced from other expressions directly.
Step.2
In startSelf method, this class clones the current definition, and updates ReferenceContainer to point to the cloned definition (right side).
Note that other expressions hold direct reference to the original definition (left side), and these references are not affected by this update.
Step.3
Body of redefinition is parsed and corresponding expression is created by derived class. This step is done no differently.
Since ReferenceContainer has updated, any reference to this expression found during this step is bound to the cloned definition. This self reference usually happens.
Step.4
After the body of redefinition is parsed, the original definition (left side) is updated by using new expression.
From now on, redefinition becomes visible to all expressions that hold direct reference to the original definition. The cloned definition is kept as-is so that any self reference found in the body will be maintained correctly.
Step.5
Finally, ReferenceContainer is updated again to point to the updated definition. Therefore successive reference to "ABC" will be bound to the updated definition. Cloned old definition is kept as-is.
-
Field Summary
Modifier and TypeFieldDescriptionprotected RedefinableExp
keeps a reference to previous declaration.Fields inherited from class com.sun.msv.reader.ExpressionWithChildState
exp
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
endSelf()
this method is called in endElement method when the state is about to be removed.protected abstract ReferenceContainer
gets appropriate ReferenceContainer to store this declaration.protected boolean
isGlobal()
protected boolean
Returns true if this declaration is a redefinition of an existing declaration.protected void
performs a task that should be done before reading any child elements.Methods inherited from class com.sun.msv.reader.ExpressionWithChildState
annealExpression, castExpression, createChildState, defaultExpression, initialExpression, makeExpression, onEndChild
Methods inherited from class com.sun.msv.reader.SimpleState
endDocument, endElement, isGrammarElement, startElement
Methods inherited from class com.sun.msv.reader.State
_assert, callInterceptExpression, characters, endPrefixMapping, getBaseURI, getLocation, getParentState, getStartTag, ignorableWhitespace, init, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
oldDecl
keeps a reference to previous declaration. this field is used only when in redefine mode. Derived class should use this declaration instead of getting one from ReferenceContainer through XMLSchemaSchema.
-
-
Constructor Details
-
RedefinableDeclState
public RedefinableDeclState()
-
-
Method Details
-
isGlobal
protected boolean isGlobal() -
isRedefine
protected boolean isRedefine()Returns true if this declaration is a redefinition of an existing declaration. -
getContainer
gets appropriate ReferenceContainer to store this declaration. -
startSelf
protected void startSelf()Description copied from class:State
performs a task that should be done before reading any child elements. derived-class can safely read startTag and/or parentState values.- Overrides:
startSelf
in classExpressionWithChildState
-
endSelf
protected void endSelf()Description copied from class:SimpleState
this method is called in endElement method when the state is about to be removed. derived-class should perform any wrap-up job- Overrides:
endSelf
in classExpressionState
-