This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
OslcQueryParameters.java
190 lines (167 loc) · 3.85 KB
/
OslcQueryParameters.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
*
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
*
* Michael Fiedler - initial API and implementation
*******************************************************************************/
package org.eclipse.lyo.oslc4j.client.resources;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* A container for OSLC Query parameters which can be associated with an OslcQuery object.
*
* @see OslcQuery
*
*/
public class OslcQueryParameters {
private String where;
private String select;
private String searchTerms;
private String orderBy;
private String prefix;
private String configurationContext;
private static final Logger logger = Logger.getLogger(OslcQuery.class.getName());
public OslcQueryParameters()
{
}
/**
* Initialize an OSLC Parameter using the supplied terms
*
* @param where
* @param select
* @param searchTerms
* @param orderBy
* @param prefix
*/
public OslcQueryParameters (String where, String select, String searchTerms, String orderBy, String prefix) {
this.where = where;
this.select = select;
this.searchTerms = searchTerms;
this.orderBy = orderBy;
this.prefix = prefix;
}
/**
* Initialize an OSLC Parameter using the supplied terms
*
* @param where
* @param select
* @param searchTerms
* @param orderBy
* @param prefix
* @param configurationContext
*/
public OslcQueryParameters (String where, String select, String searchTerms, String orderBy, String prefix,
String configurationContext) {
this.where = where;
this.select = select;
this.searchTerms = searchTerms;
this.orderBy = orderBy;
this.prefix = prefix;
this.configurationContext = configurationContext;
}
/**
*
* @return
*/
public String getWhere() {
return where;
}
/**
*
* @param where
*/
public void setWhere(String where) {
this.where = where;
}
/**
*
* @return
*/
public String getSelect() {
return select;
}
/**
*
* @param select
*/
public void setSelect(String select) {
this.select = select;
}
/**
*
* @return
*/
public String getSearchTerms() {
return searchTerms;
}
/**
*
* @param searchTerms
*/
public void setSearchTerms(String searchTerms) {
this.searchTerms = searchTerms;
}
/**
*
* @return
*/
public String getOrderBy() {
return orderBy;
}
/**
*
* @param orderBy
*/
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
/**
*
* @return
*/
public String getPrefix() {
return prefix;
}
/**
*
* @param prefix
*/
public void setPrefix(String prefix) {
this.prefix = prefix;
}
/**
*
* @return
*/
public String getConfigurationContext() {
return configurationContext;
}
/**
*
* @param configurationContext
*/
public void setConfigurationContext(String configurationContext) {
this.configurationContext = configurationContext;
}
private String encodeQueryParams(String oslcQueryParam) {
String encodedQueryParms = null;
try {
encodedQueryParms = URLEncoder.encode(oslcQueryParam, "UTF-8");
} catch (UnsupportedEncodingException e) {
//Should not occur
logger.log(Level.SEVERE, "Could not UTF-8 encode query parameters: " + oslcQueryParam, e);
}
return encodedQueryParms;
}
}