本文整理匯總了Java中org.openrdf.rio.RDFFormat.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java RDFFormat.equals方法的具體用法?Java RDFFormat.equals怎麽用?Java RDFFormat.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openrdf.rio.RDFFormat
的用法示例。
在下文中一共展示了RDFFormat.equals方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performAdd
import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
/**
* executes merge of triples from File
*
* @param file
* @param baseURI
* @param dataFormat
* @param tx
* @param contexts
* @throws RDFParseException
*/
// performAdd
// as we use mergeGraphs, baseURI is always file.toURI
public void performAdd(File file, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException {
try {
graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType());
if (dataFormat.equals(RDFFormat.NQUADS) || dataFormat.equals(RDFFormat.TRIG)) {
graphManager.mergeGraphs(new FileHandle(file),tx);
} else {
if (notNull(contexts) && contexts.length>0) {
for (int i = 0; i < contexts.length; i++) {
if(notNull(contexts[i])){
graphManager.mergeAs(contexts[i].toString(), new FileHandle(file), getGraphPerms(),tx);
}else{
graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file),getGraphPerms(), tx);
}
}
} else {
graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file), getGraphPerms(),tx);
}
}
} catch (FailedRequestException e) {
logger.error(e.getLocalizedMessage());
throw new RDFParseException("Request to MarkLogic server failed, check file and format.");
}
}
示例2: checkFileParseable
import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
private static void checkFileParseable(@Nullable final File file,
@Nullable final String formatString) {
if (file == null) {
if (formatString == null) {
throw new IllegalArgumentException("Cannot detect RDF format "
+ "and compression of STDIN: please specify option -s");
}
return;
}
checkFileExist(file);
final RDFFormat defaultFormat = detectRDFFormat(formatString, null);
final Compression defaultCompression = detectCompression(formatString, null);
final RDFFormat format = RDFFormat.forFileName(file.getName());
if (format == null && defaultFormat == null) {
throw new IllegalArgumentException("Unknown RDF format for file " + file);
} else if (format != null && defaultFormat != null && !format.equals(defaultFormat)) {
System.err.println("Warning: detected RDF format for file " + file
+ " doesn't match specified format");
}
final Compression compression = Compression.forFileName(file.getName(), Compression.NONE);
if (defaultCompression != null && !compression.equals(defaultCompression)) {
System.err.println("Warning: detected compression format for file " + file
+ " doesn't match specified format");
}
}
示例3: writeRDF
import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
public static RDFHandler writeRDF(final OutputStream out, final RDFFormat format,
@Nullable final Map<String, String> namespaces,
@Nullable final Map<? extends RioSetting<?>, ? extends Object> settings)
throws IOException, RDFHandlerException {
final RDFWriter writer = Rio.createWriter(format, out);
final WriterConfig config = writer.getWriterConfig();
config.set(BasicWriterSettings.PRETTY_PRINT, true);
config.set(BasicWriterSettings.RDF_LANGSTRING_TO_LANG_LITERAL, true);
config.set(BasicWriterSettings.XSD_STRING_TO_PLAIN_LITERAL, true);
if (format.equals(RDFFormat.RDFXML)) {
config.set(XMLWriterSettings.INCLUDE_XML_PI, true);
config.set(XMLWriterSettings.INCLUDE_ROOT_RDF_TAG, true);
}
if (settings != null) {
for (final Map.Entry entry : settings.entrySet()) {
config.set((RioSetting) entry.getKey(), entry.getValue());
}
}
return namespaces == null ? writer : newNamespaceHandler(writer, namespaces, null);
}
示例4: readRDF
import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
public static void readRDF(final InputStream in, @Nullable final RDFFormat format,
@Nullable final Map<String, String> namespaces, @Nullable final String base,
final boolean preserveBNodes, final RDFHandler handler) throws IOException,
RDFParseException, RDFHandlerException {
final RDFParser parser = Rio.createParser(format);
parser.setValueFactory(Data.getValueFactory());
final ParserConfig config = parser.getParserConfig();
config.set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
config.set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true);
config.set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);
config.set(BasicParserSettings.VERIFY_LANGUAGE_TAGS, true);
config.set(BasicParserSettings.VERIFY_RELATIVE_URIS, true);
config.set(BasicParserSettings.NORMALIZE_DATATYPE_VALUES, true);
config.set(BasicParserSettings.NORMALIZE_LANGUAGE_TAGS, true);
config.set(BasicParserSettings.PRESERVE_BNODE_IDS, preserveBNodes);
if (format.equals(RDFFormat.NTRIPLES)) {
config.set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, true);
} else if (format.equals(RDFFormat.JSONLD)) {
// following parameters are currently ignored by used library
config.set(JSONLDSettings.COMPACT_ARRAYS, true);
config.set(JSONLDSettings.OPTIMIZE, true);
config.set(JSONLDSettings.USE_NATIVE_TYPES, false);
config.set(JSONLDSettings.USE_RDF_TYPE, false);
config.set(JSONLDSettings.JSONLD_MODE, JSONLDMode.COMPACT);
} else if (format.equals(RDFFormat.RDFJSON)) {
config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_DATATYPES, true);
config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_LANGUAGES, true);
config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_TYPES, true);
config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_VALUES, true);
config.set(RDFJSONParserSettings.FAIL_ON_UNKNOWN_PROPERTY, true);
config.set(RDFJSONParserSettings.SUPPORT_GRAPHS_EXTENSION, true);
} else if (format.equals(RDFFormat.TRIX)) {
config.set(TriXParserSettings.FAIL_ON_TRIX_INVALID_STATEMENT, true);
config.set(TriXParserSettings.FAIL_ON_TRIX_MISSING_DATATYPE, false);
} else if (format.equals(RDFFormat.RDFXML)) {
config.set(XMLParserSettings.FAIL_ON_DUPLICATE_RDF_ID, true);
config.set(XMLParserSettings.FAIL_ON_INVALID_NCNAME, true);
config.set(XMLParserSettings.FAIL_ON_INVALID_QNAME, true);
config.set(XMLParserSettings.FAIL_ON_MISMATCHED_TAGS, true);
config.set(XMLParserSettings.FAIL_ON_NON_STANDARD_ATTRIBUTES, false);
config.set(XMLParserSettings.FAIL_ON_SAX_NON_FATAL_ERRORS, false);
}
if (namespaces != null && parser instanceof RDFParserBase) {
try {
final Field field = RDFParserBase.class.getDeclaredField("namespaceTable");
field.setAccessible(true);
field.set(parser, Data.newNamespaceMap(Data.newNamespaceMap(), namespaces));
} catch (final Throwable ex) {
// ignore
ex.printStackTrace();
}
}
parser.setRDFHandler(handler);
parser.parse(in, Strings.nullToEmpty(base));
}
示例5: packOntologies
import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
private void packOntologies(Map<URL, RDFFormat> rdfSources, File dir, String META_INF_ONTOLOGIES)
throws IOException {
File list = new File(dir, META_INF_ONTOLOGIES);
list.getParentFile().mkdirs();
PrintStream inf = new PrintStream(new FileOutputStream(list));
try {
for (URL rdf : rdfSources.keySet()) {
try {
RDFFormat format = rdfSources.get(rdf);
String path = "META-INF/ontologies/";
URLConnection conn = rdf.openConnection();
if (format != null) {
for (String type : format.getMIMETypes()) {
conn.addRequestProperty("Accept", type);
}
}
InputStream in = conn.getInputStream();
try {
String name = getLocalName(rdf.toExternalForm());
if (format != null && !format.equals(RDFFormat.forFileName(name))) {
name += "." + format.getDefaultFileExtension();
}
File file = new File(dir, path + name);
file.getParentFile().mkdirs();
OutputStream out = new FileOutputStream(file);
try {
int read;
byte[] buf = new byte[1024];
while ((read = in.read(buf)) >= 0) {
out.write(buf, 0, read);
}
} finally {
out.close();
}
inf.println(path + name);
} finally {
in.close();
}
} catch (ConnectException exc) {
throw new IOException("Cannot connect to " + rdf, exc);
}
}
} finally {
inf.close();
}
}