Subversion Repositories XServices

Rev

Rev 66 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
66 brianR 1
/*
2
 *   Copyright 2011 Brian Rosenberger (Brutex Network)
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
package net.brutex.xservices.ws;
18
 
19
import java.math.BigInteger;
20
import java.util.GregorianCalendar;
21
 
22
import javax.jws.WebMethod;
23
import javax.jws.WebParam;
24
import javax.jws.WebService;
25
import javax.xml.bind.annotation.XmlElement;
26
 
27
import net.brutex.xservices.types.DateFormatType;
28
import net.brutex.xservices.types.DateTimeUnits;
29
import net.brutex.xservices.util.BrutexNamespaces;
30
 
31
import org.apache.cxf.annotations.WSDLDocumentation;
32
import org.apache.cxf.annotations.WSDLDocumentationCollection;
33
 
34
/**
35
 * Date and time related services.
36
 * @author Brian Rosenberger
37
 *
38
 */
39
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES)
40
@WSDLDocumentationCollection(
41
    {
42
    	@WSDLDocumentation(value = BrutexNamespaces.BRUTEX_COPYRIGHT, placement = WSDLDocumentation.Placement.TOP)
43
    }
44
)
45
public interface DateService {
46
 
47
	public static final String SERVICE_NAME = "DateService";
48
	public static final String OPERATION_GETDATE = "getDate";
49
	public static final String OPERATION_GETTIMESTAMP = "getTimestamp";
50
	public static final String OPERATION_GETINTIMEZONE = "getInTimezone";
51
	public static final String OPERATION_FORMATDATE = "formatDate";
52
	public static final String OPERATION_FORMATDATEADVANCED = "formatDateAdvanced";
53
	public static final String OPERATION_PARSEDATE = "parseDate";
54
	public static final String OPERATION_PARSEDATEADVANCED = "parseDateAdvanced";
55
	public static final String OPERATION_DATETIMEDIFF = "dateTimeDiff";
56
	public static final String OPERATION_DATETIMEDIFF2 = "dateTimeDiff2";
68 brianR 57
	public static final String OPERATION_DATEADD = "dateAdd";
66 brianR 58
 
59
	public static final String PARAM_TIMEZONE = "timezone";
60
	public static final String PARAM_DATETIME = "datetime";
61
	public static final String PARAM_FORMAT = "format";
68 brianR 62
	public static final String PARAM_UNIT = "unit";
66 brianR 63
 
64
	/**
65
	 * Get current date and time.
66
	 *
67
	 * @param timezone Optional timezone. Defaults to server timezone.
68
	 * @return Current date and time.
69
	 * @throws XServicesFault
70
	 */
71
	@WebMethod(operationName=OPERATION_GETDATE)
72
	@WSDLDocumentation(value="Get current date and time.")
73
	public abstract GregorianCalendar getDate(
74
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
75
 
76
	/**
77
	 * Get milliseconds since 01.01.1970.
78
	 *
79
	 * @return timestamp milliseconds
80
	 */
81
	@WebMethod(operationName=OPERATION_GETTIMESTAMP)
82
	@WSDLDocumentation(value="Get milliseconds since 01.01.1970 (Unix timestap).")
83
	public abstract BigInteger getTimestamp();
84
 
85
	/**
86
	 * Display a date time with a different time zone.
87
	 * Changes representation only (no conversion).
88
	 *
89
	 * @param cal date time.
90
	 * @param timezone time zone
91
	 * @return date time
92
	 * @throws XServicesFault
93
	 */
94
	@WebMethod(operationName=OPERATION_GETINTIMEZONE)
95
	public abstract GregorianCalendar getInTimezone(
96
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
97
			@WebParam(name=PARAM_TIMEZONE) @XmlElement(required=true) String timezone) throws XServicesFault;
98
 
99
	/**
100
	 * @param cal
101
	 * @param format
102
	 * @return formatted date/time string
103
	 * @throws XServicesFault
104
	 */
105
	@WebMethod(operationName=OPERATION_FORMATDATE)
106
	public abstract String formatDate(
107
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
108
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format) throws XServicesFault;
109
 
110
	@WebMethod(operationName=OPERATION_FORMATDATEADVANCED)
111
	public abstract String formatDateAdvanced(
112
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
113
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format) throws XServicesFault;
114
 
115
	@WebMethod(operationName=OPERATION_PARSEDATE)
116
	public abstract GregorianCalendar parseDate(
117
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
118
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format,
119
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
120
 
121
	@WebMethod(operationName=OPERATION_PARSEDATEADVANCED)
122
	public abstract GregorianCalendar parseDateAdvanced(
123
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
124
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format,
125
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
126
 
127
	@WebMethod(operationName=OPERATION_DATETIMEDIFF)
128
	public abstract BigInteger dateTimeDiff(
129
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
130
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal) throws XServicesFault;
131
 
132
	/**
133
	 * Fully elapsed units between two dates.
134
	 * 4:15:10-4:15:55 in minutes = 0 and in seconds = 45
135
	 *
136
	 * @param fromCal
137
	 * @param toCal
138
	 * @param unit
139
	 * @return Date/time difference in unit
140
	 * @throws XServicesFault
141
	 */
142
	@WebMethod(operationName=OPERATION_DATETIMEDIFF2)
143
	@WSDLDocumentation(value="Get elapsed time between to dates.")
144
	public abstract BigInteger dateTimeDiff2(
145
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
146
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal,
68 brianR 147
			@WebParam(name="PARAM_UNIT") DateTimeUnits unit) throws XServicesFault;
148
 
149
	/**
150
	 * Add or substract a time span from a date.
151
	 *
152
	 * @param cal
153
	 * @param unit
154
	 * @return New date and time.
155
	 * @throws XServicesFault
156
	 */
157
	@WebMethod(operationName=OPERATION_DATEADD)
158
	@WSDLDocumentation(value="Add or substract a time span from a date.")
159
	public abstract GregorianCalendar dateAdd(
160
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
161
			@WebParam(name="value") @XmlElement(required=true) BigInteger value,
162
			@WebParam(name=PARAM_UNIT) @XmlElement(required=true) DateTimeUnits unit) throws XServicesFault;
163
 
66 brianR 164
}