Strabon

changeset 329:a449fcf2e56c

added enumeration type for result formats
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Jun 22 19:56:58 2012 +0300 (2012-06-22)
parents 5a4a3f40bead
children 26fe4bcae66a
files resultio/src/main/java/org/openrdf/query/resultio/sparqlxml/Format.java
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/sparqlxml/Format.java	Fri Jun 22 19:56:58 2012 +0300
     1.3 @@ -0,0 +1,90 @@
     1.4 +package org.openrdf.query.resultio.sparqlxml;
     1.5 +
     1.6 +import java.util.HashMap;
     1.7 +import java.util.Map;
     1.8 +
     1.9 +/**
    1.10 + * This enumeration type represents the available formats
    1.11 + * for the results of the evaluation of a SPARQL query.
    1.12 + * 
    1.13 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    1.14 + *
    1.15 + */
    1.16 +public enum Format {
    1.17 +
    1.18 +	/**
    1.19 +	 * Default format
    1.20 +	 */
    1.21 +	DEFAULT(""),
    1.22 +	
    1.23 +	/**
    1.24 +	 * XML format
    1.25 +	 */
    1.26 +	XML("XML"),
    1.27 +	
    1.28 +	/**
    1.29 +	 * KML format
    1.30 +	 */
    1.31 +	KML("KML"),
    1.32 +	
    1.33 +	/**
    1.34 +	 * KMZ format (compressed KML)
    1.35 +	 */
    1.36 +	KMZ("KMZ"),
    1.37 +	
    1.38 +	/**
    1.39 +	 * GeoJSON format
    1.40 +	 */
    1.41 +	GEOJSON("GeoJSON"),
    1.42 +	
    1.43 +	/**
    1.44 +	 * Format for experiments
    1.45 +	 */
    1.46 +	EXP("EXP"),
    1.47 +	
    1.48 +	/**
    1.49 +	 * HTML format
    1.50 +	 */
    1.51 +	HTML("HTML");
    1.52 +	
    1.53 +	/**
    1.54 +	 * The string representation of this format
    1.55 +	 */
    1.56 +	private String name;
    1.57 +	
    1.58 +	/**
    1.59 +	 * Map a string constant to a Format
    1.60 +	 */
    1.61 +	private static final Map<String, Format> stringToEnum = new HashMap<String, Format>();
    1.62 +	
    1.63 +	
    1.64 +	static { // initialize map from constant name to enum constant
    1.65 +		for (Format format : values()) {
    1.66 +			stringToEnum.put(format.toString(), format);
    1.67 +		}
    1.68 +	}
    1.69 +	
    1.70 +	/**
    1.71 +	 * Format constructor.
    1.72 +	 * 
    1.73 +	 * @param name
    1.74 +	 */
    1.75 +	Format(String name) {
    1.76 +		this.name = name;
    1.77 +	}
    1.78 +	
    1.79 +	@Override
    1.80 +	public String toString() {
    1.81 +		return name;
    1.82 +	}
    1.83 +	
    1.84 +	/**
    1.85 +	 * Returns a Format enum given a language string.
    1.86 +	 * 
    1.87 +	 * @param lang
    1.88 +	 * @return
    1.89 +	 */
    1.90 +	public static Format fromString(String lang) {
    1.91 +		return stringToEnum.get(lang);
    1.92 +	}
    1.93 +}