1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.apache.commons.rdf.api;
19
20 /**
21 * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-iri" >RDF-1.1 IRI</a>,
22 * as defined by <a href= "http://www.w3.org/TR/rdf11-concepts/#section-IRIs" >RDF-1.1
23 * Concepts and Abstract Syntax</a>, a W3C Recommendation published on 25
24 * February 2014.
25 *
26 * @see RDF#createIRI(String)
27 */
28 public interface IRI extends BlankNodeOrIRI {
29
30 /**
31 * Return the IRI encoded as a native Unicode String.<br>
32 *
33 * The returned string must not include URL-encoding to escape non-ASCII
34 * characters.
35 *
36 * @return The IRI encoded as a native Unicode String.
37 */
38 String getIRIString();
39
40 /**
41 * Check it this IRI is equal to another IRI. <blockquote>
42 * <a href="http://www.w3.org/TR/rdf11-concepts/#section-IRIs">IRI
43 * equality</a>: Two IRIs are equal if and only if they are equivalent under
44 * Simple String Comparison according to section 5.1 of [RFC3987]. Further
45 * normalization MUST NOT be performed when comparing IRIs for equality.
46 * </blockquote>
47 *
48 * Two IRI instances are equal if and only if their {@link #getIRIString()}
49 * are equal.
50 *
51 * Implementations MUST also override {@link #hashCode()} so that two equal
52 * IRIs produce the same hash code.
53 *
54 * @param other
55 * Another object
56 * @return true if other is an IRI and is equal to this
57 * @see Object#equals(Object)
58 */
59 @Override
60 boolean equals(Object other);
61
62 /**
63 * Calculate a hash code for this IRI.
64 * <p>
65 * The returned hash code MUST be equal to the {@link String#hashCode()} of
66 * the {@link #getIRIString()}.
67 * <p>
68 * This method MUST be implemented in conjunction with
69 * {@link #equals(Object)} so that two equal IRIs produce the same hash
70 * code.
71 *
72 * @return a hash code value for this IRI.
73 * @see Object#hashCode()
74 */
75 @Override
76 int hashCode();
77 }