public abstract class SimpleStepAdapter extends java.lang.Object implements ISimpleStep
ISimpleStep
adapter class.
This adapter class provides default implementations for
the methods described by the ISimpleStep
interface.
Classes that wish to implement ISimpleStep
can extend this class
and override only the methods which they are interested in.
Modifier and Type | Field and Description |
---|---|
protected FieldInformation[] |
mInputFields
Input field information.
|
protected FieldInformation[] |
mOutputFields
Output field information.
|
protected java.lang.String[] |
mParameterNames
Parameters.
|
protected java.util.Map<java.lang.String,java.lang.String> |
mParameterValues
Parameter values.
|
protected long |
mRowCount
Current row.
|
protected Timings |
mTimings
Timings support.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
mValues
Field values.
|
Constructor and Description |
---|
SimpleStepAdapter() |
Modifier and Type | Method and Description |
---|---|
int |
getOutputFieldCount()
Return the number of output fields provided by this step.
|
FieldInformation |
getOutputFieldInformation(int index)
Return the information about an output field provided by this step.
|
java.lang.Object |
getOutputFieldValue(int index)
Return the value of an output field in the current row.
|
int |
getParameterCount()
Return the number of parameters this step requires.
|
java.lang.String |
getParameterName(int index)
Get the name of a parameter required by this step.
|
void |
postExec()
Execution of the job is complete.
|
void |
preExec(boolean previewMode)
Prepare for execution.
|
void |
processRow()
Process a row of data.
|
void |
release()
Release resources.
|
void |
setInputFieldCount(int count)
Set the number of fields provided by the parent step.
|
void |
setInputFieldInformation(int index,
java.lang.String name,
DataType type,
int length)
Set the input field information provided by the parent step.
|
void |
setInputFieldValue(int index,
java.lang.Object value)
Set the value of an input field.
|
void |
setParameterValue(int index,
java.lang.String value)
Set the value of a parameter required by this step.
|
void |
validateInputs()
Validate input field information.
|
protected FieldInformation[] mInputFields
protected FieldInformation[] mOutputFields
If validateInputs()
is not overridden, the SimpleStepAdapter
returns the input fields as output.
protected java.lang.String[] mParameterNames
To enable the discovery and setting of parameters, the subclass may override the
parameter methods (getParameterCount()
, getParameterName()
,
setParameterValue()
) or the subclass may
create and populate the mParameterNames
String
array with the set
of parameter names and assign mParameterValues
with a Map
instance.
protected java.util.Map<java.lang.String,java.lang.String> mParameterValues
To enable the discovery and setting of parameters, the subclass may override the
parameter methods (getParameterCount()
, getParameterName()
,
setParameterValue()
) or the subclass may
create and populate the mParameterNames
String
array with the set
of parameter names and assign mParameterValues
with a Map
instance.
protected long mRowCount
protected java.util.Map<java.lang.String,java.lang.Object> mValues
protected Timings mTimings
If non-null, the Timings
instance will be used to collect and report
timings. The subclass must implement ISupportTimings
in order for the
Timings
instance to be assigned.
public int getOutputFieldCount()
ISimpleStep
If you want to "pass-through" any fields from the parent, you must include those fields in this count.
getOutputFieldCount
in interface ISimpleStep
public FieldInformation getOutputFieldInformation(int index) throws java.lang.IndexOutOfBoundsException
ISimpleStep
This method must return a valid instance of FieldInformation
.
getOutputFieldInformation
in interface ISimpleStep
index
- The 0-based index of the output field.java.lang.IndexOutOfBoundsException
- If the index argument is out of bounds.public java.lang.Object getOutputFieldValue(int index) throws java.lang.IndexOutOfBoundsException
ISimpleStep
The Data Management Platform will always pass a index
that
is in bounds.
getOutputFieldValue
in interface ISimpleStep
index
- The 0-based index of the output fieldnull
.java.lang.IndexOutOfBoundsException
- If the index argument is out of bounds.public int getParameterCount()
StepParameters
getParameterCount
in interface StepParameters
public java.lang.String getParameterName(int index) throws java.lang.IndexOutOfBoundsException
StepParameters
getParameterName
in interface StepParameters
index
- The 0-based index of the parameter name to retrievejava.lang.IndexOutOfBoundsException
- if the index argument is out of boundspublic void postExec()
ISimpleStep
The plugin step should release any resources used during execution.
postExec
in interface ISimpleStep
public void preExec(boolean previewMode) throws StepException
ISimpleStep
Called after all parameters are set and all input fields from the parent have been specified, but before execution of the job begins. The plugin should prepare to accept input rows.
preExec
in interface ISimpleStep
previewMode
- true
if the job is being previewed.StepException
- If anything goes wrong or the plugin cannot begin
to process rows.public void processRow() throws StepException
ISimpleStep
Called after all of the fields of an input row have been passed in. Process the row and make output fields available. Throw an exception to signal an error.
processRow
in interface ISimpleStep
StepException
- If an error occurs during row processing.public void release()
ISimpleStep
The plugin step should release any resources, such as file handles, here.
Called immediately before the plugin is released for garbage collection. This usually happens when the process running a job shuts down, although it can also happen when a node is deleted from a job.
release
in interface ISimpleStep
public void setInputFieldCount(int count)
ISimpleStep
setInputFieldCount
in interface ISimpleStep
count
- The number of fields provided by the parent step.public void setInputFieldInformation(int index, java.lang.String name, DataType type, int length)
ISimpleStep
The Data Management Platform will always pass a index
that
is in bounds.
setInputFieldInformation
in interface ISimpleStep
index
- The 0-based index of the input field.name
- The name of the input field.type
- The data type of the input field.length
- The maximum character length of the input field. This only
applies for string fields.public void setInputFieldValue(int index, java.lang.Object value)
ISimpleStep
The value being set is provided by the parent step.
The Data Management Platform will always pass a index
that
is in bounds.
setInputFieldValue
in interface ISimpleStep
index
- The 0-based index of the input field.value
- The value of the input field.public void setParameterValue(int index, java.lang.String value) throws java.lang.IndexOutOfBoundsException
StepParameters
setParameterValue
in interface StepParameters
index
- The 0-based index of the parametervalue
- The value of the parameterjava.lang.IndexOutOfBoundsException
- if the index argument is out of boundspublic void validateInputs() throws StepException
ISimpleStep
Called after all parameters are set and all input field information from the parent has been specified.
validateInputs
in interface ISimpleStep
StepException
- If the inputs are not valid.Copyright © 2012 SAS Institute Inc. All Rights Reserved.