001: /*
002: * WingMergeableElement.java
003: *
004: * Version: $Revision: 1.2 $
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.WingException;
044: import org.xml.sax.Attributes;
045: import org.xml.sax.SAXException;
046:
047: /**
048: * This is an interface to represent all WingElements that can be merged.
049: *
050: * @author Scott Phillips
051: */
052:
053: public interface WingMergeableElement extends WingElement {
054:
055: /**
056: * Determine if the given SAX startElement event is equivalent to this
057: * WingElement.
058: *
059: * @param namespace
060: * The element's name space
061: * @param localName
062: * The local, unqualified, name for this element
063: * @param qName
064: * The qualified name for this element
065: * @param attributes
066: * The element's attributes
067: * @return True if this WingElement is equivalent to the given SAX Event.
068: */
069: public boolean mergeEqual(String namespace, String localName,
070: String qName, Attributes attributes) throws SAXException,
071: WingException;
072:
073: /**
074: * Merge the given SAX startElement event into this element's child. If this
075: * SAX event matches a child element of this element then it should be
076: * removed from the internal book keep of this element and returned.
077: * typically this is accomplished by looping through all children elements
078: * and returned the first one that returns true for the mergeEqual method.
079: *
080: * @param namespace
081: * The element's name space
082: * @param localName
083: * The local, unqualified, name for this element *
084: * @param qName
085: * The qualified name for this element
086: * @param attributes
087: * The element's attributes
088: * @return The child element
089: */
090: public WingMergeableElement mergeChild(String namespace,
091: String localName, String qName, Attributes attributes)
092: throws SAXException, WingException;
093:
094: /**
095: * Inform this element that it is being merged with an existing element.
096: * Practically this means that when this method is being transformed to SAX it
097: * should assume that the element's SAX events have all ready been sent. In
098: * this case the element would only need to transform to SAX the children of
099: * this element.
100: *
101: * Further more if the element needs to add any attributes to the SAX
102: * startElement event it may modify the attributes object passed to make
103: * changes.
104: *
105: * @return The attributes for this merged element
106: */
107: public Attributes merge(Attributes attributes) throws SAXException,
108: WingException;
109: }
|