001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package com.sun.tools.xjc.reader.internalizer;
037:
038: import org.w3c.dom.Element;
039: import org.xml.sax.helpers.XMLFilterImpl;
040:
041: /**
042: * Encapsulates schema-language dependent internalization logic.
043: *
044: * {@link Internalizer} and {@link DOMForest} are responsible for
045: * doing schema language independent part, and this object is responsible
046: * for schema language dependent part.
047: *
048: * @author
049: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
050: */
051: public interface InternalizationLogic {
052: /**
053: * Creates a new instance of XMLFilter that can be used to
054: * find references to external schemas.
055: *
056: * <p>
057: * Schemas that are included/imported need to be a part of
058: * {@link DOMForest}, and this filter will be expected to
059: * find such references.
060: *
061: * <p>
062: * Once such a reference is found, the filter is expected to
063: * call the parse method of DOMForest.
064: *
065: * <p>
066: * {@link DOMForest} will register ErrorHandler to the returned
067: * object, so any error should be sent to that error handler.
068: *
069: * @return
070: * This method returns {@link XMLFilterImpl} because
071: * the filter has to be usable for two directions
072: * (wrapping a reader and wrapping a ContentHandler)
073: */
074: XMLFilterImpl createExternalReferenceFinder(DOMForest parent);
075:
076: /**
077: * Checks if the specified element is a valid target node
078: * to attach a customization.
079: *
080: * @param parent
081: * The owner DOMForest object. Probably useful only
082: * to obtain context information, such as error handler.
083: * @param bindings
084: * <jaxb:bindings> element or a customization element.
085: * @return
086: * true if it's OK, false if not.
087: */
088: boolean checkIfValidTargetNode(DOMForest parent, Element bindings,
089: Element target);
090:
091: /**
092: * Prepares an element that actually receives customizations.
093: *
094: * <p>
095: * For example, in XML Schema, target nodes can be any schema
096: * element but it is always the <xsd:appinfo> element that
097: * receives customization.
098: *
099: * @param target
100: * The target node designated by the customization.
101: * @return
102: * Always return non-null valid object
103: */
104: Element refineTarget(Element target);
105: }
|