001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.tax;
042:
043: /**
044: * Holder for a prefix, URI pair.
045: * <p>
046: * Default namespace prefix is "".
047: *
048: * @author Libor Kramolis
049: * @version 0.1
050: */
051: public final class TreeNamespace {
052:
053: /** It is NOT in any namespace (including default) */
054: public static final TreeNamespace NO_NAMESPACE = new TreeNamespace(
055: null, ""); // NOI18N
056:
057: /** */
058: public static final TreeNamespace XML_NAMESPACE = new TreeNamespace(
059: "xml", "http://www.w3.org/XML/1998/namespace"); // NOI18N
060:
061: /** */
062: public static final TreeNamespace XMLNS_NAMESPACE = new TreeNamespace(
063: "xmlns", "http://www.w3.org/2000/xmlns/"); // NOI18N
064:
065: /** For sticklers. */
066: public static final String DEFAULT_NS_PREFIX = ""; // NOI18N
067:
068: /** */
069: private String prefix;
070:
071: /** */
072: private String uri;
073:
074: //
075: // init
076: //
077:
078: /**
079: * Creates new TreeNamespace.
080: * @param prefix namespace prefix or null if no namespace (including default)
081: * @param uri string representation of URI
082: */
083: protected TreeNamespace(String prefix, String uri) {
084: if (uri == null)
085: throw new IllegalArgumentException(Util.THIS
086: .getString("EXC_uri_cannot_be_null"));
087: this .prefix = prefix;
088: this .uri = uri;
089: }
090:
091: /** Creates new TreeNamespace -- copy constructor. */
092: protected TreeNamespace(TreeNamespace namespace) {
093: this .prefix = namespace.prefix;
094: this .uri = namespace.uri;
095: }
096:
097: //
098: // itself
099: //
100:
101: /**
102: * @return prefix of null if no namespace
103: */
104: public String getPrefix() {
105: return prefix;
106: }
107:
108: /**
109: * @return string representation URI (never null)
110: */
111: public String getURI() {
112: return uri;
113: }
114:
115: }
|