]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.server/src/org/simantics/db/server/protocol/ExceptionFunction.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.server / src / org / simantics / db / server / protocol / ExceptionFunction.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 ExceptionFunction extends AbstractFunction {\r
17     public int messageNumber = 0;\r
18     public String what = "";\r
19     public int errorClass = 0;\r
20     public ExceptionFunction() {\r
21         super(MessageNumber.ExceptionRequest, MessageNumber.ExceptionResponse);\r
22     }\r
23     public ExceptionFunction(int messageNumber, String what) {\r
24         super(MessageNumber.ExceptionRequest, MessageNumber.ExceptionResponse);\r
25         this.messageNumber = messageNumber;\r
26         this.what = what;\r
27     }\r
28     @Override\r
29     public DataBuffer serialize(ByteOrder byteOrder) {\r
30         buffer.clear();\r
31         buffer.order(byteOrder);\r
32         buffer.put(messageNumber);\r
33         buffer.put(what);\r
34         buffer.mark();\r
35         return buffer;\r
36     }\r
37     @Override\r
38     public void deserialize(int receivedNumber_, DataBuffer dataBuffer) {\r
39         receivedNumber = receivedNumber_;\r
40         if (notRightDataForUs())\r
41             return;\r
42         messageNumber = dataBuffer.get(messageNumber);\r
43         errorClass = dataBuffer.get(errorClass);\r
44         what = dataBuffer.get(what);\r
45         gotResponse();\r
46     }\r
47 }\r