View Javadoc
1   /**
2    * Redistribution and use of this software and associated documentation
3    * ("Software"), with or without modification, are permitted provided
4    * that the following conditions are met:
5    *
6    * 1. Redistributions of source code must retain copyright
7    *    statements and notices.  Redistributions must also contain a
8    *    copy of this document.
9    *
10   * 2. Redistributions in binary form must reproduce the
11   *    above copyright notice, this list of conditions and the
12   *    following disclaimer in the documentation and/or other
13   *    materials provided with the distribution.
14   *
15   * 3. The name "Exolab" must not be used to endorse or promote
16   *    products derived from this Software without prior written
17   *    permission of Intalio, Inc.  For written permission,
18   *    please contact info@exolab.org.
19   *
20   * 4. Products derived from this Software may not be called "Exolab"
21   *    nor may "Exolab" appear in their names without prior written
22   *    permission of Intalio, Inc. Exolab is a registered
23   *    trademark of Intalio, Inc.
24   *
25   * 5. Due credit should be given to the Exolab Project
26   *    (http://www.exolab.org/).
27   *
28   * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
29   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
32   * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39   * OF THE POSSIBILITY OF SUCH DAMAGE.
40   *
41   * Copyright 1999-2002 (C) Intalio, Inc. All Rights Reserved.
42   *
43   * $Id$
44   */
45  
46  package org.exolab.castor.xml.schema.reader;
47  
48  //-- imported classes and packages
49  import org.exolab.castor.xml.AttributeSet;
50  import org.exolab.castor.xml.Namespaces;
51  import org.exolab.castor.xml.XMLException;
52  import org.exolab.castor.xml.schema.SchemaContext;
53  
54  /**
55   * A class for Skipping unknown elements during unmarshalling 
56   * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a>
57   * @version $Revision$ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $ 
58  **/
59  public class UnknownUnmarshaller extends ComponentReader {
60  
61  
62        //--------------------/
63       //- Member Variables -/
64      //--------------------/
65  
66      /**
67       * The name of the element we are "unmarshalling"
68      **/
69      String name;
70      
71        //----------------/
72       //- Constructors -/
73      //----------------/
74  
75      public UnknownUnmarshaller(final SchemaContext schemaContext, final String name) {
76          super(schemaContext);
77          this.name = name;
78      } //-- UnknownUnmarshaller
79  
80        //-----------/
81       //- Methods -/
82      //-----------/
83  
84      /**
85       * Returns the name of the element that this ComponentReader
86       * handles
87       * @return the name of the element that this ComponentReader
88       * handles
89      **/
90      public String elementName() {
91          return name;
92      } //-- elementName
93  
94      /**
95       * Sets the name of the element that this UnknownUnmarshaller handles
96       * @param name the name of the element that this unmarshaller handles
97      **/
98      public void elementName(String name) {
99          this.name = name;
100     } //-- elementName
101 
102     /**
103      * Returns the Object created by this ComponentReader
104      * @return the Object created by this ComponentReader
105     **/
106     public Object getObject() {
107         return null;
108     } //-- getObject
109     
110     /**
111      * Signals the start of an element with the given name.
112      *
113      * @param name the NCName of the element. It is an error
114      * if the name is a QName (ie. contains a prefix).
115      * @param namespace the namespace of the element. This may be null.
116      * Note: A null namespace is not the same as the default namespace unless
117      * the default namespace is also null.
118      * @param atts the AttributeSet containing the attributes associated
119      * with the element.
120      * @param nsDecls the namespace declarations being declared for this 
121      * element. This may be null.
122     **/
123     public void startElement(String name, String namespace, AttributeSet atts,
124         Namespaces nsDecls)
125         throws XMLException
126     {
127         //-- do nothing, this method is overwritten by subclasses
128         
129     } //-- startElement
130 
131     /**
132      * Signals to end of the element with the given name.
133      *
134      * @param name the NCName of the element. It is an error
135      * if the name is a QName (ie. contains a prefix).
136      * @param namespace the namespace of the element.
137     **/
138     public void endElement(String name, String namespace)
139         throws XMLException
140     {
141         //-- do nothing, this method is overwritten by subclasses
142     } //-- endElement
143 
144     public void characters(char[] ch, int start, int length) 
145         throws XMLException
146     {
147     } //-- characters
148 
149 } //-- UnknownUnmarshaller