Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 8a0231b7 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- implemented parsing/storing/rendering of nameless entities (for patterns)

parent 9e5a9adf
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
*
* Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck
* Sourceforge version 1.5 - 2006
* Copyright (C) INRIA, 2009
* Copyright (C) INRIA, 2009-2010
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -44,6 +44,11 @@ public class ClassId extends ClassExpression implements Id {
URI uri;
/**
* Creates an anonymous class pattern
*/
public ClassId() {}
public ClassId(final String id) throws AlignmentException {
if (id == null) {
throw new NullPointerException("The id must not be null");
......
......@@ -3,7 +3,7 @@
*
* Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck
* Sourceforge version 1.4 - 2006 -- then InstanceExpr
* Copyright (C) INRIA, 2009
* Copyright (C) INRIA, 2009-2010
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -44,6 +44,11 @@ public class InstanceId extends InstanceExpression implements Id {
uri = u;
}
/**
* Creates an anonymous instance pattern
*/
public InstanceId() {}
/**
* Constructs a InstanceId.
*
......
......@@ -3,7 +3,7 @@
*
* Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck
* Sourceforge version 1.7 - 2006 -- then AttributeExpr.java
* Copyright (C) INRIA, 2009
* Copyright (C) INRIA, 2009-2010
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -43,6 +43,11 @@ public class PropertyId extends PropertyExpression implements Id {
URI uri;
/**
* Creates an anonymous property pattern
*/
public PropertyId() {}
public PropertyId( final URI u ) {
if ( u == null ) {
throw new NullPointerException("The URI must not be null");
......
......@@ -3,7 +3,7 @@
*
* Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck
* Sourceforge version 1.5 - 2006 -- then RelationExpr
* Copyright (C) INRIA, 2009
* Copyright (C) INRIA, 2009-2010
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -39,6 +39,11 @@ public class RelationId extends RelationExpression implements Id {
URI uri;
/**
* Creates an anonymous relation pattern
*/
public RelationId() {}
public RelationId(final String id) throws AlignmentException {
if (id == null) {
throw new NullPointerException("The id must not be null");
......
......@@ -361,8 +361,10 @@ public class RDFRendererVisitor implements AlignmentVisitor {
// DONE+TESTED
public void visit( final ClassId e ) throws AlignmentException {
indentedOutput("<"+SyntaxElement.CLASS_EXPR.print(DEF));
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
if ( e.getURI() != null ) {
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
}
if ( isPattern ) renderVariables( e );
writer.print("/>");
}
......@@ -512,8 +514,10 @@ public class RDFRendererVisitor implements AlignmentVisitor {
// DONE
public void visit(final PropertyId e) throws AlignmentException {
indentedOutput("<"+SyntaxElement.PROPERTY_EXPR.print(DEF));
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
if ( e.getURI() != null ){
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
}
if ( isPattern ) renderVariables( e );
writer.print("/>");
}
......@@ -621,8 +625,10 @@ public class RDFRendererVisitor implements AlignmentVisitor {
// DONE
public void visit( final RelationId e ) throws AlignmentException {
indentedOutput("<"+SyntaxElement.RELATION_EXPR.print(DEF));
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
if ( e.getURI() != null ) {
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
}
if ( isPattern ) renderVariables( e );
writer.print("/>");
}
......@@ -704,8 +710,10 @@ public class RDFRendererVisitor implements AlignmentVisitor {
// DONE+TESTED
public void visit( final InstanceId e ) throws AlignmentException {
indentedOutput("<"+SyntaxElement.INSTANCE_EXPR.print(DEF));
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
if ( e.getURI() != null ) {
writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF));
writer.print("=\""+e.getURI()+"\"");
}
if ( isPattern ) renderVariables( e );
writer.print("/>");
}
......
......@@ -420,9 +420,8 @@ public class RDFParser {
} else {
throw new AlignmentException("There is no parser for entity "+rdfType.getLocalName());
}
//2010 test for variable? if yes store it!
if ( isPattern ) {
StmtIterator stmtIt = node.listProperties((Property)SyntaxElement.VAR.resource );
StmtIterator stmtIt = node.listProperties( (Property)SyntaxElement.VAR.resource );
if ( stmtIt.hasNext() ) {
final String varname = stmtIt.nextStatement().getString();
final Variable var = alignment.recordVariable( varname, result );
......@@ -459,7 +458,11 @@ public class RDFParser {
op = SyntaxElement.NOT.getOperator();
stmt = node.getProperty( (Property)SyntaxElement.NOT.resource );
} else {
throw new AlignmentException( "Class statement must containt one constructor or Id : "+node );
if ( isPattern ) { // not necessarily with a variable (real patterns)
return new ClassId();
} else {
throw new AlignmentException( "Class statement must containt one constructor or Id : "+node );
}
}
//JE2010MUSTCHECK
Resource coll = stmt.getResource(); //JE2010MUSTCHECK
......@@ -599,7 +602,11 @@ public class RDFParser {
op = SyntaxElement.NOT.getOperator();
stmt = node.getProperty( (Property)SyntaxElement.NOT.resource );
} else {
throw new AlignmentException( "Property statement must containt one constructor or Id : "+node );
if ( isPattern ) { // not necessarily with a variable (real patterns)
return new PropertyId();
} else {
throw new AlignmentException( "Property statement must containt one constructor or Id : "+node );
}
}
Resource coll = stmt.getResource(); //JE2010MUSTCHECK
if ( op == SyntaxElement.NOT.getOperator() ) {
......@@ -720,7 +727,11 @@ public class RDFParser {
op = SyntaxElement.TRANSITIVE.getOperator();
stmt = node.getProperty( (Property)SyntaxElement.TRANSITIVE.resource );
} else {
throw new AlignmentException( "Relation statement must containt one constructor or Id : "+node );
if ( isPattern ) { // not necessarily with a variable (real patterns)
return new RelationId();
} else {
throw new AlignmentException( "Relation statement must containt one constructor or Id : "+node );
}
}
Resource coll = stmt.getResource(); //JE2010MUSTCHECK
if ( op == SyntaxElement.NOT.getOperator() ||
......@@ -768,6 +779,8 @@ public class RDFParser {
URI id = getNodeId( node );
if ( id != null ) return new InstanceId( id );
else throw new AlignmentException("Cannot parse anonymous individual");
} else if ( isPattern ) { // not necessarily with a variable (real patterns)
return new InstanceId();
} else {
throw new AlignmentException("There is no pasrser for entity "+rdfType.getLocalName());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment