Last change
on this file since 1128 was
1128,
checked in by oschonef, 13 years ago
|
- initial import of OAI harvester (... now for real ;)
|
-
Property svn:eol-style set to
native
|
File size:
1.2 KB
|
Line | |
---|
1 | package eu.clarin.cmdi.oai.harvester.impl; |
---|
2 | |
---|
3 | import java.net.URI; |
---|
4 | import java.net.URISyntaxException; |
---|
5 | |
---|
6 | final class RequestUriBuilder { |
---|
7 | private static final String SEPARATOR_PARAMETER = "&"; |
---|
8 | private static final String SEPARATOR_NAME_VALUE = "="; |
---|
9 | private static final String ARG_VERB = "verb"; |
---|
10 | private final StringBuilder builder = new StringBuilder(); |
---|
11 | |
---|
12 | |
---|
13 | RequestUriBuilder setVerb(String verb) { |
---|
14 | builder.setLength(0); // clear builder |
---|
15 | return addParameter(ARG_VERB, verb); |
---|
16 | } |
---|
17 | |
---|
18 | public RequestUriBuilder addParameter(String name, String value) { |
---|
19 | if (builder.length() > 0) { |
---|
20 | builder.append(SEPARATOR_PARAMETER); |
---|
21 | } |
---|
22 | builder.append(name); |
---|
23 | builder.append(SEPARATOR_NAME_VALUE); |
---|
24 | builder.append(value); |
---|
25 | return this; |
---|
26 | } |
---|
27 | |
---|
28 | public URI createURI(URI baseURI) { |
---|
29 | try { |
---|
30 | return new URI(baseURI.getScheme(), null, baseURI.getHost(), |
---|
31 | baseURI.getPort(), baseURI.getPath(), builder.toString(), |
---|
32 | null); |
---|
33 | } catch (URISyntaxException e) { |
---|
34 | throw new InternalError("should not happen: " + e); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | } // class RequestUriBuilder |
---|
Note: See
TracBrowser
for help on using the repository browser.