Java Doc for Coercions.java in  » Workflow-Engines » jbpm-jpdl-3.2.2 » org » jbpm » jpdl » el » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » jbpm jpdl 3.2.2 » org.jbpm.jpdl.el.impl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jbpm.jpdl.el.impl.Coercions

Coercions
public class Coercions (Code)

This class contains the logic for coercing data types before operators are applied to them.

The following is the list of rules applied for various type conversions.

     Applying arithmetic operator
     Binary operator - A {+,-,*} B
     if A and B are null
     return 0
     if A or B is BigDecimal, coerce both to BigDecimal and then:
     if operator is +, return A.add(B)
     if operator is -, return A.subtract(B)
     if operator is *, return A.multiply(B)
     if A or B is Float, Double, or String containing ".", "e", or "E"
     if A or B is BigInteger, coerce both A and B to BigDecimal and apply operator
     coerce both A and B to Double and apply operator
     if A or B is BigInteger, coerce both to BigInteger and then:
     if operator is +, return A.add(B)
     if operator is -, return A.subtract(B)
     if operator is *, return A.multiply(B)
     otherwise
     coerce both A and B to Long
     apply operator
     if operator results in exception (such as divide by 0), error
     Binary operator - A {/,div} B
     if A and B are null
     return 0
     if A or B is a BigDecimal or BigInteger, coerce both to BigDecimal and
     return A.divide(B, BigDecimal.ROUND_HALF_UP)
     otherwise
     coerce both A and B to Double
     apply operator
     if operator results in exception (such as divide by 0), error
     Binary operator - A {%,mod} B
     if A and B are null
     return 0
     if A or B is BigDecimal, Float, Double, or String containing ".", "e" or "E"
     coerce both to Double
     apply operator
     if A or B is BigInteger, coerce both to BigInteger and return
     A.remainder(B)
     otherwise
     coerce both A and B to Long
     apply operator
     if operator results in exception (such as divide by 0), error
     Unary minus operator - -A
     if A is null
     return 0
     if A is BigInteger or BigDecimal, return A.negate()
     if A is String
     if A contains ".", "e", or "E"
     coerce to Double, apply operator
     otherwise
     coerce to a Long and apply operator
     if A is Byte,Short,Integer,Long,Float,Double
     retain type, apply operator
     if operator results in exception, error
     otherwise
     error
     Applying "empty" operator - empty A
     if A is null
     return true
     if A is zero-length String
     return true
     if A is zero-length array
     return true
     if A is List and ((List) A).isEmpty()
     return true
     if A is Map and ((Map) A).isEmpty()
     return true
     if A is Collection an ((Collection) A).isEmpty()
     return true
     otherwise
     return false
     Applying logical operators
     Binary operator - A {and,or} B
     coerce both A and B to Boolean, apply operator
     NOTE - operator stops as soon as expression can be determined, i.e.,
     A and B and C and D - if B is false, then only A and B is evaluated
     Unary not operator - not A
     coerce A to Boolean, apply operator
     Applying relational operator
     A {<,>,<=,>=,lt,gt,lte,gte} B
     if A==B
     if operator is >= or <=
     return true
     otherwise
     return false
     if A or B is null
     return false
     if A or B is BigDecimal, coerce both A and B to BigDecimal and use the
     return value of A.compareTo(B)
     if A or B is Float or Double
     coerce both A and B to Double
     apply operator
     if A or B is BigInteger, coerce both A and B to BigInteger and use the
     return value of A.compareTo(B)
     if A or B is Byte,Short,Character,Integer,Long
     coerce both A and B to Long
     apply operator
     if A or B is String
     coerce both A and B to String, compare lexically
     if A is Comparable
     if A.compareTo (B) throws exception
     error
     otherwise
     use result of A.compareTo(B)
     if B is Comparable
     if B.compareTo (A) throws exception
     error
     otherwise
     use result of B.compareTo(A)
     otherwise
     error
     Applying equality operator
     A {==,!=} B
     if A==B
     apply operator
     if A or B is null
     return false for ==, true for !=
     if A or B is BigDecimal, coerce both A and B to BigDecimal and then:
     if operator is == or eq, return A.equals(B)
     if operator is != or ne, return !A.equals(B)
     if A or B is Float or Double
     coerce both A and B to Double
     apply operator
     if A or B is BigInteger, coerce both A and B to BigInteger and then:
     if operator is == or eq, return A.equals(B)
     if operator is != or ne, return !A.equals(B)
     if A or B is Byte,Short,Character,Integer,Long
     coerce both A and B to Long
     apply operator
     if A or B is Boolean
     coerce both A and B to Boolean
     apply operator
     if A or B is String
     coerce both A and B to String, compare lexically
     otherwise
     if an error occurs while calling A.equals(B)
     error
     apply operator to result of A.equals(B)
     coercions
     coerce A to String
     A is String
     return A
     A is null
     return ""
     A.toString throws exception
     error
     otherwise
     return A.toString
     coerce A to Number type N
     A is null or ""
     return 0
     A is Character
     convert to short, apply following rules
     A is Boolean
     error
     A is Number type N
     return A
     A is Number, coerce quietly to type N using the following algorithm
     If N is BigInteger
     If A is BigDecimal, return A.toBigInteger()
     Otherwise, return BigInteger.valueOf(A.longValue())
     if N is BigDecimal
     If A is a BigInteger, return new BigDecimal(A)
     Otherwise, return new BigDecimal(A.doubleValue())
     If N is Byte, return new Byte(A.byteValue())
     If N is Short, return new Short(A.shortValue())
     If N is Integer, return new Integer(A.integerValue())
     If N is Long, return new Long(A.longValue())
     If N is Float, return new Float(A.floatValue())
     If N is Double, return new Double(A.doubleValue())
     otherwise ERROR
     A is String
     If N is BigDecimal then:
     If new BigDecimal(A) throws an exception then ERROR
     Otherwise, return new BigDecimal(A)
     If N is BigInteger then:
     If new BigInteger(A) throws an exception, then ERROR
     Otherwise, return new BigInteger(A)
     new N.valueOf(A) throws exception
     error
     return N.valueOf(A)
     otherwise
     error
     coerce A to Character should be
     A is null or ""
     return (char) 0
     A is Character
     return A
     A is Boolean
     error
     A is Number with less precision than short
     coerce quietly - return (char) A
     A is Number with greater precision than short
     coerce quietly - return (char) A
     A is String
     return A.charAt (0)
     otherwise
     error
     coerce A to Boolean
     A is null or ""
     return false
     A is Boolean
     return A
     A is String
     Boolean.valueOf(A) throws exception
     error
     return Boolean.valueOf(A)
     otherwise
     error
     coerce A to any other type T
     A is null
     return null
     A is assignable to T
     coerce quietly
     A is String
     T has no PropertyEditor
     if A is "", return null
     otherwise error
     T's PropertyEditor throws exception
     if A is "", return null
     otherwise error
     otherwise
     apply T's PropertyEditor
     otherwise
     error
     

author:
   Nathan Abramson - Art Technology Group
version:
   $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$




Method Summary
public static  ObjectapplyArithmeticOperator(Object pLeft, Object pRight, ArithmeticOperator pOperator, Logger pLogger)
     Performs all of the necessary type conversions, then calls on the appropriate operator.
public static  ObjectapplyEqualityOperator(Object pLeft, Object pRight, EqualityOperator pOperator, Logger pLogger)
     Performs all of the necessary type conversions, then calls on the appropriate operator.
public static  ObjectapplyRelationalOperator(Object pLeft, Object pRight, RelationalOperator pOperator, Logger pLogger)
     Performs all of the necessary type conversions, then calls on the appropriate operator.
public static  Objectcoerce(Object pValue, Class pClass, Logger pLogger)
     Coerces the given value to the specified class.
public static  BooleancoerceToBoolean(Object pValue, Logger pLogger)
    
public static  CharactercoerceToCharacter(Object pValue, Logger pLogger)
    
public static  IntegercoerceToInteger(Object pValue, Logger pLogger)
     Coerces a value to an Integer, returning null if the coercion isn't possible.
public static  ObjectcoerceToObject(Object pValue, Class pClass, Logger pLogger)
    
public static  NumbercoerceToPrimitiveNumber(Object pValue, Class pClass, Logger pLogger)
    
static  NumbercoerceToPrimitiveNumber(long pValue, Class pClass)
    
static  NumbercoerceToPrimitiveNumber(double pValue, Class pClass)
    
static  NumbercoerceToPrimitiveNumber(Number pValue, Class pClass)
    
static  NumbercoerceToPrimitiveNumber(String pValue, Class pClass)
    
public static  StringcoerceToString(Object pValue, Logger pLogger)
    
public static  booleanisBigDecimal(Object pObject)
     Returns true if the given object is BigDecimal.
public static  booleanisBigInteger(Object pObject)
     Returns true if the given object is BigInteger.
public static  booleanisFloatingPointString(Object pObject)
    
public static  booleanisFloatingPointType(Object pObject)
    
public static  booleanisFloatingPointType(Class pClass)
    
public static  booleanisIntegerType(Object pObject)
    
public static  booleanisIntegerType(Class pClass)
    
static  booleanisNumberClass(Class pClass)
    



Method Detail
applyArithmeticOperator
public static Object applyArithmeticOperator(Object pLeft, Object pRight, ArithmeticOperator pOperator, Logger pLogger) throws ELException(Code)
Performs all of the necessary type conversions, then calls on the appropriate operator.



applyEqualityOperator
public static Object applyEqualityOperator(Object pLeft, Object pRight, EqualityOperator pOperator, Logger pLogger) throws ELException(Code)
Performs all of the necessary type conversions, then calls on the appropriate operator.



applyRelationalOperator
public static Object applyRelationalOperator(Object pLeft, Object pRight, RelationalOperator pOperator, Logger pLogger) throws ELException(Code)
Performs all of the necessary type conversions, then calls on the appropriate operator.



coerce
public static Object coerce(Object pValue, Class pClass, Logger pLogger) throws ELException(Code)
Coerces the given value to the specified class.



coerceToBoolean
public static Boolean coerceToBoolean(Object pValue, Logger pLogger) throws ELException(Code)
Coerces a value to a Boolean



coerceToCharacter
public static Character coerceToCharacter(Object pValue, Logger pLogger) throws ELException(Code)
Coerces a value to a Character



coerceToInteger
public static Integer coerceToInteger(Object pValue, Logger pLogger) throws ELException(Code)
Coerces a value to an Integer, returning null if the coercion isn't possible.



coerceToObject
public static Object coerceToObject(Object pValue, Class pClass, Logger pLogger) throws ELException(Code)
Coerces a value to the specified Class that is not covered by any of the above cases



coerceToPrimitiveNumber
public static Number coerceToPrimitiveNumber(Object pValue, Class pClass, Logger pLogger) throws ELException(Code)
Coerces a value to the given primitive number class



coerceToPrimitiveNumber
static Number coerceToPrimitiveNumber(long pValue, Class pClass) throws ELException(Code)
Coerces a long to the given primitive number class



coerceToPrimitiveNumber
static Number coerceToPrimitiveNumber(double pValue, Class pClass) throws ELException(Code)
Coerces a double to the given primitive number class



coerceToPrimitiveNumber
static Number coerceToPrimitiveNumber(Number pValue, Class pClass) throws ELException(Code)
Coerces a Number to the given primitive number class



coerceToPrimitiveNumber
static Number coerceToPrimitiveNumber(String pValue, Class pClass) throws ELException(Code)
Coerces a String to the given primitive number class



coerceToString
public static String coerceToString(Object pValue, Logger pLogger) throws ELException(Code)
Coerces the specified value to a String



isBigDecimal
public static boolean isBigDecimal(Object pObject)(Code)
Returns true if the given object is BigDecimal.
Parameters:
  pObject - - Object to evaluate - true if the given object is BigDecimal



isBigInteger
public static boolean isBigInteger(Object pObject)(Code)
Returns true if the given object is BigInteger.
Parameters:
  pObject - - Object to evaluate - true if the given object is BigInteger



isFloatingPointString
public static boolean isFloatingPointString(Object pObject)(Code)
Returns true if the given string might contain a floating point number - i.e., it contains ".", "e", or "E"



isFloatingPointType
public static boolean isFloatingPointType(Object pObject)(Code)
Returns true if the given Object is of a floating point type



isFloatingPointType
public static boolean isFloatingPointType(Class pClass)(Code)
Returns true if the given class is of a floating point type



isIntegerType
public static boolean isIntegerType(Object pObject)(Code)
Returns true if the given Object is of an integer type



isIntegerType
public static boolean isIntegerType(Class pClass)(Code)
Returns true if the given class is of an integer type



isNumberClass
static boolean isNumberClass(Class pClass)(Code)
Returns true if the given class is Byte, Short, Integer, Long, Float, Double, BigInteger, or BigDecimal



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.