~ubuntu-branches/ubuntu/trusty/tomcat6/trusty

« back to all changes in this revision

Viewing changes to java/org/apache/catalina/tribes/io/XByteBuffer.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-02-17 00:02:00 UTC
  • mfrom: (1.2.10)
  • Revision ID: package-import@ubuntu.com-20140217000200-qs6ki7bhqnfhkas7
Tags: 6.0.39-1
* Team upload.
* New upstream release.
  - Refreshed the patches
* Standards-Version updated to 3.9.5 (no changes)
* Switch to debhelper level 9
* Use XZ compression for the upstream tarball
* Use canonical URL for the Vcs-Git field

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 * <li><b>END_DATA</b>  - 7 bytes - <i>TLF2003</i></lI>
43
43
 * </ul>
44
44
 * @author Filip Hanik
45
 
 * @version $Id: XByteBuffer.java 939515 2010-04-29 23:59:49Z kkolinko $
 
45
 * @version $Id: XByteBuffer.java 1561773 2014-01-27 18:19:12Z markt $
46
46
 */
47
47
public class XByteBuffer
48
48
{
92
92
    /**
93
93
     * Constructs a new XByteBuffer
94
94
     * @param size - the initial size of the byte buffer
95
 
     * @todo use a pool of byte[] for performance
 
95
     *
 
96
     * TODO use a pool of byte[] for performance
96
97
     */
97
98
    public XByteBuffer(int size, boolean discard) {
98
99
        buf = new byte[size];
154
155
     * Appends the data to the buffer. If the data is incorrectly formatted, ie, the data should always start with the
155
156
     * header, false will be returned and the data will be discarded.
156
157
     * @param b - bytes to be appended
157
 
     * @param off - the offset to extract data from
158
158
     * @param len - the number of bytes to append.
159
159
     * @return true if the data was appended correctly. Returns false if the package is incorrect, ie missing header or something, or the length of data is 0
160
160
     */
339
339
    
340
340
    /**
341
341
     * Creates a complete data package
342
 
     * @param indata - the message data to be contained within the package
343
 
     * @param compressed - compression flag for the indata buffer
 
342
     * @param cdata - the message data to be contained within the package
344
343
     * @return - a full package (header,size,data,footer)
345
 
     * 
346
344
     */
347
345
    public static byte[] createDataPackage(ChannelData cdata) {
348
346
//        return createDataPackage(cdata.getDataPackage());
432
430
 
433
431
    
434
432
    /**
435
 
     * Converts an integer to four bytes
436
 
     * @param n - the integer
 
433
     * Converts an boolean to four bytes
 
434
     * @param bool - the boolean
437
435
     * @return - four bytes in an array
438
436
     * @deprecated use toBytes(boolean,byte[],int)
439
437
     */
448
446
        return data;
449
447
    }
450
448
    
451
 
    /**
452
 
     * 
453
 
     * @param <any> long
454
 
     * @return use
455
 
     */
 
449
 
456
450
    public static boolean toBoolean(byte[] b, int offset) {
457
451
        return b[offset] != 0;
458
452
    }
588
582
    /**
589
583
     * Serializes a message into cluster data
590
584
     * @param msg ClusterMessage
591
 
     * @param compress boolean
592
 
     * @return 
593
 
     * @throws IOException
594
585
     */
595
586
    public static byte[] serialize(Serializable msg) throws IOException {
596
587
        ByteArrayOutputStream outs = new ByteArrayOutputStream();