Class IntakeTool
- java.lang.Object
-
- org.apache.turbine.services.intake.IntakeTool
-
- All Implemented Interfaces:
org.apache.fulcrum.pool.Recyclable,ApplicationTool
public class IntakeTool extends Object implements ApplicationTool, org.apache.fulcrum.pool.Recyclable
The main class through which Intake is accessed. Provides easy access to the Fulcrum Intake component.- Version:
- $Id$
- Author:
- John D. McNally, Henning P. Schmiedehausen, Quinton McCombs, Eric Pugh
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classIntakeTool.PullHelperInner class to present a nice interface to the template designer
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_KEYConstant for default keyprotected HashMap<String,org.apache.fulcrum.intake.model.Group>groupsGroups from intake.xmlstatic StringINTAKE_GRPConstant for the hidden fieldnameprotected org.apache.fulcrum.intake.IntakeServiceintakeServiceThe Intake service.protected static org.apache.logging.log4j.LoggerlogUsed for loggingprotected org.apache.fulcrum.parser.ValueParserppValueParser instance
-
Constructor Summary
Constructors Constructor Description IntakeTool()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGroupsToParameters(org.apache.fulcrum.parser.ValueParser vp)Add all registered group ids to the value parserStringdeclareGroup(org.apache.fulcrum.intake.model.Group group)A convenience method to write out the hidden form fields that notify intake of the group.voiddeclareGroup(org.apache.fulcrum.intake.model.Group group, StringBuilder sb)xhtml valid hidden input field(s) that notifies intake of the group's presence.StringdeclareGroups()A convenience method to write out the hidden form fields that notify intake of the relevant groups.voiddispose()Disposes the object after use.IntakeTool.PullHelperget(String groupName)get a specific groupIntakeTool.PullHelperget(String groupName, boolean throwExceptions)Get a specific grouporg.apache.fulcrum.intake.model.Groupget(String groupName, String key)Get a specific group by name and key.org.apache.fulcrum.intake.model.Groupget(String groupName, String key, boolean create)Get a specific group by name and key.Map<String,org.apache.fulcrum.intake.model.Group>getGroups()Get a Map containing all the groups.voidinit(Object runData)Prepares intake for a single requestbooleanisAllValid()Loops through all of the Groups and checks to see if the data within the Group is valid.booleanisDisposed()Checks whether the recyclable has been disposed.voidnewForm()Declare that a new form startsvoidrecycle()Recycles the object for a new client.voidrefresh()Implementation of ApplicationTool interface is not needed for this tool as it is request scopedvoidremove(org.apache.fulcrum.intake.model.Group group)Removes group.voidremoveAll()Removes all groups.
-
-
-
Field Detail
-
log
protected static final org.apache.logging.log4j.Logger log
Used for logging
-
DEFAULT_KEY
public static final String DEFAULT_KEY
Constant for default key- See Also:
- Constant Field Values
-
INTAKE_GRP
public static final String INTAKE_GRP
Constant for the hidden fieldname- See Also:
- Constant Field Values
-
groups
protected HashMap<String,org.apache.fulcrum.intake.model.Group> groups
Groups from intake.xml
-
pp
protected org.apache.fulcrum.parser.ValueParser pp
ValueParser instance
-
intakeService
protected org.apache.fulcrum.intake.IntakeService intakeService
The Intake service.
-
-
Constructor Detail
-
IntakeTool
public IntakeTool()
Constructor
-
-
Method Detail
-
init
public void init(Object runData)
Prepares intake for a single request- Specified by:
initin interfaceApplicationTool- Parameters:
runData- initialization data
-
addGroupsToParameters
public void addGroupsToParameters(org.apache.fulcrum.parser.ValueParser vp)
Add all registered group ids to the value parser- Parameters:
vp- the value parser
-
declareGroups
public String declareGroups()
A convenience method to write out the hidden form fields that notify intake of the relevant groups. It should be used only in templates with 1 form. In multiform templates, the groups that are relevant for each form need to be declared using $intake.newForm() and $intake.declareGroup($group) for the relevant groups in the form.- Returns:
- the HTML that declares all groups to Intake in hidden input fields
-
declareGroup
public String declareGroup(org.apache.fulcrum.intake.model.Group group)
A convenience method to write out the hidden form fields that notify intake of the group.- Parameters:
group- the group to declare- Returns:
- the HTML that declares the group to Intake in a hidden input field
-
declareGroup
public void declareGroup(org.apache.fulcrum.intake.model.Group group, StringBuilder sb)
xhtml valid hidden input field(s) that notifies intake of the group's presence.- Parameters:
group- the group to declaresb- a String Builder where the hidden field HTML will be appended
-
newForm
public void newForm()
Declare that a new form starts
-
refresh
public void refresh()
Implementation of ApplicationTool interface is not needed for this tool as it is request scoped- Specified by:
refreshin interfaceApplicationTool
-
get
public IntakeTool.PullHelper get(String groupName)
get a specific group- Parameters:
groupName- the name of the group- Returns:
- a
IntakeTool.PullHelperwrapper around the group
-
get
public IntakeTool.PullHelper get(String groupName, boolean throwExceptions) throws org.apache.fulcrum.intake.IntakeException
Get a specific group- Parameters:
groupName- the name of the groupthrowExceptions- if false, exceptions will be suppressed.- Returns:
- a
IntakeTool.PullHelperwrapper around the group - Throws:
org.apache.fulcrum.intake.IntakeException- could not retrieve group
-
isAllValid
public boolean isAllValid()
Loops through all of the Groups and checks to see if the data within the Group is valid.- Returns:
- true if all groups are valid
-
get
public org.apache.fulcrum.intake.model.Group get(String groupName, String key) throws org.apache.fulcrum.intake.IntakeException
Get a specific group by name and key.- Parameters:
groupName- the name of the groupkey- the key for the group- Returns:
- the
Group - Throws:
org.apache.fulcrum.intake.IntakeException- if the group could not be retrieved
-
get
public org.apache.fulcrum.intake.model.Group get(String groupName, String key, boolean create) throws org.apache.fulcrum.intake.IntakeException
Get a specific group by name and key. Also specify whether or not you want to create a new group.- Parameters:
groupName- the name of the groupkey- the key for the groupcreate- true if a new group should be created- Returns:
- the
Group - Throws:
org.apache.fulcrum.intake.IntakeException- if the group could not be retrieved
-
remove
public void remove(org.apache.fulcrum.intake.model.Group group)
Removes group. Primary use is to remove a group that has been processed by an action and is no longer appropriate in the view (screen).- Parameters:
group- the group instance to remove
-
removeAll
public void removeAll()
Removes all groups. Primary use is to remove groups that have been processed by an action and are no longer appropriate in the view (screen).
-
getGroups
public Map<String,org.apache.fulcrum.intake.model.Group> getGroups()
Get a Map containing all the groups.- Returns:
- the Group Map
-
recycle
public void recycle()
Recycles the object for a new client. Recycle methods with parameters must be added to implementing object and they will be automatically called by pool implementations when the object is taken from the pool for a new client. The parameters must correspond to the parameters of the constructors of the object. For new objects, constructors can call their corresponding recycle methods whenever applicable. The recycle methods must call their super.- Specified by:
recyclein interfaceorg.apache.fulcrum.pool.Recyclable
-
dispose
public void dispose()
Disposes the object after use. The method is called when the object is returned to its pool. The dispose method must call its super.- Specified by:
disposein interfaceorg.apache.fulcrum.pool.Recyclable
-
isDisposed
public boolean isDisposed()
Checks whether the recyclable has been disposed.- Specified by:
isDisposedin interfaceorg.apache.fulcrum.pool.Recyclable- Returns:
- true, if the recyclable is disposed.
-
-