KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xsd > Namespace


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 package org.netbeans.modules.xml.xsd;
20
21 /**
22  * Represents a Namespace
23  * @author anovak
24  */

25 class Namespace {
26
27     public static final String JavaDoc XMLNS_ATTR = "xmlns"; //NOI18N
28
public static final String JavaDoc XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance"; //NOI18N
29
public static final String JavaDoc XSI_LOCATION = "schemaLocation"; //NOI18N
30
public static final String JavaDoc XSI_NO_NAMESPACE_LOCATION = "noNamespaceSchemaLocation"; //NOI18N
31
public static final String JavaDoc XSD_SCHEMA_URI = "http://www.w3.org/2001/XMLSchema"; // NOI18N
32

33     /** Not real URI, anything will work */
34     private final String JavaDoc uri;
35     /** Prefix */
36     private final String JavaDoc prefix;
37     /** Schema Location */
38     private String JavaDoc schemaLocation;
39     /** Grammar for this Namespace */
40     private XSDGrammar grammar;
41     
42     /** Creates a new instance of Type */
43     public Namespace(String JavaDoc uri, String JavaDoc prefix) {
44         this.uri = uri;
45         this.prefix = prefix;
46         this.schemaLocation = null;
47         this.grammar = null;
48     }
49     
50     /**
51      * Getter for property uri.
52      * @return Value of property uri.
53      */

54     public java.lang.String JavaDoc getURI() {
55         return uri;
56     }
57     
58     /**
59      * Getter for property prefix.
60      * @return Value of property prefix.
61      */

62     public java.lang.String JavaDoc getPrefix() {
63         return prefix;
64     }
65
66     public void setSchemaLocation(String JavaDoc location) {
67         this.schemaLocation = location;
68     }
69     
70     public String JavaDoc getSchemaLocation() {
71         return schemaLocation;
72     }
73     
74     /**
75      * Getter for property grammar.
76      * @return Value of property grammar.
77      */

78     public org.netbeans.modules.xml.xsd.XSDGrammar getGrammar() {
79         return grammar;
80     }
81     
82     /**
83      * Setter for property grammar.
84      * @param grammar New value of property grammar.
85      */

86     public void setGrammar(org.netbeans.modules.xml.xsd.XSDGrammar grammar) {
87         this.grammar = grammar;
88     }
89     
90     /** @ret xsdf for String of form xsdf:some_name */
91     public static String JavaDoc getPrefix(String JavaDoc name) {
92         int i = name.indexOf(':');
93         if (i >= 0) {
94             return name.substring(0, i);
95         }
96         
97         return null;
98     }
99     
100     /** @ret some_name for String of form xsdf:some_name */
101     public static String JavaDoc getSufix(String JavaDoc name) {
102         int i = name.indexOf(':');
103         if (i >= 0) {
104             return name.substring(i + 1);
105         }
106         
107         return null;
108     }
109
110 }
111
Popular Tags