]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.server/src/org/simantics/db/server/protocol/GetResourceSegmentFunction.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.server / src / org / simantics / db / server / protocol / GetResourceSegmentFunction.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.server.protocol;\r
13 \r
14 import java.nio.ByteOrder;\r
15 \r
16 public class GetResourceSegmentFunction extends AbstractFunction {\r
17     public byte[] clusterUID = null;\r
18     public int resourceIndex = 0;\r
19     public long segmentOffset = 0;\r
20     public short segmentSize = 0;\r
21     public boolean isExternalResource = false;\r
22     public long valueSize = 0;\r
23     public byte[] segment = null;\r
24     public GetResourceSegmentFunction() {\r
25         super(MessageNumber.GetResourceSegmentRequest, MessageNumber.GetResourceSegmentResponse);\r
26     }\r
27     public GetResourceSegmentFunction(byte[] clusterUID, int resourceIndex, long segmentOffset, short segmentSize) {\r
28         super(MessageNumber.GetResourceSegmentRequest, MessageNumber.GetResourceSegmentResponse);\r
29         this.clusterUID = clusterUID;\r
30         this.resourceIndex = resourceIndex;\r
31         this.segmentOffset = segmentOffset;\r
32         this.segmentSize = segmentSize;\r
33     }\r
34     @Override\r
35     public DataBuffer serialize(ByteOrder byteOrder) {\r
36         buffer.clear();\r
37         buffer.order(byteOrder);\r
38         buffer.put(clusterUID);\r
39         buffer.put(resourceIndex);\r
40         buffer.put(segmentOffset);\r
41         buffer.put(segmentSize);\r
42         buffer.mark();\r
43         return buffer;\r
44     }\r
45     @Override\r
46     public void deserialize(int receivedNumber_, DataBuffer dataBuffer) {\r
47         receivedNumber = receivedNumber_;\r
48         if (notRightDataForUs())\r
49             return;\r
50         isExternalResource = dataBuffer.get(isExternalResource);\r
51         valueSize = dataBuffer.get(valueSize);\r
52         segment = dataBuffer.get(segment);\r
53         gotResponse();\r
54     }\r
55 }\r