Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
owlapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ambuj Kumar Mondal
owlapi
Commits
73189913
There was an error fetching the commit references. Please try again later.
Commit
73189913
authored
Nov 14, 2020
by
ignazio
Browse files
Options
Downloads
Patches
Plain Diff
Specify RioSetting values for Rio renderers #614
parent
c54f6deb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rio/src/main/java/org/semanticweb/owlapi/rio/RioParserImpl.java
+20
-0
20 additions, 0 deletions
...c/main/java/org/semanticweb/owlapi/rio/RioParserImpl.java
rio/src/main/java/org/semanticweb/owlapi/rio/RioStorer.java
+53
-0
53 additions, 0 deletions
rio/src/main/java/org/semanticweb/owlapi/rio/RioStorer.java
with
73 additions
and
0 deletions
rio/src/main/java/org/semanticweb/owlapi/rio/RioParserImpl.java
+
20
−
0
View file @
73189913
...
...
@@ -40,10 +40,12 @@ import static org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.Reader
;
import
java.io.Serializable
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
...
...
@@ -62,6 +64,7 @@ import org.eclipse.rdf4j.rio.RDFHandlerException;
import
org.eclipse.rdf4j.rio.RDFParseException
;
import
org.eclipse.rdf4j.rio.RDFParser
;
import
org.eclipse.rdf4j.rio.Rio
;
import
org.eclipse.rdf4j.rio.RioSetting
;
import
org.eclipse.rdf4j.rio.UnsupportedRDFormatException
;
import
org.eclipse.rdf4j.rio.helpers.BasicParserSettings
;
import
org.eclipse.rdf4j.rio.helpers.StatementCollector
;
...
...
@@ -224,6 +227,7 @@ public class RioParserImpl extends AbstractOWLParser implements RioParser {
createParser
.
getParserConfig
().
addNonFatalError
(
BasicParserSettings
.
VERIFY_LANGUAGE_TAGS
);
createParser
.
getParserConfig
().
addNonFatalError
(
XMLParserSettings
.
DISALLOW_DOCTYPE_DECL
);
createParser
.
getParserConfig
().
set
(
XMLParserSettings
.
DISALLOW_DOCTYPE_DECL
,
Boolean
.
FALSE
);
addParametersIfPresent
(
documentSource
,
createParser
);
createParser
.
setRDFHandler
(
handler
);
long
rioParseStart
=
System
.
currentTimeMillis
();
if
(
owlFormatFactory
.
isTextual
()
&&
documentSource
.
isReaderAvailable
())
{
...
...
@@ -247,6 +251,22 @@ public class RioParserImpl extends AbstractOWLParser implements RioParser {
}
}
// These warnings are suppressed because the types cannot be easily determined here without
// forcing constraints that might need to be updated when Rio introduces new settings.
@SuppressWarnings
({
"null"
,
"rawtypes"
,
"unchecked"
})
protected
void
addParametersIfPresent
(
OWLOntologyDocumentSource
documentSource
,
RDFParser
createParser
)
{
Collection
<
RioSetting
<?>>
supportedSettings
=
createParser
.
getSupportedSettings
();
if
(
documentSource
.
getFormat
()
!=
null
&&
!
supportedSettings
.
isEmpty
())
{
for
(
RioSetting
r
:
supportedSettings
)
{
Serializable
v
=
documentSource
.
getFormat
().
getParameter
(
r
,
null
);
if
(
v
!=
null
)
{
createParser
.
getParserConfig
().
set
(
r
,
v
);
}
}
}
}
@Override
public
String
toString
()
{
return
getClass
().
getName
()
+
" : "
+
owlFormatFactory
;
...
...
This diff is collapsed.
Click to expand it.
rio/src/main/java/org/semanticweb/owlapi/rio/RioStorer.java
+
53
−
0
View file @
73189913
...
...
@@ -39,8 +39,11 @@ import java.io.BufferedWriter;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.Serializable
;
import
java.io.Writer
;
import
java.net.URISyntaxException
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
javax.annotation.Nonnull
;
import
javax.annotation.Nullable
;
...
...
@@ -51,7 +54,11 @@ import org.eclipse.rdf4j.rio.RDFFormat;
import
org.eclipse.rdf4j.rio.RDFHandler
;
import
org.eclipse.rdf4j.rio.RDFWriter
;
import
org.eclipse.rdf4j.rio.Rio
;
import
org.eclipse.rdf4j.rio.RioSetting
;
import
org.eclipse.rdf4j.rio.UnsupportedRDFormatException
;
import
org.eclipse.rdf4j.rio.helpers.BasicWriterSettings
;
import
org.eclipse.rdf4j.rio.helpers.JSONLDSettings
;
import
org.eclipse.rdf4j.rio.helpers.NTriplesWriterSettings
;
import
org.eclipse.rdf4j.rio.helpers.StatementCollector
;
import
org.semanticweb.owlapi.formats.RioRDFDocumentFormat
;
import
org.semanticweb.owlapi.formats.RioRDFDocumentFormatFactory
;
...
...
@@ -212,6 +219,9 @@ public class RioStorer extends AbstractOWLStorer {
}
}
try
{
// if this is a writer rather than a statement collector, set its config from the format
// parameters, if any
addSettingsIfPresent
(
format
);
final
RioRenderer
ren
=
new
RioRenderer
(
ontology
,
rioHandler
,
format
,
contexts
);
ren
.
render
();
}
catch
(
final
IOException
e
)
{
...
...
@@ -248,10 +258,53 @@ public class RioStorer extends AbstractOWLStorer {
}
}
try
{
// if this is a writer rather than a statement collector, set its config from the format
// parameters, if any
addSettingsIfPresent
(
format
);
final
RioRenderer
ren
=
new
RioRenderer
(
ontology
,
rioHandler
,
format
,
contexts
);
ren
.
render
();
}
catch
(
final
IOException
e
)
{
throw
new
OWLOntologyStorageException
(
e
);
}
}
// These warnings are suppressed because the types cannot be easily determined here without
// forcing constraints that might need to be updated when Rio introduces new settings.
@SuppressWarnings
({
"rawtypes"
,
"null"
,
"unchecked"
})
protected
void
addSettingsIfPresent
(
OWLDocumentFormat
format
)
{
if
(
rioHandler
instanceof
RDFWriter
)
{
RDFWriter
w
=
(
RDFWriter
)
rioHandler
;
Collection
<
RioSetting
<?>>
supportedSettings
=
knownSettings
(
w
);
for
(
RioSetting
r
:
supportedSettings
)
{
Serializable
v
=
format
.
getParameter
(
r
,
null
);
if
(
v
!=
null
)
{
w
.
getWriterConfig
().
set
(
r
,
v
);
}
}
}
}
protected
Collection
<
RioSetting
<?>>
knownSettings
(
RDFWriter
w
)
{
try
{
return
w
.
getSupportedSettings
();
}
catch
(
UnsupportedOperationException
e
)
{
LOGGER
.
debug
(
"Bug in RIO means this exception is thrown in some formats where an unmodifiable class is modified. As a workaround, OWLAPI will try all the known settings - relying on the caller to only use supported settings."
,
e
);
return
Arrays
.
asList
(
JSONLDSettings
.
COMPACT_ARRAYS
,
JSONLDSettings
.
HIERARCHICAL_VIEW
,
JSONLDSettings
.
JSONLD_MODE
,
JSONLDSettings
.
OPTIMIZE
,
JSONLDSettings
.
USE_NATIVE_TYPES
,
JSONLDSettings
.
USE_RDF_TYPE
,
BasicWriterSettings
.
BASE_DIRECTIVE
,
BasicWriterSettings
.
INLINE_BLANK_NODES
,
BasicWriterSettings
.
PRETTY_PRINT
,
BasicWriterSettings
.
RDF_LANGSTRING_TO_LANG_LITERAL
,
BasicWriterSettings
.
XSD_STRING_TO_PLAIN_LITERAL
,
NTriplesWriterSettings
.
ESCAPE_UNICODE
);
// parsing only settings, not used here
// NTriplesParserSettings
// RDFJSONParserSettings
// XMLParserSettings
// TriXParserSettings
// TurtleParserSettings
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment