KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > XMLElement


1 /**
2  * org/ozone-db/xml/XMLElement.java
3  *
4  * The contents of this file are subject to the OpenXML Public
5  * License Version 1.0; you may not use this file except in compliance
6  * with the License. You may obtain a copy of the License at
7  * http://www.openxml.org/license.html
8  *
9  * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
10  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
11  * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
12  * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
13  * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
14  * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
15  *
16  * The Initial Developer of this code under the License is Assaf Arkin.
17  * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
18  * All Rights Reserved.
19  */

20
21 /**
22  * Changes for Persistent DOM running with ozone are
23  * Copyright 1999 by SMB GmbH. All rights reserved.
24  */

25
26 package org.ozoneDB.xml;
27
28 import org.w3c.dom.*;
29 import org.ozoneDB.xml.dom.*;
30
31
32 /**
33  * Base class for user XML elements. {@link XMLDocument} is designed to create
34  * elements of classes derived from {@link XMLElement}. In addition to several
35  * API extensions, user XML elements can be used to map XML documents directly
36  * into application data structures.
37  * <P>
38  * {@link XMLElement} extends the DOM {@link Element} with the following methods:
39  * <UL>
40  * <LI>{@link #setReadOnly} renders an element read-only preventing any changes
41  * to it's attribute or content
42  * <LI>{@link #setUserObject} and {@link #getUserObject} may be used to associate
43  * a user object with an element
44  * </UL>
45  * <P>
46  * In order to support user elements, a document class must extend {@link
47  * XMLDocument}. It then registers tag name to element class associations using
48  * {@link XMLDocument#registerElement}.
49  * <P>
50  * The user elements will be returns whenever {@link XMLDocument#createElement}
51  * is called on the document, or when a document of this type is parsed.
52  * <P>
53  * A user element derived from {@link XMLElement} must pass the owner document
54  * and tag name to its constructor. The class and its constructor must be
55  * declared public and the constructor must have the same signature as the
56  * {@link XMLElement} constructor. The last three requirements may be relaxed
57  * if an external element factory is used.
58  *
59  *
60  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
61  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
62  * @see org.w3c.dom.Element
63  * @see XMLDocument#registerElement
64  * @see XMLElementFactory
65  * @deprecated Alternative API will be introduced in OpenXML 1.1
66  */

67 public class XMLElement extends ElementImpl implements XMLElementProxy {
68
69
70     /**
71      * Constructor requires owner document and element tag name. This will be
72      * provided when an element of this or a derived class is being constructed
73      * by an {@link XMLDocument}. The arguments must pass to this constructor
74      * unaffected. Derived classes must implement at least one constructor with
75      * the exact same signature to support element class registration; this
76      * requirement is relaxed if an external element factory is used.
77      *
78      * @param owner The owner document
79      * @param tagName The element's tag name
80      */

81     public XMLElement( Document owner, String JavaDoc tagName ) {
82         super( (DocumentImpl)owner, tagName );
83     }
84
85
86     public XMLElement() {
87         super();
88     }
89
90
91     /**
92      * Associates this element with a user object. There is no limit on what
93      * the user object may hold.
94      *
95      * @param userObject The user object
96      */

97     public void setUserObject( Object JavaDoc userObject ) {
98         _userObject = userObject;
99     }
100
101
102     /**
103      * Returns the user object associated with this element. There is no limit
104      * on what the user object may hold.
105      *
106      * @return The user object
107      */

108     public Object JavaDoc getUserObject() {
109         return _userObject;
110     }
111
112
113     /**
114      * Returns the identifier of this element. Unless specifies otherwise in
115      * the DTD, this would be the value of the <TT>id</TT> attribute. It may
116      * be a textual value or null.
117      *
118      * @return The identifier of this element
119      */

120     public String JavaDoc getID() {
121         return getAttribute( "id" );
122     }
123
124     /**
125      * Holds a user object. Any object can be associated with this element
126      * using the appropriate set/get methods.
127      */

128     protected Object JavaDoc _userObject;
129
130 }
131
Popular Tags