00001 /* 00002 * PofWriter.hpp 00003 * 00004 * Copyright 2001-2008 by Oracle. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_POF_WRITER_HPP 00017 #define COH_POF_WRITER_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/io/pof/PofContext.hpp" 00022 #include "coherence/io/pof/RawDate.hpp" 00023 #include "coherence/io/pof/RawDateTime.hpp" 00024 #include "coherence/io/pof/RawDayTimeInterval.hpp" 00025 #include "coherence/io/pof/RawTime.hpp" 00026 #include "coherence/io/pof/RawTimeInterval.hpp" 00027 #include "coherence/io/pof/RawYearMonthInterval.hpp" 00028 #include "coherence/util/Binary.hpp" 00029 #include "coherence/util/Collection.hpp" 00030 #include "coherence/util/LongArray.hpp" 00031 #include "coherence/util/Map.hpp" 00032 00033 COH_OPEN_NAMESPACE3(coherence,io,pof) 00034 00035 using coherence::util::Binary; 00036 using coherence::util::Collection; 00037 using coherence::util::Map; 00038 using coherence::util::LongArray; 00039 00040 00041 /** 00042 * The PofWriter interface provides the capability of writing a set of 00043 * non-primitive types ("user types") to a POF stream as an ordered sequence 00044 * of indexed properties. 00045 * 00046 * The serialized format of a POF user type is as follows: 00047 * <ul> 00048 * <li>Type Identifier</li> 00049 * <li>Version Identifier</li> 00050 * <li>[Property Index, Property Value]*</li> 00051 * <li>-1</li> 00052 * </ul> 00053 * The type identifier is an integer value greater than or equal to zero that 00054 * identifies the non-primitive type. The type identifier has no explicit 00055 * or self-describing meaning within the POF stream itself; in other words, 00056 * the type identifier does not contain the actual class definition. Instead, 00057 * the PofWriter and corresponding {@link PofReader} share a 00058 * {@link PofContext} which contains the necessary meta-data, including type 00059 * identifier to type mappings. 00060 * 00061 * The version identifier is used to support both backwards and forwards 00062 * compatibility of serialized POF user types. Versioning of user types allows 00063 * the addition of new properties to a user type, but not the replacement or 00064 * removal of properties that existed in a previous version of the user type. 00065 * 00066 * When a version <i>v1</i> of a user type written by a PofWriter is read by 00067 * a PofReader that supports version <i>v2</i> of the same user type, the 00068 * PofReader returns default values for the additional properties of the User 00069 * Type that exist in <i>v2</i> but do not exist in <i>v1</i>. Conversely, 00070 * when a version <i>v2</i> of a user type written by a PofWriter is read by 00071 * a PofReader that supports version <i>v1</i> of the same user type, the 00072 * instance of user type <i>v1</i> must store those additional opaque 00073 * properties for later encoding. The PofReader enables the user type to 00074 * store off the opaque properties in binary form (see {@link 00075 * PofReader#readRemainder PofReader::readRemainder}). When the user type 00076 * is re-encoded, it must be done so using the version identifier 00077 * <i>v2</i>, since it is including the unaltered <i>v2</i> properties. The 00078 * opaque properties are subsequently included in the POF stream using the 00079 * {@link #writeRemainder} method. 00080 * 00081 * Following the version identifier is an ordered sequence of index/value 00082 * pairs, each of which is composed of a property index encoded as 00083 * non-negative integer value whose value is greater than the previous 00084 * property index, and a property value encoded as a POF value. The user type 00085 * is finally terminated with an illegal property index of -1. 00086 * 00087 * @author jh 2008.01.18 00088 * 00089 * @see PofContext 00090 * @see PofReader 00091 */ 00092 class COH_EXPORT PofWriter 00093 : public interface_spec<PofWriter> 00094 { 00095 // ----- primitive type support ----------------------------------------- 00096 00097 public: 00098 /** 00099 * Write a boolean property to the POF stream. 00100 * 00101 * @param iProp the property index 00102 * @param f the <tt>bool</tt> property value to write 00103 * 00104 * @throws coherence::lang::IllegalArgumentException if the property 00105 * index is invalid, or is less than or equal to the index of 00106 * the previous property written to the POF stream 00107 * @throws coherence::io::IOException if an I/O error occurs 00108 */ 00109 virtual void writeBoolean(int32_t iProp, bool f) = 0; 00110 00111 /** 00112 * Write an octet property to the POF stream. 00113 * 00114 * @param iProp the property index 00115 * @param b the <tt>octet_t</tt> property value to write 00116 * 00117 * @throws coherence::lang::IllegalArgumentException if the property 00118 * index is invalid, or is less than or equal to the index of 00119 * the previous property written to the POF stream 00120 * @throws coherence::io::IOException if an I/O error occurs 00121 */ 00122 virtual void writeOctet(int32_t iProp, octet_t b) = 0; 00123 00124 /** 00125 * Write a 16-bit Unicode character property (represented as a 00126 * <tt>char16_t</tt>) to the POF stream. 00127 * 00128 * @param iProp the property index 00129 * @param ch the <tt>char16_t</tt> property value to write 00130 * 00131 * @throws coherence::lang::IllegalArgumentException if the property 00132 * index is invalid, or is less than or equal to the index of 00133 * the previous property written to the POF stream 00134 * @throws coherence::io::IOException if an I/O error occurs 00135 */ 00136 virtual void writeChar16(int32_t iProp, char16_t ch) = 0; 00137 00138 /** 00139 * Write a 16-bit integer property to the POF stream. 00140 * 00141 * @param iProp the property index 00142 * @param n the <tt>int16_t</tt> property value to write 00143 * 00144 * @throws coherence::lang::IllegalArgumentException if the property 00145 * index is invalid, or is less than or equal to the index of 00146 * the previous property written to the POF stream 00147 * @throws coherence::io::IOException if an I/O error occurs 00148 */ 00149 virtual void writeInt16(int32_t iProp, int16_t n) = 0; 00150 00151 /** 00152 * Write a 32-bit integer property to the POF stream. 00153 * 00154 * @param iProp the property index 00155 * @param n the <tt>int32_t</tt> property value to write 00156 * 00157 * @throws coherence::lang::IllegalArgumentException if the property 00158 * index is invalid, or is less than or equal to the index of 00159 * the previous property written to the POF stream 00160 * @throws coherence::io::IOException if an I/O error occurs 00161 */ 00162 virtual void writeInt32(int32_t iProp, int32_t n) = 0; 00163 00164 /** 00165 * Write a 64-bit integer property to the POF stream. 00166 * 00167 * @param iProp the property index 00168 * @param l the <tt>int64_t</tt> property value to write 00169 * 00170 * @throws coherence::lang::IllegalArgumentException if the property 00171 * index is invalid, or is less than or equal to the index of 00172 * the previous property written to the POF stream 00173 * @throws coherence::io::IOException if an I/O error occurs 00174 */ 00175 virtual void writeInt64(int32_t iProp, int64_t l) = 0; 00176 00177 /** 00178 * Write a 32-bit floating-point property to the POF stream. 00179 * 00180 * @param iProp the property index 00181 * @param fl the <tt>float32_t</tt> property value to write 00182 * 00183 * @throws coherence::lang::IllegalArgumentException if the property 00184 * index is invalid, or is less than or equal to the index of 00185 * the previous property written to the POF stream 00186 * @throws coherence::io::IOException if an I/O error occurs 00187 */ 00188 virtual void writeFloat32(int32_t iProp, float32_t fl) = 0; 00189 00190 /** 00191 * Write a 64-bit floating-point property to the POF stream. 00192 * 00193 * @param iProp the property index 00194 * @param dfl the <tt>float64_t</tt> property value to write 00195 * 00196 * @throws coherence::lang::IllegalArgumentException if the property 00197 * index is invalid, or is less than or equal to the index of 00198 * the previous property written to the POF stream 00199 * @throws coherence::io::IOException if an I/O error occurs 00200 */ 00201 virtual void writeFloat64(int32_t iProp, float64_t dfl) = 0; 00202 00203 00204 // ----- primitive array support ---------------------------------------- 00205 00206 public: 00207 /** 00208 * Write a boolean array property to the POF stream. 00209 * 00210 * @param iProp the property index 00211 * @param vaf the <tt>bool</tt> array property value to write 00212 * 00213 * @throws coherence::lang::IllegalArgumentException if the property 00214 * index is invalid, or is less than or equal to the index of 00215 * the previous property written to the POF stream 00216 * @throws coherence::io::IOException if an I/O error occurs 00217 */ 00218 virtual void writeBooleanArray(int32_t iProp, Array<bool>::View vaf) = 0; 00219 00220 /** 00221 * Write an octect array property to the POF stream. 00222 * 00223 * @param iProp the property index 00224 * @param vab the <tt>octet_t</tt> array property value to write 00225 * 00226 * @throws coherence::lang::IllegalArgumentException if the property 00227 * index is invalid, or is less than or equal to the index of 00228 * the previous property written to the POF stream 00229 * @throws coherence::io::IOException if an I/O error occurs 00230 */ 00231 virtual void writeOctetArray(int32_t iProp, Array<octet_t>::View vab) = 0; 00232 00233 /** 00234 * Write a 16-bit Unicode character array property to the POF stream. 00235 * 00236 * @param iProp the property index 00237 * @param vach the <tt>char16_t</tt> array property value to write 00238 * 00239 * @throws coherence::lang::IllegalArgumentException if the property 00240 * index is invalid, or is less than or equal to the index of 00241 * the previous property written to the POF stream 00242 * @throws coherence::io::IOException if an I/O error occurs 00243 */ 00244 virtual void writeChar16Array(int32_t iProp, Array<char16_t>::View vach) = 0; 00245 00246 /** 00247 * Write a 16-bit integer array property to the POF stream. 00248 * 00249 * @param iProp the property index 00250 * @param van the <tt>int16_t</tt> array property value to write 00251 * 00252 * @throws coherence::lang::IllegalArgumentException if the property 00253 * index is invalid, or is less than or equal to the index of 00254 * the previous property written to the POF stream 00255 * @throws coherence::io::IOException if an I/O error occurs 00256 */ 00257 virtual void writeInt16Array(int32_t iProp, Array<int16_t>::View van) = 0; 00258 00259 /** 00260 * Write a 32-bit integer array property to the POF stream. 00261 * 00262 * @param iProp the property index 00263 * @param van the <tt>int32_t</tt> array property value to write 00264 * 00265 * @throws coherence::lang::IllegalArgumentException if the property 00266 * index is invalid, or is less than or equal to the index of 00267 * the previous property written to the POF stream 00268 * @throws coherence::io::IOException if an I/O error occurs 00269 */ 00270 virtual void writeInt32Array(int32_t iProp, Array<int32_t>::View van) = 0; 00271 00272 /** 00273 * Write a 64-bit integer array property to the POF stream. 00274 * 00275 * @param iProp the property index 00276 * @param val the <tt>int64_t</tt> array property value to write 00277 * 00278 * @throws coherence::lang::IllegalArgumentException if the property 00279 * index is invalid, or is less than or equal to the index of 00280 * the previous property written to the POF stream 00281 * @throws coherence::io::IOException if an I/O error occurs 00282 */ 00283 virtual void writeInt64Array(int32_t iProp, Array<int64_t>::View val) = 0; 00284 00285 /** 00286 * Write a 32-bit floating-point array property to the POF stream. 00287 * 00288 * @param iProp the property index 00289 * @param vafl the <tt>float32_t</tt> array property value to write 00290 * 00291 * @throws coherence::lang::IllegalArgumentException if the property 00292 * index is invalid, or is less than or equal to the index of 00293 * the previous property written to the POF stream 00294 * @throws coherence::io::IOException if an I/O error occurs 00295 */ 00296 virtual void writeFloat32Array(int32_t iProp, Array<float32_t>::View vafl) = 0; 00297 00298 /** 00299 * Write a 64-bit floating-point array property to the POF stream. 00300 * 00301 * @param iProp the property index 00302 * @param vadfl the <tt>float64_t</tt> array property value to write 00303 * 00304 * @throws coherence::lang::IllegalArgumentException if the property 00305 * index is invalid, or is less than or equal to the index of 00306 * the previous property written to the POF stream 00307 * @throws coherence::io::IOException if an I/O error occurs 00308 */ 00309 virtual void writeFloat64Array(int32_t iProp, Array<float64_t>::View vadfl) = 0; 00310 00311 00312 // ----- object value support ------------------------------------------- 00313 00314 public: 00315 /** 00316 * Write a <tt>Binary</tt> property to the POF stream. 00317 * 00318 * @param iProp the property index 00319 * @param vBin the <tt>Binary</tt> property value to write 00320 * 00321 * @throws coherence::lang::IllegalArgumentException if the property 00322 * index is invalid, or is less than or equal to the index of 00323 * the previous property written to the POF stream 00324 * @throws coherence::io::IOException if an I/O error occurs 00325 */ 00326 virtual void writeBinary(int32_t iProp, Binary::View vBin) = 0; 00327 00328 /** 00329 * Write a <tt>String</tt> property to the POF stream. 00330 * 00331 * @param iProp the property index 00332 * @param vs the <tt>String</tt> property value to write 00333 * 00334 * @throws coherence::lang::IllegalArgumentException if the property 00335 * index is invalid, or is less than or equal to the index of 00336 * the previous property written to the POF stream 00337 * @throws coherence::io::IOException if an I/O error occurs 00338 */ 00339 virtual void writeString(int32_t iProp, String::View vs) = 0; 00340 00341 /** 00342 * Write a {@link RawDate} property to the POF stream. 00343 * 00344 * @param iProp the property index 00345 * @param vDate the <tt>RawDate</tt> property value to write 00346 * 00347 * @throws coherence::lang::IllegalArgumentException if the property 00348 * index is invalid, or is less than or equal to the index of 00349 * the previous property written to the POF stream 00350 * @throws coherence::io::IOException if an I/O error occurs 00351 */ 00352 virtual void writeRawDate(int32_t iProp, RawDate::View vDate) = 0; 00353 00354 /** 00355 * Write a {@link RawDateTime} property to the POF stream. 00356 * 00357 * @param iProp the property index 00358 * @param vdt the <tt>RawDateTime</tt> property value to write 00359 * 00360 * @throws coherence::lang::IllegalArgumentException if the property 00361 * index is invalid, or is less than or equal to the index of 00362 * the previous property written to the POF stream 00363 * @throws coherence::io::IOException if an I/O error occurs 00364 */ 00365 virtual void writeRawDateTime(int32_t iProp, RawDateTime::View vdt) = 0; 00366 00367 /** 00368 * Write a {@link RawDayTimeInterval} property to the POF stream. 00369 * 00370 * @param iProp the property index 00371 * @param vInterval the <tt>RawDayTimeInterval</tt> property value to 00372 * write 00373 * 00374 * @throws coherence::lang::IllegalArgumentException if the property 00375 * index is invalid, or is less than or equal to the index of 00376 * the previous property written to the POF stream 00377 * @throws coherence::io::IOException if an I/O error occurs 00378 */ 00379 virtual void writeRawDayTimeInterval(int32_t iProp, 00380 RawDayTimeInterval::View vInterval) = 0; 00381 00382 /** 00383 * Write a {@link RawTime} property to the POF stream. 00384 * 00385 * @param iProp the property index 00386 * @param vTime the <tt>RawTime</tt> property value to write 00387 * 00388 * @throws coherence::lang::IllegalArgumentException if the property 00389 * index is invalid, or is less than or equal to the index of 00390 * the previous property written to the POF stream 00391 * @throws coherence::io::IOException if an I/O error occurs 00392 */ 00393 virtual void writeRawTime(int32_t iProp, RawTime::View vTime) = 0; 00394 00395 /** 00396 * Write a {@link RawTimeInterval} property to the POF stream. 00397 * 00398 * @param iProp the property index 00399 * @param vInterval the <tt>RawTimeInterval</tt> property value to 00400 * write 00401 * 00402 * @throws coherence::lang::IllegalArgumentException if the property 00403 * index is invalid, or is less than or equal to the index of 00404 * the previous property written to the POF stream 00405 * @throws coherence::io::IOException if an I/O error occurs 00406 */ 00407 virtual void writeRawTimeInterval(int32_t iProp, 00408 RawTimeInterval::View vInterval) = 0; 00409 00410 /** 00411 * Write a {@link RawYearMonthInterval} property to the POF stream. 00412 * 00413 * @param iProp the property index 00414 * @param vInterval the <tt>RawYearMonthInterval</tt> property value 00415 * to write 00416 * 00417 * @throws coherence::lang::IllegalArgumentException if the property 00418 * index is invalid, or is less than or equal to the index of 00419 * the previous property written to the POF stream 00420 * @throws coherence::io::IOException if an I/O error occurs 00421 */ 00422 virtual void writeRawYearMonthInterval(int32_t iProp, 00423 RawYearMonthInterval::View vInterval) = 0; 00424 00425 /** 00426 * Write an <tt>Object</tt> property to the POF stream. 00427 * 00428 * The given object must be an instance of one of the following: 00429 * <ul> 00430 * <li>Boolean</li> 00431 * <li>Octet</li> 00432 * <li>Char16</li> 00433 * <li>Int16</li> 00434 * <li>Int32</li> 00435 * <li>Int64</li> 00436 * <li>Float32</li> 00437 * <li>Float64</li> 00438 * <li>Array<bool></li> 00439 * <li>Array<octet_t></li> 00440 * <li>Array<char16_t></li> 00441 * <li>Array<int16_t></li> 00442 * <li>Array<int32_t></li> 00443 * <li>Array<int64_t></li> 00444 * <li>Array<float32_t></li> 00445 * <li>Array<float64_t></li> 00446 * <li>Binary</li> 00447 * <li>String</li> 00448 * <li>{@link RawDate}</li> 00449 * <li>{@link RawDateTime}</li> 00450 * <li>{@link RawDayTimeInterval}</li> 00451 * <li>{@link RawTime}</li> 00452 * <li>{@link RawTimeInterval}</li> 00453 * <li>{@link RawYearMonthInterval}</li> 00454 * <li>Collection, with the same restrictions for all elements</li> 00455 * <li>LongArray, with the same restrictions for all elements</li> 00456 * <li>ObjectArray, with the same restrictions for all elements</li> 00457 * </ul> 00458 * 00459 * Otherwise, a {@link PofSerializer} for the object must be 00460 * obtainable from the {@link PofContext} associated with this 00461 * PofWriter. 00462 * 00463 * @throws coherence::lang::IllegalArgumentException if the property 00464 * index is invalid, or is less than or equal to the index of 00465 * the previous property written to the POF stream 00466 * @throws coherence::lang::IllegalArgumentException if the given 00467 * property cannot be encoded into a POF stream 00468 * @throws coherence::io::IOException if an I/O error occurs 00469 */ 00470 virtual void writeObject(int32_t iProp, Object::View v) = 0; 00471 00472 00473 // ----- collection support --------------------------------------------- 00474 00475 public: 00476 /** 00477 * Write an <tt>ObjectArray</tt> property to the POF stream. 00478 * 00479 * Each element of the given array must be an instance (or a 00480 * collection of instances) of one of the following: 00481 * <ul> 00482 * <li>Boolean</li> 00483 * <li>Octet</li> 00484 * <li>Char16</li> 00485 * <li>Int16</li> 00486 * <li>Int32</li> 00487 * <li>Int64</li> 00488 * <li>Float32</li> 00489 * <li>Float64</li> 00490 * <li>Array<bool></li> 00491 * <li>Array<octet_t></li> 00492 * <li>Array<char16_t></li> 00493 * <li>Array<int16_t></li> 00494 * <li>Array<int32_t></li> 00495 * <li>Array<int64_t></li> 00496 * <li>Array<float32_t></li> 00497 * <li>Array<float64_t></li> 00498 * <li>Binary</li> 00499 * <li>String</li> 00500 * <li>{@link RawDate}</li> 00501 * <li>{@link RawDateTime}</li> 00502 * <li>{@link RawDayTimeInterval}</li> 00503 * <li>{@link RawTime}</li> 00504 * <li>{@link RawTimeInterval}</li> 00505 * <li>{@link RawYearMonthInterval}</li> 00506 * <li>Collection, with the same restrictions for all elements</li> 00507 * <li>LongArray, with the same restrictions for all elements</li> 00508 * <li>ObjectArray, with the same restrictions for all elements</li> 00509 * </ul> 00510 * 00511 * Otherwise, a {@link PofSerializer} for each element of the array 00512 * must be obtainable from the {@link PofContext} associated with this 00513 * PofWriter. 00514 * 00515 * @param iProp the property index 00516 * @param va the <tt>ObjectArray</tt> property value to write 00517 * 00518 * @throws coherence::lang::IllegalArgumentException if the property 00519 * index is invalid, or is less than or equal to the index of 00520 * the previous property written to the POF stream 00521 * @throws coherence::lang::IllegalArgumentException if the given 00522 * property cannot be encoded into a POF stream 00523 * @throws coherence::io::IOException if an I/O error occurs 00524 */ 00525 virtual void writeObjectArray(int32_t iProp, ObjectArray::View va) = 0; 00526 00527 /** 00528 * Write a uniform <tt>ObjectArray</tt> property to the POF stream. 00529 * 00530 * Each element of the given array must be an instance (or a 00531 * collection of instances) of one of the following: 00532 * <ul> 00533 * <li>Boolean</li> 00534 * <li>Octet</li> 00535 * <li>Char16</li> 00536 * <li>Int16</li> 00537 * <li>Int32</li> 00538 * <li>Int64</li> 00539 * <li>Float32</li> 00540 * <li>Float64</li> 00541 * <li>Array<bool></li> 00542 * <li>Array<octet_t></li> 00543 * <li>Array<char16_t></li> 00544 * <li>Array<int16_t></li> 00545 * <li>Array<int32_t></li> 00546 * <li>Array<int64_t></li> 00547 * <li>Array<float32_t></li> 00548 * <li>Array<float64_t></li> 00549 * <li>Binary</li> 00550 * <li>String</li> 00551 * <li>{@link RawDate}</li> 00552 * <li>{@link RawDateTime}</li> 00553 * <li>{@link RawDayTimeInterval}</li> 00554 * <li>{@link RawTime}</li> 00555 * <li>{@link RawTimeInterval}</li> 00556 * <li>{@link RawYearMonthInterval}</li> 00557 * <li>Collection, with the same restrictions for all elements</li> 00558 * <li>LongArray, with the same restrictions for all elements</li> 00559 * <li>ObjectArray, with the same restrictions for all elements</li> 00560 * </ul> 00561 * 00562 * Otherwise, a {@link PofSerializer} for each element of the array 00563 * must be obtainable from the {@link PofContext} associated with this 00564 * PofWriter. 00565 * 00566 * Additionally, the type of each element must be equal to the 00567 * specified class. 00568 * 00569 * @param iProp the property index 00570 * @param va the <tt>ObjectArray</tt> property value to write 00571 * @param vClass the class of all elements; must not be <tt>NULL</tt> 00572 * 00573 * @throws coherence::lang::IllegalArgumentException if the property 00574 * index is invalid, or is less than or equal to the index of 00575 * the previous property written to the POF stream 00576 * @throws coherence::lang::IllegalArgumentException if the given 00577 * property cannot be encoded into a POF stream 00578 * @throws coherence::lang::IllegalArgumentException if the type of 00579 * one or more elements of the array is not equal to the 00580 * specified class 00581 * @throws coherence::io::IOException if an I/O error occurs 00582 */ 00583 virtual void writeObjectArray(int32_t iProp, ObjectArray::View va, 00584 Class::View vClass) = 0; 00585 00586 /** 00587 * Write a <tt>LongArray</tt> property to the POF stream. 00588 * 00589 * Each element of the given array must be an instance (or a 00590 * collection of instances) of one of the following: 00591 * <ul> 00592 * <li>Boolean</li> 00593 * <li>Octet</li> 00594 * <li>Char16</li> 00595 * <li>Int16</li> 00596 * <li>Int32</li> 00597 * <li>Int64</li> 00598 * <li>Float32</li> 00599 * <li>Float64</li> 00600 * <li>Array<bool></li> 00601 * <li>Array<octet_t></li> 00602 * <li>Array<char16_t></li> 00603 * <li>Array<int16_t></li> 00604 * <li>Array<int32_t></li> 00605 * <li>Array<int64_t></li> 00606 * <li>Array<float32_t></li> 00607 * <li>Array<float64_t></li> 00608 * <li>Binary</li> 00609 * <li>String</li> 00610 * <li>{@link RawDate}</li> 00611 * <li>{@link RawDateTime}</li> 00612 * <li>{@link RawDayTimeInterval}</li> 00613 * <li>{@link RawTime}</li> 00614 * <li>{@link RawTimeInterval}</li> 00615 * <li>{@link RawYearMonthInterval}</li> 00616 * <li>Collection, with the same restrictions for all elements</li> 00617 * <li>LongArray, with the same restrictions for all elements</li> 00618 * <li>ObjectArray, with the same restrictions for all elements</li> 00619 * </ul> 00620 * 00621 * Otherwise, a {@link PofSerializer} for each element of the array 00622 * must be obtainable from the {@link PofContext} associated with this 00623 * PofWriter. 00624 * 00625 * @param iProp the property index 00626 * @param vla the <tt>LongArray</tt> property value to write 00627 * 00628 * @throws coherence::lang::IllegalArgumentException if the property 00629 * index is invalid, or is less than or equal to the index of 00630 * the previous property written to the POF stream 00631 * @throws coherence::lang::IllegalArgumentException if the given 00632 * property cannot be encoded into a POF stream 00633 * @throws coherence::io::IOException if an I/O error occurs 00634 */ 00635 virtual void writeLongArray(int32_t iProp, LongArray::View vla) = 0; 00636 00637 /** 00638 * Write a uniform <tt>LongArray</tt> property to the POF stream. 00639 * 00640 * Each element of the given array must be an instance (or a 00641 * collection of instances) of one of the following: 00642 * <ul> 00643 * <li>Boolean</li> 00644 * <li>Octet</li> 00645 * <li>Char16</li> 00646 * <li>Int16</li> 00647 * <li>Int32</li> 00648 * <li>Int64</li> 00649 * <li>Float32</li> 00650 * <li>Float64</li> 00651 * <li>Array<bool></li> 00652 * <li>Array<octet_t></li> 00653 * <li>Array<char16_t></li> 00654 * <li>Array<int16_t></li> 00655 * <li>Array<int32_t></li> 00656 * <li>Array<int64_t></li> 00657 * <li>Array<float32_t></li> 00658 * <li>Array<float64_t></li> 00659 * <li>Binary</li> 00660 * <li>String</li> 00661 * <li>{@link RawDate}</li> 00662 * <li>{@link RawDateTime}</li> 00663 * <li>{@link RawDayTimeInterval}</li> 00664 * <li>{@link RawTime}</li> 00665 * <li>{@link RawTimeInterval}</li> 00666 * <li>{@link RawYearMonthInterval}</li> 00667 * <li>Collection, with the same restrictions for all elements</li> 00668 * <li>LongArray, with the same restrictions for all elements</li> 00669 * <li>ObjectArray, with the same restrictions for all elements</li> 00670 * </ul> 00671 * 00672 * Otherwise, a {@link PofSerializer} for each element of the array 00673 * must be obtainable from the {@link PofContext} associated with this 00674 * PofWriter. 00675 * 00676 * Additionally, the type of each element must be equal to the 00677 * specified class. 00678 * 00679 * @param iProp the property index 00680 * @param vla the <tt>LongArray</tt> property value to write 00681 * @param vClass the class of all elements; must not be <tt>NULL</tt> 00682 * 00683 * @throws coherence::lang::IllegalArgumentException if the property 00684 * index is invalid, or is less than or equal to the index of 00685 * the previous property written to the POF stream 00686 * @throws coherence::lang::IllegalArgumentException if the given 00687 * property cannot be encoded into a POF stream 00688 * @throws coherence::lang::IllegalArgumentException if the type of 00689 * one or more elements of the array is not equal to the 00690 * specified class 00691 * @throws coherence::io::IOException if an I/O error occurs 00692 */ 00693 virtual void writeLongArray(int32_t iProp, LongArray::View vla, 00694 Class::View vClass) = 0; 00695 00696 /** 00697 * Write a <tt>Collection</tt> property to the POF stream. 00698 * 00699 * Each element of the given <tt>Collection</tt> must be an instance 00700 * (or collection of instances) of one of the following: 00701 * <ul> 00702 * <li>Boolean</li> 00703 * <li>Octet</li> 00704 * <li>Char16</li> 00705 * <li>Int16</li> 00706 * <li>Int32</li> 00707 * <li>Int64</li> 00708 * <li>Float32</li> 00709 * <li>Float64</li> 00710 * <li>Array<bool></li> 00711 * <li>Array<octet_t></li> 00712 * <li>Array<char16_t></li> 00713 * <li>Array<int16_t></li> 00714 * <li>Array<int32_t></li> 00715 * <li>Array<int64_t></li> 00716 * <li>Array<float32_t></li> 00717 * <li>Array<float64_t></li> 00718 * <li>Binary</li> 00719 * <li>String</li> 00720 * <li>{@link RawDate}</li> 00721 * <li>{@link RawDateTime}</li> 00722 * <li>{@link RawDayTimeInterval}</li> 00723 * <li>{@link RawTime}</li> 00724 * <li>{@link RawTimeInterval}</li> 00725 * <li>{@link RawYearMonthInterval}</li> 00726 * <li>Collection, with the same restrictions for all elements</li> 00727 * <li>LongArray, with the same restrictions for all elements</li> 00728 * <li>ObjectArray, with the same restrictions for all elements</li> 00729 * </ul> 00730 * 00731 * Otherwise, a {@link PofSerializer} for each element of the 00732 * <tt>Collection</tt> must be obtainable from the {@link PofContext} 00733 * associated with this PofWriter. 00734 * 00735 * @param iProp the property index 00736 * @param vCol the <tt>Collection</tt> property value to write 00737 * 00738 * @throws coherence::lang::IllegalArgumentException if the property 00739 * index is invalid, or is less than or equal to the index of 00740 * the previous property written to the POF stream 00741 * @throws coherence::lang::IllegalArgumentException if the given 00742 * property cannot be encoded into a POF stream 00743 * @throws coherence::io::IOException if an I/O error occurs 00744 */ 00745 virtual void writeCollection(int32_t iProp, Collection::View vCol) = 0; 00746 00747 /** 00748 * Write a uniform <tt>Collection</tt> property to the POF stream. 00749 * 00750 * Each element of the given <tt>Collection</tt> must be an instance 00751 * (or collection of instances) of one of the following: 00752 * <ul> 00753 * <li>Boolean</li> 00754 * <li>Octet</li> 00755 * <li>Char16</li> 00756 * <li>Int16</li> 00757 * <li>Int32</li> 00758 * <li>Int64</li> 00759 * <li>Float32</li> 00760 * <li>Float64</li> 00761 * <li>Array<bool></li> 00762 * <li>Array<octet_t></li> 00763 * <li>Array<char16_t></li> 00764 * <li>Array<int16_t></li> 00765 * <li>Array<int32_t></li> 00766 * <li>Array<int64_t></li> 00767 * <li>Array<float32_t></li> 00768 * <li>Array<float64_t></li> 00769 * <li>Binary</li> 00770 * <li>String</li> 00771 * <li>{@link RawDate}</li> 00772 * <li>{@link RawDateTime}</li> 00773 * <li>{@link RawDayTimeInterval}</li> 00774 * <li>{@link RawTime}</li> 00775 * <li>{@link RawTimeInterval}</li> 00776 * <li>{@link RawYearMonthInterval}</li> 00777 * <li>Collection, with the same restrictions for all elements</li> 00778 * <li>LongArray, with the same restrictions for all elements</li> 00779 * <li>ObjectArray, with the same restrictions for all elements</li> 00780 * </ul> 00781 * 00782 * Otherwise, a {@link PofSerializer} for each element of the 00783 * <tt>Collection</tt> must be obtainable from the {@link PofContext} 00784 * associated with this PofWriter. 00785 * 00786 * Additionally, the type of each element must be equal to the 00787 * specified class. 00788 * 00789 * @param iProp the property index 00790 * @param vCol the <tt>Collection</tt> property value to write 00791 * @param vClass the class of all elements; must not be <tt>NULL</tt> 00792 * 00793 * @throws coherence::lang::IllegalArgumentException if the property 00794 * index is invalid, or is less than or equal to the index of 00795 * the previous property written to the POF stream 00796 * @throws coherence::lang::IllegalArgumentException if the given 00797 * property cannot be encoded into a POF stream 00798 * @throws coherence::lang::IllegalArgumentException if the type of 00799 * one or more elements of the <tt>Collection</tt> is not 00800 * equal to the specified class 00801 * @throws coherence::io::IOException if an I/O error occurs 00802 */ 00803 virtual void writeCollection(int32_t iProp, Collection::View vCol, 00804 Class::View vClass) = 0; 00805 00806 /** 00807 * Write a <tt>Map</tt> property to the POF stream. 00808 * 00809 * Each key and value of the given <tt>Map</tt> must be an instance 00810 * (or a collection of instances) of one of the following: 00811 * <ul> 00812 * <li>Boolean</li> 00813 * <li>Octet</li> 00814 * <li>Char16</li> 00815 * <li>Int16</li> 00816 * <li>Int32</li> 00817 * <li>Int64</li> 00818 * <li>Float32</li> 00819 * <li>Float64</li> 00820 * <li>Array<bool></li> 00821 * <li>Array<octet_t></li> 00822 * <li>Array<char16_t></li> 00823 * <li>Array<int16_t></li> 00824 * <li>Array<int32_t></li> 00825 * <li>Array<int64_t></li> 00826 * <li>Array<float32_t></li> 00827 * <li>Array<float64_t></li> 00828 * <li>Binary</li> 00829 * <li>String</li> 00830 * <li>{@link RawDate}</li> 00831 * <li>{@link RawDateTime}</li> 00832 * <li>{@link RawDayTimeInterval}</li> 00833 * <li>{@link RawTime}</li> 00834 * <li>{@link RawTimeInterval}</li> 00835 * <li>{@link RawYearMonthInterval}</li> 00836 * <li>Collection, with the same restrictions for all elements</li> 00837 * <li>LongArray, with the same restrictions for all elements</li> 00838 * <li>ObjectArray, with the same restrictions for all elements</li> 00839 * </ul> 00840 * 00841 * Otherwise, a {@link PofSerializer} for each key and value of 00842 * the <tt>Map</tt> must be obtainable from the {@link PofContext} 00843 * associated with this PofWriter. 00844 * 00845 * @param iProp the property index 00846 * @param vMap the <tt>Map</tt> property value to write 00847 * 00848 * @throws coherence::lang::IllegalArgumentException if the property 00849 * index is invalid, or is less than or equal to the index of 00850 * the previous property written to the POF stream 00851 * @throws coherence::lang::IllegalArgumentException if the given 00852 * property cannot be encoded into a POF stream 00853 * @throws coherence::io::IOException if an I/O error occurs 00854 */ 00855 virtual void writeMap(int32_t iProp, Map::View vMap) = 0; 00856 00857 /** 00858 * Write a uniform key <tt>Map</tt> property to the POF stream. 00859 * 00860 * Each key and value of the given <tt>Map</tt> must be an instance 00861 * (or a collection of instances) of one of the following: 00862 * <ul> 00863 * <li>Boolean</li> 00864 * <li>Octet</li> 00865 * <li>Char16</li> 00866 * <li>Int16</li> 00867 * <li>Int32</li> 00868 * <li>Int64</li> 00869 * <li>Float32</li> 00870 * <li>Float64</li> 00871 * <li>Array<bool></li> 00872 * <li>Array<octet_t></li> 00873 * <li>Array<char16_t></li> 00874 * <li>Array<int16_t></li> 00875 * <li>Array<int32_t></li> 00876 * <li>Array<int64_t></li> 00877 * <li>Array<float32_t></li> 00878 * <li>Array<float64_t></li> 00879 * <li>Binary</li> 00880 * <li>String</li> 00881 * <li>{@link RawDate}</li> 00882 * <li>{@link RawDateTime}</li> 00883 * <li>{@link RawDayTimeInterval}</li> 00884 * <li>{@link RawTime}</li> 00885 * <li>{@link RawTimeInterval}</li> 00886 * <li>{@link RawYearMonthInterval}</li> 00887 * <li>Collection, with the same restrictions for all elements</li> 00888 * <li>LongArray, with the same restrictions for all elements</li> 00889 * <li>ObjectArray, with the same restrictions for all elements</li> 00890 * </ul> 00891 * 00892 * Otherwise, a {@link PofSerializer} for each key and value of 00893 * the <tt>Map</tt> must be obtainable from the {@link PofContext} 00894 * associated with this PofWriter. 00895 * 00896 * Additionally, the type of each key must be equal to the specified 00897 * class. 00898 * 00899 * @param iProp the property index 00900 * @param vMap the <tt>Map</tt> property value to write 00901 * @param vClassKey the class of all keys; must not be <tt>NULL</tt> 00902 * 00903 * @throws coherence::lang::IllegalArgumentException if the property 00904 * index is invalid, or is less than or equal to the index of 00905 * the previous property written to the POF stream 00906 * @throws coherence::lang::IllegalArgumentException if the given 00907 * property cannot be encoded into a POF stream 00908 * @throws coherence::lang::IllegalArgumentException if the type of 00909 * one or more keys of the <tt>Map</tt> is not equal to the 00910 * specified class 00911 * @throws coherence::io::IOException if an I/O error occurs 00912 */ 00913 virtual void writeMap(int32_t iProp, Map::View vMap, 00914 Class::View vClassKey) = 0; 00915 00916 /** 00917 * Write a uniform <tt>Map</tt> property to the POF stream. 00918 * 00919 * Each key and value of the given <tt>Map</tt> must be an instance 00920 * (or a collection of instances) of one of the following: 00921 * <ul> 00922 * <li>Boolean</li> 00923 * <li>Octet</li> 00924 * <li>Char16</li> 00925 * <li>Int16</li> 00926 * <li>Int32</li> 00927 * <li>Int64</li> 00928 * <li>Float32</li> 00929 * <li>Float64</li> 00930 * <li>Array<bool></li> 00931 * <li>Array<octet_t></li> 00932 * <li>Array<char16_t></li> 00933 * <li>Array<int16_t></li> 00934 * <li>Array<int32_t></li> 00935 * <li>Array<int64_t></li> 00936 * <li>Array<float32_t></li> 00937 * <li>Array<float64_t></li> 00938 * <li>Binary</li> 00939 * <li>String</li> 00940 * <li>{@link RawDate}</li> 00941 * <li>{@link RawDateTime}</li> 00942 * <li>{@link RawDayTimeInterval}</li> 00943 * <li>{@link RawTime}</li> 00944 * <li>{@link RawTimeInterval}</li> 00945 * <li>{@link RawYearMonthInterval}</li> 00946 * <li>Collection, with the same restrictions for all elements</li> 00947 * <li>LongArray, with the same restrictions for all elements</li> 00948 * <li>ObjectArray, with the same restrictions for all elements</li> 00949 * </ul> 00950 * 00951 * Otherwise, a {@link PofSerializer} for each key and value of 00952 * the <tt>Map</tt> must be obtainable from the {@link PofContext} 00953 * associated with this PofWriter. 00954 * 00955 * Additionally, the type of each key must be equal to the specified 00956 * class. 00957 * 00958 * @param iProp the property index 00959 * @param vMap the <tt>Map</tt> property value to write 00960 * @param vClassKey the class of all keys; must not be 00961 * <tt>NULL</tt> 00962 * @param vClassValue the class of all values; must not be 00963 * <tt>NULL</tt> 00964 * 00965 * @throws coherence::lang::IllegalArgumentException if the property 00966 * index is invalid, or is less than or equal to the index of 00967 * the previous property written to the POF stream 00968 * @throws coherence::lang::IllegalArgumentException if the given 00969 * property cannot be encoded into a POF stream 00970 * @throws coherence::lang::IllegalArgumentException if the type of 00971 * one or more keys or values of the <tt>Map</tt> is not equal 00972 * to the specified classes 00973 * @throws coherence::io::IOException if an I/O error occurs 00974 */ 00975 virtual void writeMap(int32_t iProp, Map::View vMap, 00976 Class::View vClassKey, Class::View vClassValue) = 0; 00977 00978 00979 // ----- POF user type support ------------------------------------------ 00980 00981 public: 00982 /** 00983 * Return the PofContext object used by this PofWriter to serialize 00984 * user types to a POF stream. 00985 * 00986 * @return the PofContext object that contains user type meta-data 00987 */ 00988 virtual PofContext::View getPofContext() const = 0; 00989 00990 /** 00991 * Configure the PofContext object used by this PofWriter to serialize 00992 * user types to a POF stream. 00993 * 00994 * Note: this is an advanced method that should be used with care. For 00995 * example, if this method is being used to switch to another 00996 * PofContext mid-POF stream, it is important to eventually restore 00997 * the original PofContext. For example: 00998 * <pre> 00999 * PofContext::View vCtxOrig = hWriter->getPofContext(); 01000 * 01001 * // switch to another PofContext 01002 * PofContext::View vCtxNew = ...; 01003 * hWriter->setContext(vCtxNew); 01004 * 01005 * // output POF data using the writer 01006 * ... 01007 * 01008 * // restore the original PofContext 01009 * hWriter->setPofContext(vCtxOrig); 01010 * </pre> 01011 * 01012 * @param vCtx the new PofContext; must not be <tt>NULL</tt> 01013 */ 01014 virtual void setPofContext(PofContext::View vCtx) = 0; 01015 01016 /** 01017 * Determine the user type that is currently being written. 01018 * 01019 * @return the user type identifier, or -1 if the PofWriter is not 01020 * currently writing a user type 01021 */ 01022 virtual int32_t getUserTypeId() const = 0; 01023 01024 /** 01025 * Determine the version identifier of the user type that is currently 01026 * being written. 01027 * 01028 * @return the integer version ID of the user type; always 01029 * non-negative 01030 * 01031 * @throws coherence::lang::IllegalStateException if no user type is 01032 * being parsed 01033 */ 01034 virtual int32_t getVersionId() const = 0; 01035 01036 /** 01037 * Set the version identifier of the user type that is currently being 01038 * written. 01039 * 01040 * @param nVersionId the user type identifier; must be non-negative 01041 * 01042 * @throws coherence::lang::IllegalArgumentException if the given 01043 * version ID is negative 01044 * @throws coherence::lang::IllegalStateException if no user type is 01045 * being written 01046 */ 01047 virtual void setVersionId(int32_t nVersionId) = 0; 01048 01049 /** 01050 * Write the remaining properties to the POF stream, terminating the 01051 * writing of the currrent user type. As part of writing out a user 01052 * type, this method must be called by the PofSerializer that is 01053 * writing out the user type, or the POF stream will be corrupted. 01054 * 01055 * Calling this method terminates the current user type by writing 01056 * a -1 to the POF stream after the last indexed property. Subsequent 01057 * calls to the various <tt>writeXYZ</tt> methods of this interface 01058 * will fail after this method is called. 01059 * 01060 * @param vBinProps a buffer that contains zero or more indexed 01061 * properties in binary POF encoded form; may be 01062 * <tt>NULL</tt> 01063 * 01064 * @throws coherence::lang::IllegalStateException if no user type is 01065 * being written 01066 * @throws coherence::io::IOException if an I/O error occurs 01067 */ 01068 virtual void writeRemainder(Binary::View vBinProps) = 0; 01069 }; 01070 01071 COH_CLOSE_NAMESPACE3 01072 01073 #endif // COH_POF_WRITER_HPP