Source Code Cross Referenced for EmulatedFieldsForLoading.java in  » Apache-Harmony-Java-SE » java-package » java » io » 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 » Apache Harmony Java SE » java package » java.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package java.io;
019:
020:        /**
021:         * An EmulatedFieldsForLoading is an object that represents a set of emulated
022:         * fields for an object being loaded. It is a concrete implementation for
023:         * ObjectInputStream.GetField
024:         * 
025:         * @see ObjectInputStream.GetField
026:         * @see EmulatedFieldsForDumping
027:         */
028:        class EmulatedFieldsForLoading extends ObjectInputStream.GetField {
029:
030:            // The class descriptor with the declared fields the receiver emulates
031:            private ObjectStreamClass streamClass;
032:
033:            // The actual representation, with a more powerful API (set&get)
034:            private EmulatedFields emulatedFields;
035:
036:            /**
037:             * Constructs a new instance of EmulatedFieldsForDumping.
038:             * 
039:             * @param streamClass
040:             *            an ObjectStreamClass, defining the class for which to emulate
041:             *            fields.
042:             */
043:            EmulatedFieldsForLoading(ObjectStreamClass streamClass) {
044:                super ();
045:                this .streamClass = streamClass;
046:                emulatedFields = new EmulatedFields(
047:                        streamClass.getLoadFields(), streamClass.fields());
048:            }
049:
050:            /**
051:             * Return a boolean indicating if the field named <code>name</code> has
052:             * been assigned a value explicitly (false) or if it still holds a default
053:             * value for the type (true) because it hasn't been assigned to yet.
054:             * 
055:             * @param name
056:             *            A String, the name of the field to test
057:             * @return <code>true</code> if the field holds it default value,
058:             *         <code>false</code> otherwise.
059:             * 
060:             * @throws IOException
061:             *             If an IO error occurs
062:             * @throws IllegalArgumentException
063:             *             If the corresponding field can not be found.
064:             */
065:            @Override
066:            public boolean defaulted(String name) throws IOException,
067:                    IllegalArgumentException {
068:                return emulatedFields.defaulted(name);
069:            }
070:
071:            /**
072:             * Return the actual EmulatedFields instance used by the receiver. We have
073:             * the actual work in a separate class so that the code can be shared. The
074:             * receiver has to be of a subclass of GetField.
075:             * 
076:             * @return array of ObjectSlot the receiver represents.
077:             */
078:            EmulatedFields emulatedFields() {
079:                return emulatedFields;
080:            }
081:
082:            /**
083:             * Find and return the byte value of a given field named <code>name</code>
084:             * in the receiver. If the field has not been assigned any value yet, the
085:             * default value <code>defaultValue</code> is returned instead.
086:             * 
087:             * @param name
088:             *            A String, the name of the field to find
089:             * @param defaultValue
090:             *            Return value in case the field has not been assigned to yet.
091:             * @return the value of the given field if it has been assigned, or the
092:             *         default value otherwise
093:             * 
094:             * @throws IOException
095:             *             If an IO error occurs
096:             * @throws IllegalArgumentException
097:             *             If the corresponding field can not be found.
098:             */
099:            @Override
100:            public byte get(String name, byte defaultValue) throws IOException,
101:                    IllegalArgumentException {
102:                return emulatedFields.get(name, defaultValue);
103:            }
104:
105:            /**
106:             * Find and return the char value of a given field named <code>name</code>
107:             * in the receiver. If the field has not been assigned any value yet, the
108:             * default value <code>defaultValue</code> is returned instead.
109:             * 
110:             * @param name
111:             *            A String, the name of the field to find
112:             * @param defaultValue
113:             *            Return value in case the field has not been assigned to yet.
114:             * @return the value of the given field if it has been assigned, or the
115:             *         default value otherwise
116:             * 
117:             * @throws IOException
118:             *             If an IO error occurs
119:             * @throws IllegalArgumentException
120:             *             If the corresponding field can not be found.
121:             */
122:            @Override
123:            public char get(String name, char defaultValue) throws IOException,
124:                    IllegalArgumentException {
125:                return emulatedFields.get(name, defaultValue);
126:            }
127:
128:            /**
129:             * Find and return the double value of a given field named <code>name</code>
130:             * in the receiver. If the field has not been assigned any value yet, the
131:             * default value <code>defaultValue</code> is returned instead.
132:             * 
133:             * @param name
134:             *            A String, the name of the field to find
135:             * @param defaultValue
136:             *            Return value in case the field has not been assigned to yet.
137:             * @return the value of the given field if it has been assigned, or the
138:             *         default value otherwise
139:             * 
140:             * @throws IOException
141:             *             If an IO error occurs
142:             * @throws IllegalArgumentException
143:             *             If the corresponding field can not be found.
144:             */
145:            @Override
146:            public double get(String name, double defaultValue)
147:                    throws IOException, IllegalArgumentException {
148:                return emulatedFields.get(name, defaultValue);
149:            }
150:
151:            /**
152:             * Find and return the float value of a given field named <code>name</code>
153:             * in the receiver. If the field has not been assigned any value yet, the
154:             * default value <code>defaultValue</code> is returned instead.
155:             * 
156:             * @param name
157:             *            A String, the name of the field to find
158:             * @param defaultValue
159:             *            Return value in case the field has not been assigned to yet.
160:             * @return the value of the given field if it has been assigned, or the
161:             *         default value otherwise
162:             * 
163:             * @throws IOException
164:             *             If an IO error occurs
165:             * @throws IllegalArgumentException
166:             *             If the corresponding field can not be found.
167:             */
168:            @Override
169:            public float get(String name, float defaultValue)
170:                    throws IOException, IllegalArgumentException {
171:                return emulatedFields.get(name, defaultValue);
172:            }
173:
174:            /**
175:             * Find and return the int value of a given field named <code>name</code>
176:             * in the receiver. If the field has not been assigned any value yet, the
177:             * default value <code>defaultValue</code> is returned instead.
178:             * 
179:             * @param name
180:             *            A String, the name of the field to find
181:             * @param defaultValue
182:             *            Return value in case the field has not been assigned to yet.
183:             * @return the value of the given field if it has been assigned, or the
184:             *         default value otherwise
185:             * 
186:             * @throws IOException
187:             *             If an IO error occurs
188:             * @throws IllegalArgumentException
189:             *             If the corresponding field can not be found.
190:             */
191:            @Override
192:            public int get(String name, int defaultValue) throws IOException,
193:                    IllegalArgumentException {
194:                return emulatedFields.get(name, defaultValue);
195:            }
196:
197:            /**
198:             * Find and return the long value of a given field named <code>name</code>
199:             * in the receiver. If the field has not been assigned any value yet, the
200:             * default value <code>defaultValue</code> is returned instead.
201:             * 
202:             * @param name
203:             *            A String, the name of the field to find
204:             * @param defaultValue
205:             *            Return value in case the field has not been assigned to yet.
206:             * @return the value of the given field if it has been assigned, or the
207:             *         default value otherwise
208:             * 
209:             * @throws IOException
210:             *             If an IO error occurs
211:             * @throws IllegalArgumentException
212:             *             If the corresponding field can not be found.
213:             */
214:            @Override
215:            public long get(String name, long defaultValue) throws IOException,
216:                    IllegalArgumentException {
217:                return emulatedFields.get(name, defaultValue);
218:            }
219:
220:            /**
221:             * Find and return the Object value of a given field named <code>name</code>
222:             * in the receiver. If the field has not been assigned any value yet, the
223:             * default value <code>defaultValue</code> is returned instead.
224:             * 
225:             * @param name
226:             *            A String, the name of the field to find
227:             * @param defaultValue
228:             *            Return value in case the field has not been assigned to yet.
229:             * @return the value of the given field if it has been assigned, or the
230:             *         default value otherwise
231:             * 
232:             * @throws IOException
233:             *             If an IO error occurs
234:             * @throws IllegalArgumentException
235:             *             If the corresponding field can not be found.
236:             */
237:            @Override
238:            public Object get(String name, Object defaultValue)
239:                    throws IOException, IllegalArgumentException {
240:                return emulatedFields.get(name, defaultValue);
241:            }
242:
243:            /**
244:             * Find and return the short value of a given field named <code>name</code>
245:             * in the receiver. If the field has not been assigned any value yet, the
246:             * default value <code>defaultValue</code> is returned instead.
247:             * 
248:             * @param name
249:             *            A String, the name of the field to find
250:             * @param defaultValue
251:             *            Return value in case the field has not been assigned to yet.
252:             * @return the value of the given field if it has been assigned, or the
253:             *         default value otherwise
254:             * 
255:             * @throws IOException
256:             *             If an IO error occurs
257:             * @throws IllegalArgumentException
258:             *             If the corresponding field can not be found.
259:             */
260:            @Override
261:            public short get(String name, short defaultValue)
262:                    throws IOException, IllegalArgumentException {
263:                return emulatedFields.get(name, defaultValue);
264:            }
265:
266:            /**
267:             * Find and return the boolean value of a given field named
268:             * <code>name</code> in the receiver. If the field has not been assigned
269:             * any value yet, the default value <code>defaultValue</code> is returned
270:             * instead.
271:             * 
272:             * @param name
273:             *            A String, the name of the field to find
274:             * @param defaultValue
275:             *            Return value in case the field has not been assigned to yet.
276:             * @return the value of the given field if it has been assigned, or the
277:             *         default value otherwise
278:             * 
279:             * @throws IOException
280:             *             If an IO error occurs
281:             * @throws IllegalArgumentException
282:             *             If the corresponding field can not be found.
283:             */
284:            @Override
285:            public boolean get(String name, boolean defaultValue)
286:                    throws IOException, IllegalArgumentException {
287:                return emulatedFields.get(name, defaultValue);
288:            }
289:
290:            /**
291:             * Return the class descriptor for which the emulated fields are defined.
292:             * 
293:             * @return ObjectStreamClass The class descriptor for which the emulated
294:             *         fields are defined.
295:             */
296:            @Override
297:            public ObjectStreamClass getObjectStreamClass() {
298:                return streamClass;
299:            }
300:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.