|
3.1.2: 2012-07-31 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.util.parser.DefaultItemFunction<T>
public class DefaultItemFunction<T extends Nameable>
JEP function that can be used to return the name of a default item in a project. The constructor need to specify the project and the type of item to look for. Use 'default()' or 'default(col("header"))' in the JEP expression to use this function. The first variant will always return the default item if one exists for the project. The second variant will return the default item only if the 'col("header")' part is null or an empty string.
Before this function is used the setCurrentSubtype(ItemSubtype)
can be called to limit the search to items with a specific subtype. If
there is more than one matching item in a project, it is undefined which
one is returned, but multiple uses of this function will return the same
item.
Field Summary | |
---|---|
private DbControl |
dc
|
private Map<Object,T> |
itemCache
|
private Item |
itemType
|
private int |
numParameters
|
private Project |
project
|
private ItemSubtype |
subtype
|
Constructor Summary | |
---|---|
DefaultItemFunction(DbControl dc,
Project project,
Item itemType)
Create a new function instance. |
Method Summary | |
---|---|
boolean |
checkNumberOfParameters(int n)
|
T |
findDefaultItem()
Find a default item. |
String |
getFunctionName()
Get the name of this function. |
int |
getNumberOfParameters()
|
void |
run(Stack stack)
|
void |
setCurNumberOfParameters(int n)
|
void |
setCurrentSubtype(ItemSubtype subtype)
Set the current subtype to use when looking for default items. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final DbControl dc
private final Project project
private final Item itemType
private ItemSubtype subtype
private int numParameters
private Map<Object,T extends Nameable> itemCache
Constructor Detail |
---|
public DefaultItemFunction(DbControl dc, Project project, Item itemType)
dc
- The DbControl to use when loading items from the databaseproject
- The project (null is allowed)itemType
- The type of item to look forMethod Detail |
---|
public String getFunctionName()
JepFunction
JEP
parser.
getFunctionName
in interface JepFunction
JEP.addFunction(String, PostfixMathCommandI)
public int getNumberOfParameters()
getNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public void setCurNumberOfParameters(int n)
setCurNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public void run(Stack stack) throws ParseException
run
in interface org.nfunk.jep.function.PostfixMathCommandI
ParseException
public T findDefaultItem()
setCurrentSubtype(ItemSubtype)
the
Project.findDefaultItems(DbControl, ItemSubtype, boolean)
method is used in non-strict mode, otherwise the
Project.findDefaultItems(DbControl, Item, boolean)
is used in strict mode.
public void setCurrentSubtype(ItemSubtype subtype)
|
3.1.2: 2012-07-31 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |