001: /*
002: * Head.java
003: *
004: * Version: $Revision: 1.4 $
005: *
006: * Date: $Date: 2006/03/13 17:19:39 $
007: *
008: * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
009: * Institute of Technology. All rights reserved.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions are
013: * met:
014: *
015: * - Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * - Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in the
020: * documentation and/or other materials provided with the distribution.
021: *
022: * - Neither the name of the Hewlett-Packard Company nor the name of the
023: * Massachusetts Institute of Technology nor the names of their
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038: * DAMAGE.
039: */
040:
041: package org.dspace.app.xmlui.wing.element;
042:
043: import org.dspace.app.xmlui.wing.AttributeMap;
044: import org.dspace.app.xmlui.wing.WingContext;
045: import org.dspace.app.xmlui.wing.WingException;
046: import org.xml.sax.ContentHandler;
047: import org.xml.sax.SAXException;
048: import org.xml.sax.ext.LexicalHandler;
049: import org.xml.sax.helpers.NamespaceSupport;
050:
051: /**
052: * This class represents a head for either a table, division, or list.
053: *
054: * @author Scott Phillips
055: */
056:
057: public class Head extends TextContainer implements StructuralElement {
058: /** The name of the head element */
059: public static final String E_HEAD = "head";
060:
061: /** The head's name */
062: private String name;
063:
064: /**
065: * Construct a new head.
066: *
067: * @param context
068: * (Required) The context this element is contained in
069: * @param name
070: * (May be null) a local identifier used to differentiate the
071: * element from its siblings.
072: */
073: protected Head(WingContext context, String name)
074: throws WingException {
075: super (context);
076: this .name = name;
077: }
078:
079: /**
080: * Translate this element and all contained elements into SAX events. The
081: * events should be routed to the contentHandler found in the WingContext.
082: *
083: * @param contentHandler
084: * (Required) The registered contentHandler where SAX events
085: * should be routed too.
086: * @param lexicalHandler
087: * (Required) The registered lexicalHandler where lexical
088: * events (such as CDATA, DTD, etc) should be routed too.
089: * @param namespaces
090: * (Required) SAX Helper class to keep track of namespaces able
091: * to determine the correct prefix for a given namespace URI.
092: */
093: public void toSAX(ContentHandler contentHandler,
094: LexicalHandler lexicalHandler, NamespaceSupport namespaces)
095: throws SAXException {
096: AttributeMap attributes = new AttributeMap();
097: if (this .name != null) {
098: attributes.put(A_NAME, name);
099: attributes.put(A_ID, context.generateID(E_HEAD, name));
100: }
101:
102: startElement(contentHandler, namespaces, E_HEAD, attributes);
103: super .toSAX(contentHandler, lexicalHandler, namespaces);
104: endElement(contentHandler, namespaces, E_HEAD);
105: }
106:
107: /**
108: * dispose
109: */
110: public void dispose() {
111: super.dispose();
112: }
113:
114: }
|