IDragElement.java revision a0bccbddc52575255c5ce19c9d2c96d9639d26ca
1/*
2 * Copyright (C) 2009 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
17package com.android.ide.common.api;
18
19/**
20 * Represents an XML element with a name, attributes and inner elements.
21 * <p/>
22 * The semantic of the element name is to be a fully qualified class name of a View to inflate.
23 * The element name is not expected to have a namespace.
24 * <p>
25 * <b>NOTE: This is not a public or final API; if you rely on this be prepared
26 * to adjust your code for the next tools release.</b>
27 * </p>
28 */
29public interface IDragElement {
30
31    /**
32     * Returns the element name, which must match a fully qualified class name of
33     * a View to inflate.
34     */
35    public abstract String getFqcn();
36
37    /**
38     * Returns the bounds of the element's node, if it originated from an existing
39     * canvas. The rectangle is invalid and non-null when the element originated
40     * from the object palette.
41     *
42     * The bounds are absolute for the canvas.
43     */
44    public abstract Rect getBounds();
45
46    /**
47     * Returns the fully qualified class name of the parent, if the element originated
48     * from an existing canvas. Returns null if the element has no parent, such as a top
49     * level element or an element originating from the object palette.
50     */
51    public abstract String getParentFqcn();
52
53    /**
54     * Returns the bounds of the element's parent, absolute for the canvas, or invalid if there
55     * is no suitable parent. This is generally invalid when {@link #getParentFqcn()} is null.
56     *
57     * The returned rectangle can be invalid. It is never null.
58     */
59    public abstract Rect getParentBounds();
60
61    /**
62     * Returns a list of attributes. The list can be empty but is never null.
63     */
64    public abstract IDragAttribute[] getAttributes();
65
66    /**
67     * Returns the requested attribute or null if not found.
68     */
69    public abstract IDragAttribute getAttribute(String uri, String localName);
70
71    /**
72     * Returns a list of inner elements. The list can be empty but is never null.
73     */
74    public abstract IDragElement[] getInnerElements();
75
76    /**
77     * An XML attribute in the {@link IDragElement}.
78     * <p/>
79     * The attribute is always represented by a namespace URI, a name and a value.
80     * The name cannot be empty.
81     * The namespace URI can be empty for an attribute without a namespace but is never null.
82     * The value can be empty but cannot be null.
83     */
84    public interface IDragAttribute {
85
86        /**
87         * Returns the namespace URI of the attribute.
88         * Can be empty for an attribute without a namespace but is never null.
89         */
90        public abstract String getUri();
91
92        /** Returns the XML local name of the attribute. Cannot be null nor empty. */
93        public abstract String getName();
94
95        /** Returns the value of the attribute. Cannot be null. Can be empty. */
96        public abstract String getValue();
97    }
98}
99
100