Package gw.lang.parser
Interface ICoercionManager
-
- All Superinterfaces:
IPluginHost,IService
- All Known Implementing Classes:
GWCoercionManager,StandardCoercionManager
public interface ICoercionManager extends IService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanCoerce(IType lhsType, IType rhsType)java.lang.ObjectconvertNullAsPrimitive(IType intrType, boolean isForBoxing)Converts a null value to a value compatible with the specified primitive type.java.lang.ObjectconvertValue(java.lang.Object value, IType intrType)ICoercerfindCoercer(IType lhsType, IType rhsType, boolean runtime)java.lang.StringformatDate(java.util.Date value, java.lang.String strFormat)java.lang.StringformatNumber(java.lang.Double value, java.lang.String strFormat)java.lang.StringformatTime(java.util.Date value, java.lang.String strFormat)booleanisDateTime(java.lang.String str)booleanisPrimitiveOrBoxed(IType type)Determine whether the specified type is either a primitive or a boxed primitive.java.math.BigDecimalmakeBigDecimalFrom(java.lang.Object obj)java.math.BigIntegermakeBigIntegerFrom(java.lang.Object obj)java.lang.BooleanmakeBooleanFrom(java.lang.Object obj)java.util.DatemakeDateFrom(java.lang.Object obj)Returns a new Date instance representing the object.java.lang.DoublemakeDoubleFrom(java.lang.Object obj)Returns a Double for an arbitrary object.java.lang.FloatmakeFloatFrom(java.lang.Object obj)java.lang.IntegermakeIntegerFrom(java.lang.Object obj)java.lang.LongmakeLongFrom(java.lang.Object obj)booleanmakePrimitiveBooleanFrom(java.lang.Object obj)doublemakePrimitiveDoubleFrom(java.lang.Object obj)floatmakePrimitiveFloatFrom(java.lang.Object obj)intmakePrimitiveIntegerFrom(java.lang.Object obj)longmakePrimitiveLongFrom(java.lang.Object obj)RationalmakeRationalFrom(java.lang.Object obj)java.lang.StringmakeStringFrom(java.lang.Object obj)booleannotCoercibleOrRequiresExplicitCoercion(IType lhsType, IType rhsType)java.util.DateparseDateTime(java.lang.String str)Produce a date from a string using standard DateFormat parsing.java.lang.NumberparseNumber(java.lang.String strValue)ICoercerresolveCoercerStatically(IType lhsType, IType rhsType)Determine and return a statically valid coercer from the rhsType to the lhsType.ITypeverifyTypesComparable(IType lhsType, IType rhsType, boolean bBiDirectional)Verifies that the right hand type can be converted or coerced to the left hand type.ITypeverifyTypesComparable(IType lhsType, IType rhsType, boolean bBiDirectional, IFullParserState parserState)Verifies that the right hand type can be converted or coerced to the left hand type.-
Methods inherited from interface gw.plugin.IPluginHost
getInterface
-
-
-
-
Method Detail
-
canCoerce
boolean canCoerce(IType lhsType, IType rhsType)
- Parameters:
lhsType- type to be coerced torhsType- type to be coerced from- Returns:
- true if a coercion exists from rhsType to lhsType, false otherwise
-
convertValue
java.lang.Object convertValue(java.lang.Object value, IType intrType)- Parameters:
intrType- type to coerce tovalue- the value to coerce (may not be null)- Returns:
- the converted value
-
notCoercibleOrRequiresExplicitCoercion
boolean notCoercibleOrRequiresExplicitCoercion(IType lhsType, IType rhsType)
-
verifyTypesComparable
IType verifyTypesComparable(IType lhsType, IType rhsType, boolean bBiDirectional) throws ParseIssue
Verifies that the right hand type can be converted or coerced to the left hand type. If bBiDirectional is true, it will verify that either converts to another- Throws:
ParseIssue
-
verifyTypesComparable
IType verifyTypesComparable(IType lhsType, IType rhsType, boolean bBiDirectional, IFullParserState parserState) throws ParseIssue
Verifies that the right hand type can be converted or coerced to the left hand type. If bBiDirectional is true, it will verify that either converts to another. The parser state will be used to report parse errors with.- Throws:
ParseIssue
-
convertNullAsPrimitive
java.lang.Object convertNullAsPrimitive(IType intrType, boolean isForBoxing)
Converts a null value to a value compatible with the specified primitive type.- Parameters:
intrType- The primitive type to convert to.- Returns:
- A wrapped primitive value corresponding to null.
-
resolveCoercerStatically
ICoercer resolveCoercerStatically(IType lhsType, IType rhsType)
Determine and return a statically valid coercer from the rhsType to the lhsType. Returns null if no coercion is necessary.- Parameters:
lhsType- the type to coerce torhsType- the type to coerce from
-
isPrimitiveOrBoxed
boolean isPrimitiveOrBoxed(IType type)
Determine whether the specified type is either a primitive or a boxed primitive.- Parameters:
type- the type to examine- Returns:
- true if the specified type is a primitive or a boxed primitive
-
makePrimitiveBooleanFrom
boolean makePrimitiveBooleanFrom(java.lang.Object obj)
- Returns:
- A Boolean for an arbitrary object.
-
makeBooleanFrom
java.lang.Boolean makeBooleanFrom(java.lang.Object obj)
-
makePrimitiveIntegerFrom
int makePrimitiveIntegerFrom(java.lang.Object obj)
-
makeIntegerFrom
java.lang.Integer makeIntegerFrom(java.lang.Object obj)
-
makePrimitiveLongFrom
long makePrimitiveLongFrom(java.lang.Object obj)
-
makeLongFrom
java.lang.Long makeLongFrom(java.lang.Object obj)
-
makePrimitiveFloatFrom
float makePrimitiveFloatFrom(java.lang.Object obj)
-
makeFloatFrom
java.lang.Float makeFloatFrom(java.lang.Object obj)
-
makePrimitiveDoubleFrom
double makePrimitiveDoubleFrom(java.lang.Object obj)
-
makeDoubleFrom
java.lang.Double makeDoubleFrom(java.lang.Object obj)
Returns a Double for an arbitrary object. Uses a semi-intelligent algorithm to create an appropriate Double instance. If the Object argument is a:null value - an appropriate value respecting this parsed element's nullAsZero setting e.g., either null or an 'empty' value. Double - returns the argument as is. Number - the Number's doubleValue(). String - Double.parseDouble( String ) Boolean - a pooled instance of either Double( 0 ) or Double( 1 ) Date - A Double for Date.getTime(). default - A parsed Double for the Object argument's toString() method.
- Returns:
- A Double for an arbitrary object (may return a pooled instance).
-
makeBigDecimalFrom
java.math.BigDecimal makeBigDecimalFrom(java.lang.Object obj)
-
makeBigIntegerFrom
java.math.BigInteger makeBigIntegerFrom(java.lang.Object obj)
-
makeRationalFrom
Rational makeRationalFrom(java.lang.Object obj)
-
makeStringFrom
java.lang.String makeStringFrom(java.lang.Object obj)
-
makeDateFrom
java.util.Date makeDateFrom(java.lang.Object obj)
Returns a new Date instance representing the object.
-
parseDateTime
java.util.Date parseDateTime(java.lang.String str) throws java.text.ParseExceptionProduce a date from a string using standard DateFormat parsing.- Throws:
java.text.ParseException
-
isDateTime
boolean isDateTime(java.lang.String str) throws java.text.ParseException- Throws:
java.text.ParseException
-
formatDate
java.lang.String formatDate(java.util.Date value, java.lang.String strFormat)
-
formatTime
java.lang.String formatTime(java.util.Date value, java.lang.String strFormat)
-
formatNumber
java.lang.String formatNumber(java.lang.Double value, java.lang.String strFormat)
-
parseNumber
java.lang.Number parseNumber(java.lang.String strValue)
-
-