Source Code Cross Referenced for MsgD.java in  » Database-DBMS » db4o-6.4 » com » db4o » internal » cs » messages » 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 DBMS » db4o 6.4 » com.db4o.internal.cs.messages 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (C) 2004 - 2007  db4objects Inc.  http://www.db4o.com
002:
003:        This file is part of the db4o open source object database.
004:
005:        db4o is free software; you can redistribute it and/or modify it under
006:        the terms of version 2 of the GNU General Public License as published
007:        by the Free Software Foundation and as clarified by db4objects' GPL 
008:        interpretation policy, available at
009:        http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010:        Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011:        Suite 350, San Mateo, CA 94403, USA.
012:
013:        db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014:        WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:        FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:        for more details.
017:
018:        You should have received a copy of the GNU General Public License along
019:        with this program; if not, write to the Free Software Foundation, Inc.,
020:        59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */
021:        package com.db4o.internal.cs.messages;
022:
023:        import com.db4o.foundation.network.*;
024:        import com.db4o.internal.*;
025:
026:        /**
027:         * Messages with Data for Client/Server Communication
028:         */
029:        public class MsgD extends Msg {
030:
031:            StatefulBuffer _payLoad;
032:
033:            MsgD() {
034:                super ();
035:            }
036:
037:            MsgD(String aName) {
038:                super (aName);
039:            }
040:
041:            public Buffer getByteLoad() {
042:                return _payLoad;
043:            }
044:
045:            public final StatefulBuffer payLoad() {
046:                return _payLoad;
047:            }
048:
049:            public void payLoad(StatefulBuffer writer) {
050:                _payLoad = writer;
051:            }
052:
053:            public final MsgD getWriterForByte(Transaction trans, byte b) {
054:                MsgD msg = getWriterForLength(trans, 1);
055:                msg._payLoad.writeByte(b);
056:                return msg;
057:            }
058:
059:            public final MsgD getWriterForLength(Transaction trans, int length) {
060:                MsgD message = (MsgD) publicClone();
061:                message.setTransaction(trans);
062:                message._payLoad = new StatefulBuffer(trans, length
063:                        + Const4.MESSAGE_LENGTH);
064:                message.writeInt(_msgID);
065:                message.writeInt(length);
066:                if (trans.parentTransaction() == null) {
067:                    message._payLoad.writeByte(Const4.SYSTEM_TRANS);
068:                } else {
069:                    message._payLoad.writeByte(Const4.USER_TRANS);
070:                }
071:                return message;
072:            }
073:
074:            public final MsgD getWriter(Transaction trans) {
075:                return getWriterForLength(trans, 0);
076:            }
077:
078:            public final MsgD getWriterForInts(Transaction trans, int[] ints) {
079:                MsgD message = getWriterForLength(trans, Const4.INT_LENGTH
080:                        * ints.length);
081:                for (int i = 0; i < ints.length; i++) {
082:                    message.writeInt(ints[i]);
083:                }
084:                return message;
085:            }
086:
087:            public final MsgD getWriterForIntArray(Transaction a_trans,
088:                    int[] ints, int length) {
089:                MsgD message = getWriterForLength(a_trans, Const4.INT_LENGTH
090:                        * (length + 1));
091:                message.writeInt(length);
092:                for (int i = 0; i < length; i++) {
093:                    message.writeInt(ints[i]);
094:                }
095:                return message;
096:            }
097:
098:            public final MsgD getWriterForInt(Transaction a_trans, int id) {
099:                MsgD message = getWriterForLength(a_trans, Const4.INT_LENGTH);
100:                message.writeInt(id);
101:                return message;
102:            }
103:
104:            public final MsgD getWriterForIntString(Transaction a_trans,
105:                    int anInt, String str) {
106:                MsgD message = getWriterForLength(a_trans, Const4.stringIO
107:                        .length(str)
108:                        + Const4.INT_LENGTH * 2);
109:                message.writeInt(anInt);
110:                message.writeString(str);
111:                return message;
112:            }
113:
114:            public final MsgD getWriterForLong(Transaction a_trans, long a_long) {
115:                MsgD message = getWriterForLength(a_trans, Const4.LONG_LENGTH);
116:                message.writeLong(a_long);
117:                return message;
118:            }
119:
120:            public MsgD getWriterForSingleObject(Transaction trans, Object obj) {
121:                SerializedGraph serialized = Serializer.marshall(trans
122:                        .container(), obj);
123:                MsgD msg = getWriterForLength(trans, serialized
124:                        .marshalledLength());
125:                serialized.write(msg._payLoad);
126:                return msg;
127:            }
128:
129:            public final MsgD getWriterForString(Transaction a_trans, String str) {
130:                MsgD message = getWriterForLength(a_trans, Const4.stringIO
131:                        .length(str)
132:                        + Const4.INT_LENGTH);
133:                message.writeString(str);
134:                return message;
135:            }
136:
137:            public MsgD getWriter(StatefulBuffer bytes) {
138:                MsgD message = getWriterForLength(bytes.getTransaction(), bytes
139:                        .length());
140:                message._payLoad.append(bytes._buffer);
141:                return message;
142:            }
143:
144:            public byte[] readBytes() {
145:                return _payLoad.readBytes(readInt());
146:            }
147:
148:            public final int readInt() {
149:                return _payLoad.readInt();
150:            }
151:
152:            public final long readLong() {
153:                return _payLoad.readLong();
154:            }
155:
156:            public final boolean readBoolean() {
157:                return _payLoad.readByte() != 0;
158:            }
159:
160:            public Object readObjectFromPayLoad() {
161:                return Serializer.unmarshall(stream(), _payLoad);
162:            }
163:
164:            final Msg readPayLoad(MessageDispatcher messageDispatcher,
165:                    Transaction a_trans, Socket4 sock, Buffer reader) {
166:                int length = reader.readInt();
167:                a_trans = checkParentTransaction(a_trans, reader);
168:                final MsgD command = (MsgD) publicClone();
169:                command.setTransaction(a_trans);
170:                command.setMessageDispatcher(messageDispatcher);
171:                command._payLoad = readMessageBuffer(a_trans, sock, length);
172:                return command;
173:            }
174:
175:            public final String readString() {
176:                int length = readInt();
177:                return Const4.stringIO.read(_payLoad, length);
178:            }
179:
180:            public Object readSingleObject() {
181:                return Serializer.unmarshall(stream(), SerializedGraph
182:                        .read(_payLoad));
183:            }
184:
185:            public final void writeBytes(byte[] aBytes) {
186:                writeInt(aBytes.length);
187:                _payLoad.append(aBytes);
188:            }
189:
190:            public final void writeInt(int aInt) {
191:                _payLoad.writeInt(aInt);
192:            }
193:
194:            public final void writeLong(long l) {
195:                _payLoad.writeLong(l);
196:            }
197:
198:            public final void writeString(String aStr) {
199:                _payLoad.writeInt(aStr.length());
200:                Const4.stringIO.write(_payLoad, aStr);
201:            }
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.