Top Description Fields Constructors Methods
com.sun.msv.reader.xmlschema

public abstract Class RedefinableDeclState

extends ExpressionWithChildState
Class Inheritance
Known Direct Subclasses
com.sun.msv.reader.xmlschema.GroupState, com.sun.msv.reader.xmlschema.AttributeGroupState, com.sun.msv.reader.xmlschema.ComplexTypeDeclState
Imports
com.sun.msv.grammar.ReferenceContainer, com.sun.msv.grammar.xmlschema.RedefinableExp, com.sun.msv.reader.ExpressionWithChildState

state that parses redefinable declaration. "Declarations" are attribute, element, complexType, group, and attributeGroup. simpleType is treated differently.

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

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 TypeField and Description
protected RedefinableExp
oldDecl

keeps a reference to previous declaration.

Inherited from com.sun.msv.reader.ExpressionWithChildState:
exp

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
endSelf()

Overrides com.sun.msv.reader.ExpressionState.endSelf.

this method is called in endElement method when the state is about to be removed.
protected abstract ReferenceContainer
getContainer()

gets appropriate ReferenceContainer to store this declaration.

protected boolean
protected boolean
isRedefine()

Returns true if this declaration is a redefinition of an existing declaration.

protected void
startSelf()

Overrides com.sun.msv.reader.ExpressionWithChildState.startSelf.

performs a task that should be done before reading any child elements.
Inherited from com.sun.msv.reader.ExpressionWithChildState:
annealExpressioncastExpressioncreateChildStatedefaultExpressioninitialExpressionmakeExpressiononEndChild

Field Detail

oldDeclback to summary
protected RedefinableExp 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 Detail

RedefinableDeclStateback to summary
public RedefinableDeclState()

Method Detail

endSelfback to summary
protected void endSelf()

Overrides com.sun.msv.reader.ExpressionState.endSelf.

Doc from com.sun.msv.reader.SimpleState.endSelf.

this method is called in endElement method when the state is about to be removed. derived-class should perform any wrap-up job

getContainerback to summary
protected abstract ReferenceContainer getContainer()

gets appropriate ReferenceContainer to store this declaration.

isGlobalback to summary
protected boolean isGlobal()
isRedefineback to summary
protected boolean isRedefine()

Returns true if this declaration is a redefinition of an existing declaration.

startSelfback to summary
protected void startSelf()

Overrides com.sun.msv.reader.ExpressionWithChildState.startSelf.

Doc from com.sun.msv.reader.State.startSelf.

performs a task that should be done before reading any child elements. derived-class can safely read startTag and/or parentState values.