Source Code Cross Referenced for TupleBinding.java in  » JMX » je » com » sleepycat » bind » tuple » 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 » JMX » je » com.sleepycat.bind.tuple 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2000,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: TupleBinding.java,v 1.30.2.2 2008/01/07 15:14:06 cwl Exp $
007:         */
008:
009:        package com.sleepycat.bind.tuple;
010:
011:        import java.util.HashMap;
012:        import java.util.Map;
013:
014:        import com.sleepycat.bind.EntryBinding;
015:        import com.sleepycat.je.DatabaseEntry;
016:
017:        /**
018:         * An abstract <code>EntryBinding</code> that treats a key or data entry as a
019:         * tuple; it includes predefined bindings for Java primitive types.
020:         *
021:         * <p>This class takes care of converting the entries to/from {@link
022:         * TupleInput} and {@link TupleOutput} objects.  Its two abstract methods must
023:         * be implemented by a concrete subclass to convert between tuples and key or
024:         * data objects.</p>
025:         * <ul>
026:         * <li> {@link #entryToObject(TupleInput)} </li>
027:         * <li> {@link #objectToEntry(Object,TupleOutput)} </li>
028:         * </ul>
029:         *
030:         * <p>For key or data entries which are Java primitive classes (String,
031:         * Integer, etc) {@link #getPrimitiveBinding} may be used to return a builtin
032:         * tuple binding.  A custom tuple binding for these types is not needed.
033:         * <em>Note:</em> {@link #getPrimitiveBinding} returns bindings that do not
034:         * sort negative floating point numbers correctly by default.  See {@link
035:         * SortedFloatBinding} and {@link SortedDoubleBinding} for details.</p>
036:         *
037:         * <p>When a tuple binding is used as a key binding, it produces key values
038:         * with a reasonable default sort order.  For more information on the default
039:         * sort order, see {@link com.sleepycat.bind.tuple.TupleOutput}.</p>
040:         *
041:         * @author Mark Hayes
042:         */
043:        public abstract class TupleBinding extends TupleBase implements 
044:                EntryBinding {
045:
046:            private static final Map primitives = new HashMap();
047:            static {
048:                addPrimitive(String.class, String.class, new StringBinding());
049:                addPrimitive(Character.class, Character.TYPE,
050:                        new CharacterBinding());
051:                addPrimitive(Boolean.class, Boolean.TYPE, new BooleanBinding());
052:                addPrimitive(Byte.class, Byte.TYPE, new ByteBinding());
053:                addPrimitive(Short.class, Short.TYPE, new ShortBinding());
054:                addPrimitive(Integer.class, Integer.TYPE, new IntegerBinding());
055:                addPrimitive(Long.class, Long.TYPE, new LongBinding());
056:                addPrimitive(Float.class, Float.TYPE, new FloatBinding());
057:                addPrimitive(Double.class, Double.TYPE, new DoubleBinding());
058:            }
059:
060:            private static void addPrimitive(Class cls1, Class cls2,
061:                    TupleBinding binding) {
062:                primitives.put(cls1, binding);
063:                primitives.put(cls2, binding);
064:            }
065:
066:            /**
067:             * Creates a tuple binding.
068:             */
069:            public TupleBinding() {
070:            }
071:
072:            // javadoc is inherited
073:            public Object entryToObject(DatabaseEntry entry) {
074:
075:                return entryToObject(entryToInput(entry));
076:            }
077:
078:            // javadoc is inherited
079:            public void objectToEntry(Object object, DatabaseEntry entry) {
080:
081:                TupleOutput output = getTupleOutput(object);
082:                objectToEntry(object, output);
083:                outputToEntry(output, entry);
084:            }
085:
086:            /**
087:             * Constructs a key or data object from a {@link TupleInput} entry.
088:             *
089:             * @param input is the tuple key or data entry.
090:             *
091:             * @return the key or data object constructed from the entry.
092:             */
093:            public abstract Object entryToObject(TupleInput input);
094:
095:            /**
096:             * Converts a key or data object to a tuple entry.
097:             *
098:             * @param object is the key or data object.
099:             *
100:             * @param output is the tuple entry to which the key or data should be
101:             * written.
102:             */
103:            public abstract void objectToEntry(Object object, TupleOutput output);
104:
105:            /**
106:             * Creates a tuple binding for a primitive Java class.  The following
107:             * Java classes are supported.
108:             * <ul>
109:             * <li><code>String</code></li>
110:             * <li><code>Character</code></li>
111:             * <li><code>Boolean</code></li>
112:             * <li><code>Byte</code></li>
113:             * <li><code>Short</code></li>
114:             * <li><code>Integer</code></li>
115:             * <li><code>Long</code></li>
116:             * <li><code>Float</code></li>
117:             * <li><code>Double</code></li>
118:             * </ul>
119:             *
120:             * <p><em>Note:</em> {@link #getPrimitiveBinding} returns bindings that do
121:             * not sort negative floating point numbers correctly by default.  See
122:             * {@link SortedFloatBinding} and {@link SortedDoubleBinding} for
123:             * details.</p>
124:             *
125:             * @param cls is the primitive Java class.
126:             *
127:             * @return a new binding for the primitive class or null if the cls
128:             * parameter is not one of the supported classes.
129:             */
130:            public static TupleBinding getPrimitiveBinding(Class cls) {
131:
132:                return (TupleBinding) primitives.get(cls);
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.