Class AbstractRuntimeObjectModel
- java.lang.Object
-
- org.apache.sling.scripting.sightly.render.AbstractRuntimeObjectModel
-
- All Implemented Interfaces:
RuntimeObjectModel
public abstract class AbstractRuntimeObjectModel extends java.lang.Object implements RuntimeObjectModel
Default abstract implementation ofRuntimeObjectModel.
-
-
Constructor Summary
Constructors Constructor Description AbstractRuntimeObjectModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.ObjectgetProperty(java.lang.Object target, java.lang.Object propertyObj)booleanisCollection(java.lang.Object target)Checks if an object is aCollectionor is backed by one.booleanisDate(java.lang.Object target)Checks if the provided object represents a date or calendar.booleanisNumber(java.lang.Object target)Checks if the provided object represents a number or not.booleanisPrimitive(java.lang.Object obj)Checks if the provided object represents a primitive data type or not.java.lang.ObjectresolveProperty(java.lang.Object target, java.lang.Object property)Resolve a property of a target object and return its value.booleantoBoolean(java.lang.Object object)Convert the given object to a boolean valuejava.util.Collection<java.lang.Object>toCollection(java.lang.Object object)Force the conversion of the object to a collectionjava.util.DatetoDate(java.lang.Object object)Convert the given object to aDateobjectjava.util.MaptoMap(java.lang.Object object)Force the conversion of the target object to a mapjava.lang.NumbertoNumber(java.lang.Object object)Coerce the object to a numeric valuejava.lang.StringtoString(java.lang.Object target)Convert the given object to a string.
-
-
-
Method Detail
-
isPrimitive
public boolean isPrimitive(java.lang.Object obj)
Description copied from interface:RuntimeObjectModelChecks if the provided object represents a primitive data type or not.- Specified by:
isPrimitivein interfaceRuntimeObjectModel- Parameters:
obj- the target object- Returns:
trueif thetargetis a primitive,falseotherwise
-
isDate
public boolean isDate(java.lang.Object target)
Description copied from interface:RuntimeObjectModelChecks if the provided object represents a date or calendar.- Specified by:
isDatein interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
trueif thetargetis a date or calendar,falseotherwise
-
isNumber
public boolean isNumber(java.lang.Object target)
Description copied from interface:RuntimeObjectModelChecks if the provided object represents a number or not.- Specified by:
isNumberin interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
trueif thetargetis a number,falseotherwise
-
isCollection
public boolean isCollection(java.lang.Object target)
Description copied from interface:RuntimeObjectModelChecks if an object is aCollectionor is backed by one.- Specified by:
isCollectionin interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
trueif thetargetis a collection or is backed by one,falseotherwise
-
resolveProperty
public java.lang.Object resolveProperty(java.lang.Object target, java.lang.Object property)Description copied from interface:RuntimeObjectModelResolve a property of a target object and return its value. The property can be either an index or a name- Specified by:
resolvePropertyin interfaceRuntimeObjectModel- Parameters:
target- the target objectproperty- the property to be resolved- Returns:
- the value of the property
-
toBoolean
public boolean toBoolean(java.lang.Object object)
Description copied from interface:RuntimeObjectModelConvert the given object to a boolean value- Specified by:
toBooleanin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the boolean representation of that object
-
toNumber
public java.lang.Number toNumber(java.lang.Object object)
Description copied from interface:RuntimeObjectModelCoerce the object to a numeric value- Specified by:
toNumberin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the numeric representation
-
toDate
public java.util.Date toDate(java.lang.Object object)
Description copied from interface:RuntimeObjectModelConvert the given object to aDateobject- Specified by:
toDatein interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the date represented by the
object
-
toString
public java.lang.String toString(java.lang.Object target)
Description copied from interface:RuntimeObjectModelConvert the given object to a string.- Specified by:
toStringin interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
- the string representation of the object
-
toCollection
public java.util.Collection<java.lang.Object> toCollection(java.lang.Object object)
Description copied from interface:RuntimeObjectModelForce the conversion of the object to a collection- Specified by:
toCollectionin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the collection representation of the object
-
toMap
public java.util.Map toMap(java.lang.Object object)
Description copied from interface:RuntimeObjectModelForce the conversion of the target object to a map- Specified by:
toMapin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- a map representation of the object. Default is an empty map
-
getProperty
protected java.lang.Object getProperty(java.lang.Object target, java.lang.Object propertyObj)
-
-