]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.server/src/org/simantics/db/server/protocol/AbstractMessage.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.server / src / org / simantics / db / server / protocol / AbstractMessage.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 public abstract class AbstractMessage extends Message {
15         protected final int requestNumber;
16         protected final int responseNumber;
17         protected int receivedNumber = 0;
18         protected boolean responsePending = false;
19         protected DataBuffer buffer;
20         private String exceptionText = null;
21         AbstractMessage(int requestNumber, int responseNumber) {
22                 this.requestNumber = requestNumber;
23                 this.responseNumber = responseNumber;
24                 this.buffer = new DataBuffer(DataBuffer.Allocation.DirectAllocation); //ByteBuffer.allocate(0);
25         }
26         AbstractMessage(int requestNumber, int responseNumber, DataBuffer buffer) {
27                 this.requestNumber = requestNumber;
28                 this.responseNumber = responseNumber;
29                 this.buffer = buffer;
30         }
31     public int getRequestNumber() {
32         return requestNumber;
33     }
34     public int getResponseNumber() {
35         return responseNumber;
36     }
37         @Override
38         boolean hasResponse() {
39                 return responseNumber != 0;
40         }
41         @Override
42         String getExceptionText() {
43                 return this.exceptionText;
44         }
45         @Override
46         void setExceptionText(String text) {
47                 this.exceptionText = text;
48         }
49     void gotResponse() {
50         responsePending = false;
51     }
52 }