org.dspace.app.xmlui.wing.element
Class AbstractWingElement

java.lang.Object
  extended by org.dspace.app.xmlui.wing.element.AbstractWingElement
All Implemented Interfaces:
WingElement
Direct Known Subclasses:
Body, Container, Data, Division, Field, List, Meta, Options, PageMeta, Params, Reference, ReferenceSet, RepositoryMeta, Row, SimpleHTMLFragment, Table, UserMeta, WingDocument

public abstract class AbstractWingElement
extends Object
implements WingElement

This class represents a generic element inside the Wing framework. The primary purpose of this abstract class is to create a generic datatype for storage of any WingElement. Second, this class also provides a set of utilities for easy maintenance of each wing element. There are a set of methods for sending SAX events that handle namespaces and attributes so that each individual wing element does not. There are also a set of utility methods for checking method parameters.

Author:
Scott Phillips

Field Summary
protected  WingContext context
          The current context this element is operating under.
 
Constructor Summary
protected AbstractWingElement()
          Construct a new WingElement without access to the current wing Context.
protected AbstractWingElement(WingContext context)
          Construct a new WingElement.
 
Method Summary
 void dispose()
          Dispose
protected  void endElement(ContentHandler contentHandler, NamespaceSupport namespaces, Namespace namespace, String name)
          Send the SAX events to end this element.
protected  void endElement(ContentHandler contentHandler, NamespaceSupport namespaces, String name)
          Send the SAX events to end this element.
protected  WingContext getWingContext()
          Return the currently registered wing context.
protected  void greater(int parameter, int greater, String message)
          Check to make sure that the parameter is GREATER THAN (note: not equal to) the given greater variable.
protected  void lesser(int parameter, int lesser, String message)
          Check to make sure that the parameter is LESS THAN (note: not equal to) the given lesser variable.
protected  void require(Message parameter, String message)
          Check to make sure the parameter is not null or an empty string.
protected  void require(String parameter, String message)
          Check to make sure the parameter is not null or an empty string.
protected  void requireFalse(boolean test, String message)
          Check to make sure that the boolean test value is false.
protected  void requireTrue(boolean test, String message)
          Check to make sure that the boolean test value is true.
protected  void restrict(String parameter, String[] options, String message)
          Check to make sure that the parameter is a member of one of the options.
protected  void sendCharacters(ContentHandler contentHandler, String characters)
          Send the SAX event for these plain characters, not wrapped in any elements.
protected  void setWingContext(WingContext context)
          Set the WingContext, note there are potential side effects of changing the WingContext once it has been used.
protected  void startElement(ContentHandler contentHandler, NamespaceSupport namespaces, Namespace namespace, String name, AttributeMap attributes)
          Send the SAX events to start this element.
protected  void startElement(ContentHandler contentHandler, NamespaceSupport namespaces, String name, AttributeMap attributes)
          Send the SAX event to start this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.dspace.app.xmlui.wing.element.WingElement
toSAX
 

Field Detail

context

protected WingContext context
The current context this element is operating under. From the context contentHandler, namespace support, and unique id generation can be found. This context is shared between many elements.

Constructor Detail

AbstractWingElement

protected AbstractWingElement(WingContext context)
Construct a new WingElement. All wing elements must have access to a current WingContext.

Parameters:
context - (Required) The context this element is contained in.

AbstractWingElement

protected AbstractWingElement()
Construct a new WingElement without access to the current wing Context. This means that the wing element will not be able to know the component name because the context is not available. This invocation method is intended for wing element implementations that are outside the wing pacakage.

Method Detail

getWingContext

protected WingContext getWingContext()
Return the currently registered wing context.


setWingContext

protected void setWingContext(WingContext context)
Set the WingContext, note there are potential side effects of changing the WingContext once it has been used. This context should not be changed after elements have been added to a wingElement.

Parameters:
context - The new WingContext.

require

protected void require(String parameter,
                       String message)
                throws WingInvalidArgument
Check to make sure the parameter is not null or an empty string.

Parameters:
parameter - A non null and none empty string
message - The exception message thrown if parameter is invalid.
Throws:
WingInvalidArgument

require

protected void require(Message parameter,
                       String message)
                throws WingInvalidArgument
Check to make sure the parameter is not null or an empty string.

Parameters:
parameter - A non null and none empty string
message - The exception message thrown if parameter is invalid.
Throws:
WingInvalidArgument

restrict

protected void restrict(String parameter,
                        String[] options,
                        String message)
                 throws WingInvalidArgument
Check to make sure that the parameter is a member of one of the options. This method will accept null values, if you need to restrict and not allow null values then use the require() method in conjunction with this method.

Parameters:
parameter - A null string, or a member of the options array.
options - A list of possible values for the parameter.
message - The exception message thrown if the parameter is invalid.
Throws:
WingInvalidArgument

greater

protected void greater(int parameter,
                       int greater,
                       String message)
                throws WingInvalidArgument
Check to make sure that the parameter is GREATER THAN (note: not equal to) the given greater variable.

Parameters:
parameter - An int who's value is greater than greater.
greater - An int who's value is lesser that greater.
message - The exception message thrown if the parameter is invalid.
Throws:
WingInvalidArgument

lesser

protected void lesser(int parameter,
                      int lesser,
                      String message)
               throws WingInvalidArgument
Check to make sure that the parameter is LESS THAN (note: not equal to) the given lesser variable.

Parameters:
parameter - An int who's value is less than lesser.
lesser - An int who's value is greater that lesser.
message - The exception message thrown if the parameter is invalid.
Throws:
WingInvalidArgument

requireFalse

protected void requireFalse(boolean test,
                            String message)
                     throws WingInvalidArgument
Check to make sure that the boolean test value is false.

Parameters:
test - A false value.
message - The exception message thrown if "test" is invalid.
Throws:
WingInvalidArgument

requireTrue

protected void requireTrue(boolean test,
                           String message)
                    throws WingInvalidArgument
Check to make sure that the boolean test value is true.

Parameters:
test - A true value.
message - The exception message thrown if "test" is invalid.
Throws:
WingInvalidArgument

startElement

protected void startElement(ContentHandler contentHandler,
                            NamespaceSupport namespaces,
                            String name,
                            AttributeMap attributes)
                     throws SAXException
Send the SAX event to start this element. Assume the DRI namespace.

Parameters:
contentHandler - (Required) The registered contentHandler where SAX events should be routed too.
namespaces - (Required) SAX Helper class to keep track of namespaces able to determine the correct prefix for a given namespace URI.
name - (Required) The element's localName
attributes - (May be null) Attributes for this element.
Throws:
SAXException

startElement

protected void startElement(ContentHandler contentHandler,
                            NamespaceSupport namespaces,
                            Namespace namespace,
                            String name,
                            AttributeMap attributes)
                     throws SAXException
Send the SAX events to start this element.

Parameters:
contentHandler - (Required) The registered contentHandler where SAX events should be routed too.
namespaces - (Required) SAX Helper class to keep track of namespaces able to determine the correct prefix for a given namespace URI.
namespace - (Required) The namespace of this element.
name - (Required) The local name of this element.
attributes - (May be null) Attributes for this element
Throws:
SAXException

sendCharacters

protected void sendCharacters(ContentHandler contentHandler,
                              String characters)
                       throws SAXException
Send the SAX event for these plain characters, not wrapped in any elements.

Parameters:
contentHandler - (Required) The registered contentHandler where SAX events should be routed too.
characters - (May be null) Characters to send.
Throws:
SAXException

endElement

protected void endElement(ContentHandler contentHandler,
                          NamespaceSupport namespaces,
                          String name)
                   throws SAXException
Send the SAX events to end this element. Assume the DRI namespace.

Parameters:
contentHandler - (Required) The registered contentHandler where SAX events should be routed too.
namespaces - (Required) SAX Helper class to keep track of namespaces able to determine the correct prefix for a given namespace URI.
name - (Required) The localName of this element.
Throws:
SAXException

endElement

protected void endElement(ContentHandler contentHandler,
                          NamespaceSupport namespaces,
                          Namespace namespace,
                          String name)
                   throws SAXException
Send the SAX events to end this element.

Parameters:
contentHandler - (Required) The registered contentHandler where SAX events should be routed too.
namespaces - (Required) SAX Helper class to keep track of namespaces able to determine the correct prefix for a given namespace URI.
namespace - (Required) The namespace of this element.
name - (Required) The local name of this element.
Throws:
SAXException

dispose

public void dispose()
Dispose

Specified by:
dispose in interface WingElement


Copyright © 2012 DuraSpace. All Rights Reserved.