public class DefaultItemFunction<T extends Nameable> extends java.lang.Object implements JepFunction
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.
Modifier and Type | Field and Description |
---|---|
private DbControl |
dc |
private java.util.Map<java.lang.Object,T> |
itemCache |
private Item |
itemType |
private int |
numParameters |
private Project |
project |
private ItemSubtype |
subtype |
Constructor and Description |
---|
DefaultItemFunction(DbControl dc,
Project project,
Item itemType)
Create a new function instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n) |
T |
findDefaultItem()
Find a default item.
|
java.lang.String |
getFunctionName()
Get the name of this function.
|
int |
getNumberOfParameters() |
void |
run(java.util.Stack stack) |
void |
setCurNumberOfParameters(int n) |
void |
setCurrentSubtype(ItemSubtype subtype)
Set the current subtype to use when looking for default items.
|
private final DbControl dc
private final Project project
private final Item itemType
private ItemSubtype subtype
private int numParameters
public java.lang.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(java.util.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)