01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the "License"). You may not use this file except
05: * in compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://jwsdp.dev.java.net/CDDLv1.0.html
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * HEADER in each file and include the License file at
14: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
15: * add the following below this CDDL HEADER, with the
16: * fields enclosed by brackets "[]" replaced with your
17: * own identifying information: Portions Copyright [yyyy]
18: * [name of copyright owner]
19: */
20: package com.sun.xml.xsom.parser;
21:
22: import org.xml.sax.ContentHandler;
23: import org.xml.sax.EntityResolver;
24: import org.xml.sax.ErrorHandler;
25:
26: /**
27: * Used to parse <xs:annotation>.
28: *
29: * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
30: */
31: public abstract class AnnotationParser {
32: /**
33: * Called every time a new <xs:annotation> element
34: * is found.
35: *
36: * The sub-tree rooted at <xs:annotation> will be
37: * sent to this ContentHandler as if it is a whole document.
38: *
39: * @param context
40: * indicates the schema component that owns this annotation.
41: * Always non-null.
42: * @param parentElementName
43: * local name of the element that contains <xs:annotation>.
44: * (e.g., "element", "attribute", ... )
45: * @param errorHandler
46: * The error handler that the client application specifies.
47: * The returned content handler can send its errors to this
48: * object.
49: * @param entityResolver
50: * The entity resolver that is currently in use. Again,
51: * The returned content handler can use this object
52: * if it needs to resolve entities.
53: */
54: public abstract ContentHandler getContentHandler(
55: AnnotationContext context, String parentElementName,
56: ErrorHandler errorHandler, EntityResolver entityResolver);
57:
58: /**
59: * Once the SAX events are fed to the ContentHandler,
60: * this method will be called to retrieve the parsed result.
61: *
62: * @param existing
63: * An annotation object which was returned from another
64: * AnnotationParser before. Sometimes, one schema component
65: * can have multiple <:xs:annotation> elements and
66: * this parameter is used to merge all those annotations
67: * together. If there is no existing object, null will be
68: * passed.
69: * @return
70: * Any object, including null.
71: */
72: public abstract Object getResult(Object existing);
73: }
|