KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > ws > rm > MessageNumber


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 package org.apache.sandesha.ws.rm;
19
20 import org.apache.axis.AxisFault;
21 import org.apache.axis.message.MessageElement;
22 import org.apache.sandesha.Constants;
23
24 import javax.xml.namespace.QName JavaDoc;
25 import javax.xml.soap.SOAPException JavaDoc;
26
27 /**
28  * class MessageNumber
29  *
30  * @author Amila Navarathna
31  * @author Jaliya Ekanayaka
32  * @author Sudar Nimalan
33  */

34 public class MessageNumber implements IRmElement {
35
36     /**
37      * Field messageNumber
38      */

39     private long messageNumber;
40
41     /**
42      * Field messageNoElement
43      */

44     private MessageElement messageNoElement;
45
46     /**
47      * Constructor MessageNumber
48      */

49     public MessageNumber() {
50
51         messageNoElement = new MessageElement();
52
53         messageNoElement.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.MSG_NUMBER);
54     }
55
56     /**
57      * Method getMessageNumber
58      *
59      * @return long
60      */

61     public long getMessageNumber() {
62         return messageNumber;
63     }
64
65     /**
66      * Method getSoapElement
67      *
68      * @return MessageElement
69      * @throws SOAPException
70      */

71     public MessageElement getSoapElement() throws SOAPException JavaDoc {
72
73         // create the soap element for the message no
74
messageNoElement.addTextNode((new Long JavaDoc(messageNumber)).toString());
75         return messageNoElement;
76     }
77
78     /**
79      * Method fromSOAPEnvelope
80      *
81      * @param element
82      * @return MessageNumber
83      */

84     public MessageNumber fromSOAPEnvelope(MessageElement element) throws AxisFault {
85
86         double tempMsgNo = (new Double JavaDoc(element.getValue())).doubleValue();
87         if (tempMsgNo >= Constants.WSRM.MAX_MSG_NO)
88             throw new AxisFault(new QName JavaDoc(Constants.FaultCodes.WSRM_FAULT_MSG_NO_ROLLOVER),
89                     Constants.FaultMessages.MSG_NO_ROLLOVER, null, null);
90
91         messageNumber = (new Long JavaDoc(element.getValue())).longValue();
92         return this;
93     }
94
95     /**
96      * Method toSOAPEnvelope
97      *
98      * @param msgElement
99      * @return MessageElement
100      * @throws SOAPException
101      */

102     public MessageElement toSOAPEnvelope(MessageElement msgElement) throws SOAPException JavaDoc {
103
104         msgElement.addChildElement(Constants.WSRM.MSG_NUMBER, Constants.WSRM.NS_PREFIX_RM)
105                 .addTextNode((new Long JavaDoc(messageNumber)).toString());
106
107         return msgElement;
108     }
109
110     /**
111      * Method setMessageNumber Set the message no in the soap message element
112      * create
113      *
114      * @param msgNo the message no
115      */

116     public void setMessageNumber(long msgNo) {
117         messageNumber = msgNo;
118     }
119
120
121     /**
122      * Method addChildElement
123      *
124      * @param element
125      */

126     public void addChildElement(MessageElement element) {
127     }
128 }
Popular Tags