Java Doc for Casting.java in  » Database-ORM » MMBase » org » mmbase » util » 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 » Database ORM » MMBase » org.mmbase.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mmbase.util.Casting

Casting
public class Casting (Code)

Inner Class :public static class ListWrapper extends AbstractList
Inner Class :public static class NodeListWrapper extends org.mmbase.bridge.util.CollectionNodeList
Inner Class :public static class StringWrapper implements CharSequence
Inner Class :public static interface Unwrappable

Field Summary
static  DocumentBuilderDOCUMENTBUILDER
    
final public static  ThreadLocal<DateFormat>ISO_8601_DATE
    
final public static  ThreadLocal<DateFormat>ISO_8601_LOOSE
     A Date formatter that creates a date based on a ISO 8601 date and a ISO 8601 time. I.e.
final public static  ThreadLocal<DateFormat>ISO_8601_TIME
    
final public static  ThreadLocal<DateFormat>ISO_8601_UTC
     A Date formatter that creates a ISO 8601 datetime according to UTC/GMT. I.e.


Method Summary
public static  booleanequals(Object o1, Object o2)
    
public static  booleanisStringRepresentable(Class type)
     Whether or not Casting can more or less reliably cast a certain type to String and back.
public static  booleanisType(Class type, Object value)
     Returns whether the passed object is of the given class. Unlike Class instanceof this also includes Object Types that are representative for primitive types (i.e.
public static  booleantoBoolean(Object b)
     Convert an object to a boolean. If the value is numeric, this call returns true if the value is a positive, non-zero, value.
public static  byte[]toByte(Object obj)
     Convert an object to a byte array.
public static  CollectiontoCollection(Object o, String delimiter)
     Transforms an object to a collection.
public static  CollectiontoCollection(Object o)
    
public static  DatetoDate(Object d)
     Convert an object to a Date.
public static  doubletoDouble(Object i, double def)
     Convert an object to an double.
public static  doubletoDouble(Object i)
     Convert an object to an double.
public static  floattoFloat(Object i, float def)
     Convert an object to an float.
public static  floattoFloat(Object i)
     Convert an object to an float.
public static  InputStreamtoInputStream(Object obj)
    
public static  inttoInt(Object i, int def)
     Convert an object to an int.
public static  inttoInt(Object i)
     Convert an object to an int.
public static  IntegertoInteger(Object i)
     Convert an object to an Integer.
public static  ListtoList(Object o)
     Convert an object to a List.
public static  ListtoList(Object o, String delimiter)
     As Casting.toList(Object) but with one extra argument.
Parameters:
  delimiter - Regexp to use when splitting up the string if the object is a String.
public static  longtoLong(Object i, long def)
     Convert an object to a long.
public static  longtoLong(Object i)
     Convert an object to a long.
public static  MaptoMap(Object o)
    
public static  NodetoNode(Object i, Cloud cloud)
     Convert an object to an Node.
public static  StringtoString(Object o)
     Convert an object to a String.
public static  StringBuffertoStringBuffer(StringBuffer buffer, Object o)
     Convert an object to a string, using a StringBuffer.
public static  StringBuildertoStringBuilder(StringBuilder buffer, Object o)
    
public static  CtoType(Class<C> type, Object value)
     Tries to 'cast' an object for use with the provided class.
public static  CtoType(Class<C> type, Cloud cloud, Object value)
     Tries to 'cast' an object for use with the provided class.
public static  WritertoWriter(Writer writer, Object o)
     Convert an object to a string, using a Writer.
public static  DocumenttoXML(Object o)
     Convert the value to a Document object.
public static  ObjectunWrap(Object o)
     When you want to undo the wrapping, this method can be used.
public static  Objectwrap(Object o, CharTransformer escaper)
     Wraps an object in another object with a toString as we desire.

Field Detail
DOCUMENTBUILDER
static DocumentBuilder DOCUMENTBUILDER(Code)



ISO_8601_DATE
final public static ThreadLocal<DateFormat> ISO_8601_DATE(Code)



ISO_8601_LOOSE
final public static ThreadLocal<DateFormat> ISO_8601_LOOSE(Code)
A Date formatter that creates a date based on a ISO 8601 date and a ISO 8601 time. I.e. 2004-12-01 14:30:00. It is NOT 100% ISO 8601, as opposed to Casting.ISO_8601_UTC , as the standard actually requires a 'T' to be placed between the date and the time. The date given is the date for the local (server) time. Use this formatter if you want to display user-friendly dates in local time. XXX: According to http://en.wikipedia.org/wiki/ISO_8601, the standard allows ' ' in stead of 'T' if no misunderstanding arises, which is the case here. So I don't think this is 'loose'.



ISO_8601_TIME
final public static ThreadLocal<DateFormat> ISO_8601_TIME(Code)



ISO_8601_UTC
final public static ThreadLocal<DateFormat> ISO_8601_UTC(Code)
A Date formatter that creates a ISO 8601 datetime according to UTC/GMT. I.e. 2004-12-01T14:30:00Z. This is 100% ISO 8601, as opposed to Casting.ISO_8601_LOOSE . Use this formatter if you want to export dates. XXX: Hmm, we parse with UTC now, while we don't store them as such.





Method Detail
equals
public static boolean equals(Object o1, Object o2)(Code)

since:
   MMBase-1.9



isStringRepresentable
public static boolean isStringRepresentable(Class type)(Code)
Whether or not Casting can more or less reliably cast a certain type to String and back. For collection types also the entries of the collection must be string representable.
since:
   MMBase-1.8



isType
public static boolean isType(Class type, Object value)(Code)
Returns whether the passed object is of the given class. Unlike Class instanceof this also includes Object Types that are representative for primitive types (i.e. Integer for int).
Parameters:
  type - the type (class) to check
Parameters:
  value - the value whose type to check true if compatible
since:
   MMBase-1.8



toBoolean
public static boolean toBoolean(Object b)(Code)
Convert an object to a boolean. If the value is numeric, this call returns true if the value is a positive, non-zero, value. In other words, values '0' and '-1' are considered false. If the value is a string, this call returns true if the value is "true" or "yes" (case-insensitive). In all other cases (including calling byte fields), false is returned.
Parameters:
  b - the object to convert the converted value as a boolean



toByte
public static byte[] toByte(Object obj)(Code)
Convert an object to a byte array.
Parameters:
  obj - The object to be converted the value as an byte[] (binary/blob field)



toCollection
public static Collection toCollection(Object o, String delimiter)(Code)
Transforms an object to a collection. If the object is a collection already, then nothing happens. If it is a Map, then the 'entry set' is returned. A string is interpreted as a comma-separated list of strings. Other objects are wrapped in an ArrayList with one element.
since:
   MMBase-1.8.5



toCollection
public static Collection toCollection(Object o)(Code)

since:
   MMBase-1.8



toDate
public static Date toDate(Object d)(Code)
Convert an object to a Date. String values are parsed to a date, if possible. Numeric values are assumed to represent number of seconds since 1970. All remaining values return 1969-12-31 23:59 GMT.
Parameters:
  d - the object to convert the converted value as a Date, never null
since:
   MMBase-1.7



toDouble
public static double toDouble(Object i, double def)(Code)
Convert an object to an double. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. All remaining values return the default value.
Parameters:
  i - the object to convert
Parameters:
  def - the default value if conversion is impossible the converted value as a double



toDouble
public static double toDouble(Object i)(Code)
Convert an object to an double. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. All remaining values return -1.
Parameters:
  i - the object to convert the converted value as a double



toFloat
public static float toFloat(Object i, float def)(Code)
Convert an object to an float. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. All remaining values return the default value.
Parameters:
  i - the object to convert
Parameters:
  def - the default value if conversion is impossible the converted value as a float



toFloat
public static float toFloat(Object i)(Code)
Convert an object to an float. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. All remaining values return -1.
Parameters:
  i - the object to convert the converted value as a float



toInputStream
public static InputStream toInputStream(Object obj)(Code)



toInt
public static int toInt(Object i, int def)(Code)
Convert an object to an int. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. If a value is an Node, it's number field is returned. All remaining values return the provided default value.
Parameters:
  i - the object to convert
Parameters:
  def - the default value if conversion is impossible the converted value as an int
since:
   MMBase-1.7



toInt
public static int toInt(Object i)(Code)
Convert an object to an int. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. If a value is a Node, it's number field is returned. All remaining values return -1.
Parameters:
  i - the object to convert the converted value as an int



toInteger
public static Integer toInteger(Object i)(Code)
Convert an object to an Integer. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. All remaining values return -1.
Parameters:
  i - the object to convert the converted value as a Integer



toList
public static List toList(Object o)(Code)
Convert an object to a List. A String is split up (as if it was a comma-separated String). Individual objects are wrapped and returned as Lists with one item. null and the empty string are returned as an empty list.
Parameters:
  o - the object to convert the converted value as a List
since:
   MMBase-1.7



toList
public static List toList(Object o, String delimiter)(Code)
As Casting.toList(Object) but with one extra argument.
Parameters:
  delimiter - Regexp to use when splitting up the string if the object is a String. null or the empty string mean the default, which is a comma.
since:
   MMBase-1.8



toLong
public static long toLong(Object i, long def)(Code)
Convert an object to a long. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. All remaining values return the provided default value.
Parameters:
  i - the object to convert
Parameters:
  def - the default value if conversion is impossible the converted value as a long
since:
   MMBase-1.7



toLong
public static long toLong(Object i)(Code)
Convert an object to a long. Boolean values return 0 for false, 1 for true. String values are parsed to a number, if possible. All remaining values return -1.
Parameters:
  i - the object to convert the converted value as a long
since:
   MMBase-1.7



toMap
public static Map toMap(Object o)(Code)

since:
   MMBase-1.8



toNode
public static Node toNode(Object i, Cloud cloud)(Code)
Convert an object to an Node. If the value is Numeric, the method tries to obtain the mmbase object with that number. A Map returns a virtual Node representing the map, (a MapNode ). All remaining situations return the node with the alias i.toString(), which can be null if no node which such an alias.
Parameters:
  i - the object to convert
Parameters:
  cloud - the Cloud to use for loading a node the value as a Node
since:
   MMBase-1.7



toString
public static String toString(Object o)(Code)
Convert an object to a String. null is converted to an empty string.
Parameters:
  o - the object to convert the converted value as a String



toStringBuffer
public static StringBuffer toStringBuffer(StringBuffer buffer, Object o)(Code)
Convert an object to a string, using a StringBuffer.
Parameters:
  buffer - The StringBuffer with which to create the string
Parameters:
  o - the object to convert the StringBuffer used for conversion (same as the buffer parameter)
since:
   MMBase-1.7



toStringBuilder
public static StringBuilder toStringBuilder(StringBuilder buffer, Object o)(Code)
Convert an object to a string, using a StringBuilder
Parameters:
  buffer - The StringBuilder with which to create the string
Parameters:
  o - the object to convert the StringBuilder used for conversion (same as the buffer parameter)
since:
   MMBase-1.9



toType
public static C toType(Class<C> type, Object value)(Code)
Tries to 'cast' an object for use with the provided class. E.g. if value is a String, but the type passed is Integer, then the string is act to an Integer. If the type passed is a primitive type, the object is cast to an Object Types that is representative for that type (i.e. Integer for int).
Parameters:
  type - the type (class)
Parameters:
  value - The value to be converted value the converted value
since:
   MMBase-1.8



toType
public static C toType(Class<C> type, Cloud cloud, Object value)(Code)
Tries to 'cast' an object for use with the provided class. E.g. if value is a String, but the type passed is Integer, then the string is act to an Integer. If the type passed is a primitive type, the object is cast to an Object Types that is representative for that type (i.e. Integer for int).
Parameters:
  type - the type (class)
Parameters:
  cloud - When casting to Node, a cloud may be needed. May be null, for an anonymous cloud to be tried.
Parameters:
  value - The value to be converted value the converted value
since:
   MMBase-1.8



toWriter
public static Writer toWriter(Writer writer, Object o) throws java.io.IOException(Code)
Convert an object to a string, using a Writer.
Parameters:
  writer - The Writer with which to create (write) the string
Parameters:
  o - the object to convert the Writer used for conversion (same as the writer parameter)
since:
   MMBase-1.7



toXML
public static Document toXML(Object o)(Code)
Convert the value to a Document object. If the value is not itself a Document, the method attempts to attempts to convert the String value into an XML. A null value is returned as null. If the value cannot be converted, this method throws an IllegalArgumentException.
Parameters:
  o - the object to be converted to an XML document the value as a DOM Element or null
throws:
  IllegalArgumentException - if the value could not be converted
since:
   MMBase-1.6



unWrap
public static Object unWrap(Object o)(Code)
When you want to undo the wrapping, this method can be used.
since:
   MMBase-1.8



wrap
public static Object wrap(Object o, CharTransformer escaper)(Code)
Wraps an object in another object with a toString as we desire. Casting can now be done with toString() on the resulting object. This is used to make JSTL en EL behave similarly as mmbase taglib when writing objects to the page (taglib calls Casting, but JSTL of course doesn't).
Parameters:
  o - The object to be wrapped
Parameters:
  escaper - null or a CharTransformer to pipe the strings through
since:
   MMBase-1.8



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.