1 29 30 package com.hp.hpl.jena.rdf.model.impl; 31 32 import com.hp.hpl.jena.*; 33 import com.hp.hpl.jena.rdf.model.*; 34 import com.hp.hpl.jena.shared.*; 35 import java.util.Properties ; 36 import com.hp.hpl.jena.JenaRuntime ; 37 38 43 public class RDFReaderFImpl extends Object implements RDFReaderF { 44 45 protected static Properties langToClassName = null; 46 47 49 protected static final String LANGS[] = { "RDF/XML", 50 "RDF/XML-ABBREV", 51 "N-TRIPLE", 52 "N-TRIPLES", 53 "N3", 54 "TURTLE"}; 55 57 protected static final String DEFAULTREADERS[] = { 58 "com.hp.hpl.jena.rdf.arp.JenaReader", 59 "com.hp.hpl.jena.rdf.arp.JenaReader", 60 Jena.PATH + ".rdf.model.impl.NTripleReader", 61 Jena.PATH + ".rdf.model.impl.NTripleReader", 62 "com.hp.hpl.jena.n3.N3JenaReader", 63 "com.hp.hpl.jena.n3.TurtleJenaReader" 64 }; 65 66 protected static final String DEFAULTLANG = LANGS[0]; 67 68 protected static final String PROPNAMEBASE = Jena.PATH + ".reader."; 69 70 static { langToClassName = new Properties (); 72 for (int i = 0; i<LANGS.length; i++) { 73 langToClassName.setProperty( 74 LANGS[i], 75 JenaRuntime.getSystemProperty(PROPNAMEBASE + LANGS[i], 76 DEFAULTREADERS[i])); 77 } 78 } 79 80 81 82 public RDFReaderFImpl() { 83 } 84 85 public RDFReader getReader() { 86 return getReader(DEFAULTLANG); 87 } 88 89 public RDFReader getReader(String lang) { 90 91 if (lang==null || lang.equals("")) { 93 lang = LANGS[0]; 94 } 95 96 String className = langToClassName.getProperty(lang); 97 if (className == null || className.equals("")) { 98 throw new NoReaderForLangException( lang ); 99 } 100 try { 101 return (RDFReader) Class.forName(className) 102 .newInstance(); 103 } catch (Exception e) { 104 throw new JenaException(e); 105 } 106 } 107 108 public String setReaderClassName( String lang,String className ) { 109 return setBaseReaderClassName( lang, className ); 110 } 111 112 public static String setBaseReaderClassName( String lang, String className ) { 113 String oldClassName = langToClassName.getProperty(lang); 114 langToClassName.setProperty(lang, className); 115 return oldClassName; 116 } 117 } 118 | Popular Tags |