0N/A<!--
3909N/A Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A
0N/A This code is free software; you can redistribute it and/or modify it
0N/A under the terms of the GNU General Public License version 2 only, as
2362N/A published by the Free Software Foundation. Oracle designates this
0N/A particular file as subject to the "Classpath" exception as provided
2362N/A by Oracle in the LICENSE file that accompanied this code.
0N/A
0N/A This code is distributed in the hope that it will be useful, but WITHOUT
0N/A ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A version 2 for more details (a copy is included in the LICENSE file that
0N/A accompanied this code).
0N/A
0N/A You should have received a copy of the GNU General Public License version
0N/A 2 along with this work; if not, write to the Free Software Foundation,
0N/A Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A
2362N/A Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A or visit www.oracle.com if you need additional information or have any
2362N/A questions.
0N/A-->
0N/A
0N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
0N/A<html>
0N/A<body bgcolor="white">
0N/A
0N/AContains classes related to developing
0N/A<em>beans</em> -- components
3731N/Abased on the JavaBeans&trade; architecture.
0N/AA few of the
0N/Aclasses are used by beans while they run in an application.
0N/AFor example, the event classes are
0N/Aused by beans that fire property and vetoable change
0N/Aevents (see
0N/A{@link java.beans.PropertyChangeEvent}). However, most of the classes in this
0N/Apackage are meant to be used by a bean editor (that is, a development environment
0N/Afor customizing and putting together beans to create an application). In
0N/Aparticular, these classes help the bean editor create a user
0N/Ainterface that the user can use to customize the bean. For example, a bean may
0N/Acontain a property of a special type that a bean editor may not know how to handle.
0N/ABy using the <code>PropertyEditor</code> interface, a bean developer can
0N/Aprovide an editor for this special type.
0N/A
0N/A<p>
0N/ATo minimize the resources used by a bean, the classes used by bean editors are loaded only
0N/Awhen the bean is being edited. They are not needed while the bean is running in an application
0N/Aand therefore not loaded. This information is kept in what's called a bean-info (see {@link java.beans.BeanInfo}).
0N/A
0N/A<p>
0N/AUnless explicitly stated, null values or empty Strings are not valid
0N/Aparameters for the methods in this package. You may expect to see
0N/Aexceptions if these parameters are used.
0N/A
0N/A
0N/A<h2>Long-Term Persistence</h2>
0N/A
0N/AAs of v1.4,
0N/Athe <code>java.beans</code> package provides support for
0N/A<em>long-term persistence</em> -- reading and
0N/Awriting a bean as a textual representation of its property values.
0N/AThe property values are treated as beans,
0N/Aand are recursively read or written to capture
0N/Atheir publicly available state.
0N/AThis approach is suitable for long-term storage
0N/Abecause it relies only on public API,
0N/Arather than the likely-to-change private implementation.
0N/A
0N/A<blockquote>
0N/A<hr>
0N/A<b>Note:</b>
0N/AThe persistence scheme cannot automatically instantiate
0N/Acustom inner classes, such as you might use for event handlers.
0N/ABy using the {@link java.beans.EventHandler} class
0N/Ainstead of inner classes for custom event handlers,
0N/Ayou can avoid this problem.
0N/A<hr>
0N/A</blockquote>
0N/A
0N/A<p>
0N/A
0N/AYou read and write beans in XML format using the
0N/A{@link java.beans.XMLDecoder}
0N/Aand
0N/A{@link java.beans.XMLEncoder}
0N/Aclasses, respectively.
0N/AOne notable feature of the persistence scheme is that
0N/Areading in a bean requires no special knowledge of the bean.
0N/A
0N/A<p>
0N/AWriting out a bean, on the other hand,
0N/Asometimes requires special knowledge of the bean's type.
0N/AIf the bean's state can be
0N/Aexpressed using only the no-argument constructor and
0N/Apublic getter and setter methods for properties,
0N/Ano special knowledge is required.
0N/AOtherwise, the bean requires a custom <em>persistence delegate</em> --
0N/Aan object that is in charge of writing out beans of a particular type.
0N/AAll classes provided in the JDK that descend
0N/Afrom <code>java.awt.Component</code>,
0N/Aas well as all their properties,
0N/Aautomatically have persistence delegates.
0N/A
0N/A<p>
0N/A
0N/AIf you need (or choose) to provide a persistence delegate for a bean,
0N/Ayou can do so either by using a
0N/A{@link java.beans.DefaultPersistenceDelegate}
0N/Ainstance
0N/Aor by creating your own subclass of <code>PersistenceDelegate</code>.
0N/AIf the only reason a bean needs a persistence delegate
0N/Ais because you want to invoke the bean's constructor with
0N/Aproperty values as arguments,
0N/Ayou can create the bean's persistence delegate
0N/Awith the one-argument
0N/A<code>DefaultPersistenceDelegate</code>
0N/Aconstructor.
0N/AOtherwise,
0N/Ayou need to implement your own persistence delegate,
0N/Afor which you're likely to need the following classes:
0N/A
0N/A<dl>
0N/A<dt> {@link java.beans.PersistenceDelegate}
0N/A<dd> The abstract class from which all persistence delegates descend.
0N/A Your subclass should use its knowledge of the bean's type to provide
0N/A whatever <code>Statement</code>s and <code>Expression</code>s
0N/A are necessary to create the bean
0N/A and restore its state.
0N/A<dt> {@link java.beans.Statement}
0N/A<dd> Represents the invocation of a single method on an object.
0N/A Includes a set of arguments to the method.
0N/A<dt> {@link java.beans.Expression}
0N/A<dd> A subclass of <code>Statement</code>
0N/A used for methods that return a value.
0N/A</dl>
0N/A
0N/A<p>
0N/AOnce you create a persistence delegate,
0N/Ayou register it using the
0N/A<code>setPersistenceDelegate</code> method of
0N/A<code>XMLEncoder</code>.
0N/A
0N/A
0N/A<h2>Related Documentation</h2>
0N/A
0N/AFor overview, architecture, and tutorial documentation, please see:
0N/A<ul>
0N/A <li><a href="http://java.sun.com/docs/books/tutorial/javabeans/">JavaBeans</a>, a trail in <em>The Java Tutorial</em>.
0N/A <li><a href="http://java.sun.com/products/jfc/tsc/articles/persistence2/">Long-Term Persistence</a>, an article in <em>The Swing Connection</em>.
0N/A</ul>
0N/A<p>
0N/A
0N/A</body>
0N/A</html>