public class StandardCoercionManager extends BaseService implements ICoercionManager
| Modifier and Type | Field and Description |
|---|---|
TypeSystemAwareCache<Pair<IType,IType>,ICoercer> |
_coercerCache |
static Object |
NO_DICE |
| Constructor and Description |
|---|
StandardCoercionManager() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
arePrimitiveTypesAssignable(IType toType,
IType fromType) |
boolean |
canCoerce(IType lhsType,
IType rhsType) |
Object |
convertNullAsPrimitive(IType intrType,
boolean isForBoxing)
Converts a null value to a value compatible with the specified primitive type.
|
Object |
convertValue(Object value,
IType intrType)
Given a value and a target Class, return a compatible value via the target Class.
|
ICoercer |
findCoercer(IType lhsType,
IType rhsType,
boolean runtime) |
String |
formatDate(Date value,
String strFormat) |
String |
formatNumber(Double value,
String strFormat) |
String |
formatTime(Date value,
String strFormat) |
protected ICoercer |
getCoercerInternal(IType lhsType,
IType rhsType,
boolean runtime)
Returns a coercer from values of rhsType to values of lhsType if one exists.
|
protected ICoercer |
getHighPriorityPrimitiveOrBoxedConverter(IType type) |
protected ICoercer |
getPrimitiveOrBoxedConverter(IType type) |
static boolean |
isBoxed(IType lhsType) |
boolean |
isDateTime(String str) |
static boolean |
isObjectMethod(IMethodInfo mi) |
boolean |
isPrimitiveOrBoxed(IType lhsType)
Determine whether the specified type is either a primitive or a boxed primitive.
|
static boolean |
isStructurallyAssignable_Laxed(IType toType,
IType fromType) |
static boolean |
isStructurallyAssignable_Laxed(IType toType,
IType fromType,
IMethodInfo specificMethod,
TypeVarToTypeMap inferenceMap) |
static boolean |
isStructurallyAssignable_Laxed(IType toType,
IType fromType,
TypeVarToTypeMap inferenceMap) |
static boolean |
isStructurallyAssignable(IType toType,
IType fromType) |
BigDecimal |
makeBigDecimalFrom(Object obj) |
BigInteger |
makeBigIntegerFrom(Object obj) |
Boolean |
makeBooleanFrom(Object obj) |
Date |
makeDateFrom(Object obj)
Returns a new Date instance representing the object.
|
Double |
makeDoubleFrom(Object obj)
Returns a Double for an arbitrary object.
|
Float |
makeFloatFrom(Object obj) |
Integer |
makeIntegerFrom(Object obj) |
Long |
makeLongFrom(Object obj) |
boolean |
makePrimitiveBooleanFrom(Object obj) |
double |
makePrimitiveDoubleFrom(Object obj) |
float |
makePrimitiveFloatFrom(Object obj) |
int |
makePrimitiveIntegerFrom(Object obj) |
long |
makePrimitiveLongFrom(Object obj) |
Rational |
makeRationalFrom(Object obj) |
String |
makeStringFrom(Object obj) |
boolean |
notCoercibleOrRequiresExplicitCoercion(IType lhsType,
IType rhsType) |
Date |
parseDateTime(String str)
Produce a date from a string using standard DateFormat parsing.
|
Number |
parseNumber(String strValue) |
ICoercer |
resolveCoercerStatically(IType typeToCoerceTo,
IType typeToCoerceFrom)
Determine and return a statically valid coercer from the rhsType to the lhsType.
|
IType |
verifyTypesComparable(IType lhsType,
IType rhsType,
boolean bBiDirectional)
Verifies that the right hand type can be converted or coerced to the left hand type.
|
IType |
verifyTypesComparable(IType lhsType,
IType rhsType,
boolean bBiDirectional,
IFullParserState parserState)
Verifies that the right hand type can be converted or coerced to the left hand type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInterfacepublic static final Object NO_DICE
public final TypeSystemAwareCache<Pair<IType,IType>,ICoercer> _coercerCache
public final boolean canCoerce(IType lhsType, IType rhsType)
canCoerce in interface ICoercionManagerlhsType - type to be coerced torhsType - type to be coerced frompublic final ICoercer findCoercer(IType lhsType, IType rhsType, boolean runtime)
findCoercer in interface ICoercionManagerprotected ICoercer getCoercerInternal(IType lhsType, IType rhsType, boolean runtime)
lhsType - the type to coerce torhsType - the type to coerce fromruntime - true if the coercion is happening at runtime rather than compile time
(note: This param should go away as we store the coercions on the parsed elements, rather than calling into the
coercion manager)public boolean isPrimitiveOrBoxed(IType lhsType)
ICoercionManagerisPrimitiveOrBoxed in interface ICoercionManagerlhsType - the type to examinepublic static boolean isBoxed(IType lhsType)
protected ICoercer getHighPriorityPrimitiveOrBoxedConverter(IType type)
public IType verifyTypesComparable(IType lhsType, IType rhsType, boolean bBiDirectional) throws ParseException
ICoercionManagerverifyTypesComparable in interface ICoercionManagerParseExceptionpublic IType verifyTypesComparable(IType lhsType, IType rhsType, boolean bBiDirectional, IFullParserState parserState) throws ParseException
ICoercionManagerverifyTypesComparable in interface ICoercionManagerParseExceptionpublic static boolean isStructurallyAssignable(IType toType, IType fromType)
public static boolean isStructurallyAssignable_Laxed(IType toType, IType fromType)
public static boolean isStructurallyAssignable_Laxed(IType toType, IType fromType, TypeVarToTypeMap inferenceMap)
public static boolean isStructurallyAssignable_Laxed(IType toType, IType fromType, IMethodInfo specificMethod, TypeVarToTypeMap inferenceMap)
public static boolean arePrimitiveTypesAssignable(IType toType, IType fromType)
public static boolean isObjectMethod(IMethodInfo mi)
public boolean notCoercibleOrRequiresExplicitCoercion(IType lhsType, IType rhsType)
notCoercibleOrRequiresExplicitCoercion in interface ICoercionManagerpublic final Object convertValue(Object value, IType intrType)
convertValue in interface ICoercionManagervalue - the value to coerce (may not be null)intrType - type to coerce topublic Object convertNullAsPrimitive(IType intrType, boolean isForBoxing)
ICoercionManagerconvertNullAsPrimitive in interface ICoercionManagerintrType - The primitive type to convert to.public ICoercer resolveCoercerStatically(IType typeToCoerceTo, IType typeToCoerceFrom)
ICoercionManagerresolveCoercerStatically in interface ICoercionManagertypeToCoerceTo - the type to coerce totypeToCoerceFrom - the type to coerce frompublic Double makeDoubleFrom(Object obj)
ICoercionManagernull 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.
makeDoubleFrom in interface ICoercionManagerpublic int makePrimitiveIntegerFrom(Object obj)
makePrimitiveIntegerFrom in interface ICoercionManagerpublic Integer makeIntegerFrom(Object obj)
makeIntegerFrom in interface ICoercionManagerpublic long makePrimitiveLongFrom(Object obj)
makePrimitiveLongFrom in interface ICoercionManagerpublic Long makeLongFrom(Object obj)
makeLongFrom in interface ICoercionManagerpublic BigDecimal makeBigDecimalFrom(Object obj)
makeBigDecimalFrom in interface ICoercionManagerpublic Rational makeRationalFrom(Object obj)
makeRationalFrom in interface ICoercionManagerpublic BigInteger makeBigIntegerFrom(Object obj)
makeBigIntegerFrom in interface ICoercionManagerpublic double makePrimitiveDoubleFrom(Object obj)
makePrimitiveDoubleFrom in interface ICoercionManagerpublic Float makeFloatFrom(Object obj)
makeFloatFrom in interface ICoercionManagerpublic float makePrimitiveFloatFrom(Object obj)
makePrimitiveFloatFrom in interface ICoercionManagerpublic String makeStringFrom(Object obj)
makeStringFrom in interface ICoercionManagerpublic boolean makePrimitiveBooleanFrom(Object obj)
makePrimitiveBooleanFrom in interface ICoercionManagerpublic Boolean makeBooleanFrom(Object obj)
makeBooleanFrom in interface ICoercionManagerpublic Date makeDateFrom(Object obj)
makeDateFrom in interface ICoercionManagerpublic boolean isDateTime(String str) throws ParseException
isDateTime in interface ICoercionManagerParseExceptionpublic Date parseDateTime(String str) throws ParseException
parseDateTime in interface ICoercionManagerParseExceptionpublic String formatDate(Date value, String strFormat)
formatDate in interface ICoercionManagerpublic String formatTime(Date value, String strFormat)
formatTime in interface ICoercionManagerpublic String formatNumber(Double value, String strFormat)
formatNumber in interface ICoercionManagerpublic Number parseNumber(String strValue)
parseNumber in interface ICoercionManagerCopyright © 2020. All rights reserved.