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