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


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: RawAbstractInput.java,v 1.6.2.3 2008/01/07 15:14:20 cwl Exp $
007:         */
008:
009:        package com.sleepycat.persist.impl;
010:
011:        import java.math.BigInteger;
012:        import java.util.IdentityHashMap;
013:
014:        import com.sleepycat.persist.raw.RawObject;
015:
016:        /**
017:         * Base class for EntityInput implementations that type-check RawObject
018:         * instances and convert them to regular persistent objects, via the
019:         * Format.convertRawObject method.
020:         *
021:         * The subclass implements readNext which should call checkAndConvert before
022:         * returning the final value.
023:         *
024:         * @author Mark Hayes
025:         */
026:        abstract class RawAbstractInput extends AbstractInput {
027:
028:            private IdentityHashMap converted;
029:
030:            RawAbstractInput(Catalog catalog, boolean rawAccess,
031:                    IdentityHashMap converted) {
032:                super (catalog, rawAccess);
033:                this .converted = converted;
034:            }
035:
036:            public Object readObject() {
037:                return readNext();
038:            }
039:
040:            public Object readKeyObject(Format format) {
041:                return readNext();
042:            }
043:
044:            public void registerPriKeyObject(Object o) {
045:            }
046:
047:            public int readArrayLength() {
048:                throw new UnsupportedOperationException();
049:            }
050:
051:            public int readEnumConstant(String[] names) {
052:                throw new UnsupportedOperationException();
053:            }
054:
055:            public void skipField(Format declaredFormat) {
056:            }
057:
058:            abstract Object readNext();
059:
060:            Object checkAndConvert(Object o, Format declaredFormat) {
061:                if (o == null) {
062:                    if (declaredFormat.isPrimitive()) {
063:                        throw new IllegalArgumentException(
064:                                "A primitive type may not be null or missing: "
065:                                        + declaredFormat.getClassName());
066:                    }
067:                } else if (declaredFormat.isSimple()) {
068:                    if (declaredFormat.isPrimitive()) {
069:                        if (o.getClass() != declaredFormat.getWrapperFormat()
070:                                .getType()) {
071:                            throw new IllegalArgumentException(
072:                                    "Raw value class: "
073:                                            + o.getClass().getName()
074:                                            + " must be the wrapper class for a primitive type: "
075:                                            + declaredFormat.getClassName());
076:                        }
077:                    } else {
078:                        if (o.getClass() != declaredFormat.getType()) {
079:                            throw new IllegalArgumentException(
080:                                    "Raw value class: "
081:                                            + o.getClass().getName()
082:                                            + " must be the declared class for a simple type: "
083:                                            + declaredFormat.getClassName());
084:                        }
085:                    }
086:                } else {
087:                    if (o instanceof  RawObject) {
088:                        Object o2 = null;
089:                        if (!rawAccess) {
090:                            if (converted != null) {
091:                                o2 = converted.get(o);
092:                            } else {
093:                                converted = new IdentityHashMap();
094:                            }
095:                        }
096:                        if (o2 != null) {
097:                            o = o2;
098:                        } else {
099:                            if (!rawAccess) {
100:                                o = catalog.convertRawObject((RawObject) o,
101:                                        converted);
102:                            }
103:                        }
104:                    } else {
105:                        if (!SimpleCatalog.isSimpleType(o.getClass())) {
106:                            throw new IllegalArgumentException(
107:                                    "Raw value class: "
108:                                            + o.getClass().getName()
109:                                            + " must be RawObject a simple type");
110:                        }
111:                    }
112:                    if (rawAccess) {
113:                        checkRawType(catalog, o, declaredFormat);
114:                    } else {
115:                        if (!declaredFormat.getType().isAssignableFrom(
116:                                o.getClass())) {
117:                            throw new IllegalArgumentException(
118:                                    "Raw value class: "
119:                                            + o.getClass().getName()
120:                                            + " is not assignable to type: "
121:                                            + declaredFormat.getClassName());
122:                        }
123:                    }
124:                }
125:                return o;
126:            }
127:
128:            static Format checkRawType(Catalog catalog, Object o,
129:                    Format declaredFormat) {
130:                assert declaredFormat != null;
131:                Format format;
132:                if (o instanceof  RawObject) {
133:                    format = (Format) ((RawObject) o).getType();
134:                } else {
135:                    format = catalog.getFormat(o.getClass());
136:                    if (!format.isSimple() || format.isEnum()) {
137:                        throw new IllegalArgumentException(
138:                                "Not a RawObject or a non-enum simple type: "
139:                                        + format.getClassName());
140:                    }
141:                }
142:                if (!format.isAssignableTo(declaredFormat)) {
143:                    throw new IllegalArgumentException(
144:                            "Not a subtype of the field's declared class "
145:                                    + declaredFormat.getClassName() + ": "
146:                                    + format.getClassName());
147:                }
148:                if (!format.isCurrentVersion()) {
149:                    throw new IllegalArgumentException(
150:                            "Raw type version is not current.  Class: "
151:                                    + format.getClassName() + " Version: "
152:                                    + format.getVersion());
153:                }
154:                Format proxiedFormat = format.getProxiedFormat();
155:                if (proxiedFormat != null) {
156:                    format = proxiedFormat;
157:                }
158:                return format;
159:            }
160:
161:            /* The following methods are a subset of the methods in TupleInput. */
162:
163:            public String readString() {
164:                return (String) readNext();
165:            }
166:
167:            public char readChar() {
168:                return ((Character) readNext()).charValue();
169:            }
170:
171:            public boolean readBoolean() {
172:                return ((Boolean) readNext()).booleanValue();
173:            }
174:
175:            public byte readByte() {
176:                return ((Byte) readNext()).byteValue();
177:            }
178:
179:            public short readShort() {
180:                return ((Short) readNext()).shortValue();
181:            }
182:
183:            public int readInt() {
184:                return ((Integer) readNext()).intValue();
185:            }
186:
187:            public long readLong() {
188:                return ((Long) readNext()).longValue();
189:            }
190:
191:            public float readSortedFloat() {
192:                return ((Float) readNext()).floatValue();
193:            }
194:
195:            public double readSortedDouble() {
196:                return ((Double) readNext()).doubleValue();
197:            }
198:
199:            public BigInteger readBigInteger() {
200:                return (BigInteger) readNext();
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.