Package cronapi
Class Var
- java.lang.Object
-
- cronapi.Var
-
- All Implemented Interfaces:
com.fasterxml.jackson.databind.JsonSerializable,cronapi.Variable,Comparable<Var>,org.apache.olingo.odata2.core.ep.producer.OlingoJsonSerializer,org.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterface
public class Var extends Object implements Comparable<Var>, com.fasterxml.jackson.databind.JsonSerializable, org.apache.olingo.odata2.core.ep.producer.OlingoJsonSerializer, org.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterface, cronapi.Variable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVar.JsonAdapterstatic classVar.Type
-
Field Summary
Fields Modifier and Type Field Description static String[]ALLOWED_TYPESstatic Object[]EMPTY_OBJ_ARRAYstatic ScriptEngineenginestatic StringEXP_NULLstatic ScriptEngineManagerfactorystatic PatternISO_PATTERNstatic Class[]MAPPED_TYPESstatic VarVAR_DATE_ZEROstatic VarVAR_EMPTYstatic VarVAR_FALSEstatic VarVAR_NEGATIVE_ONEstatic VarVAR_NULLstatic VarVAR_ONEstatic VarVAR_TRUEstatic VarVAR_ZERO
-
Constructor Summary
Constructors Constructor Description Var()Construct a Var with an NULL typeVar(Var var)Construct a Var from a given VarVar(Object object)Construct a Var and assign its contained object to that specified.Var(Object object, boolean modifiable)Var(String id, Object object)Construct a Var and assign its contained object to that specified.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(Var var)Add all values from one List to another.Varappend(Object value)static Object[]asObjectArray(Var[] vars)ObjectcloneObject()Clone ObjectintcompareTo(Var var)Compare this object's value to anotherbooleancontainsKey(String name)static Objectdeserialize(String value)static StringdeserializeType(String value)booleanequals(Object obj)Test to see if this object equals another one.static Vareval(String val)Varget(int index)If this object is a linked list, then calling this method will return the Var at the index indicatedObjectget(String name)VargetField(String field)StringgetId()StringgetMD5()ObjectgetObject()ObjectgetObject(Class type)BooleangetObjectAsBoolean()Get object as an boolean.byte[]getObjectAsByteArray()Get object as a byte array.DataSourcegetObjectAsDataSource()Get the contained datasourceCalendargetObjectAsDateTime()Get object as an boolean.DoublegetObjectAsDouble()Get object as a double.FilegetObjectAsFile()IntegergetObjectAsInt()Get object as an int.com.google.gson.JsonElementgetObjectAsJson()com.google.gson.JsonElementgetObjectAsJsonElement()ListgetObjectAsList()Get the object as a list.LonggetObjectAsLong()Get object as an int.MapgetObjectAsMap()VargetObjectAsPOJOList()CollectiongetObjectAsRawList(Class clazz)ShortgetObjectAsShort()StringgetObjectAsString()Get object as a string.CollectiongetObjectAsVarList(Class clazz)VargetPOJO()StringgetStringField(String field)Var.TypegetType()Get the type of the underlying objectstatic ClassgetType(String key)<T> TgetTypedObject(Class<T> type)booleangreaterThan(Var var)Check to see if this var is greater than a given var.booleangreaterThanOrEqual(Var var)Check to see if this var is greater than or equal to a given varinthashCode()voidinc(Object value)booleanisBoolean()BooleanisEmpty()BooleanisEmptyOrNull()booleanisNative()BooleanisNull()booleanisNumber()booleanisString()Iterator<Var>iterator()LinkedList<String>keySet()intlength()booleanlessThan(Var var)Check to see if this Var is less than some other var.booleanlessThanOrEqual(Var var)Check to see if this var is less than or equal to some other varstatic voidmain(String[] args)voidmultiply(Object value)Varnegate()static VarnewList()static VarnewMap()Varput(Object key, Object value)voidserialize(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers)StringserializeAsJson()voidserializeWithType(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer)voidset(int index, Var var)Set the value of of a list at the index specified.org.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterfaceset(String name, Object value)voidsetField(String field, Object value)voidsetId(String id)voidsetObject(Object val)Set the value of the underlying object.intsize()If this object is a linked list, then calling this method will return the size of the linked list.StringtoString()Convert this Var to a string format.voidtrim()voidupdateWith(Object obj)static VarvalueOf(Object val)Static constructor to make a var from some value.static VarvalueOf(String id, Object val)
-
-
-
Field Detail
-
EXP_NULL
public static final String EXP_NULL
- See Also:
- Constant Field Values
-
factory
public static final ScriptEngineManager factory
-
engine
public static final ScriptEngine engine
-
ISO_PATTERN
public static final Pattern ISO_PATTERN
-
EMPTY_OBJ_ARRAY
public static final Object[] EMPTY_OBJ_ARRAY
-
VAR_NULL
public static final Var VAR_NULL
-
VAR_TRUE
public static final Var VAR_TRUE
-
VAR_FALSE
public static final Var VAR_FALSE
-
VAR_ZERO
public static final Var VAR_ZERO
-
VAR_ONE
public static final Var VAR_ONE
-
VAR_NEGATIVE_ONE
public static final Var VAR_NEGATIVE_ONE
-
VAR_EMPTY
public static final Var VAR_EMPTY
-
VAR_DATE_ZERO
public static final Var VAR_DATE_ZERO
-
ALLOWED_TYPES
public static String[] ALLOWED_TYPES
-
MAPPED_TYPES
public static Class[] MAPPED_TYPES
-
-
Constructor Detail
-
Var
public Var()
Construct a Var with an NULL type
-
Var
public Var(String id, Object object)
Construct a Var and assign its contained object to that specified.- Parameters:
object- The value to set this object to
-
Var
public Var(Object object)
Construct a Var and assign its contained object to that specified.- Parameters:
object- The value to set this object to
-
Var
public Var(Object object, boolean modifiable)
-
Var
public Var(Var var)
Construct a Var from a given Var- Parameters:
var- var to construct this one from
-
-
Method Detail
-
serializeAsJson
public String serializeAsJson()
- Specified by:
serializeAsJsonin interfaceorg.apache.olingo.odata2.core.ep.producer.OlingoJsonSerializer
-
get
public Object get(String name)
- Specified by:
getin interfaceorg.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterface
-
containsKey
public boolean containsKey(String name)
- Specified by:
containsKeyin interfaceorg.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterface
-
set
public org.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterface set(String name, Object value)
- Specified by:
setin interfaceorg.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterface
-
isString
public boolean isString()
- Specified by:
isStringin interfacecronapi.Variable
-
isNumber
public boolean isNumber()
-
isBoolean
public boolean isBoolean()
-
main
public static void main(String[] args)
-
valueOf
public static Var valueOf(Object val)
Static constructor to make a var from some value.- Parameters:
val- some value to construct a var around- Returns:
- the Var object
-
newMap
public static Var newMap()
-
newList
public static Var newList()
-
getType
public Var.Type getType()
Get the type of the underlying object- Returns:
- Will return the object's type as defined by Type
-
getId
public String getId()
-
setId
public void setId(String id)
-
getObjectAsDataSource
public DataSource getObjectAsDataSource()
Get the contained datasource- Returns:
- the object
-
getObject
public Object getObject()
- Specified by:
getObjectin interfaceorg.apache.olingo.odata2.jpa.processor.core.access.data.VirtualClassInterface
-
setObject
public void setObject(Object val)
Set the value of the underlying object. Note that the type of Var will be determined when setObject is called.- Parameters:
val- the value to set this Var to
-
getTypedObject
public <T> T getTypedObject(Class<T> type)
- Specified by:
getTypedObjectin interfacecronapi.Variable
-
cloneObject
public Object cloneObject()
Clone Object- Returns:
- a new object equal to this one
-
getObjectAsInt
public Integer getObjectAsInt()
Get object as an int. Does not make sense for a "LIST" type object- Specified by:
getObjectAsIntin interfacecronapi.Variable- Returns:
- an integer whose value equals this object
-
getObjectAsLong
public Long getObjectAsLong()
Get object as an int. Does not make sense for a "LIST" type object- Returns:
- an integer whose value equals this object
-
getObjectAsShort
public Short getObjectAsShort()
-
getObjectAsFile
public File getObjectAsFile()
-
getObjectAsJsonElement
public com.google.gson.JsonElement getObjectAsJsonElement()
-
getObjectAsJson
public com.google.gson.JsonElement getObjectAsJson()
-
getObjectAsDateTime
public Calendar getObjectAsDateTime()
Get object as an boolean.- Returns:
- an bool whose value equals this object
-
getObjectAsBoolean
public Boolean getObjectAsBoolean()
Get object as an boolean.- Returns:
- an bool whose value equals this object
-
getMD5
public String getMD5()
-
getObjectAsDouble
public Double getObjectAsDouble()
Get object as a double. Does not make sense for a "LIST" type object.- Specified by:
getObjectAsDoublein interfacecronapi.Variable- Returns:
- a double whose value equals this object
-
getObjectAsByteArray
public byte[] getObjectAsByteArray()
Get object as a byte array. Does not make sense for a "LIST" type object.- Returns:
- a byte array whose value equals this object
-
getObjectAsString
public String getObjectAsString()
Get object as a string.- Specified by:
getObjectAsStringin interfacecronapi.Variable- Returns:
- The string value of the object. Note that for lists, this is a comma separated list of the form {x,y,z,...}
-
getObjectAsRawList
public Collection getObjectAsRawList(Class clazz)
-
getObjectAsVarList
public Collection getObjectAsVarList(Class clazz)
-
getObjectAsList
public List getObjectAsList()
Get the object as a list.- Specified by:
getObjectAsListin interfacecronapi.Variable- Returns:
- a LinkedList whose elements are of type Var
-
getObjectAsMap
public Map getObjectAsMap()
-
getObjectAsPOJOList
public Var getObjectAsPOJOList()
-
isNative
public boolean isNative()
-
getPOJO
public Var getPOJO()
-
get
public Var get(int index)
If this object is a linked list, then calling this method will return the Var at the index indicated- Parameters:
index- the index of the Var to read (0 based)- Returns:
- the Var at that index
-
size
public int size()
If this object is a linked list, then calling this method will return the size of the linked list.- Returns:
- size of list
-
length
public int length()
-
trim
public void trim()
-
set
public void set(int index, Var var)Set the value of of a list at the index specified. Note that this is only value if this object is a list and also note that index must be in bounds.- Parameters:
index- the index into which the Var will be insertedvar- the var to insert
-
addAll
public void addAll(Var var)
Add all values from one List to another. Both lists are Var objects that contain linked lists.- Parameters:
var- The list to add
-
equals
public boolean equals(Object obj)
Test to see if this object equals another one. This is done by converting both objects to strings and then doing a string compare.
-
inc
public void inc(Object value)
-
multiply
public void multiply(Object value)
-
lessThan
public boolean lessThan(Var var)
Check to see if this Var is less than some other var.- Parameters:
var- the var to compare to- Returns:
- true if it is less than
-
lessThanOrEqual
public boolean lessThanOrEqual(Var var)
Check to see if this var is less than or equal to some other var- Parameters:
var- the var to compare to- Returns:
- true if this is less than or equal to var
-
greaterThan
public boolean greaterThan(Var var)
Check to see if this var is greater than a given var.- Parameters:
var- the var to compare to.- Returns:
- true if this object is grater than the given var
-
greaterThanOrEqual
public boolean greaterThanOrEqual(Var var)
Check to see if this var is greater than or equal to a given var- Parameters:
var- the var to compare to- Returns:
- true if this var is greater than or equal to the given var
-
compareTo
public int compareTo(Var var)
Compare this object's value to another- Specified by:
compareToin interfaceComparable<Var>- Parameters:
var- the object to compare to- Returns:
- the value 0 if this is equal to the argument; a value less than 0 if this is numerically less than the argument; and a value greater than 0 if this is numerically greater than the argument (signed comparison).
-
toString
public String toString()
Convert this Var to a string format.
-
negate
public Var negate()
-
serialize
public void serialize(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException- Specified by:
serializein interfacecom.fasterxml.jackson.databind.JsonSerializable- Throws:
IOException
-
serializeWithType
public void serializeWithType(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer) throws IOException- Specified by:
serializeWithTypein interfacecom.fasterxml.jackson.databind.JsonSerializable- Throws:
IOException
-
keySet
public LinkedList<String> keySet()
-
updateWith
public void updateWith(Object obj)
-
isNull
public Boolean isNull()
- Specified by:
isNullin interfacecronapi.Variable
-
isEmpty
public Boolean isEmpty()
-
isEmptyOrNull
public Boolean isEmptyOrNull()
-
-