sk.uniba.euromath.document.schema.plug
Interface IElementRuleP

All Superinterfaces:
IBaseRuleP
All Known Implementing Classes:
ElementRuleImpl

public interface IElementRuleP
extends IBaseRuleP

Represents rule for one element, already present in the document. You can assume that element is not modified while this instance is used.

Author:
Martin Vysny

Method Summary
 List<? extends Element> areElementsDeletable(Set<? extends Element> elements)
          Checks whether given elements are deletable.
 IAttributeRuleP getAttributeRule(Attr attribute)
          Returns rule for given attribute.
 INameListP<? extends INewElementRuleP> getEnclosingElements(sk.baka.ikslibs.ptr.DOMPoint start, sk.baka.ikslibs.ptr.DOMPoint end)
          Computes and returns an one-sized insertlist of elements, that can enclose given nodeset.
 INameListP<? extends IAttributeRuleP> getInsertableAttributes()
          Returns all attributes that can be created in this element.
 List<? extends IInsertListP> getInsertableElements(sk.baka.ikslibs.ptr.DOMPoint point)
          Computes insertable elements, with their positions between other nodes.
 IValueRule getValueRule()
          Gets text acceptor, that checks valid text values for given element.
 boolean isAnyStringInsertable(sk.baka.ikslibs.ptr.DOMPoint ip)
           Checks, if there can be any string inserted into given point.
 boolean isDeclosable(Element e)
          Checks if given element is declosable - if the contents of given element can replace the element.
 boolean isDeletable(sk.baka.ikslibs.ptr.DOMPoint start, sk.baka.ikslibs.ptr.DOMPoint end)
          Checks if given interval is removable from the document.
 boolean isDeletable(Node node)
          Checks if a simple node is deletable from the element.
 boolean isDeletableAttribute(Attr attribute)
          Checks, whether given attribute is deletable from its element.
 boolean isInsertable(sk.baka.ikslibs.ptr.DOMPoint ip, Node node)
          Checks if given nodes are insertable into given position.
 void validate()
           Validates the element.
 

Method Detail

getInsertableAttributes

INameListP<? extends IAttributeRuleP> getInsertableAttributes()
Returns all attributes that can be created in this element. Result namelist must be used for inserting one attribute only.

Returns:
List containing AttributeRule instances - all attribute rules, that can be added to element e.

isDeletableAttribute

boolean isDeletableAttribute(Attr attribute)
Checks, whether given attribute is deletable from its element.

Parameters:
attribute - attribute to check. It may be foreign attribute also.
Returns:
false if attribute is not deletable.

getInsertableElements

List<? extends IInsertListP> getInsertableElements(sk.baka.ikslibs.ptr.DOMPoint point)
Computes insertable elements, with their positions between other nodes. User can choose, which sequence he wishes to create.

Parameters:
point - insertion point, before which we want to insert element. If InsertPoint.FIRST, new element will be created before first node.
Returns:
array of element lists, each list represents one possibility, which elements can be inserted.

getValueRule

IValueRule getValueRule()
Gets text acceptor, that checks valid text values for given element. Result applies only to textual content of element, that doesn't contain a child element(s). It applies to whole textual content - it may be multiple Text and CData nodes.

Returns:
text acceptor. If it was called on element with one or more child elements, returns null.

isAnyStringInsertable

boolean isAnyStringInsertable(sk.baka.ikslibs.ptr.DOMPoint ip)

Checks, if there can be any string inserted into given point. Must be used only for element, that contains some elements - if true, then any string can be inserted at selected position, if false, then no string can be inserted at all.

When element doesn't contain no child element, then getValueRule should be used: it returns more useful rule.

Parameters:
ip - insert point, where we want to insert some text. ip.pos must be equal to zero.
Returns:
true, if there can be inserted any string, false otherwise.

getAttributeRule

IAttributeRuleP getAttributeRule(Attr attribute)
Returns rule for given attribute.

Parameters:
attribute - attribute, which rule must be returned. It must be a local attribute.
Returns:
rule, validating given attribute.

areElementsDeletable

List<? extends Element> areElementsDeletable(Set<? extends Element> elements)
Checks whether given elements are deletable. These elements must be children of context element. If all these elements can be safely deleted then function returns non-null reference to a list of elements, that must be deleted aswell. If null is returned then given elements are not deletable.

Parameters:
elements - set of elements that are to be deleted.
Returns:
list of elements that must be deleted aswell. The list may be empty. None of the elements contained in result list are contained in the elements aswell. If null is returned then given elements cannot be deleted.
Throws:
IllegalArgumentException - if given elements are not children of the context element.

getEnclosingElements

INameListP<? extends INewElementRuleP> getEnclosingElements(sk.baka.ikslibs.ptr.DOMPoint start,
                                                            sk.baka.ikslibs.ptr.DOMPoint end)
Computes and returns an one-sized insertlist of elements, that can enclose given nodeset.

Parameters:
start - the start of the nodeset. It must point before the end insertpoint.
end - the end of the nodeset.
Returns:
insertlist with one item. The item denotes an element, that can replace given content and contain this content as its children. If null is returned then no such element is suitable.

isDeclosable

boolean isDeclosable(Element e)
Checks if given element is declosable - if the contents of given element can replace the element.

Parameters:
e - the element to declose
Returns:
true if e is declosable, false otherwise.

isDeletable

boolean isDeletable(Node node)
Checks if a simple node is deletable from the element.

Parameters:
node - the node to query. Only the text/cdata/element/entity node that is child of context element can be queried.
Returns:
true if the node is deletable, false otherwise.

isInsertable

boolean isInsertable(sk.baka.ikslibs.ptr.DOMPoint ip,
                     Node node)
Checks if given nodes are insertable into given position.

Parameters:
ip - the point where the sequence shall be inserted
node - the node to insert. Entities, Entity references and document fragments are automatically expanded - replaced by their children. The node may be or contain any type of node, including entity references, comments etc.
Returns:
true if these nodes are insertable, false otherwise.

isDeletable

boolean isDeletable(sk.baka.ikslibs.ptr.DOMPoint start,
                    sk.baka.ikslibs.ptr.DOMPoint end)
Checks if given interval is removable from the document.

Parameters:
start - the start of the interval
end - the end of the interval
Returns:
true if these nodes are removable, false otherwise.

validate

void validate()
              throws SchemaException

Validates the element. It must be full validation, no elements nor texts must not be skipped. If this element is not valid, exception must be thrown.

When element from another namespace uri is encountered in the process of validation, just call ValidationContextP.validate() to validate this unknown element.

The only exception to this rule is emp:id attribute, which the schema must ignore.

Throws:
SchemaException - if something goes wrong in the process of validation. The Schema instance must provide as much information as possible about error. It should display path to errorneous element with getPathToRoot() method of EuromathSchemaProvider class.


Copyright © 2003-2006 null. All Rights Reserved.