Strabon

changeset 524:79b679426d4d

added method register() in stSPARQLQueryResultFormat to keep track of available stSPARQLResultsFormats
author Babis Nikolaou <charnik@di.uoa.gr>
date Sat Jul 28 15:49:30 2012 +0300 (2012-07-28)
parents e96319ec7b7c
children 9fcc1b2a52e3
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 15:20:58 2012 +0300
     1.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/stSPARQLQueryResultFormat.java	Sat Jul 28 15:49:30 2012 +0300
     1.3 @@ -1,8 +1,10 @@
     1.4  package org.openrdf.query.resultio;
     1.5  
     1.6  import java.nio.charset.Charset;
     1.7 +import java.util.ArrayList;
     1.8  import java.util.Arrays;
     1.9  import java.util.Collection;
    1.10 +import java.util.List;
    1.11  
    1.12  /**
    1.13   * Represents the concept of an tuple query result serialization format for
    1.14 @@ -61,6 +63,11 @@
    1.15  	public static final stSPARQLQueryResultFormat HTML = new stSPARQLQueryResultFormat("HTML", 
    1.16  			Arrays.asList("text/html"), Charset.forName("UTF-8"), Arrays.asList("html", "htm"));
    1.17  	
    1.18 +	/**
    1.19 +	 * The available stSPARQLQuery Result Formats
    1.20 +	 */
    1.21 +	private static final List<stSPARQLQueryResultFormat> VALUES = new ArrayList<stSPARQLQueryResultFormat>(6);
    1.22 +	
    1.23  	// registers stSPARQL/GeoSPARQL formats
    1.24  	static {
    1.25  		register(XML);
    1.26 @@ -72,6 +79,16 @@
    1.27  	}
    1.28  	
    1.29  	/**
    1.30 +	 * Register the specified stSPARQLQueryResultFormat.
    1.31 +	 * 
    1.32 +	 * @param format
    1.33 +	 */
    1.34 +	public static void register(stSPARQLQueryResultFormat format) {
    1.35 +		TupleQueryResultFormat.register(format);
    1.36 +		VALUES.add(format);
    1.37 +	}
    1.38 +	
    1.39 +	/**
    1.40  	 * Gets the stSPARQLQueryResultFormat given its name.
    1.41  	 * 
    1.42  	 * @param formatName
    1.43 @@ -95,6 +112,14 @@
    1.44  		return TupleQueryResultFormat.values();
    1.45  	}
    1.46  	
    1.47 +	public static stSPARQLQueryResultFormat forMIMEType(String mimeType) {
    1.48 +		return forMIMEType(mimeType, null);
    1.49 +	}
    1.50 +	
    1.51 +	public static stSPARQLQueryResultFormat forMIMEType(String mimeType, stSPARQLQueryResultFormat fallback) {
    1.52 +		return matchMIMEType(mimeType, VALUES, fallback);
    1.53 +	}
    1.54 +	
    1.55  	public stSPARQLQueryResultFormat(String name, String mimeType, String fileExt) {
    1.56  		super(name, mimeType, fileExt);
    1.57  	}