com.oxygenxml.validate.nvdl
Class Mode

java.lang.Object
  extended by com.oxygenxml.validate.nvdl.Mode

 class Mode
extends Object


Field Summary
(package private) static String ANONYMOUS_MODE_NAME_PREFIX
          Mode name prefix used for inline anonymous modes.
(package private) static int anonymousModeCounter
          Inline anonymous modes counter.
(package private) static int ATTRIBUTE_PROCESSING_FULL
           
(package private) static int ATTRIBUTE_PROCESSING_NONE
           
(package private) static int ATTRIBUTE_PROCESSING_QUALIFIED
           
private  Hashtable attributeMap
           
private  int attributeProcessing
           
private  Mode baseMode
          The base mode.
(package private) static Mode CURRENT
          A special mode.
private  boolean defined
          Flag indicating if this mode is defined by the user or is an automatically generated mode.
private  Hashtable elementMap
           
private  List includedModes
          List with included modes.
private  String name
          The mode name.
private  Hashtable nssAttributeMap
           
private  Hashtable nssElementMap
           
private  Locator whereDefined
          Locate the place where this mode is defined.
private  Locator whereUsed
          Locate the place this mode is first used.
 
Constructor Summary
Mode(Mode baseMode)
          Creates an anonymous mode.
Mode(String name, Mode baseMode)
          Creates a mode extending a base mode.
 
Method Summary
(package private)  void addIncludedMode(Mode mode)
           
(package private)  boolean bindAttribute(String ns, String wildcard, AttributeActionSet actions)
          Adds a set of attribute actions to be performed in this mode for attributes in a specified namespace.
(package private)  boolean bindElement(String ns, String wildcard, ActionSet actions)
          Adds a set of element actions to be performed in this mode for elements in a specified namespace.
(package private)  AttributeActionSet getAttributeActions(String ns)
          Get the set of attribute actions for a given namespace.
private  AttributeActionSet getAttributeActionsExplicit(String ns)
          Look for attribute actions specifically specified for this namespace.
(package private)  int getAttributeProcessing()
          Computes (if not already computed) the attributeProcessing for this mode and returns it.
(package private)  Mode getBaseMode()
          Get the base mode.
(package private)  ActionSet getElementActions(String ns)
          Get the set of element actions for a given namespace.
private  ActionSet getElementActionsExplicit(String ns)
          Look for element actions specifically specified for this namespace.
(package private)  String getName()
          Get this mode name.
(package private)  Locator getWhereDefined()
          Get the locator that points to the place the mode is defined.
(package private)  Locator getWhereUsed()
          Get a locator pointing to the first place this mode is used.
(package private)  boolean isAnonymous()
           
(package private)  boolean isDefined()
          Getter for the defined flag.
(package private)  void noteDefined(Locator locator)
          Record the locator this mode is defined at.
(package private)  void noteUsed(Locator locator)
          Record the locator if this is the first location this mode is used.
(package private)  void setBaseMode(Mode baseMode)
          Set a base mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_PROCESSING_NONE

static final int ATTRIBUTE_PROCESSING_NONE
See Also:
Constant Field Values

ATTRIBUTE_PROCESSING_QUALIFIED

static final int ATTRIBUTE_PROCESSING_QUALIFIED
See Also:
Constant Field Values

ATTRIBUTE_PROCESSING_FULL

static final int ATTRIBUTE_PROCESSING_FULL
See Also:
Constant Field Values

CURRENT

static final Mode CURRENT
A special mode. In a mode usage this will be resolved by the mode usage to the actual current mode from that mode usage.


ANONYMOUS_MODE_NAME_PREFIX

static final String ANONYMOUS_MODE_NAME_PREFIX
Mode name prefix used for inline anonymous modes.

See Also:
Constant Field Values

anonymousModeCounter

static int anonymousModeCounter
Inline anonymous modes counter.


name

private final String name
The mode name.


baseMode

private Mode baseMode
The base mode.


defined

private boolean defined
Flag indicating if this mode is defined by the user or is an automatically generated mode.


whereDefined

private Locator whereDefined
Locate the place where this mode is defined.


whereUsed

private Locator whereUsed
Locate the place this mode is first used. Useful to report with location errors like 'Mode "xxx" not defined'.


elementMap

private final Hashtable elementMap

attributeMap

private final Hashtable attributeMap

attributeProcessing

private int attributeProcessing

nssElementMap

private final Hashtable nssElementMap

nssAttributeMap

private final Hashtable nssAttributeMap

includedModes

private List includedModes
List with included modes.

Constructor Detail

Mode

Mode(String name,
     Mode baseMode)
Creates a mode extending a base mode.

Parameters:
name - The new mode name.
baseMode - The base mode.

Mode

public Mode(Mode baseMode)
Creates an anonymous mode.

Parameters:
baseMode -
Method Detail

addIncludedMode

void addIncludedMode(Mode mode)

getName

String getName()
Get this mode name.

Returns:
The name.

getBaseMode

Mode getBaseMode()
Get the base mode.

Returns:
The base mode.

setBaseMode

void setBaseMode(Mode baseMode)
Set a base mode.

Parameters:
baseMode - The new base mode.

getElementActions

ActionSet getElementActions(String ns)
Get the set of element actions for a given namespace. If this mode has an explicit handling of that namespace then we get those actions, otherwise we get the actions for any namespace.

Parameters:
ns - The namespace we look for element actions for.
Returns:
A set of element actions.

getElementActionsExplicit

private ActionSet getElementActionsExplicit(String ns)
Look for element actions specifically specified for this namespace. If the current mode does not have actions for that namespace look at base modes. If the actions are defined in a base mode we need to get a copy of those actions associated with this mode, so we call changeCurrentMode on them.

Parameters:
ns - The namespace
Returns:
A set of element actions.

getAttributeActions

AttributeActionSet getAttributeActions(String ns)
Get the set of attribute actions for a given namespace. If this mode has an explicit handling of that namespace then we get those actions, otherwise we get the actions for any namespace.

Parameters:
ns - The namespace we look for attribute actions for.
Returns:
A set of attribute actions.

getAttributeActionsExplicit

private AttributeActionSet getAttributeActionsExplicit(String ns)
Look for attribute actions specifically specified for this namespace. If the current mode does not have actions for that namespace look at base modes. If the actions are defined in a base mode we need to get a copy of those actions associated with this mode, so we call changeCurrentMode on them.

Parameters:
ns - The namespace
Returns:
A set of attribute actions.

getAttributeProcessing

int getAttributeProcessing()
Computes (if not already computed) the attributeProcessing for this mode and returns it. If it find anything different than attach then we need to perform attribute processing. If only attributes for a specific namespace have actions then we only need to process qualified attributes, otherwise we need to process all attributes.

Returns:
The attribute processing for this mode.

getWhereDefined

Locator getWhereDefined()
Get the locator that points to the place the mode is defined.

Returns:
a locator.

isDefined

boolean isDefined()
Getter for the defined flag.

Returns:
defined.

isAnonymous

boolean isAnonymous()

getWhereUsed

Locator getWhereUsed()
Get a locator pointing to the first place this mode is used.

Returns:
a locator.

noteUsed

void noteUsed(Locator locator)
Record the locator if this is the first location this mode is used.

Parameters:
locator - Points to the location this mode is used from.

noteDefined

void noteDefined(Locator locator)
Record the locator this mode is defined at.

Parameters:
locator - Points to the mode definition.

bindElement

boolean bindElement(String ns,
                    String wildcard,
                    ActionSet actions)
Adds a set of element actions to be performed in this mode for elements in a specified namespace.

Parameters:
ns - The namespace pattern.
wildcard - The wildcard character.
actions - The set of element actions.
Returns:
true if successfully added, that is the namespace was not already present in the elementMap, otherwise false, the caller should signal a script error in this case.

bindAttribute

boolean bindAttribute(String ns,
                      String wildcard,
                      AttributeActionSet actions)
Adds a set of attribute actions to be performed in this mode for attributes in a specified namespace.

Parameters:
ns - The namespace pattern.
wildcard - The wildcard character.
actions - The set of attribute actions.
Returns:
true if successfully added, that is the namespace was not already present in the attributeMap, otherwise false, the caller should signal a script error in this case.