Source Code Cross Referenced for TupleQueryResultFormat.java in  » RSS-RDF » sesame » org » openrdf » query » resultio » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » sesame » org.openrdf.query.resultio 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
003:         *
004:         * Licensed under the Aduna BSD-style license.
005:         */
006:        package org.openrdf.query.resultio;
007:
008:        import java.nio.charset.Charset;
009:        import java.util.ArrayList;
010:        import java.util.Arrays;
011:        import java.util.Collection;
012:        import java.util.Collections;
013:        import java.util.List;
014:
015:        import info.aduna.lang.FileFormat;
016:
017:        /**
018:         * Represents the concept of an tuple query result serialization format. Tuple
019:         * query result formats are identified by a {@link #getName() name} and can have
020:         * one or more associated MIME types, zero or more associated file extensions
021:         * and can specify a (default) character encoding.
022:         * 
023:         * @author Arjohn Kampman
024:         */
025:        public class TupleQueryResultFormat extends FileFormat {
026:
027:            /*-----------*
028:             * Constants *
029:             *-----------*/
030:
031:            /**
032:             * SPARQL Query Results XML Format.
033:             */
034:            public static final TupleQueryResultFormat SPARQL = new TupleQueryResultFormat(
035:                    "SPARQL/XML", Arrays
036:                            .asList("application/sparql-results+xml",
037:                                    "application/xml"), Charset
038:                            .forName("UTF-8"), Arrays.asList("srx", "xml"));
039:
040:            /**
041:             * Binary RDF results table format.
042:             */
043:            public static final TupleQueryResultFormat BINARY = new TupleQueryResultFormat(
044:                    "BINARY", "application/x-binary-rdf-results-table", null,
045:                    "brt");
046:
047:            /**
048:             * SPARQL Query Results JSON Format.
049:             */
050:            public static final TupleQueryResultFormat JSON = new TupleQueryResultFormat(
051:                    "SPARQL/JSON", "application/sparql-results+json", Charset
052:                            .forName("UTF-8"), "srj");
053:
054:            /*------------------*
055:             * Static variables *
056:             *------------------*/
057:
058:            /**
059:             * List of known tuple query result formats.
060:             */
061:            private static List<TupleQueryResultFormat> VALUES = new ArrayList<TupleQueryResultFormat>(
062:                    8);
063:
064:            /*--------------------*
065:             * Static initializer *
066:             *--------------------*/
067:
068:            static {
069:                register(SPARQL);
070:                register(BINARY);
071:                register(JSON);
072:            }
073:
074:            /*----------------*
075:             * Static methods *
076:             *----------------*/
077:
078:            /**
079:             * Returns all known/registered tuple query result formats.
080:             */
081:            public static Collection<TupleQueryResultFormat> values() {
082:                return Collections.unmodifiableList(VALUES);
083:            }
084:
085:            /**
086:             * Registers the specified tuple query result format.
087:             * 
088:             * @param name
089:             *        The name of the format, e.g. "SPARQL/XML".
090:             * @param mimeType
091:             *        The MIME type of the format, e.g.
092:             *        <tt>application/sparql-results+xml</tt> for the SPARQL/XML file
093:             *        format.
094:             * @param fileExt
095:             *        The (default) file extension for the format, e.g. <tt>srx</tt>
096:             *        for SPARQL/XML files.
097:             */
098:            public static TupleQueryResultFormat register(String name,
099:                    String mimeType, String fileExt) {
100:                TupleQueryResultFormat format = new TupleQueryResultFormat(
101:                        name, mimeType, fileExt);
102:                register(format);
103:                return format;
104:            }
105:
106:            /**
107:             * Registers the specified tuple query result format.
108:             */
109:            public static void register(TupleQueryResultFormat format) {
110:                VALUES.add(format);
111:            }
112:
113:            /**
114:             * Tries to determine the appropriate tuple file format based on the a MIME
115:             * type that describes the content type.
116:             * 
117:             * @param mimeType
118:             *        A MIME type, e.g. "application/sparql-results+xml".
119:             * @return A TupleQueryResultFormat object if the MIME type was recognized,
120:             *         or <tt>null</tt> otherwise.
121:             * @see #forMIMEType(String,TupleQueryResultFormat)
122:             * @see #getMIMEType
123:             */
124:            public static TupleQueryResultFormat forMIMEType(String mimeType) {
125:                return forMIMEType(mimeType, null);
126:            }
127:
128:            /**
129:             * Tries to determine the appropriate tuple file format based on the a MIME
130:             * type that describes the content type. The supplied fallback format will be
131:             * returned when the MIME type was not recognized.
132:             * 
133:             * @param mimeType
134:             *        a MIME type, e.g. "application/sparql-results+xml"
135:             * @param fallback
136:             *        a fallback TupleQueryResultFormat that will be returned by the
137:             *        method if no match for the supplied MIME type can be found.
138:             * @return A TupleQueryResultFormat that matches the MIME type, or the
139:             *         fallback format if the extension was not recognized.
140:             * @see #forMIMEType(String)
141:             * @see #getMIMEType
142:             */
143:            public static TupleQueryResultFormat forMIMEType(String mimeType,
144:                    TupleQueryResultFormat fallback) {
145:                return matchMIMEType(mimeType, VALUES, fallback);
146:            }
147:
148:            /**
149:             * Tries to determine the appropriate tuple file format for a file, based on
150:             * the extension specified in a file name.
151:             * 
152:             * @param fileName
153:             *        A file name.
154:             * @return A TupleQueryResultFormat object if the file extension was
155:             *         recognized, or <tt>null</tt> otherwise.
156:             * @see #forFileName(String,TupleQueryResultFormat)
157:             * @see #getFileExtension
158:             */
159:            public static TupleQueryResultFormat forFileName(String fileName) {
160:                return forFileName(fileName, null);
161:            }
162:
163:            /**
164:             * Tries to determine the appropriate tuple file format for a file, based on
165:             * the extension specified in a file name. The supplied fallback format will
166:             * be returned when the file name extension was not recognized.
167:             * 
168:             * @param fileName
169:             *        A file name.
170:             * @return A TupleQueryResultFormat that matches the file name extension, or
171:             *         the fallback format if the extension was not recognized.
172:             * @see #forFileName(String)
173:             * @see #getFileExtension
174:             */
175:            public static TupleQueryResultFormat forFileName(String fileName,
176:                    TupleQueryResultFormat fallback) {
177:                return matchFileName(fileName, VALUES, fallback);
178:            }
179:
180:            /*--------------*
181:             * Constructors *
182:             *--------------*/
183:
184:            /**
185:             * Creates a new TupleQueryResultFormat object.
186:             * 
187:             * @param name
188:             *        The name of the format, e.g. "SPARQL/XML".
189:             * @param mimeType
190:             *        The MIME type of the format, e.g.
191:             *        <tt>application/sparql-results+xml</tt> for the SPARQL/XML
192:             *        format.
193:             * @param fileExt
194:             *        The (default) file extension for the format, e.g. <tt>srx</tt>
195:             *        for SPARQL/XML.
196:             */
197:            public TupleQueryResultFormat(String name, String mimeType,
198:                    String fileExt) {
199:                this (name, mimeType, null, fileExt);
200:            }
201:
202:            /**
203:             * Creates a new TupleQueryResultFormat object.
204:             * 
205:             * @param name
206:             *        The name of the format, e.g. "SPARQL/XML".
207:             * @param mimeType
208:             *        The MIME type of the format, e.g.
209:             *        <tt>application/sparql-results+xml</tt> for the SPARQL/XML
210:             *        format.
211:             * @param charset
212:             *        The default character encoding of the format. Specify <tt>null</tt>
213:             *        if not applicable.
214:             * @param fileExt
215:             *        The (default) file extension for the format, e.g. <tt>srx</tt>
216:             *        for SPARQL/XML.
217:             */
218:            public TupleQueryResultFormat(String name, String mimeType,
219:                    Charset charset, String fileExt) {
220:                super (name, mimeType, charset, fileExt);
221:            }
222:
223:            /**
224:             * Creates a new TupleQueryResultFormat object.
225:             * 
226:             * @param name
227:             *        The name of the format, e.g. "SPARQL/XML".
228:             * @param mimeTypes
229:             *        The MIME types of the format, e.g.
230:             *        <tt>application/sparql-results+xml</tt> for the SPARQL/XML
231:             *        format. The first item in the list is interpreted as the default
232:             *        MIME type for the format.
233:             * @param charset
234:             *        The default character encoding of the format. Specify <tt>null</tt>
235:             *        if not applicable.
236:             * @param fileExtensions
237:             *        The format's file extensions, e.g. <tt>srx</tt> for SPARQL/XML
238:             *        files. The first item in the list is interpreted as the default
239:             *        file extension for the format.
240:             */
241:            public TupleQueryResultFormat(String name,
242:                    Collection<String> mimeTypes, Charset charset,
243:                    Collection<String> fileExtensions) {
244:                super(name, mimeTypes, charset, fileExtensions);
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.