src/share/jaxws_classes/com/sun/xml/internal/rngom/ast/builder/SchemaBuilder.java

changeset 0
373ffda63c9a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/rngom/ast/builder/SchemaBuilder.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,202 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +/*
    1.29 + * Copyright (C) 2004-2011
    1.30 + *
    1.31 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.32 + * of this software and associated documentation files (the "Software"), to deal
    1.33 + * in the Software without restriction, including without limitation the rights
    1.34 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    1.35 + * copies of the Software, and to permit persons to whom the Software is
    1.36 + * furnished to do so, subject to the following conditions:
    1.37 + *
    1.38 + * The above copyright notice and this permission notice shall be included in
    1.39 + * all copies or substantial portions of the Software.
    1.40 + *
    1.41 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.42 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.43 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.44 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.45 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    1.46 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    1.47 + * THE SOFTWARE.
    1.48 + */
    1.49 +package com.sun.xml.internal.rngom.ast.builder;
    1.50 +
    1.51 +import com.sun.xml.internal.rngom.ast.om.Location;
    1.52 +import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
    1.53 +import com.sun.xml.internal.rngom.ast.om.ParsedNameClass;
    1.54 +import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
    1.55 +import com.sun.xml.internal.rngom.parse.*;
    1.56 +import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
    1.57 +import com.sun.xml.internal.rngom.parse.Parseable;
    1.58 +
    1.59 +import java.util.List;
    1.60 +
    1.61 +// TODO: define combine error check should be done by the parser.
    1.62 +public interface SchemaBuilder<
    1.63 +    N extends ParsedNameClass,
    1.64 +    P extends ParsedPattern,
    1.65 +    E extends ParsedElementAnnotation,
    1.66 +    L extends Location,
    1.67 +    A extends Annotations<E,L,CL>,
    1.68 +    CL extends CommentList<L>> {
    1.69 +
    1.70 +    /**
    1.71 +     * Returns the {@link NameClassBuilder}, which is used to build name
    1.72 +     * classes for this {@link SchemaBuilder}. The
    1.73 +     * {@link com.sun.xml.internal.rngom.nc.NameClass}es that are built will then be
    1.74 +     * fed into this {@link SchemaBuilder}to further build RELAX NG patterns.
    1.75 +     *
    1.76 +     * @return always return a non-null valid object. This method can (and
    1.77 +     *         probably should) always return the same object.
    1.78 +     */
    1.79 +    NameClassBuilder<N,E,L,A,CL> getNameClassBuilder() throws BuildException;
    1.80 +
    1.81 +    P makeChoice(List<P> patterns, L loc, A anno) throws BuildException;
    1.82 +
    1.83 +    P makeInterleave(List<P> patterns, L loc, A anno) throws BuildException;
    1.84 +
    1.85 +    P makeGroup(List<P> patterns, L loc, A anno) throws BuildException;
    1.86 +
    1.87 +    P makeOneOrMore(P p, L loc, A anno) throws BuildException;
    1.88 +
    1.89 +    P makeZeroOrMore(P p, L loc, A anno) throws BuildException;
    1.90 +
    1.91 +    P makeOptional(P p, L loc, A anno) throws BuildException;
    1.92 +
    1.93 +    P makeList(P p, L loc, A anno) throws BuildException;
    1.94 +
    1.95 +    P makeMixed(P p, L loc, A anno) throws BuildException;
    1.96 +
    1.97 +    P makeEmpty(L loc, A anno);
    1.98 +
    1.99 +    P makeNotAllowed(L loc, A anno);
   1.100 +
   1.101 +    P makeText(L loc, A anno);
   1.102 +
   1.103 +    P makeAttribute(N nc, P p, L loc, A anno) throws BuildException;
   1.104 +
   1.105 +    P makeElement(N nc, P p, L loc, A anno) throws BuildException;
   1.106 +
   1.107 +    DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary, String type, L loc) throws BuildException;
   1.108 +
   1.109 +    P makeValue(String datatypeLibrary, String type, String value,
   1.110 +            Context c, String ns, L loc, A anno) throws BuildException;
   1.111 +
   1.112 +    /**
   1.113 +     *
   1.114 +     * @param parent
   1.115 +     *      The parent scope. null if there's no parent scope.
   1.116 +     *      For example, if the complete document looks like the following:
   1.117 +     *      <pre><xmp>
   1.118 +     *      <grammar>
   1.119 +     *        <start><element name="root"><empty/></element></start>
   1.120 +     *      </grammar>
   1.121 +     *      </xmp></pre>
   1.122 +     *      Then when the outer-most {@link Grammar} is created, it will
   1.123 +     *      receive the <tt>null</tt> parent.
   1.124 +     */
   1.125 +    Grammar<P,E,L,A,CL> makeGrammar(Scope<P,E,L,A,CL> parent);
   1.126 +
   1.127 +    /**
   1.128 +     * Called when annotation is found right inside a pattern
   1.129 +     *
   1.130 +     * such as,
   1.131 +     *
   1.132 +     * <pre><xmp>
   1.133 +     * <element name="foo">     <!-- this becomes 'P' -->
   1.134 +     *   <foreign:annotation /> <!-- this becomes 'A' -->
   1.135 +     *   ...
   1.136 +     * </element>
   1.137 +     * </xmp></pre>
   1.138 +     */
   1.139 +    P annotate(P p, A anno) throws BuildException;
   1.140 +
   1.141 +    /**
   1.142 +     * Called when element annotation is found after a pattern.
   1.143 +     *
   1.144 +     * such as,
   1.145 +     *
   1.146 +     * <pre><xmp>
   1.147 +     * <element name="foo">
   1.148 +     *   <empty />              <!-- this becomes 'P' -->
   1.149 +     *   <foreign:annotation /> <!-- this becomes 'E' -->
   1.150 +     * </element>
   1.151 +     * </xmp></pre>
   1.152 +     */
   1.153 +    P annotateAfter(P p, E e) throws BuildException;
   1.154 +
   1.155 +    P commentAfter(P p, CL comments) throws BuildException;
   1.156 +
   1.157 +    /**
   1.158 +     *
   1.159 +     * @param current
   1.160 +     *      Current grammar that we are parsing. This is what contains
   1.161 +     *      externalRef.
   1.162 +     * @param scope
   1.163 +     *      The parent scope. null if there's no parent scope.
   1.164 +     *      See {@link #makeGrammar(Scope)} for more details about
   1.165 +     *      when this parameter can be null.
   1.166 +     */
   1.167 +    P makeExternalRef(Parseable current, String uri, String ns, Scope<P,E,L,A,CL> scope,
   1.168 +        L loc, A anno) throws BuildException, IllegalSchemaException;
   1.169 +
   1.170 +    L makeLocation(String systemId, int lineNumber, int columnNumber);
   1.171 +
   1.172 +    /**
   1.173 +     * Creates {@link Annotations} object to parse annotations on patterns.
   1.174 +     *
   1.175 +     * @return
   1.176 +     *      must be non-null.
   1.177 +     */
   1.178 +    A makeAnnotations(CL comments, Context context);
   1.179 +
   1.180 +    ElementAnnotationBuilder<P,E,L,A,CL> makeElementAnnotationBuilder(String ns,
   1.181 +        String localName, String prefix, L loc, CL comments,
   1.182 +        Context context);
   1.183 +
   1.184 +    CL makeCommentList();
   1.185 +
   1.186 +    P makeErrorPattern();
   1.187 +
   1.188 +    /**
   1.189 +     * If this {@link SchemaBuilder}is interested in actually parsing
   1.190 +     * comments, this method returns true.
   1.191 +     * <p>
   1.192 +     * Returning false allows the schema parser to speed up the processing by
   1.193 +     * skiping comment-related handlings.
   1.194 +     */
   1.195 +    boolean usesComments();
   1.196 +
   1.197 +    /**
   1.198 +     * Called after all the parsing is done.
   1.199 +     *
   1.200 +     * <p>
   1.201 +     * This hook typically allows as {@link SchemaBuilder} to expand
   1.202 +     * notAllowed (if it's following the simplification as in the spec.)
   1.203 +     */
   1.204 +    P expandPattern( P p ) throws BuildException, IllegalSchemaException;
   1.205 +}

mercurial