KickJava   Java API By Example, From Geeks To Geeks.

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


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.message.MessageElement;
21 import org.apache.sandesha.Constants;
22
23 import javax.xml.soap.SOAPElement JavaDoc;
24 import javax.xml.soap.SOAPException JavaDoc;
25
26 /**
27  * class AcknowledgementRange
28  *
29  * @author Amila Navarathna
30  * @author Jaliya Ekanayaka
31  * @author Sudar Nimalan
32  */

33 public class AcknowledgementRange implements IRmElement {
34
35     /**
36      * Field ackRangeElement
37      */

38     private MessageElement ackRangeElement;
39
40     /**
41      * Field minValue
42      */

43     private long minValue;
44
45     /**
46      * Field maxValue
47      */

48     private long maxValue;
49
50     /**
51      * Constructor AcknowledgementRange
52      */

53     public AcknowledgementRange() {
54         ackRangeElement = new MessageElement();
55         ackRangeElement.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.ACK_RANGE);
56     }
57
58     /**
59      * Method setMaxValue
60      *
61      * @param max
62      */

63     public void setMaxValue(long max) {
64         maxValue = max;
65     }
66
67     /**
68      * Method setMinValue
69      *
70      * @param min
71      */

72     public void setMinValue(long min) {
73         minValue = min;
74     }
75
76     /*
77      * (non-Javadoc)
78      *
79      * @see org.apache.sandesha.ws.rm.IRmElement#getSoapElement()
80      */

81
82     /**
83      * Method getSoapElement
84      *
85      * @return MessageElement
86      */

87     public MessageElement getSoapElement() {
88
89         ackRangeElement.setAttribute(Constants.WSRM.UPPER, new Long JavaDoc(maxValue).toString());
90         ackRangeElement.setAttribute(Constants.WSRM.LOWER, new Long JavaDoc(minValue).toString());
91
92         return ackRangeElement;
93     }
94
95     /**
96      * Method toSOAPEnvelope
97      *
98      * @param msgElement
99      * @return MessageElement
100      * @throws SOAPException
101      */

102     public MessageElement toSOAPEnvelope(MessageElement msgElement)
103             throws SOAPException JavaDoc {
104
105         SOAPElement JavaDoc ackRange = msgElement.addChildElement(Constants.WSRM.ACK_RANGE, Constants.WSRM.NS_PREFIX_RM);
106
107         ackRange.setAttribute(Constants.WSRM.UPPER, new Long JavaDoc(maxValue).toString());
108         ackRange.setAttribute(Constants.WSRM.LOWER, new Long JavaDoc(minValue).toString());
109
110         return msgElement;
111     }
112
113     /**
114      * Method fromSOAPEnvelope
115      *
116      * @param element
117      * @return AcknowledgementRange
118      */

119     public AcknowledgementRange fromSOAPEnvelope(MessageElement element) {
120
121         minValue = (new Long JavaDoc(element.getAttribute(Constants.WSRM.LOWER).trim())).longValue();
122         maxValue = (new Long JavaDoc(element.getAttribute(Constants.WSRM.UPPER).trim())).longValue();
123
124         return this;
125     }
126
127
128     /**
129      * Method addChildElement
130      *
131      * @param element
132      */

133     public void addChildElement(MessageElement element) {
134     }
135
136     /**
137      * Method getMaxValue
138      *
139      * @return long
140      */

141     public long getMaxValue() {
142         return maxValue;
143     }
144
145     /**
146      * Method getMinValue
147      *
148      * @return long
149      */

150     public long getMinValue() {
151         return minValue;
152     }
153 }
Popular Tags