Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSMutableData


     * int 0001 nnnn ... // # of bytes is 2^nnnn, big-endian bytes
     *
     * @see offsetIntSize
     */
    private byte[] encodeInt(long value) {
      NSMutableData data = new NSMutableData();
      if (value > Integer.MAX_VALUE || value < 0) {
        data.appendByte((byte) typeMarker(Type.kCFBinaryPlistMarkerInt, 3));
        data.appendByte((byte) ((value >>> 56) & 0xff));
        data.appendByte((byte) ((value >>> 48) & 0xff));
        data.appendByte((byte) ((value >>> 40) & 0xff));
        data.appendByte((byte) ((value >>> 32) & 0xff));
        data.appendByte((byte) ((value >>> 24) & 0xff));
        data.appendByte((byte) ((value >>> 16) & 0xff));
        data.appendByte((byte) ((value >>> 8) & 0xff));
        data.appendByte((byte) ((value >>> 0) & 0xff));
      } else if (value > Short.MAX_VALUE || value < Short.MIN_VALUE) {
        data.appendByte((byte) typeMarker(Type.kCFBinaryPlistMarkerInt, 2));
        data.appendByte((byte) ((value >>> 24) & 0xff));
        data.appendByte((byte) ((value >>> 16) & 0xff));
        data.appendByte((byte) ((value >>> 8) & 0xff));
        data.appendByte((byte) ((value >>> 0) & 0xff));
      } else {
        data.appendByte((byte) typeMarker(Type.kCFBinaryPlistMarkerInt, 1));
        data.appendByte((byte) ((value >>> 8) & 0xff));
        data.appendByte((byte) ((value >>> 0) & 0xff));
      }
      return data.bytes();
    }
View Full Code Here


     */
    private byte[] encodeUUID(UUID value) {
      long mostSigBits = value.getMostSignificantBits();
      long leastSigBits = value.getLeastSignificantBits();

      NSMutableData data = new NSMutableData();
      data.appendByte((byte) typeMarker(Type.kCFBinaryPlistMarkerUID, 0x0f));
      data.appendByte((byte) ((mostSigBits >>> 56) & 0xff));
      data.appendByte((byte) ((mostSigBits >>> 48) & 0xff));
      data.appendByte((byte) ((mostSigBits >>> 40) & 0xff));
      data.appendByte((byte) ((mostSigBits >>> 32) & 0xff));
      data.appendByte((byte) ((mostSigBits >>> 24) & 0xff));
      data.appendByte((byte) ((mostSigBits >>> 16) & 0xff));
      data.appendByte((byte) ((mostSigBits >>> 8) & 0xff));
      data.appendByte((byte) ((mostSigBits >>> 0) & 0xff));

      data.appendByte((byte) ((leastSigBits >>> 56) & 0xff));
      data.appendByte((byte) ((leastSigBits >>> 48) & 0xff));
      data.appendByte((byte) ((leastSigBits >>> 40) & 0xff));
      data.appendByte((byte) ((leastSigBits >>> 32) & 0xff));
      data.appendByte((byte) ((leastSigBits >>> 24) & 0xff));
      data.appendByte((byte) ((leastSigBits >>> 16) & 0xff));
      data.appendByte((byte) ((leastSigBits >>> 8) & 0xff));
      data.appendByte((byte) ((leastSigBits >>> 0) & 0xff));

      return data.bytes();
    }
View Full Code Here

    /**
     * real 0010 nnnn ... // # of bytes is 2^nnnn, big-endian bytes
     */
    private byte[] encodeReal(double value) {
      NSMutableData data = new NSMutableData();
      if (value > Float.MAX_VALUE || value < Float.MIN_VALUE) {
        data.appendByte((byte) typeMarker(Type.kCFBinaryPlistMarkerReal, 3));
        long bits = Double.doubleToLongBits(value);
        data.appendByte((byte) ((bits >>> 56) & 0xff));
        data.appendByte((byte) ((bits >>> 48) & 0xff));
        data.appendByte((byte) ((bits >>> 40) & 0xff));
        data.appendByte((byte) ((bits >>> 32) & 0xff));
        data.appendByte((byte) ((bits >>> 24) & 0xff));
        data.appendByte((byte) ((bits >>> 16) & 0xff));
        data.appendByte((byte) ((bits >>> 8) & 0xff));
        data.appendByte((byte) ((bits >>> 0) & 0xff));
      } else {
        data.appendByte((byte) typeMarker(Type.kCFBinaryPlistMarkerReal, 2));
        int bits = Float.floatToIntBits((float) value);
        data.appendByte((byte) ((bits >>> 24) & 0xff));
        data.appendByte((byte) ((bits >>> 16) & 0xff));
        data.appendByte((byte) ((bits >>> 8) & 0xff));
        data.appendByte((byte) ((bits >>> 0) & 0xff));
      }
      return data.bytes();
    }
View Full Code Here

  @Override
  public void _finalizeInContext(WOContext originalContext) {
    super._finalizeInContext(originalContext);
    if (marks != null && marks.size() > 0) {
      Context context = currentContext();
      NSMutableData content = new NSMutableData();
      int last = 0;
      for (Map.Entry<String, Integer> entry : marks.entrySet()) {
        String key = entry.getKey();
        Integer offset = entry.getValue();
        NSRange range = new NSRange(last, offset - last);
        NSData data = content().subdataWithRange(range);
        content.appendData(data);
        ERXResponse partial = context.partials.get(key);
        if (partial != null) {
          NSData partialData = partial.content();
          content.appendData(partialData);
        }
        last = offset;
      }
      NSRange range = new NSRange(last, _contentLength() - last);
      NSData data = content().subdataWithRange(range);
      content.appendData(data);
      setContent(content);
    }
  }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSMutableData

Copyright © 2018 www.massapicom. 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.