Source Code Cross Referenced for DynAnyImpl.java in  » 6.0-JDK-Modules-com.sun » corba » com » sun » corba » se » impl » dynamicany » 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 » 6.0 JDK Modules com.sun » corba » com.sun.corba.se.impl.dynamicany 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000-2003 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.corba.se.impl.dynamicany;
027:
028:        import org.omg.CORBA.Any;
029:        import org.omg.CORBA.TypeCode;
030:        import org.omg.CORBA.TCKind;
031:        import org.omg.CORBA.LocalObject;
032:        import org.omg.CORBA.ORBPackage.InvalidName;
033:        import org.omg.CORBA.portable.OutputStream;
034:
035:        import org.omg.DynamicAny.*;
036:        import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
037:        import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
038:
039:        import com.sun.corba.se.impl.orbutil.ORBConstants;
040:
041:        import com.sun.corba.se.spi.orb.ORB;
042:        import com.sun.corba.se.spi.logging.CORBALogDomains;
043:        import com.sun.corba.se.impl.logging.ORBUtilSystemException;
044:
045:        abstract class DynAnyImpl extends org.omg.CORBA.LocalObject implements 
046:                DynAny {
047:            protected static final int NO_INDEX = -1;
048:            // A DynAny is destroyable if it is the root of a DynAny hierarchy.
049:            protected static final byte STATUS_DESTROYABLE = 0;
050:            // A DynAny is undestroyable if it is a node in a DynAny hierarchy other than the root.
051:            protected static final byte STATUS_UNDESTROYABLE = 1;
052:            // A DynAny is destroyed if its root has been destroyed.
053:            protected static final byte STATUS_DESTROYED = 2;
054:
055:            //
056:            // Instance variables
057:            //
058:
059:            protected ORB orb = null;
060:            protected ORBUtilSystemException wrapper;
061:
062:            // An Any is used internally to implement the basic DynAny.
063:            // It stores the DynAnys TypeCode.
064:            // For primitive types it is the only representation.
065:            // For complex types it is the streamed representation.
066:            protected Any any = null;
067:            // Destroyable is the default status for free standing DynAnys.
068:            protected byte status = STATUS_DESTROYABLE;
069:            protected int index = NO_INDEX;
070:
071:            //
072:            // Constructors
073:            //
074:
075:            protected DynAnyImpl() {
076:                wrapper = ORBUtilSystemException
077:                        .get(CORBALogDomains.RPC_PRESENTATION);
078:            }
079:
080:            protected DynAnyImpl(ORB orb, Any any, boolean copyValue) {
081:                this .orb = orb;
082:                wrapper = ORBUtilSystemException.get(orb,
083:                        CORBALogDomains.RPC_PRESENTATION);
084:                if (copyValue)
085:                    this .any = DynAnyUtil.copy(any, orb);
086:                else
087:                    this .any = any;
088:                // set the current position to 0 if any has components, otherwise to -1.
089:                index = NO_INDEX;
090:            }
091:
092:            protected DynAnyImpl(ORB orb, TypeCode typeCode) {
093:                this .orb = orb;
094:                wrapper = ORBUtilSystemException.get(orb,
095:                        CORBALogDomains.RPC_PRESENTATION);
096:                this .any = DynAnyUtil.createDefaultAnyOfType(typeCode, orb);
097:            }
098:
099:            protected DynAnyFactory factory() {
100:                try {
101:                    return (DynAnyFactory) orb
102:                            .resolve_initial_references(ORBConstants.DYN_ANY_FACTORY_NAME);
103:                } catch (InvalidName in) {
104:                    throw new RuntimeException("Unable to find DynAnyFactory");
105:                }
106:            }
107:
108:            protected Any getAny() {
109:                return any;
110:            }
111:
112:            // Uses getAny() if this is our implementation, otherwise uses to_any()
113:            // which copies the Any.
114:            protected Any getAny(DynAny dynAny) {
115:                if (dynAny instanceof  DynAnyImpl)
116:                    return ((DynAnyImpl) dynAny).getAny();
117:                else
118:                    // _REVISIT_ Nothing we can do about copying at this point
119:                    // if this is not our implementation of DynAny.
120:                    // To prevent this we would need another representation,
121:                    // one where component DynAnys are initialized but not the component Anys.
122:                    return dynAny.to_any();
123:            }
124:
125:            protected void writeAny(OutputStream out) {
126:                //System.out.println(this + " writeAny of type " + type().kind().value());
127:                any.write_value(out);
128:            }
129:
130:            protected void setStatus(byte newStatus) {
131:                status = newStatus;
132:            }
133:
134:            protected void clearData() {
135:                // This clears the data part of the Any while keeping the TypeCode info.
136:                any.type(any.type());
137:            }
138:
139:            //
140:            // DynAny interface methods
141:            //
142:
143:            public org.omg.CORBA.TypeCode type() {
144:                if (status == STATUS_DESTROYED) {
145:                    throw wrapper.dynAnyDestroyed();
146:                }
147:                return any.type();
148:            }
149:
150:            // Makes a copy of the Any value inside the parameter
151:            public void assign(org.omg.DynamicAny.DynAny dyn_any)
152:                    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch {
153:                if (status == STATUS_DESTROYED) {
154:                    throw wrapper.dynAnyDestroyed();
155:                }
156:                if ((any != null) && (!any.type().equal(dyn_any.type()))) {
157:                    throw new TypeMismatch();
158:                }
159:                any = dyn_any.to_any();
160:            }
161:
162:            // Makes a copy of the Any parameter
163:            public void from_any(org.omg.CORBA.Any value)
164:                    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
165:                    org.omg.DynamicAny.DynAnyPackage.InvalidValue {
166:                if (status == STATUS_DESTROYED) {
167:                    throw wrapper.dynAnyDestroyed();
168:                }
169:                if ((any != null) && (!any.type().equal(value.type()))) {
170:                    throw new TypeMismatch();
171:                }
172:                // If the passed Any does not contain a legal value
173:                // (such as a null string), the operation raises InvalidValue.
174:                Any tempAny = null;
175:                try {
176:                    tempAny = DynAnyUtil.copy(value, orb);
177:                } catch (Exception e) {
178:                    throw new InvalidValue();
179:                }
180:                if (!DynAnyUtil.isInitialized(tempAny)) {
181:                    throw new InvalidValue();
182:                }
183:                any = tempAny;
184:            }
185:
186:            public abstract org.omg.CORBA.Any to_any();
187:
188:            public abstract boolean equal(org.omg.DynamicAny.DynAny dyn_any);
189:
190:            public abstract void destroy();
191:
192:            public abstract org.omg.DynamicAny.DynAny copy();
193:
194:            // Needed for org.omg.CORBA.Object
195:
196:            private String[] __ids = { "IDL:omg.org/DynamicAny/DynAny:1.0" };
197:
198:            public String[] _ids() {
199:                return __ids;
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.