01: /*
02: * LICENSE INFORMATION
03: * Copyright 2005-2007 by FZI (http://www.fzi.de).
04: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
05: * <OWNER> = Max Völkel
06: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
07: * <YEAR> = 2007
08: *
09: * Project information at http://semweb4j.org/rdf2go
10: */
11: package org.ontoware.rdf2go.model.node;
12:
13: /**
14: * Marker interface for RDF types (URI, BlankNode, Literal)
15: *
16: * The following sorting order is defined by different Node types: URI >
17: * BlankNode > PlainLiteral > LanguageTaggedLiteral > DatatypedLiteral
18: *
19: * Nodes are expected to have correct implementations of equals(Object other)
20: * and hashcode()
21: *
22: * @author voelkel
23: *
24: */
25: public interface Node extends NodeOrVariable, Comparable<Node> {
26:
27: /**
28: * A convenience method for a cast to
29: * org.ontoware.rdf2go.model.node.Resource
30: *
31: * @return this Node casted as a Resource
32: * @throws ClassCastException
33: * if the node is not a Resource
34: */
35: public Resource asResource() throws ClassCastException;
36:
37: /**
38: * A convenience method for a cast to org.ontoware.rdf2go.model.node.Literal
39: *
40: * @return this Node casted as a Literal
41: * @throws ClassCastException
42: * if the node is not a Literal
43: */
44: public Literal asLiteral() throws ClassCastException;;
45:
46: /**
47: * A convenience method for a cast to
48: * org.ontoware.rdf2go.model.node.DatatypeLiteral
49: *
50: * @return this Node casted as a DatatypeLiteral
51: * @throws ClassCastException
52: * if the node is not a DatatypeLiteral
53: */
54: public DatatypeLiteral asDatatypeLiteral()
55: throws ClassCastException;;
56:
57: /**
58: * A convenience method for a cast to
59: * org.ontoware.rdf2go.model.node.LanguageTagLiteral
60: *
61: * @return this Node casted as a LanguageTagLiteral
62: * @throws ClassCastException
63: * if the node is not a LanguageTagLiteral
64: */
65: public LanguageTagLiteral asLanguageTagLiteral()
66: throws ClassCastException;;
67:
68: /**
69: * A convenience method for a cast to org.ontoware.rdf2go.model.node.URI
70: *
71: * @return this Node casted as a URI
72: * @throws ClassCastException
73: * if the node is not a URI
74: */
75: public URI asURI() throws ClassCastException;
76:
77: /**
78: * A convenience method for a cast to
79: * org.ontoware.rdf2go.model.node.BlankNode
80: *
81: * @return this Node casted as a BlankNode
82: * @throws ClassCastException
83: * if the node is not a BlankNode
84: */
85: public BlankNode asBlankNode() throws ClassCastException;
86:
87: /**
88: * A convenience function to create SPARQL queries from nodes
89: *
90: * @return this node in SPARQL syntax. A URI is wrapped in '<' and
91: * '>'. A literal is wrapped in '"' chars and escaped.
92: */
93: public String toSPARQL();
94:
95: }
|