org.marketcetera.util.auth
Class Context<T extends Setter<?>>

java.lang.Object
  extended by org.marketcetera.util.auth.Context<T>
Direct Known Subclasses:
CliContext, ConsoleContext, SpringContext

public abstract class Context<T extends Setter<?>>
extends Object

A context, comprising a group of setters. The context provides an operational context for its setters to set their respective holder data. When multiple contexts attempt to set holder data in sequence (via their respective, context-specific setters), then a later override context will override prior successful settings, while a non-override context will not.

Since:
0.5.0
Version:
$Id: Context.java 16154 2012-07-14 16:34:05Z colin $
Author:
tlerios@marketcetera.com

Constructor Summary
Context(boolean override)
          Creates a new anonymous context with the given override role.
Context(I18NBoundMessage name, boolean override)
          Creates a new context with the given name and override role.
 
Method Summary
 void add(T setter)
          Adds the given setter to the receiver's setters.
 I18NBoundMessage getName()
          Returns the receiver's name.
 boolean getOverride()
          Checks whether the receiver is an override context.
 Iterable<T> getSetters()
          Returns the receiver's setters.
 void printUsage(PrintStream stream)
          Prints the receiver's usage instructions (which include its name, if not anonymous) onto the given stream.
abstract  void setValues()
          Sets the data of the holders associated with the receivers' setters.
 boolean shouldProcess(Setter<?> setter)
          Checks whether the receiver should process the specified setter, that is, attempt to use it to set the holder data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Context

public Context(I18NBoundMessage name,
               boolean override)
Creates a new context with the given name and override role.

Parameters:
name - The context name.
override - The override role.

Context

public Context(boolean override)
Creates a new anonymous context with the given override role.

Parameters:
override - The override role.
Method Detail

shouldProcess

public boolean shouldProcess(Setter<?> setter)
Checks whether the receiver should process the specified setter, that is, attempt to use it to set the holder data. Override contexts will always process all setters; non-override contexts will only process setters whose data is not yet set.

Parameters:
setter - The setter.
Returns:
True if so.

add

public void add(T setter)
Adds the given setter to the receiver's setters.

Parameters:
setter - The setter.

getSetters

public Iterable<T> getSetters()
Returns the receiver's setters.

Returns:
The setters.

getName

public I18NBoundMessage getName()
Returns the receiver's name.

Returns:
The name. It may be null for anonymous contexts.

printUsage

public void printUsage(PrintStream stream)
Prints the receiver's usage instructions (which include its name, if not anonymous) onto the given stream.

Parameters:
stream - The stream.

getOverride

public boolean getOverride()
Checks whether the receiver is an override context.

Returns:
True iff so.

setValues

public abstract void setValues()
                        throws I18NException
Sets the data of the holders associated with the receivers' setters. Setters may be unable/unwilling to set their holder data so, when this method returns, some holders may still have unset data.

Throws:
I18NException - Thrown if the receiver cannot create an operational context for its setters, and therefore the setters cannot even attempt to set their holder data.


Copyright © 2012. All Rights Reserved.