2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.xml.api.model;
44
import java.util.Enumeration;
47
* A query interface returning possible fenomens as given by document grammar.
49
* It provides at specified <code>HintContext</code> following information:
51
* <li>allowed element names and namespaces
52
* <li>allowed entity names
53
* <li>allowed notation names
54
* <li>allowed attribute names
55
* <li>allowed values of attribute values or element content
57
* This information are returned as <code>Enumeration</code>. Every member of
58
* the enumeration represents one possible option. Empty enumeration signals
59
* that no hint can be derived from grammar in given context.
61
* Every option represents DOM <code>Node</code> that can have children. These children
62
* represents mandatory content for given option. Providing them is optional.
63
* On the other hand <code>EMPTY</code> elements may not provide any children.
65
* <h3>Context Representation</h3>
66
* Query context is represented by a read-only DOM1 model Core and XML modules
67
* (it may be replaced with DOM2).
69
* <h3>Implementation Note:</h3>
71
* DOM1 does describe only non-DTD part of document.
73
* Passed context may represent errorous XML document. The code must
74
* take into account that it can get <code>null</code>s even on places
75
* where it does not expect it. E.g. <code>getParentNode()</code> as
76
* the DOM document can be constructed as a <b>best effort</b> one.
78
* Also as the context may originate from a text editor it is better to
79
* rely on <code>getPreviousSibling</code> rather then <code>getNextSibling</code>
80
* as user usaully types text from document begining.
84
public interface GrammarQuery {
87
* @semantics Navigates through read-only Node tree to determine context and provide right results.
88
* @postconditions Let ctx unchanged
89
* @time Performs fast up to 300 ms.
91
* @param virtualElementCtx represents virtual element Node that has to be replaced, its own attributes does not name sense, it can be used just as the navigation start point.
92
* @return enumeration of <code>GrammarResult</code>s (ELEMENT_NODEs) that can be queried on name, and attributes.
93
* Every list member represents one possibility.
95
Enumeration<GrammarResult> queryElements(HintContext virtualElementCtx);
98
* Query attribute options for given context. All implementations must handle
99
* queries based on owner element context.
101
* @output list of results that can be queried on name, and attributes
102
* @time Performs fast up to 300 ms.
103
* @param ownerElementCtx represents owner <code>Element</code> that will host result.
104
* @return enumeration of <code>GrammarResult</code>s (ATTRIBUTE_NODEs) that can be queried on name, and attributes.
105
* Every list member represents one possibility.
107
Enumeration<GrammarResult> queryAttributes(HintContext ownerElementCtx);
110
* Return options for value at given context.
111
* It could be also used for completing of value parts such as Ant or XSLT property names (how to trigger it?).
112
* @semantics Navigates through read-only Node tree to determine context and provide right results.
113
* @postconditions Let ctx unchanged
114
* @time Performs fast up to 300 ms.
116
* @param virtualTextCtx represents virtual Node that has to be replaced (parent can be either Attr or Element), its own attributes does not name sense, it can be used just as the navigation start point.
117
* @return enumeration of <code>GrammarResult</code>s (TEXT_NODEs) that can be queried on name, and attributes.
118
* Every list member represents one possibility.
120
Enumeration<GrammarResult> queryValues(HintContext virtualTextCtx);
123
* query default value for given context. Two context types must be handled:
124
* an attribute and an element context.
125
* @param parentNodeCtx context for which default is queried
126
* @return default value or <code>null</code>
128
GrammarResult queryDefault(HintContext parentNodeCtx);
131
* Allow to get names of <b>parsed general entities</b>.
132
* @param prefix prefix filter
133
* @return enumeration of <code>GrammarResult</code>s (ENTITY_REFERENCE_NODEs)
135
Enumeration<GrammarResult> queryEntities(String prefix);
138
* Allow to get names of <b>declared notations</b>.
139
* @param prefix prefix filter
140
* @return enumeration of <code>GrammarResult</code>s (NOTATION_NODEs)
142
Enumeration<GrammarResult> queryNotations(String prefix);
145
* Distinquieshes between empty enumaration types.
146
* @return <code>true</code> there is no known result
147
* <code>false</code> grammar does not allow here a result
149
boolean isAllowed(Enumeration<GrammarResult> en);
153
// Candidates for separate interface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156
* Allows Grammars to supply customizer for the HintContext
157
* @param ctx the hint context node
158
* @return a Component which can be used to customize the context node
160
java.awt.Component getCustomizer(HintContext nodeCtx);
163
* Allows Grammars to supply customizer from the HintContext
164
* @param ctx the hint context node
165
* @return true if a customizer is available for this context
167
boolean hasCustomizer(HintContext nodeCtx);
170
* Allows Grammars to supply properties for the HintContext
171
* @param ctx the hint context node
172
* @return an array of properties for this context
174
org.openide.nodes.Node.Property[] getProperties(HintContext nodeCtx);