]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.server/src/org/simantics/db/server/protocol/GetResourceSegmentFunction.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.server / src / org / simantics / db / server / protocol / GetResourceSegmentFunction.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.server.protocol;
13
14 import java.nio.ByteOrder;
15
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);
26     }
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;
33     }
34     @Override
35     public DataBuffer serialize(ByteOrder byteOrder) {
36         buffer.clear();
37         buffer.order(byteOrder);
38         buffer.put(clusterUID);
39         buffer.put(resourceIndex);
40         buffer.put(segmentOffset);
41         buffer.put(segmentSize);
42         buffer.mark();
43         return buffer;
44     }
45     @Override
46     public void deserialize(int receivedNumber_, DataBuffer dataBuffer) {
47         receivedNumber = receivedNumber_;
48         if (notRightDataForUs())
49             return;
50         isExternalResource = dataBuffer.get(isExternalResource);
51         valueSize = dataBuffer.get(valueSize);
52         segment = dataBuffer.get(segment);
53         gotResponse();
54     }
55 }