dk.brics.jwig.analysis.summarygraph
Class Template

java.lang.Object
  |
  +--dk.brics.jwig.analysis.summarygraph.Template

public class Template
extends Object

XML template (document with gaps).


Field Summary
static int DIAMOND
          Used for radio buttons.
static int ONE
          One occurence.
static int STAR
          Unknown number of occurences.
static int ZERO
          Zero occurences.
 
Constructor Summary
Template(List xml)
          Constructs a new Template from JDOM tree.
Template(String str, URL context, String default_namespace)
          Constructs a new Template from a string.
 
Method Summary
 void fixAnchors()
          Inserts href attributes in all a elements that have a submit attribute and removes the submit attribute and also the status attribute, if present.
 void fixForms()
          Inserts action attributes in all form elements that do not have either a normal attribute or a gap attribute named action.
 Set getAttributeGaps()
          Returns set of attribute gap names.
static String getGap(Attribute a)
          Returns gap name of gap attribute.
static String getGap(Element e)
          Returns gap name of gap element.
static Namespace getGapNamespace()
          Returns namespace for gap elements and attributes.
 Set getTemplateGaps()
          Returns set of template gap names.
 List getXML()
          Returns list of JDOM XML content nodes.
 List inFields(Set open, String action)
          Returns field count map for each form that has an action attribute with the given value.
 List inGaps(String action)
          Returns gap count map for each form that has an action attribute with the given value.
static boolean isGap(Attribute a)
          Checks whether the given attribute represents a gap.
static boolean isGap(Element e)
          Checks whether the given element represents a gap.
static Document makeDocument(String str, URL context)
          Builds an XML document from a String and expands XInclude and import instructions.
static Document makeDocument(URL url)
          Retrieves an XML document from a URL and expands XInclude and import instructions.
 HashMap outFields(Set open)
          Returns field count map.
 HashMap outGaps()
          Returns gap count map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIAMOND

public static final int DIAMOND
Used for radio buttons.

See Also:
Constant Field Values

ONE

public static final int ONE
One occurence.

See Also:
Constant Field Values

STAR

public static final int STAR
Unknown number of occurences.

See Also:
Constant Field Values

ZERO

public static final int ZERO
Zero occurences.

See Also:
Constant Field Values
Constructor Detail

Template

public Template(List xml)
Constructs a new Template from JDOM tree. It is assumed that XInclude and import instructions have been processed.

Parameters:
xml - XML template

Template

public Template(String str,
                URL context,
                String default_namespace)
         throws JDOMException,
                MalformedURLException
Constructs a new Template from a string. Builds an XML template from a String and expands XInclude and import instructions. The namespace prefix sg is set to the JWIG gap namespace URL. The empty prefix is set to the given default namespace.

Parameters:
str - XML template string
context - URL context for resolving relative URLs (null if none)
default_namespace - initial default namespace
Throws:
JDOMException - if an error occured during JDOM parsing or XInclude/import expansion
MalformedURLException - if a malformed URL appears in an XInclude/import instruction
Method Detail

fixAnchors

public void fixAnchors()
Inserts href attributes in all a elements that have a submit attribute and removes the submit attribute and also the status attribute, if present.


fixForms

public void fixForms()
Inserts action attributes in all form elements that do not have either a normal attribute or a gap attribute named action.


getAttributeGaps

public Set getAttributeGaps()
Returns set of attribute gap names.


getGap

public static String getGap(Attribute a)
Returns gap name of gap attribute.

Returns:
gap name

getGap

public static String getGap(Element e)
Returns gap name of gap element.

Returns:
gap name

getGapNamespace

public static Namespace getGapNamespace()
Returns namespace for gap elements and attributes.

Returns:
namespace

getTemplateGaps

public Set getTemplateGaps()
Returns set of template gap names.


getXML

public List getXML()
Returns list of JDOM XML content nodes.


inFields

public List inFields(Set open,
                     String action)
Returns field count map for each form that has an action attribute with the given value.

Parameters:
open - set of names of open gaps
action - special value of JWIG form actions
Returns:
list of maps from field name to ONE, STAR, or DIAMOND (ZERO by default)

inGaps

public List inGaps(String action)
Returns gap count map for each form that has an action attribute with the given value.

Returns:
list of maps from gap name to ONE or STAR (ZERO by default)

isGap

public static boolean isGap(Attribute a)
Checks whether the given attribute represents a gap.

Returns:
true if a represents a gap

isGap

public static boolean isGap(Element e)
Checks whether the given element represents a gap.

Returns:
true if e represents a gap

makeDocument

public static Document makeDocument(String str,
                                    URL context)
                             throws JDOMException,
                                    MalformedURLException
Builds an XML document from a String and expands XInclude and import instructions.

Parameters:
str - XML document
context - URL context for resolving relative URLs (null if none)
Returns:
XML document
Throws:
JDOMException - if an error occured during JDOM parsing or XInclude/import expansion
MalformedURLException - if a malformed URL appears in an XInclude/import instruction

makeDocument

public static Document makeDocument(URL url)
                             throws JDOMException,
                                    MalformedURLException
Retrieves an XML document from a URL and expands XInclude and import instructions.

Parameters:
url - URL of XML document
Returns:
XML document
Throws:
JDOMException - if an error occured during JDOM parsing or XInclude/import expansion
MalformedURLException - if a malformed URL appears in an XInclude/import instruction

outFields

public HashMap outFields(Set open)
Returns field count map.

Parameters:
open - set of names of open gaps
Returns:
map from field name to ONE, STAR, or DIAMOND (ZERO by default)

outGaps

public HashMap outGaps()
Returns gap count map.

Returns:
map from gap name to ONE or STAR (ZERO by default)


Copyright © 2002 Anders Møller.