KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > api > model > GrammarEnvironment


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.api.model;
21
22 import java.util.Enumeration JavaDoc;
23 import org.openide.filesystems.FileObject;
24 import org.xml.sax.InputSource JavaDoc;
25
26 /**
27  * Grammar environment provides grammar factory with a context.
28  * All returned object must be treated as read-only. Grammar
29  * should do the best it can do in passed (possibly partial)
30  * environment.
31  *
32  * @author Petr Kuzel
33  */

34 public final class GrammarEnvironment {
35
36     private final FileObject fileObject;
37     private final InputSource JavaDoc inputSource;
38     private final Enumeration JavaDoc documentChildren;
39         
40     /**
41      * Creates a new instance of GrammarEnvironment.
42      *
43      * @param documentChildren Enumeration of document level DOM nodes.
44      * @param inputSource Supported document input source.
45      * @param fileObject Supported document fileObject or <code<null</code>.
46      */

47     public GrammarEnvironment(Enumeration JavaDoc documentChildren, InputSource JavaDoc inputSource, FileObject fileObject) {
48         if (inputSource == null) throw new NullPointerException JavaDoc();
49         if (documentChildren == null) throw new NullPointerException JavaDoc();
50         this.inputSource = inputSource;
51         this.fileObject = fileObject;
52         this.documentChildren = documentChildren;
53     }
54     
55     /**
56      * There is always input source of supported document reflecting
57      * current in-memory state.
58      *
59      * @return InputSource
60      */

61     public InputSource JavaDoc getInputSource() {
62         return inputSource;
63     }
64     
65     /**
66      * If supported document exists in a form of FileObject it can
67      * be retrieved. Note that data provided from file object
68      * input stream may be different than current in-memory state.
69      *
70      * @return FileObject or null.
71      */

72     public FileObject getFileObject() {
73         return fileObject;
74     }
75
76     /**
77      * Preparsed document children for fast decision based on
78      * document structure.
79      *
80      * @return Enumeration of DOM Nodes representing document
81      * children. Enumeration elements are valid only during
82      * {@link GrammarQueryManager#enabled} method invocation.
83      */

84     public Enumeration JavaDoc getDocumentChildren() {
85         return documentChildren;
86     }
87 }
88
Popular Tags