sk.uniba.euromath.document.schema.impl.export
Class NewElementRuleImpl

java.lang.Object
  extended by sk.uniba.euromath.document.schema.impl.export.NewElementRuleImpl
All Implemented Interfaces:
IQNameAcceptor, IBaseRuleP, IForeignNodeP, INewElementRuleP, ISingleQNameP

public final class NewElementRuleImpl
extends Object
implements INewElementRuleP

Implementor of NewElementRuleP interface. Not thread-safe.

Author:
Martin Vysny

Field Summary
 Set<com.sun.msv.grammar.ElementExp> exps
          Set of ElementExps, that may generate content of context element.
 
Method Summary
 boolean accepts(String namespaceURI, String localName)
           Check whether the acceptor accepts given pair.
 boolean acceptsForeign()
          Checks whether this rule can generate elements from foreign namespace.
 boolean acceptsNamespace(String namespaceURI)
          Checks if the namelist accepts/contains at least one qname from given namespace.
 boolean equals(Object obj)
           
 EnumSet<AcceptsEnum> getAccepts()
          Returns type of qnames, that this rule accepts.
 List<IAttributeListRuleP> getLists()
           For each expression returns one list of attributes, that can be created by this rule.
 Set<String> getNamespaces()
          Tries to obtain a list of namespaces of qnames that are contained in this name list.
 String getNamespaceUri()
          Returns base namespace (the namespace of local elements).
 IElementSequenceRuleP getNewContent(Element e)
           Computes all possibilities of content, that can be generated by this rule and inserted into context element.
 IValueRule getNewTextRule(Element e)
          Computes and returns value rule, that can be inserted into context element.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

exps

public final Set<com.sun.msv.grammar.ElementExp> exps
Set of ElementExps, that may generate content of context element.

Method Detail

accepts

public boolean accepts(String namespaceURI,
                       String localName)
Description copied from interface: IQNameAcceptor

Check whether the acceptor accepts given pair.

Specified by:
accepts in interface IQNameAcceptor
Parameters:
namespaceURI - the namespace part of the qname. Acceptor must take both empty-string and null values as a null namespace.

If the acceptor accepts the attribute qnames also, then local attributes should have null as their namespace, regardless of the value of getNamespaceUri() function.

localName - the local name part.
Returns:
true if it accepts given qname, false otherwise.

getAccepts

public EnumSet<AcceptsEnum> getAccepts()
Description copied from interface: IQNameAcceptor
Returns type of qnames, that this rule accepts. If the information is not known then the function should return EnumSet with both flags.

Specified by:
getAccepts in interface IQNameAcceptor
Returns:
one of ACCEPTS_* constants.

getNamespaceUri

public String getNamespaceUri()
Description copied from interface: IQNameAcceptor
Returns base namespace (the namespace of local elements).

Specified by:
getNamespaceUri in interface IQNameAcceptor
Returns:
base namespace of schema, that created this object.

getLists

public List<IAttributeListRuleP> getLists()
Description copied from interface: INewElementRuleP

For each expression returns one list of attributes, that can be created by this rule. Only required attributes must be included in result set. Special care must be taken: there must not be two equal list rules (with equal rules). If all lists being returned are zero-length then a zero-length sequence must be returned instead.

Should be computed only once, when this function is called for first time.

Specified by:
getLists in interface INewElementRuleP
Returns:
list of creatable attributes.

acceptsForeign

public boolean acceptsForeign()
Checks whether this rule can generate elements from foreign namespace.

Returns:
true if this rule can generate elements from foreign namespace.

toString

public String toString()
Overrides:
toString in class Object

getNewContent

public IElementSequenceRuleP getNewContent(Element e)
Description copied from interface: INewElementRuleP

Computes all possibilities of content, that can be generated by this rule and inserted into context element. There must be only such insertlists, that doesn't contain optional elements. All InsertLists with length equal to 1 should be grouped together in one InsertList.

This content must be computed with existing attributes in mind. Expressions, whose contents violates given attribute set, must not be used.

It must NOT be computed when instance of this object is created.

Specified by:
getNewContent in interface INewElementRuleP
Parameters:
e - element with already created attributes. It can be assumed that element has no content.
Returns:
array of Insertlists, that can generate sequence of element. If no content is required, return null.

getNewTextRule

public IValueRule getNewTextRule(Element e)
Description copied from interface: INewElementRuleP
Computes and returns value rule, that can be inserted into context element.

Specified by:
getNewTextRule in interface INewElementRuleP
Parameters:
e - element with already created attributes. It can be assumed that element has no content. It may not be inserted in the document.
Returns:
ValueRule for validating element's text context. If null, then no text content is required.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

acceptsNamespace

public boolean acceptsNamespace(String namespaceURI)
Description copied from interface: IForeignNodeP
Checks if the namelist accepts/contains at least one qname from given namespace.

Specified by:
acceptsNamespace in interface IForeignNodeP
Parameters:
namespaceURI - the namespace to check.
Returns:
true if the namelist accepts at least one qname with given namespace.

getNamespaces

public Set<String> getNamespaces()
Description copied from interface: IForeignNodeP
Tries to obtain a list of namespaces of qnames that are contained in this name list. If the set cannot be computed (or it would be infinite) then return null.

Specified by:
getNamespaces in interface IForeignNodeP
Returns:
namespaces of items contained in the namelist, or null if it cannot be computed and/or represented. null namespace is represented as an empty string.


Copyright © 2003-2006 null. All Rights Reserved.