1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.server.protocol;
14 import java.nio.ByteOrder;
16 public class GetResourceSegmentFunction extends AbstractFunction {
17 public byte[] clusterUID = null;
18 public int resourceIndex = 0;
19 public long segmentOffset = 0;
20 public short segmentSize = 0;
21 public boolean isExternalResource = false;
22 public long valueSize = 0;
23 public byte[] segment = null;
24 public GetResourceSegmentFunction() {
25 super(MessageNumber.GetResourceSegmentRequest, MessageNumber.GetResourceSegmentResponse);
27 public GetResourceSegmentFunction(byte[] clusterUID, int resourceIndex, long segmentOffset, short segmentSize) {
28 super(MessageNumber.GetResourceSegmentRequest, MessageNumber.GetResourceSegmentResponse);
29 this.clusterUID = clusterUID;
30 this.resourceIndex = resourceIndex;
31 this.segmentOffset = segmentOffset;
32 this.segmentSize = segmentSize;
35 public DataBuffer serialize(ByteOrder byteOrder) {
37 buffer.order(byteOrder);
38 buffer.put(clusterUID);
39 buffer.put(resourceIndex);
40 buffer.put(segmentOffset);
41 buffer.put(segmentSize);
46 public void deserialize(int receivedNumber_, DataBuffer dataBuffer) {
47 receivedNumber = receivedNumber_;
48 if (notRightDataForUs())
50 isExternalResource = dataBuffer.get(isExternalResource);
51 valueSize = dataBuffer.get(valueSize);
52 segment = dataBuffer.get(segment);