001/* 002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 003 * 004 * This software is open source. 005 * See the bottom of this file for the licence. 006 * 007 * $Id: UserDataAttribute.java,v 1.2 2001/06/20 18:59:23 jstrachan Exp $ 008 */ 009 010package org.dom4j.util; 011 012import org.dom4j.Element; 013import org.dom4j.Namespace; 014import org.dom4j.QName; 015import org.dom4j.tree.DefaultAttribute; 016 017/** <p><code>UserDataAttribute</code> support the adornment of a user 018 * data object on an Element or Attribute instance such that the 019 * methods {@link #getData} {@link #setData(Object)} 020 * will get and set the values of a user data object. 021 * This can be useful for developers wishing to create XML trees and 022 * adorn the trees with user defined objects.</p> 023 * 024 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 025 * @version $Revision: 1.2 $ 026 */ 027public class UserDataAttribute extends DefaultAttribute { 028 029 /** The user data object */ 030 private Object data; 031 032 033 public UserDataAttribute(QName qname) { 034 super(qname); 035 } 036 037 public UserDataAttribute(QName qname, String text) { 038 super(qname, text); 039 } 040 041 042 public Object getData() { 043 return data; 044 } 045 046 public void setData(Object data) { 047 this.data = data; 048 } 049} 050 051 052 053 054/* 055 * Redistribution and use of this software and associated documentation 056 * ("Software"), with or without modification, are permitted provided 057 * that the following conditions are met: 058 * 059 * 1. Redistributions of source code must retain copyright 060 * statements and notices. Redistributions must also contain a 061 * copy of this document. 062 * 063 * 2. Redistributions in binary form must reproduce the 064 * above copyright notice, this list of conditions and the 065 * following disclaimer in the documentation and/or other 066 * materials provided with the distribution. 067 * 068 * 3. The name "DOM4J" must not be used to endorse or promote 069 * products derived from this Software without prior written 070 * permission of MetaStuff, Ltd. For written permission, 071 * please contact dom4j-info@metastuff.com. 072 * 073 * 4. Products derived from this Software may not be called "DOM4J" 074 * nor may "DOM4J" appear in their names without prior written 075 * permission of MetaStuff, Ltd. DOM4J is a registered 076 * trademark of MetaStuff, Ltd. 077 * 078 * 5. Due credit should be given to the DOM4J Project 079 * (http://dom4j.org/). 080 * 081 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 082 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 083 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 084 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 085 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 086 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 087 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 088 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 089 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 090 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 091 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 092 * OF THE POSSIBILITY OF SUCH DAMAGE. 093 * 094 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 095 * 096 * $Id: UserDataAttribute.java,v 1.2 2001/06/20 18:59:23 jstrachan Exp $ 097 */