com.taco.swinger.text2gui
Class ComponentAddStrategy

java.lang.Object
  extended by com.taco.swinger.text2gui.ComponentAddStrategy
All Implemented Interfaces:
IComponentAddStrategy, IInterpolatingConverter, IInterpolatingStringToObjectConverter, IInterpolatingResourceBundleToObjectConverter
Direct Known Subclasses:
BorderLayoutComponentAddStrategy, GridBagLayoutComponentAddStrategy

public class ComponentAddStrategy
extends java.lang.Object
implements IComponentAddStrategy

The default implementation of IComponentAddStrategy that simply passes the constraint to Container.add(). It uses a converter passed to the constructor to convert strings and bundle keys to constraints.


Field Summary
protected  IInterpolatingConverter _constraintConverter
          The string converter used to convert to constraints.
static ComponentAddStrategy DEFAULT_INSTANCE
          The default instance of this class which uses the default constructor.
 
Constructor Summary
protected ComponentAddStrategy()
          Construct a new instance that uses constraint strings themselves as constraints.
  ComponentAddStrategy(IInterpolatingConverter constraintConverter)
          Construct a new instance that uses the argument converter as both the string to constraint converter and the resource bundle to constraint converter.
 
Method Summary
 void addComponent(java.lang.Object container, java.lang.Object component, java.lang.Object constraint)
          Add component to container using Container.add(), passing the argument constraint the constraint parameter if non-null.
 java.lang.String name()
          Return the result of invoking name() on the constraint converter.
 java.lang.Object toObject(java.util.ResourceBundle bundle, java.lang.String baseKey, INoReturnMap argMap, KeyLookupRecord context)
          Convert a set of resource bundle keys representing a constraint to an actual constraint.
 java.lang.Object toObject(java.lang.String s, java.util.ResourceBundle bundle, INoReturnMap argMap, KeyLookupRecord context)
          Convert a string representing a constraint to an actual constraint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_constraintConverter

protected IInterpolatingConverter _constraintConverter
The string converter used to convert to constraints.


DEFAULT_INSTANCE

public static final ComponentAddStrategy DEFAULT_INSTANCE
The default instance of this class which uses the default constructor.

Constructor Detail

ComponentAddStrategy

protected ComponentAddStrategy()
Construct a new instance that uses constraint strings themselves as constraints.


ComponentAddStrategy

public ComponentAddStrategy(IInterpolatingConverter constraintConverter)
Construct a new instance that uses the argument converter as both the string to constraint converter and the resource bundle to constraint converter.

Throws:
java.lang.NullPointerException - if constraintConverter is null
Method Detail

addComponent

public void addComponent(java.lang.Object container,
                         java.lang.Object component,
                         java.lang.Object constraint)
Add component to container using Container.add(), passing the argument constraint the constraint parameter if non-null.

Specified by:
addComponent in interface IComponentAddStrategy
Parameters:
container - The container to which to add the component. Normally, this will be an instance of Container.
component - The component to add to the container. Normally, this will be an instance of Component.
constraint - The constraint for adding the component to the container. A null value indicates no constraint.

toObject

public java.lang.Object toObject(java.lang.String s,
                                 java.util.ResourceBundle bundle,
                                 INoReturnMap argMap,
                                 KeyLookupRecord context)
                          throws java.text.ParseException,
                                 java.util.MissingResourceException
Convert a string representing a constraint to an actual constraint.

Specified by:
toObject in interface IInterpolatingStringToObjectConverter
Throws:
java.text.ParseException
java.util.MissingResourceException

toObject

public java.lang.Object toObject(java.util.ResourceBundle bundle,
                                 java.lang.String baseKey,
                                 INoReturnMap argMap,
                                 KeyLookupRecord context)
                          throws java.text.ParseException,
                                 java.util.MissingResourceException
Convert a set of resource bundle keys representing a constraint to an actual constraint.

Specified by:
toObject in interface IInterpolatingResourceBundleToObjectConverter
Throws:
java.text.ParseException
java.util.MissingResourceException

name

public java.lang.String name()
Return the result of invoking name() on the constraint converter.

Specified by:
name in interface IInterpolatingConverter