Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSMutableData.appendBytes()


      }

      NSMutableData theData = new NSMutableData();

      // write header
      theData.appendBytes("bplist00".getBytes());

      // add six padded bytes

      // do uniquing
View Full Code Here


      // CF expects intsize to be calculated based on the offset table start position
      // and not on the offset of the last object.
      int intsize = EncodedObject.refSizeForValue(offsetTableStart);

      for (Long offset : objectOffsets) {
        theData.appendBytes(EncodedObject.encodeRef(offset, intsize));
      }

      // add trailer calculations to data
      // typedef struct {
      // uint8_t _unused[5];
View Full Code Here

      // uint8_t _objectRefSize;
      // uint64_t _numObjects;
      // uint64_t _topObject;
      // uint64_t _offsetTableOffset;
      // } CFBinaryPlistTrailer;
      theData.appendBytes(new byte[5]);
      theData.appendByte((byte) 0x0); // _sortVersion which AFIK is not being used in CF
      theData.appendByte((byte) intsize); // _offsetIntSize which byte size for all ints in file
      theData.appendByte((byte) refsize); // _objectRefSize which is total # of objects value in bytes
      theData.appendBytes(longToByteArray2(numberOfObjects, 8)); // _numObjects which is object count
      theData.appendBytes(longToByteArray2(theTopObject, 8)); // _topObject appears to be set to 0 in CF
View Full Code Here

      // } CFBinaryPlistTrailer;
      theData.appendBytes(new byte[5]);
      theData.appendByte((byte) 0x0); // _sortVersion which AFIK is not being used in CF
      theData.appendByte((byte) intsize); // _offsetIntSize which byte size for all ints in file
      theData.appendByte((byte) refsize); // _objectRefSize which is total # of objects value in bytes
      theData.appendBytes(longToByteArray2(numberOfObjects, 8)); // _numObjects which is object count
      theData.appendBytes(longToByteArray2(theTopObject, 8)); // _topObject appears to be set to 0 in CF
      theData.appendBytes(longToByteArray2(offsetTableStart, 8)); // _offsetTableOffset

      // write to stream
      try {
View Full Code Here

      theData.appendBytes(new byte[5]);
      theData.appendByte((byte) 0x0); // _sortVersion which AFIK is not being used in CF
      theData.appendByte((byte) intsize); // _offsetIntSize which byte size for all ints in file
      theData.appendByte((byte) refsize); // _objectRefSize which is total # of objects value in bytes
      theData.appendBytes(longToByteArray2(numberOfObjects, 8)); // _numObjects which is object count
      theData.appendBytes(longToByteArray2(theTopObject, 8)); // _topObject appears to be set to 0 in CF
      theData.appendBytes(longToByteArray2(offsetTableStart, 8)); // _offsetTableOffset

      // write to stream
      try {
        theData.writeToStream(out);
View Full Code Here

      theData.appendByte((byte) 0x0); // _sortVersion which AFIK is not being used in CF
      theData.appendByte((byte) intsize); // _offsetIntSize which byte size for all ints in file
      theData.appendByte((byte) refsize); // _objectRefSize which is total # of objects value in bytes
      theData.appendBytes(longToByteArray2(numberOfObjects, 8)); // _numObjects which is object count
      theData.appendBytes(longToByteArray2(theTopObject, 8)); // _topObject appears to be set to 0 in CF
      theData.appendBytes(longToByteArray2(offsetTableStart, 8)); // _offsetTableOffset

      // write to stream
      try {
        theData.writeToStream(out);
      } catch (IOException e) {
View Full Code Here

        // This is kind of funky we do a first encoding to see if we can get away with ASCII encoding
        // This is true if UTF-8 encoding yield the same length as the char count.
        byte[] theBytes = value.getBytes(encoding);
 
        if (theBytes.length == value.length()) {
          data.appendBytes(encodeCount(value.length(), Type.kCFBinaryPlistMarkerASCIIString));
        } else {
          if (Charset.isSupported("UTF-16BE")) {
            encoding = CharEncoding.UTF_16BE;
          }
          theBytes = value.getBytes(encoding);
View Full Code Here

        } else {
          if (Charset.isSupported("UTF-16BE")) {
            encoding = CharEncoding.UTF_16BE;
          }
          theBytes = value.getBytes(encoding);
          data.appendBytes(encodeCount(value.length(), Type.kCFBinaryPlistMarkerUnicode16String));
        }
        data.appendBytes(theBytes);
        return data.bytes();
      }
      catch (UnsupportedEncodingException e) {
View Full Code Here

            encoding = CharEncoding.UTF_16BE;
          }
          theBytes = value.getBytes(encoding);
          data.appendBytes(encodeCount(value.length(), Type.kCFBinaryPlistMarkerUnicode16String));
        }
        data.appendBytes(theBytes);
        return data.bytes();
      }
      catch (UnsupportedEncodingException e) {
        throw NSForwardException._runtimeExceptionForThrowable(e);
      }
View Full Code Here

    /*
     * data 0100 nnnn [int] ... // nnnn is number of bytes unless 1111 then int count follows, followed by bytes
     */
    private byte[] encodeData(byte[] theData) {
      NSMutableData data = new NSMutableData(theData.length + 8);
      data.appendBytes(encodeCount(theData.length, Type.kCFBinaryPlistMarkerData));
      data.appendBytes(theData);
      return data.bytes();
    }

  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.