01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wfs.kvp;
06:
07: import net.opengis.ows.AcceptFormatsType;
08: import net.opengis.ows.OwsFactory;
09: import org.geoserver.ows.KvpParser;
10: import org.geoserver.ows.util.KvpUtils;
11: import java.util.Iterator;
12: import java.util.List;
13:
14: /**
15: * Parses a kvp of the form "acceptFormats=format1,format2,...,formatN" into
16: * an instance of {@link net.opengis.ows.v1_0_0.AcceptFormatsType}.
17: *
18: * @author Justin Deoliveira, The Open Planning Project
19: *
20: */
21: public class AcceptFormatsKvpParser extends KvpParser {
22: public AcceptFormatsKvpParser() {
23: super ("acceptFormats", AcceptFormatsType.class);
24: }
25:
26: public Object parse(String value) throws Exception {
27: List values = KvpUtils.readFlat(value);
28:
29: AcceptFormatsType acceptFormats = OwsFactory.eINSTANCE
30: .createAcceptFormatsType();
31:
32: for (Iterator v = values.iterator(); v.hasNext();) {
33: acceptFormats.getOutputFormat().add(v.next());
34: }
35:
36: return acceptFormats;
37: }
38: }
|