sk.uniba.euromath.document.schema
Class NewElementRule

java.lang.Object
  extended by sk.uniba.euromath.document.schema.BaseRule
      extended by sk.uniba.euromath.document.schema.NewElementRule

public class NewElementRule
extends BaseRule

Represents rule for one element (the context element), that is being created. This rule may consist of more than one expression, but all expressions must generate exactly one element with required name. These expressions are alternatives to each other; only one expression can be selected to generate new contents of element.

Returned values depends on context element of this instance. This context element doesn't exist yet, it is being created.

Representing class must properly implement equals() and hashValue() to ensure, that it can be properly placed into HashMap. These values should be computed only from enclosed expressions.

When creating element with this rule, choose between the following:

  1. Creating elements: when creating elements, then text is always validated with AnyString, therefore there can be no text at all. So, when creating elements, no text is needed to be created.
  2. When creating text, just rely on the value returned by getNewTextRule, there is no need to creating elements.

So, creation algorithm is as follows:

Author:
Martin Vysny

Method Summary
 List<AttributeListRule> getLists()
           For each expression returns one list of attributes, that can be created by this rule.
 ElementSequenceRule 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.
 
Methods inherited from class sk.uniba.euromath.document.schema.BaseRule
valueOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLists

public List<AttributeListRule> getLists()

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.

Returns:
list of creatable attributes.

getNewContent

public ElementSequenceRule getNewContent(Element e)

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.

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)
Computes and returns value rule, that can be inserted into context element.

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.


Copyright © 2003-2006 null. All Rights Reserved.