• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ide.eclipse.adt.internal.editors.descriptors;
18 
19 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode;
20 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
21 
22 
23 /**
24  * Describes an XMLNS attribute that is hidden.
25  * <p/>
26  * Such an attribute has no user interface and no corresponding {@link UiAttributeNode}.
27  * It also has a single constant default value.
28  * <p/>
29  * When loading an XML, we'll ignore this attribute.
30  * However when writing a new XML, we should always write this attribute.
31  * <p/>
32  * Currently this is used for the xmlns:android attribute in the manifest element.
33  */
34 public final class XmlnsAttributeDescriptor extends AttributeDescriptor {
35 
36     /**
37      * URI of the reserved "xmlns"  prefix, as described in
38      * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html#normalizeDocumentAlgo
39      */
40     public final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/"; //$NON-NLS-1$
41 
42     private String mValue;
43 
44 
XmlnsAttributeDescriptor(String defaultPrefix, String value)45     public XmlnsAttributeDescriptor(String defaultPrefix, String value) {
46         super(defaultPrefix, XMLNS_URI);
47         mValue = value;
48     }
49 
50     /**
51      * Returns the value of this specialized attribute descriptor, which is the URI associated
52      * to the declared namespace prefix.
53      */
getValue()54     public String getValue() {
55         return mValue;
56     }
57 
58     /**
59      * Returns the "xmlns" prefix that is always used by this node for its namespace URI.
60      * This is defined by the XML specification.
61      */
getXmlNsPrefix()62     public String getXmlNsPrefix() {
63         return "xmlns"; //$NON-NLS-1$
64     }
65 
66     /**
67      * Returns the fully-qualified attribute name, namely "xmlns:xxx" where xxx is
68      * the defaultPrefix passed in the constructor.
69      */
getXmlNsName()70     public String getXmlNsName() {
71         return getXmlNsPrefix() + ":" + getXmlLocalName(); //$NON-NLS-1$
72     }
73 
74     /**
75      * @return Always returns null. {@link XmlnsAttributeDescriptor} has no user interface.
76      */
77     @Override
createUiNode(UiElementNode uiParent)78     public UiAttributeNode createUiNode(UiElementNode uiParent) {
79         return null;
80     }
81 }
82