View Javadoc
1   /*
2    * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4    *
5    * This code is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License version 2 only, as
7    * published by the Free Software Foundation.  Oracle designates this
8    * particular file as subject to the "Classpath" exception as provided
9    * by Oracle in the LICENSE file that accompanied this code.
10   *
11   * This code is distributed in the hope that it will be useful, but WITHOUT
12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   * version 2 for more details (a copy is included in the LICENSE file that
15   * accompanied this code).
16   *
17   * You should have received a copy of the GNU General Public License version
18   * 2 along with this work; if not, write to the Free Software Foundation,
19   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20   *
21   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22   * or visit www.oracle.com if you need additional information or have any
23   * questions.
24   */
25  
26  package com.sun.tools.internal.xjc.reader.xmlschema.bindinfo;
27  
28  import java.util.Collection;
29  
30  import javax.xml.namespace.QName;
31  
32  import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder;
33  
34  import org.xml.sax.Locator;
35  
36  /**
37   * Base interface for all binding customization declarations.
38   *
39   * <p>
40   * Because of the setParent method, one customization declaration
41   * can be attached to one component alone.
42   *
43   * @author
44   *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
45   */
46  public interface BIDeclaration {
47  
48      /**
49       * Sets the parent BindInfo object of this declaration.
50       * A declaration object can use this pointer to access
51       * context information, such as other customizations.
52       *
53       * <p>
54       * This method can be only called from {@link BindInfo},
55       * and only once. This is a good opportunity to do some
56       * follow-up initialization after JAXB unmarshalling
57       * populated {@link BIDeclaration}.
58       */
59      void setParent( BindInfo parent );
60  
61      /**
62       * Gets the name of this binding declaration,
63       * which is the same as the tag name of the binding element.
64       */
65      QName getName();
66  
67      /**
68       * Gets the source location where this declaration was written.
69       * For declarations that are generated by XJC itself,
70       * this method returns null.
71       */
72      Locator getLocation();
73  
74      /**
75       * Marks this declaration to be acknowledged -- either actually
76       * used or the existence is admitted (for example when
77       * a property customization is given at the point of definition.)
78       *
79       * <p>
80       * Declarations that are not acknowledged will be considered
81       * as an error.
82       */
83      void markAsAcknowledged();
84  
85      /**
86       * Checks if this declaration was acknowledged.
87       */
88      boolean isAcknowledged();
89  
90      /**
91       * Called when the parent {@link BindInfo} got its owner set.
92       *
93       * This is when declarations are connected to {@link BGMBuilder} and
94       * its sibling components.
95       */
96      void onSetOwner();
97  
98      /**
99       * Gets child {@link BIDeclaration}s if any.
100      *
101      * @return
102      *      can be empty but always non-null. read-only.
103      */
104     Collection<BIDeclaration> getChildren();
105 }