Strabon
changeset 520:55c2dcbfb273
added method valueOf() to return an stSPARQLQueryResultFormat instance according to a format name
author | Babis Nikolaou <charnik@di.uoa.gr> |
---|---|
date | Sat Jul 28 13:25:59 2012 +0300 (2012-07-28) |
parents | 81346ef0ee23 |
children | 0098de3c67c8 |
files | resultio/src/main/java/org/openrdf/query/resultio/stSPARQLQueryResultFormat.java |
line diff
1.1 --- a/resultio/src/main/java/org/openrdf/query/resultio/stSPARQLQueryResultFormat.java Sat Jul 28 03:40:49 2012 +0300 1.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/stSPARQLQueryResultFormat.java Sat Jul 28 13:25:59 2012 +0300 1.3 @@ -47,7 +47,7 @@ 1.4 * GeoJSON format (see http://www.geojson.org/geojson-spec.html) 1.5 */ 1.6 public static final stSPARQLQueryResultFormat GEOJSON = new stSPARQLQueryResultFormat("GeoJSON", 1.7 - Arrays.asList("application/json", "application/json"), Charset.forName("UTF-8"), Arrays.asList("json")); 1.8 + Arrays.asList("application/json", "application/geojson"), Charset.forName("UTF-8"), Arrays.asList("json")); 1.9 1.10 /** 1.11 * Tab separated value format (extension of {@link TupleQueryResultFormat#TSV} format to include geometries) 1.12 @@ -71,6 +71,30 @@ 1.13 register(HTML); 1.14 } 1.15 1.16 + /** 1.17 + * Gets the stSPARQLQueryResultFormat given its name. 1.18 + * 1.19 + * @param formatName 1.20 + * @return 1.21 + */ 1.22 + public static stSPARQLQueryResultFormat valueOf(String formatName) { 1.23 + for (TupleQueryResultFormat format : values()) { 1.24 + if (format instanceof stSPARQLQueryResultFormat && 1.25 + format.getName().equalsIgnoreCase(formatName)) { 1.26 + return (stSPARQLQueryResultFormat) format; 1.27 + } 1.28 + } 1.29 + 1.30 + return null; 1.31 + } 1.32 + 1.33 + /** 1.34 + * Returns all known/registered tuple query result formats. 1.35 + */ 1.36 + public static Collection<TupleQueryResultFormat> values() { 1.37 + return TupleQueryResultFormat.values(); 1.38 + } 1.39 + 1.40 public stSPARQLQueryResultFormat(String name, String mimeType, String fileExt) { 1.41 super(name, mimeType, fileExt); 1.42 }