xdoclet.plugins
Class BetwixtPlugin

java.lang.Object
  |
  +--java.beans.beancontext.BeanContextChildSupport
        |
        +--java.beans.beancontext.BeanContextSupport
              |
              +--xdoclet.beans.BeanContextSupportEx
                    |
                    +--xdoclet.Plugin
                          |
                          +--xdoclet.plugins.BetwixtPlugin
All Implemented Interfaces:
BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServicesListener, Collection, DesignMode, EventListener, PropertyChangeListener, Serializable, VetoableChangeListener, Visibility

public abstract class BetwixtPlugin
extends Plugin

Plugin backed by Betwixt. This plugin is used as a base class for plugins using beans generated by XGGPlugin.

The plugin developer only has to implement one of the populate methods (which one depending on whether the plugin is intended to be used in one file or multiple files mode).

The implemented populate method should cast the root bean to the class that is passed to the constructor and populate the bean with sub-beans, using the metaData that's passes to the same populate method. The metaData should also be cast to the appropriate type, like XClass or whatever metadata type the plugin expects to be fed with.

Version:
$Revision: 1.8 $
Author:
Aslak Hellesøy
See Also:
Serialized Form

Field Summary
static String SERIALIZED_BEANREADER
           
 
Fields inherited from class java.beans.beancontext.BeanContextSupport
bcmListeners, children, designTime, locale, okToUseGui
 
Fields inherited from class java.beans.beancontext.BeanContextChildSupport
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport
 
Fields inherited from interface java.beans.beancontext.BeanContext
globalHierarchyLock
 
Fields inherited from interface java.beans.DesignMode
PROPERTYNAME
 
Constructor Summary
protected BetwixtPlugin(Class rootClass)
           
 
Method Summary
protected  void generate(File file, Collection metaData)
          Generates a file.
protected  void generate(File file, Object metaData)
          Generates a file.
protected  Object parse(String mergeFile)
           Parses an XML stream into a bean.
protected  void populate(XGGPojo root, Collection metaData)
          Populates the XML tree.
protected  void populate(XGGPojo root, Object metaData)
          Populates the XML tree.
 void setVersion(String version)
          Sets the version.
 
Methods inherited from class xdoclet.Plugin
Acleanup, AcreateMetadataCollection, AgetFilenameSubstitutionValue, AgetPackageName, AsetClasspath, checkClass, createAccept, createPackageSubstitution, execute, getDestinationDir, getDestinationFileForAll, getDestinationFileForOne, getEncoding, getFileName, getFilteredMetadataCollection, getMetadataProvider, getName, getPackageName, getXDoclet, isGenerateOneFile, jxpath, setDestination, setDestinationDir, setEncoding, setFileName, setMetadataProvider, setName, setPackageName, validate
 
Methods inherited from class xdoclet.beans.BeanContextSupportEx
add, createInvocations, getInvocations, getParent, setParent
 
Methods inherited from class java.beans.beancontext.BeanContextSupport
addAll, addBeanContextMembershipListener, avoidingGui, bcsChildren, bcsPreDeserializationHook, bcsPreSerializationHook, childDeserializedHook, childJustAddedHook, childJustRemovedHook, classEquals, clear, contains, containsAll, containsKey, copyChildren, createBCSChild, deserialize, dontUseGui, fireChildrenAdded, fireChildrenRemoved, getBeanContextPeer, getChildBeanContextChild, getChildBeanContextMembershipListener, getChildPropertyChangeListener, getChildSerializable, getChildVetoableChangeListener, getChildVisibility, getLocale, getResource, getResourceAsStream, initialize, instantiateChild, isDesignTime, isEmpty, isSerializing, iterator, needsGui, okToUseGui, propertyChange, readChildren, remove, remove, removeAll, removeBeanContextMembershipListener, retainAll, serialize, setDesignTime, setLocale, size, toArray, toArray, validatePendingAdd, validatePendingRemove, vetoableChange, writeChildren
 
Methods inherited from class java.beans.beancontext.BeanContextChildSupport
addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, initializeBeanContextResources, isDelegated, releaseBeanContextResources, removePropertyChangeListener, removeVetoableChangeListener, serviceAvailable, serviceRevoked, setBeanContext, validatePendingSetBeanContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

SERIALIZED_BEANREADER

public static final String SERIALIZED_BEANREADER
See Also:
Constant Field Values
Constructor Detail

BetwixtPlugin

protected BetwixtPlugin(Class rootClass)
Method Detail

setVersion

public void setVersion(String version)
Sets the version.

Parameters:
version - DTD/XSD version.

parse

protected final Object parse(String mergeFile)
                      throws XDocletException

Parses an XML stream into a bean. This method can be used by subclasses to merge in additional content. The result should be cast to the expected Bean class.

The stream will be sought for on the classpath, and the mergeFile should be a relative path.

Parameters:
mergeFile - a relative path to a resource containing XML.
Returns:
a Java Bean, or null if the mergeFile wasn't found.
Throws:
XDocletException - if the file can't be properly parsed.

generate

protected final void generate(File file,
                              Object metaData)
                       throws IOException,
                              XDocletException
Description copied from class: Plugin
Generates a file.

Specified by:
generate in class Plugin
Parameters:
file - file to be generated.
metaData - metadata used during generation.
Throws:
XDocletException - if generation fails.
IOException - if an IO error occurs.

generate

protected final void generate(File file,
                              Collection metaData)
                       throws IOException,
                              XDocletException
Description copied from class: Plugin
Generates a file.

Specified by:
generate in class Plugin
Parameters:
file - file to be generated.
metaData - metadata used during generation.
Throws:
IOException - if an IO error occurs.
XDocletException - if generation fails.

populate

protected void populate(XGGPojo root,
                        Object metaData)
                 throws XDocletException
Populates the XML tree.

Parameters:
root - Object representing the root element in the XML.
metaData - data that can be used to populate the XML tree.
Throws:
XDocletException - if population fails.

populate

protected void populate(XGGPojo root,
                        Collection metaData)
                 throws XDocletException
Populates the XML tree.

Parameters:
root - Object representing the root element in the XML.
metaData - data that can be used to populate the XML tree.
Throws:
XDocletException - if population fails.


Copyright © 2000-2003 XDoclet Team. All Rights Reserved.