All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class xv.xv_ViewFactory

java.lang.Object
   |
   +----xm.xm_Factory
           |
           +----xv.xv_ViewFactory

public class xv_ViewFactory
extends xm_Factory
implements ViewFactory

Factory for generating views for displaying XML nodes in a JEditorPane. Since the constructors of swing.text.View objects must be passed the Element of which they are Views, this class can only create Views given an actual Element object: a node type and/or name are not sufficient. Consequently this class has a more limited range of methods than other classes driven by the node type registry (eg. xm_NodeFactory).

Note that this factory can only create View objects which have a single- argument constructor, where that single argument is the element for which it is a View. This is a little irritating, since there are Views (such as BoxView) which take additional arguments, but is not a major problem in practice. This limitation could be lifted with a considerable amount of work - the bulk of which is in configuring the argument values to use and implementing a mechanism to make them accessible to this factory. One possibility is to use an XML configuration file, and pass the list of attributes associated with one element type to the View class for it to use as it wishes.

Another possible enhancement would be to use an XML configuration file (an extension to an XSL stylesheet?) to offer more flexibility than simply specifying a single View class for each registry entry. (This argument applies equally well to customizer classes.)

Given the name/type of an XML node (or a node itself), it creates a view object suitable for displaying it.


Variable Index

 o ElementClassName
Name of class which is passed as the first argument to the constructors of View objects.
 o UsualViewClassName
Name of class from which all view objects must be derived.
 o ViewConstructorArgs
Identities of class which is passed as the first argument to the constructors of View objects.
 o ViewConstructorClasses
Identities of class which is passed as the first argument to the constructors of View objects.

Constructor Index

 o xv_ViewFactory()
Default constructor.

Method Index

 o create(Element)
Create a view suitable for the InputElement.
 o createView(xg_Node)

Create a view of a type suitable for displaying a node whose name is 'InputNodeName'.

 o getViewClassName(String, int)
Get the name of the view class suitable for displaying a node whose name is 'InputNodeName'.

Variables

 o UsualViewClassName
 public static final String UsualViewClassName
Name of class from which all view objects must be derived.

 o ElementClassName
 public static final String ElementClassName
Name of class which is passed as the first argument to the constructors of View objects.

 o ViewConstructorClasses
 protected Class ViewConstructorClasses[]
Identities of class which is passed as the first argument to the constructors of View objects.

 o ViewConstructorArgs
 protected Object ViewConstructorArgs[]
Identities of class which is passed as the first argument to the constructors of View objects.

Constructors

 o xv_ViewFactory
 public xv_ViewFactory()
Default constructor.

Methods

 o createView
 public View createView(xg_Node InputNode) throws xv_ViewCreationException

Create a view of a type suitable for displaying a node whose name is 'InputNodeName'. If no view is registered for InputNodeName, then a custopmizer suitable for InputNodeType is created. This dual-level scheme allows special views to be added, while still creating views of the correct standard type the rest of the time.

Non-standard views can be added by registering them with xm_NodeTypeRegistry.

Parameters:
InputNode - The node for which we need a view
Returns:
The newly-created view for the InputNode
Throws: xv_ViewCreationException
Either no view class is registered or it cannot be instantiated
 o getViewClassName
 public String getViewClassName(String InputNodeName,
                                int InputNodeType) throws xv_ViewCreationException
Get the name of the view class suitable for displaying a node whose name is 'InputNodeName'. If no view is registered for InputNodeName, get the name of a view suitable for InputNodeType.

Parameters:
InputNodeName - The name of the node for which we need a view
InputNodeType - The type of node for which we need a view
Returns:
The newly-created view for the named entity
Throws: xv_ViewCreationException
No view class is registered
 o create
 public View create(Element InputElement)
Create a view suitable for the InputElement.

Parameters:
InputElement - The element for which a view is required
Returns:
The newly-created view

All Packages  Class Hierarchy  This Package  Previous  Next  Index