001 /*
002 * Copyright (c) 1995-2010, The University of Sheffield. See the file
003 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
004 *
005 * This file is part of GATE (see http://gate.ac.uk/), and is free
006 * software, licenced under the GNU Library General Public License,
007 * Version 2, June 1991 (in the distribution as file licence.html,
008 * and also available at http://gate.ac.uk/gate/licence.html).
009 *
010 * $Id: ONodeID.java 12006 2009-12-01 17:24:28Z thomas_heitz $
011 */
012 package gate.creole.ontology;
013
014 /**
015 * An ONodeID represents the id of either a blank node or a resource.
016 * If the node represented by this is a blank node, name space will be
017 * blank and the resource name will be whatever internal name for the
018 * blank node the implementation uses. If the node respresented by this
019 * is a named resource, the ID will be an URI consisting of a name space
020 * and a resource name. <br>
021 * TODO: plan for URI/IRI encodings and comparion of OURIs that have non-ASCII
022 * resource names. Most likely each ORUI will remember the string it was
023 * created from and return that string for getResourceName or toString.
024 * The toDisplayString method will always generate a valid IRI, and the
025 * toASCIIString will always generate a valid URI representation.
026 * Whether these representations are stored or generated on the fly and which
027 * of these representations are used with the backend is implementation
028 * dependent.
029 *
030 * @author Johann Petrak
031 */
032 public interface ONodeID extends Comparable<ONodeID> {
033 public String getNameSpace();
034 public String getResourceName();
035 /**
036 * Return the node ID as the string from which the ID was originally created.
037 * @return
038 */
039 @Override
040 public String toString();
041 /**
042 * Return the node ID as a pure ASCII string.
043 * If the node is an OURI, this will return a string that has non ASCII
044 * characters escaped according to URI escaping rules.<br>
045 * if the node is a BNodeID, this will return the same string as toString().
046 * <p>
047 * NOTE: URI encoding and translation from/to IRIs is not implemented yet!
048 *
049 * @return
050 */
051 public String toASCIIString();
052 /**
053 * Return the node ID as a unicode string.
054 * If the node is an OURI, this will return a string that is a valid IRI.
055 * If the node is a BNodeID, this will return the same sting as toString().
056 * <p>
057 * NOTE: not implemented yet!
058 *
059 * @return
060 */
061 public String toDisplayString();
062 /**
063 * Return if this represents a blank node or a named resource.
064 * Returns true if this represents a blank node (is a BNodeID) or a named
065 * resource (is a ORUI).
066 * <p>
067 * NOTE: not implemented yet!
068 *
069 * @return
070 */
071 public boolean isAnonymousResource();
072
073 public int compareTo(ONodeID other);
074 @Override
075 public boolean equals(Object other);
076 @Override
077 public int hashCode();
078 /**
079 * Return a representation of the node that conforms to Turtle syntax.
080 * This will return a string that conforms to TURTLE (Terse RDF Triple
081 * Language) - see http://www.w3.org/TeamSubmission/turtle/
082 * <p>
083 * TODO: at the moment, this only returns either the blank node ID unchanged
084 * or the URI as returned by toString() between "<" and ">". This will have
085 * to use a proper ASCII representation of the URI or an IRI representation
086 * instead.
087 *
088 * @return
089 */
090 public String toTurtle();
091 /**
092 * Validate if the string that was passed on as a bnode id or as an URI/IRI
093 * to the constructor of the implementing class can be converted to
094 * a blank node identifier or and URI/IRI that conforms to the implementaion.
095 * <p>
096 * TODO: this is not yet implemented.
097 *
098 * @throws IllegalArgumentException
099 */
100 public void validate() throws IllegalArgumentException;
101 }
|