Package uk.ac.starlink.topcat
Class TopcatJELUtils
- java.lang.Object
-
- uk.ac.starlink.ttools.jel.JELUtils
-
- uk.ac.starlink.topcat.TopcatJELUtils
-
public class TopcatJELUtils extends uk.ac.starlink.ttools.jel.JELUtils
This class provides some utility methods for use with the JEL expression compiler.- Author:
- Mark Taylor (Starlink)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACTIVATION_CLASSES_PROPERTY
-
Constructor Summary
Constructors Constructor Description TopcatJELUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Class
classForName(java.lang.String cname)
Returns the class with the given name, or null if it's not on the path.static java.lang.String
combineSubsetsExpression(TopcatModel tcModel, java.lang.String expr, RowSubset[] rowSubsets)
Returns a JEL expression that represents the union of a given array of subsets ANDed with a given JEL expression.static java.util.List<java.lang.Class>
getActivationStaticClasses()
Returns the list of classes whose static methods will be mapped into the JEL evaluation namespace for activation purposes only.static java.lang.String
getColumnId(uk.ac.starlink.table.gui.StarTableColumn tcol)
Returns the JEL $Identifier for a given column.static java.lang.String
getDataExpression(TopcatModel tcModel, GuiCoordContent content)
Returns a JEL-friendly expression which may be used to reference a GuiCoordContent, if possible.static gnu.jel.Library
getLibrary(uk.ac.starlink.ttools.jel.JELRowReader rowReader, boolean activation)
Returns a JEL Library suitable for expression evaluation.static java.lang.String
getSubsetExpression(TopcatModel tcModel, RowSubset rset)
Returns a JEL-friendly expression which may be used to reference a RowSubset.static boolean
isJelIdentifier(java.lang.String label)
Indicates whether a given string is a syntactically legal Java identifier.static java.lang.Class
wrapPrimitiveClass(java.lang.Class prim)
Turns a primitive class into the corresponding wrapper class.
-
-
-
Field Detail
-
ACTIVATION_CLASSES_PROPERTY
public static final java.lang.String ACTIVATION_CLASSES_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLibrary
public static gnu.jel.Library getLibrary(uk.ac.starlink.ttools.jel.JELRowReader rowReader, boolean activation)
Returns a JEL Library suitable for expression evaluation.- Parameters:
rowReader
- object which can read rows from the table to be used for expression evaluationactivation
- true iff the result is to include classes used only for activation (e.g. write to System.out, pop up viewers) as well as classes with methods for calculations- Returns:
- a JEL library
-
getActivationStaticClasses
public static java.util.List<java.lang.Class> getActivationStaticClasses()
Returns the list of classes whose static methods will be mapped into the JEL evaluation namespace for activation purposes only. This may be modified.- Returns:
- list of activation classes with static methods
-
wrapPrimitiveClass
public static java.lang.Class wrapPrimitiveClass(java.lang.Class prim)
Turns a primitive class into the corresponding wrapper class.- Parameters:
prim
- primitive class- Returns:
- the corresponding non-primitive wrapper class
-
classForName
public static java.lang.Class classForName(java.lang.String cname)
Returns the class with the given name, or null if it's not on the path.- Parameters:
cname
- class name- Returns:
- class or null
-
getDataExpression
public static java.lang.String getDataExpression(TopcatModel tcModel, GuiCoordContent content)
Returns a JEL-friendly expression which may be used to reference a GuiCoordContent, if possible.- Parameters:
tcModel
- topcat modelcontent
- user specification for a plotted quantity- Returns:
- JEL-safe expression for referencing the quantity
-
getSubsetExpression
public static java.lang.String getSubsetExpression(TopcatModel tcModel, RowSubset rset)
Returns a JEL-friendly expression which may be used to reference a RowSubset.- Parameters:
tcModel
- topcat modelrset
- row subset- Returns:
- JEL-safe expression for subset
-
getColumnId
public static java.lang.String getColumnId(uk.ac.starlink.table.gui.StarTableColumn tcol)
Returns the JEL $Identifier for a given column.- Parameters:
tcol
- table column from data model- Returns:
- "$nn" expression referencing column
-
isJelIdentifier
public static boolean isJelIdentifier(java.lang.String label)
Indicates whether a given string is a syntactically legal Java identifier. It has to have the right form and not be a reserved word.- Parameters:
label
- text to test- Returns:
- true iff it can be used as an identifier in JEL expressions
-
combineSubsetsExpression
public static java.lang.String combineSubsetsExpression(TopcatModel tcModel, java.lang.String expr, RowSubset[] rowSubsets)
Returns a JEL expression that represents the union of a given array of subsets ANDed with a given JEL expression.- Parameters:
tcModel
- topcat modelexpr
- expression to AND withrowSubsets
- array of zero or more subsets composing union; if none are provided, ALL is assumed- Returns:
- combined expression
-
-