net.sf.composite.composites
Class BaseComposite

java.lang.Object
  extended by net.sf.composite.composites.BaseComposite
All Implemented Interfaces:
Composite, ListableComposite, SimpleComposite, StrictlyTypedComposite, ValidatableComposite
Direct Known Subclasses:
CompositeDecorator

public class BaseComposite
extends java.lang.Object
implements SimpleComposite, ListableComposite, StrictlyTypedComposite, ValidatableComposite

A Convenient base class for composites that provides exception handling, argument checking and default implementations of the methods defined in ListableComposite, StrictlyTypedComposite, ValidatableComposite and SpecializableComposite. The final interface is not declared to be implemented by this class so that subclasses may choose to expose the interface or not.

Since:
Dec 27, 2004
Author:
Matt Sgarlata

Constructor Summary
BaseComposite()
          Creates a new composite.
BaseComposite(Component component)
          Creates a new composite that is composed of only a single component.
 
Method Summary
 boolean containsComponentOfType(java.lang.Class componentType)
          Indicates whether one or more components of the given type make up this composite.
 java.lang.Object[] getComponents()
          Returns the components that make up this composite.
 java.lang.Object[] getComponentsOfType(java.lang.Class componentType)
          Returns the components that make up this composite that are of the given type.
 java.lang.Class getComponentType()
          Indicates a type which must be implemented by each of the components of this composite
 ComponentValidator getComponentValidator()
           
 Specializer getSpecializer()
           
protected  void initializeImpl()
           
 boolean isSpecializable(java.lang.Class type)
           
 void setComponent(java.lang.Object component)
           
 void setComponents(java.lang.Object[] components)
          Sets the components that make up this composite.
 void setComponentValidator(ComponentValidator componentValidator)
           
 void setSpecializer(Specializer specializer)
           
 java.lang.Object specialize(java.lang.Class type)
           
 void validate()
          Validates that the internal state of this composite is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseComposite

public BaseComposite()
Creates a new composite. To complete initialization of the composite, either BaseComposite#setComponents(Component[]) or BaseComposite#setComponent(Component).


BaseComposite

public BaseComposite(Component component)
Creates a new composite that is composed of only a single component.

Parameters:
the - component that makes up this composite
Method Detail

initializeImpl

protected void initializeImpl()

validate

public void validate()
              throws ComponentValidationException
Description copied from interface: ValidatableComposite
Validates that the internal state of this composite is valid.

Specified by:
validate in interface ValidatableComposite
Throws:
ComponentValidationException - if the composite is not validation or validation could not be performed for some reason

containsComponentOfType

public boolean containsComponentOfType(java.lang.Class componentType)
                                throws CompositeException
Description copied from interface: ListableComposite
Indicates whether one or more components of the given type make up this composite.

Specified by:
containsComponentOfType in interface ListableComposite
Parameters:
componentType - the type of component for which we are searching
Returns:
true if one or more of the components of the given type make up this composite or
false, otherwise
Throws:
CompositeException - if an error occurrs

getComponentsOfType

public java.lang.Object[] getComponentsOfType(java.lang.Class componentType)
                                       throws CompositeException
Description copied from interface: ListableComposite
Returns the components that make up this composite that are of the given type.

Specified by:
getComponentsOfType in interface ListableComposite
Parameters:
componentType - the type of component for which we are searching
Returns:
the components that make up this composite that are of the given type
Throws:
CompositeException - if an error occurrs
See Also:
ContainerUtils.getElementsOfType(Object[], Class)

getComponentType

public java.lang.Class getComponentType()
                                 throws CompositeException
Description copied from interface: StrictlyTypedComposite
Indicates a type which must be implemented by each of the components of this composite

Specified by:
getComponentType in interface StrictlyTypedComposite
Returns:
the type which must be implemented by each of the components of this composite
Throws:
CompositeException - if an error occurrs

isSpecializable

public boolean isSpecializable(java.lang.Class type)
                        throws SpecializationException
Throws:
SpecializationException

specialize

public java.lang.Object specialize(java.lang.Class type)
                            throws SpecializationException
Throws:
SpecializationException

getComponents

public java.lang.Object[] getComponents()
Description copied from interface: SimpleComposite
Returns the components that make up this composite.

Specified by:
getComponents in interface SimpleComposite
Returns:
the components that make up this composite

setComponents

public void setComponents(java.lang.Object[] components)
Description copied from interface: SimpleComposite
Sets the components that make up this composite.

Specified by:
setComponents in interface SimpleComposite
Parameters:
components - the components that make up this composite

setComponent

public final void setComponent(java.lang.Object component)

getComponentValidator

public ComponentValidator getComponentValidator()

setComponentValidator

public void setComponentValidator(ComponentValidator componentValidator)

getSpecializer

public Specializer getSpecializer()

setSpecializer

public void setSpecializer(Specializer specializer)


Copyright © 2005-2008.