Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alignment API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
moex
Alignment API
Commits
1e909a13
Commit
1e909a13
authored
15 years ago
by
Jérôme Euzenat
Browse files
Options
Downloads
Patches
Plain Diff
- fixed a reentrance bug of InputStream/Reader when using parseString
parent
4d43bd96
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/fr/inrialpes/exmo/align/parser/AlignmentParser.java
+13
-4
13 additions, 4 deletions
src/fr/inrialpes/exmo/align/parser/AlignmentParser.java
src/fr/inrialpes/exmo/align/parser/RDFParser.java
+0
-3
0 additions, 3 deletions
src/fr/inrialpes/exmo/align/parser/RDFParser.java
with
13 additions
and
7 deletions
src/fr/inrialpes/exmo/align/parser/AlignmentParser.java
+
13
−
4
View file @
1e909a13
...
@@ -26,6 +26,7 @@ import java.io.StringReader;
...
@@ -26,6 +26,7 @@ import java.io.StringReader;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.ByteArrayInputStream
;
import
java.net.URI
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.lang.Integer
;
import
java.lang.Integer
;
...
@@ -155,14 +156,16 @@ public class AlignmentParser {
...
@@ -155,14 +156,16 @@ public class AlignmentParser {
* This dispatch is ridiculous, but that's life
* This dispatch is ridiculous, but that's life
*/
*/
private
Alignment
callParser
(
XMLParser
p
,
Object
o
)
throws
AlignmentException
{
private
Alignment
callParser
(
XMLParser
p
,
Object
o
)
throws
AlignmentException
{
if
(
o
instanceof
String
)
return
p
.
parse
((
String
)
o
);
if
(
o
instanceof
URI
)
return
p
.
parse
(
((
URI
)
o
).
toString
()
);
if
(
o
instanceof
String
)
return
p
.
parse
(
new
ByteArrayInputStream
(
((
String
)
o
).
getBytes
()
)
);
if
(
o
instanceof
Reader
)
return
p
.
parse
((
Reader
)
o
);
if
(
o
instanceof
Reader
)
return
p
.
parse
((
Reader
)
o
);
if
(
o
instanceof
InputStream
)
return
p
.
parse
((
InputStream
)
o
);
if
(
o
instanceof
InputStream
)
return
p
.
parse
((
InputStream
)
o
);
throw
new
AlignmentException
(
"AlignmentParser: cannot parse :"
+
o
);
throw
new
AlignmentException
(
"AlignmentParser: cannot parse :"
+
o
);
}
}
private
Alignment
callParser
(
RDFParser
p
,
Object
o
)
throws
AlignmentException
{
private
Alignment
callParser
(
RDFParser
p
,
Object
o
)
throws
AlignmentException
{
if
(
o
instanceof
String
)
return
p
.
parse
((
String
)
o
);
if
(
o
instanceof
URI
)
return
p
.
parse
(
((
URI
)
o
).
toString
()
);
if
(
o
instanceof
String
)
return
p
.
parse
(
new
ByteArrayInputStream
(
((
String
)
o
).
getBytes
()
)
);
if
(
o
instanceof
Reader
)
return
p
.
parse
((
Reader
)
o
);
if
(
o
instanceof
Reader
)
return
p
.
parse
((
Reader
)
o
);
if
(
o
instanceof
InputStream
)
return
p
.
parse
((
InputStream
)
o
);
if
(
o
instanceof
InputStream
)
return
p
.
parse
((
InputStream
)
o
);
throw
new
AlignmentException
(
"AlignmentParser: cannot parse :"
+
o
);
throw
new
AlignmentException
(
"AlignmentParser: cannot parse :"
+
o
);
...
@@ -173,7 +176,9 @@ public class AlignmentParser {
...
@@ -173,7 +176,9 @@ public class AlignmentParser {
* @param s String the string to parse
* @param s String the string to parse
*/
*/
public
Alignment
parseString
(
String
s
)
throws
AlignmentException
{
public
Alignment
parseString
(
String
s
)
throws
AlignmentException
{
parse
(
new
StringReader
(
s
)
);
// JE: The problem here is that InputStream are consumed by parsers
// So they must be opened again! Like Readers...
callParser
(
s
);
return
alignment
;
return
alignment
;
}
}
...
@@ -192,7 +197,11 @@ public class AlignmentParser {
...
@@ -192,7 +197,11 @@ public class AlignmentParser {
*/
*/
public
Alignment
parse
(
String
uri
)
throws
AlignmentException
{
public
Alignment
parse
(
String
uri
)
throws
AlignmentException
{
this
.
uri
=
uri
;
// should be obsoloted
this
.
uri
=
uri
;
// should be obsoloted
callParser
(
uri
);
try
{
callParser
(
new
URI
(
uri
)
);
}
catch
(
URISyntaxException
urisex
)
{
throw
new
AlignmentException
(
"Invalid URI : "
+
uri
,
urisex
);
}
return
alignment
;
return
alignment
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/fr/inrialpes/exmo/align/parser/RDFParser.java
+
0
−
3
View file @
1e909a13
...
@@ -202,8 +202,6 @@ public class RDFParser {
...
@@ -202,8 +202,6 @@ public class RDFParser {
if
(
is
==
null
)
throw
new
AlignmentException
(
"The reader must not be null"
);
if
(
is
==
null
)
throw
new
AlignmentException
(
"The reader must not be null"
);
Model
align
=
ModelFactory
.
createDefaultModel
();
Model
align
=
ModelFactory
.
createDefaultModel
();
align
.
read
(
is
,
null
);
align
.
read
(
is
,
null
);
// Apparently this does not really works
//align.write(System.out);
return
parse
(
align
);
return
parse
(
align
);
}
}
...
@@ -211,7 +209,6 @@ public class RDFParser {
...
@@ -211,7 +209,6 @@ public class RDFParser {
if
(
is
==
null
)
throw
new
AlignmentException
(
"The inputstream must not be null"
);
if
(
is
==
null
)
throw
new
AlignmentException
(
"The inputstream must not be null"
);
Model
align
=
ModelFactory
.
createDefaultModel
();
Model
align
=
ModelFactory
.
createDefaultModel
();
align
.
read
(
is
,
null
);
align
.
read
(
is
,
null
);
//debug align.write(System.out);
return
parse
(
align
);
return
parse
(
align
);
}
}
...
...
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