📄 datatagiteratorusingassigndata.java
字号:
package jsp.tags.dapact.tags.data;
import jsp.tags.dapact.conf.UserClassFactory;
import jsp.tags.dapact.lookup.BaseLookupValue;
import jsp.tags.dapact.tags.data.DataException;
import jsp.tags.dapact.util.TagUtil;
/**
* Title: Data Aware Processing And Control Tags
* Description: Tag library for the processing and controlling the input and output of data.
* Copyright: LGPL (http://www.gnu.org/copyleft/lesser.html)
* Compile Date: @compile_date@
* @author Allen M Servedio
* @amp_sign@version @VERSION@
*/
/**
* This concrete class allows assignment of an object (that implements the
* RetrieveValueByNameIteratorInf interface) either by looking it up by name or
* by a subclass assigning it through the {@link #setDataIterateObj(RetrieveValueByNameIteratorInf)}.
* The system will check the data iterate object property first and then use the
* {@link #getDataIterateObjName()} method to lookup the data object.
*/
public class DataTagIteratorUsingAssignData extends BaseDataTagIterator
{
/**
* Default constructor...
*/
public DataTagIteratorUsingAssignData()
{
}
/**
* Called by objects that want to request a value by its name.
*
* @param requestor the object requesting the value or the object that the value
* is being requested for (like with a lookup: you would pass the TagSupport
* object, not the lookup which is what actually calls this function).
* @param name the name of the value to retrieve.
*
* @return the value that was found by the name supplied.
*/
public Object retrieveValueByName(Object requestor, String name)
{
Object result = null;
RetrieveValueByNameIteratorInf dataIterateObj = getDataIterateObj();
if (dataIterateObj != null)
{
result = dataIterateObj.retrieveValueByName(requestor, name);
}
return result;
}
/**
* This function should be called when processing is done or is aborted (so that sub
* classes can close their resources). This function should be able to handle multiple
* calls to it without causing an error (so, it the iterator calls it and then the
* finalize() method calls it, the only exceptions that should occur are in the first
* call when it tries to close the resources). Subsequent calls should probably be
* ignored, unless there is a reason to try again.
*/
public void close() throws DataException
{
RetrieveValueByNameIteratorInf dataIterateObj = getDataIterateObj();
if (dataIterateObj != null)
{
dataIterateObj.close();
}
}
/**
* This function is called to tell the sub class to advance to the next group of
* data.
*
* @return this function should return <code>true</code> until there is no more data,
* then it should return <code>false</code>.
*/
public boolean next() throws DataException
{
boolean result = false;
RetrieveValueByNameIteratorInf dataIterateObj = getDataIterateObj();
if (dataIterateObj != null)
{
result = dataIterateObj.next();
}
return result;
}
/**
* Called by the container to free the tags resources - super class calls close().
*/
public void release()
{
super.release();
dataIterateObj = null;
}
/*=============================================================================*/
/* PROPERTIES/ATTRIBUTES */
/*=============================================================================*/
/**
* Set the data iterate object to be used to iterate over the set of data and to respond
* to requests for data. If this is set, it will ignore the data iterate object name.
*/
public void setDataIterateObj(RetrieveValueByNameIteratorInf dataIterateObj)
{
this.dataIterateObj = dataIterateObj;
}
/**
* Get the data iterate object to be used to iterate over the set of data and to respond
* to requests for data. If this is set, it will ignore the data iterate object name.
* It will lookup the object (using the data iterate object name) if it is null.
*/
public RetrieveValueByNameIteratorInf getDataIterateObj()
{
// If no data iterate object has been set, look it up.
if (dataIterateObj == null)
{
BaseLookupValue lookup = UserClassFactory.getLookupValueInstance(getLookupValueName());
if (lookup != null)
{
// Set the data iterator from the looked up value.
try
{
dataIterateObj = (RetrieveValueByNameIteratorInf)lookup.lookupValue(getDataIterateObjName(), dataIterateObj, this, pageContext);
}
catch (java.lang.ClassCastException e)
{
UserClassFactory.getLogger().log("The object referenced by the following name is not of type RetrieveValueByNameIteratorInf: " + getDataIterateObjName(), e);
}
}
}
return dataIterateObj;
}
/**
* Set the name of the object.
*/
public void setName(String name)
{
super.setName(name);
RetrieveValueByNameIteratorInf dataIterateObj = getDataIterateObj();
if (dataIterateObj != null)
{
dataIterateObj.setName(name);
}
}
/**
* A string constant that is used to retrieve and set the value of the Data Iterate Obj Name property.
*/
public static final String DATA_ITERATE_OBJ_NAME_CONST = TagUtil.HIDE_ATTR_CHAR+"DataIterateObjName";
/**
* Get the data iterate object name of the object which is used to find the data object
* to iterate over (and use to respond to requests for data).
*/
public String getDataIterateObjName()
{
return (String)getValue(DATA_ITERATE_OBJ_NAME_CONST);
}
/**
* Set the data iterate object name of the object which is used to find the data object
* to iterate over (and use to respond to requests for data).
*/
public void setDataIterateObjName(String name)
{
this.setValue(DATA_ITERATE_OBJ_NAME_CONST, name);
}
private RetrieveValueByNameIteratorInf dataIterateObj;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -