001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.model;
007:
008: import javax.xml.datatype.XMLGregorianCalendar;
009:
010: /**
011: * A factory for creating URIs, blank nodes, literals and statements.
012: *
013: * @author Arjohn Kampman
014: */
015: public interface ValueFactory {
016:
017: /**
018: * Creates a new URI from the supplied string-representation.
019: *
020: * @param uri
021: * A string-representation of a URI.
022: * @return An object representing the URI.
023: * @throws IlllegalArgumentException
024: * If the supplied string does not resolve to a legal (absolute) URI.
025: */
026: public URI createURI(String uri);
027:
028: /**
029: * Creates a new URI from the supplied namespace and local name. Calling this
030: * method is funtionally equivalent to calling
031: * {@link #createURI(String) createURI(namespace+localName)}, but allows the
032: * ValueFactory to reuse supplied namespace and local name strings whenever
033: * possible. Note that the values returned by {@link URI#getNamespace()} and
034: * {@link URI#getLocalName()} are not necessarily the same as the values that
035: * are supplied to this method.
036: *
037: * @param namespace
038: * The URI's namespace.
039: * @param localName
040: * The URI's local name.
041: * @throws IllegalArgumentException
042: * If the supplied namespace and localname do not resolve to a legal
043: * (absolute) URI.
044: */
045: public URI createURI(String namespace, String localName);
046:
047: /**
048: * Creates a new bNode.
049: *
050: * @return An object representing the bNode.
051: */
052: public BNode createBNode();
053:
054: /**
055: * Creates a new blank node with the given node identifier.
056: *
057: * @param nodeID
058: * The blank node identifier.
059: * @return An object representing the blank node.
060: */
061: public BNode createBNode(String nodeID);
062:
063: /**
064: * Creates a new literal with the supplied label.
065: *
066: * @param label
067: * The literal's label.
068: */
069: public Literal createLiteral(String label);
070:
071: /**
072: * Creates a new literal with the supplied label and language attribute.
073: *
074: * @param label
075: * The literal's label.
076: * @param language
077: * The literal's language attribute, or <tt>null</tt> if the literal
078: * doesn't have a language.
079: */
080: public Literal createLiteral(String label, String language);
081:
082: /**
083: * Creates a new literal with the supplied label and datatype.
084: *
085: * @param label
086: * The literal's label.
087: * @param datatype
088: * The literal's datatype, or <tt>null</tt> if the literal doesn't
089: * have a datatype.
090: */
091: public Literal createLiteral(String label, URI datatype);
092:
093: /**
094: * Creates a new <tt>xsd:boolean</tt>-typed literal representing the
095: * specified value.
096: *
097: * @param value
098: * The value for the literal.
099: * @return An <tt>xsd:boolean</tt>-typed literal for the specified value.
100: */
101: public Literal createLiteral(boolean value);
102:
103: /**
104: * Creates a new <tt>xsd:byte</tt>-typed literal representing the
105: * specified value.
106: *
107: * @param value
108: * The value for the literal.
109: * @return An <tt>xsd:byte</tt>-typed literal for the specified value.
110: */
111: public Literal createLiteral(byte value);
112:
113: /**
114: * Creates a new <tt>xsd:short</tt>-typed literal representing the
115: * specified value.
116: *
117: * @param value
118: * The value for the literal.
119: * @return An <tt>xsd:short</tt>-typed literal for the specified value.
120: */
121: public Literal createLiteral(short value);
122:
123: /**
124: * Creates a new <tt>xsd:int</tt>-typed literal representing the specified
125: * value.
126: *
127: * @param value
128: * The value for the literal.
129: * @return An <tt>xsd:int</tt>-typed literal for the specified value.
130: */
131: public Literal createLiteral(int value);
132:
133: /**
134: * Creates a new <tt>xsd:long</tt>-typed literal representing the
135: * specified value.
136: *
137: * @param value
138: * The value for the literal.
139: * @return An <tt>xsd:long</tt>-typed literal for the specified value.
140: */
141: public Literal createLiteral(long value);
142:
143: /**
144: * Creates a new <tt>xsd:float</tt>-typed literal representing the
145: * specified value.
146: *
147: * @param value
148: * The value for the literal.
149: * @return An <tt>xsd:float</tt>-typed literal for the specified value.
150: */
151: public Literal createLiteral(float value);
152:
153: /**
154: * Creates a new <tt>xsd:double</tt>-typed literal representing the
155: * specified value.
156: *
157: * @param value
158: * The value for the literal.
159: * @return An <tt>xsd:double</tt>-typed literal for the specified value.
160: */
161: public Literal createLiteral(double value);
162:
163: /**
164: * Creates a new literal representing the specified calendar that is typed
165: * using the appropriate XML Schema date/time datatype.
166: *
167: * @param calendar
168: * The value for the literal.
169: * @return An typed literal for the specified calendar.
170: */
171: public Literal createLiteral(XMLGregorianCalendar calendar);
172:
173: /**
174: * Creates a new statement with the supplied subject, predicate and object.
175: *
176: * @param subject
177: * The statement's subject.
178: * @param predicate
179: * The statement's predicate.
180: * @param object
181: * The statement's object.
182: * @return The created statement.
183: */
184: public Statement createStatement(Resource subject, URI predicate,
185: Value object);
186:
187: /**
188: * Creates a new statement with the supplied subject, predicate and object
189: * and associated context.
190: *
191: * @param subject
192: * The statement's subject.
193: * @param predicate
194: * The statement's predicate.
195: * @param object
196: * The statement's object.
197: * @param context
198: * The statement's context.
199: * @return The created statement.
200: */
201: public Statement createStatement(Resource subject, URI predicate,
202: Value object, Resource context);
203: }
|