Index: src/nongnu/cashews/rdf/Blank.java =================================================================== RCS file: src/nongnu/cashews/rdf/Blank.java diff -N src/nongnu/cashews/rdf/Blank.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/rdf/Blank.java 4 Apr 2005 15:27:36 -0000 @@ -0,0 +1,95 @@ +/* Blank.java -- Representation of a RDF blank node. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor. + + The CASheW-s editor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. +*/ + +package nongnu.cashews.rdf; + +/** + *

+ * Blank nodes allow different parts of an RDF graph to be connected, + * where there are no URIs to use for the intervening nodes. Each blank + * node has an identifier, which allows it to be used and referenced + * in a triple. + *

+ * + * @author Andrew John Hughes (address@hidden) + */ +public class Blank + implements Subject, RDFObject +{ + + /** + * The identifier for this blank node. + * + * @serial the identifier for this node. + */ + private String id; + + /** + * Constructs a Blank using the specified identifier. + * + * @param identifier the identifier for this blank node. + */ + public Blank(String identifier) + { + setIdentifier(identifier); + } + + /** + * Returns a textual representation of the blank node. + * + * @return a textual representation. + */ + public String toString() + { + return getClass().getName() + + "[id = " + + id + + "]"; + } + + /** + * Returns a deep copy of this blank node. + * + * @return a clone of the blank node. + */ + public Blank clone() + { + try + { + return (Blank) super.clone(); + } + catch (CloneNotSupportedException e) + { + throw new IllegalStateException("Unexpected exception: " + e, e); + } + } + + /** + * Sets the identifier used by the blank node to the one specified. + * + * @param identifier the new identifier to use. + */ + public void setIdentifier(String identifier) + { + id = identifier; + } + +} Index: src/nongnu/cashews/rdf/RDFURI.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/RDFURI.java,v retrieving revision 1.4 diff -u -3 -p -u -r1.4 RDFURI.java --- src/nongnu/cashews/rdf/RDFURI.java 4 Apr 2005 00:59:33 -0000 1.4 +++ src/nongnu/cashews/rdf/RDFURI.java 4 Apr 2005 15:27:36 -0000 @@ -26,7 +26,7 @@ import java.net.URISyntaxException; /** *

- * This interface represents an RDF URI. + * This class represents an RDF URI. *

* * @author Andrew John Hughes (address@hidden) Index: src/nongnu/cashews/rdf/XMLParser.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/XMLParser.java,v retrieving revision 1.4 diff -u -3 -p -u -r1.4 XMLParser.java --- src/nongnu/cashews/rdf/XMLParser.java 4 Apr 2005 00:59:33 -0000 1.4 +++ src/nongnu/cashews/rdf/XMLParser.java 4 Apr 2005 15:27:36 -0000 @@ -276,6 +276,15 @@ public class XMLParser String value = attributes.getValue(RDF_NAMESPACE, "about"); if (value != null) subject = parseRDFURI(value); + else + { + /* Check for blank node subject */ + value = attributes.getValue(RDF_NAMESPACE, "nodeID"); + if (value != null) + subject = new Blank(value); + else + logger.warning("No subject found in RDF description."); + } inSubject = true; logger.fine("Created subject: " + subject); } @@ -286,21 +295,34 @@ public class XMLParser } else { - if (inSubject) + if (inRDF) { - /* Predicate element */ - predicateURI = uri + localName; - logger.finer("Start of predicate: " + predicateURI); - predicate = parseRDFURI(predicateURI); - logger.fine("Created predicate: " + predicate); - inSubject = false; - inPredicate = true; - /* Check for RDF URI object */ - String value = attributes.getValue(RDF_NAMESPACE, "resource"); - if (value != null) + if (inSubject) { - object = parseRDFURI(value); - logger.fine("Created object: " + object); + /* Predicate element */ + predicateURI = uri + localName; + logger.finer("Start of predicate: " + predicateURI); + predicate = parseRDFURI(predicateURI); + logger.fine("Created predicate: " + predicate); + inSubject = false; + inPredicate = true; + /* Check for RDF URI object */ + String value = attributes.getValue(RDF_NAMESPACE, + "resource"); + if (value != null) + { + object = parseRDFURI(value); + logger.fine("Created object: " + object); + } + else + { + value = attributes.getValue(RDF_NAMESPACE, "nodeID"); + if (value != null) + { + object = new Blank(value); + logger.fine("Created object: " + object); + } + } } } }