2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package com
.intellij
.psi
.xml
;
18 import com
.intellij
.psi
.PsiNamedElement
;
19 import com
.intellij
.util
.IncorrectOperationException
;
20 import com
.intellij
.xml
.XmlAttributeDescriptor
;
21 import com
.intellij
.openapi
.util
.TextRange
;
22 import org
.jetbrains
.annotations
.NonNls
;
23 import org
.jetbrains
.annotations
.NotNull
;
24 import org
.jetbrains
.annotations
.Nullable
;
29 public interface XmlAttribute
extends XmlElement
, PsiNamedElement
{
30 XmlAttribute
[] EMPTY_ARRAY
= new XmlAttribute
[0];
32 @NonNls @NotNull String
getName();
34 @NonNls @NotNull String
getLocalName();
36 @NonNls @NotNull String
getNamespace();
38 @NonNls @NotNull String
getNamespacePrefix();
43 * @return text inside XML attribute with quotes stripped off
48 * @return text inside XML attribute with quotes stripped off and XML char entities replaced with corresponding characters
50 String
getDisplayValue();
53 * @param offset in string returned by {@link #getText()} (with quotes stripped)
54 * @return offset in the string returned from {@link #getDisplayValue()} or -1 if the offset is out of valid range
56 int physicalToDisplay(int offset
);
58 * @param offset in the string returned from {@link #getDisplayValue()}
59 * @return offset in string returned by {@link #getText()} (with quotes stripped) or -1 if the offset is out of valid range
61 int displayToPhysical(int offset
);
64 * @return TextRange of the XML attribute value.
65 * If quotes are present, it returns <code>new TextRange(1, getTextLength()-1)</code>, otherwise it is <code>new TextRange(0, getTextLength())</code>
67 TextRange
getValueTextRange();
70 * @return true if the attribute is a namespace declaration (its name equals to <code>xmlns</code> or starts with <code>xmlns:</code>)
72 boolean isNamespaceDeclaration();
74 @Nullable XmlAttributeDescriptor
getDescriptor();
78 // TODO: remove this. For tree functions XmlChildRole.XXX_FINDER should be used.
79 // In this case function is also used to get references from attribute value
81 XmlAttributeValue
getValueElement();
83 void setValue(String value
) throws IncorrectOperationException
;