001/** 002 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 003 * This file is part of the LDP4j Project: 004 * http://www.ldp4j.org/ 005 * 006 * Center for Open Middleware 007 * http://www.centeropenmiddleware.com/ 008 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 009 * Copyright (C) 2014-2016 Center for Open Middleware. 010 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 011 * Licensed under the Apache License, Version 2.0 (the "License"); 012 * you may not use this file except in compliance with the License. 013 * You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, software 018 * distributed under the License is distributed on an "AS IS" BASIS, 019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 020 * See the License for the specific language governing permissions and 021 * limitations under the License. 022 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 023 * Artifact : org.ldp4j.framework:ldp4j-application-api:0.2.1 024 * Bundle : ldp4j-application-api-0.2.1.jar 025 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 026 */ 027package org.ldp4j.application.vocabulary; 028 029import java.net.URI; 030 031import javax.xml.namespace.QName; 032 033/** 034 * W3C Resource Description Framework (RDF) Vocabulary. 035 * <p> 036 * This vocabulary provides an informal representation of the terms as defined 037 * in the RDF specification. Check the specification for normative 038 * reference. 039 * <p> 040 * 041 * <b>Namespace:</b> {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#} <br/> 042 * <b>Prefix:</b> {@code rdf} 043 * 044 * @version 1.0 045 * @since 1.0.0 046 * @author Miguel Esteban Gutiérrez 047 * @see <a href=http://www.w3.org/TR/2004/REC-rdf-schema-20040210/">http://www.w3.org/TR/2004/REC-rdf-schema-20040210/</a> 048 */ 049public final class RDF extends AbstractImmutableVocabulary<ImmutableTerm> { 050 051 private static final long serialVersionUID = -1616871929205422837L; 052 053 /** The namespace of the vocabulary ({@code http://www.w3.org/1999/02/22-rdf-syntax-ns#}) **/ 054 public static final String NAMESPACE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 055 056 /** The preferred prefix of the vocabulary ({@code rdf}) **/ 057 public static final String NS_PREFIX = "rdf"; 058 059 /* ---------------------------------------------------------------------- */ 060 /* PROPERTIES */ 061 /* ---------------------------------------------------------------------- */ 062 063 /** 064 * TYPE 065 * <p> 066 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#type}. 067 * <p> 068 * The subject is an instance of a class. 069 * 070 * @see <a 071 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_type">rdf:type</a> 072 */ 073 public static final Term TYPE; 074 075 /** 076 * FIRST 077 * <p> 078 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#first}. 079 * <p> 080 * The first item in the subject RDF list. 081 * 082 * @see <a 083 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_first">rdf:first</a> 084 */ 085 public static final Term FIRST; 086 087 /** 088 * REST 089 * <p> 090 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#rest}. 091 * <p> 092 * The rest of the subject RDF list after the first item. 093 * 094 * @see <a 095 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_rest">rdf:rest</a> 096 */ 097 public static final Term REST; 098 099 /** 100 * VALUE 101 * <p> 102 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#value}. 103 * <p> 104 * The definition of the subject resource. 105 * 106 * @see <a 107 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_value">rdf:value</a> 108 */ 109 public static final Term VALUE; 110 111 /** 112 * SUBJECT 113 * <p> 114 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#subject}. 115 * <p> 116 * The subject of the subject RDF statement. 117 * 118 * @see <a 119 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_subject">rdf:subject</a> 120 */ 121 public static final Term SUBJECT; 122 123 /** 124 * PREDICATE 125 * <p> 126 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate}. 127 * <p> 128 * The predicate of the subject RDF statement. 129 * 130 * @see <a 131 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_predicate">rdf:predicate</a> 132 */ 133 public static final Term PREDICATE; 134 135 /** 136 * OBJECT 137 * <p> 138 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#object}. 139 * <p> 140 * The object of the subject RDF statement. 141 * 142 * @see <a 143 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_object">rdf:object</a> 144 */ 145 public static final Term OBJECT; 146 147 /* ---------------------------------------------------------------------- */ 148 /* CLASSES */ 149 /* ---------------------------------------------------------------------- */ 150 151 /** 152 * XML_LITERAL 153 * <p> 154 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral}. 155 * <p> 156 * The class of XML literal values. 157 * 158 * @see <a 159 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_xmlliteral">rdf:XMLLiteral</a> 160 */ 161 public static final Term XML_LITERAL; 162 163 /** 164 * PROPERTY 165 * <p> 166 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#Property}. 167 * <p> 168 * The class of RDF properties. 169 * 170 * @see <a 171 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_property">rdf:Property</a> 172 */ 173 public static final Term PROPERTY; 174 175 /** 176 * STATEMENT 177 * <p> 178 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement}. 179 * <p> 180 * The class of RDF statements. 181 * 182 * @see <a 183 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_statement">rdf:Statement</a> 184 */ 185 public static final Term STATEMENT; 186 187 /** 188 * BAG 189 * <p> 190 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag}. 191 * <p> 192 * The class of unordered containers. 193 * 194 * @see <a 195 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_bag">rdf:Bag</a> 196 */ 197 public static final Term BAG; 198 199 /** 200 * SEQ 201 * <p> 202 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq}. 203 * <p> 204 * The class of ordered containers. 205 * 206 * @see <a 207 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_seq">rdf:Seq</a> 208 */ 209 public static final Term SEQ; 210 211 /** 212 * ALT 213 * <p> 214 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt}. 215 * <p> 216 * The class of containers of alternatives. 217 * 218 * @see <a 219 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_alt">rdf:Alt</a> 220 */ 221 public static final Term ALT; 222 223 /** 224 * LIST 225 * <p> 226 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#List}. 227 * <p> 228 * The class of RDF Lists. 229 * 230 * @see <a 231 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_list">rdf:List</a> 232 */ 233 public static final Term LIST; 234 235 /* ---------------------------------------------------------------------- */ 236 /* INDIVIDUALS */ 237 /* ---------------------------------------------------------------------- */ 238 239 /** 240 * NIL 241 * <p> 242 * {@code http://www.w3.org/1999/02/22-rdf-syntax-ns#nil}. 243 * <p> 244 * The class of RDF Lists. 245 * 246 * @see <a 247 * href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210/#ch_nil">rdf:nil</a> 248 */ 249 public static final Term NIL; 250 251 /** The unique instance of the vocabulary **/ 252 private static final RDF VOCABULARY=new RDF(); 253 254 static { 255 // Initialize properties 256 TYPE=term("type"); 257 FIRST=term("first"); 258 REST=term("rest"); 259 VALUE=term("value"); 260 SUBJECT=term("subject"); 261 PREDICATE=term("predicate"); 262 OBJECT=term("object"); 263 // Initialize classes 264 XML_LITERAL=term("XMLLiteral"); 265 PROPERTY=term("Property"); 266 STATEMENT=term("Statement"); 267 BAG=term("Bag"); 268 SEQ=term("Seq"); 269 ALT=term("Alt"); 270 LIST=term("List"); 271 // Initialize individuals 272 NIL=term("nil"); 273 VOCABULARY.initialize(); 274 } 275 276 private RDF() { 277 super(ImmutableTerm.class,RDF.NAMESPACE,RDF.NS_PREFIX); 278 } 279 280 /** 281 * Create a term 282 * 283 * @param localPart 284 * The local part of the term's URI 285 * @return A {@code LDPTerm} instance that represents the term. 286 */ 287 private static Term term(String localPart) { 288 return new ImmutableTerm(VOCABULARY,localPart); 289 } 290 291 /** 292 * Retrieve the LDP vocabulary instance. 293 * @return Return the unique instance of the vocabulary. 294 */ 295 public static RDF getInstance() { 296 return RDF.VOCABULARY; 297 } 298 299 /** 300 * Get the terms of the vocabulary 301 * 302 * @return An array with all the terms of the vocabulary. 303 */ 304 public static Term[] values() { 305 return getInstance().terms(); 306 } 307 308 /** 309 * Find the term that matches the specified name. 310 * 311 * @param term 312 * A {@code String}-based representation of the term's name. 313 * @return The {@code Term} that matches the specified name. 314 */ 315 public static Term valueOf(String term) { 316 return getInstance().fromName(term); 317 } 318 319 /** 320 * Find the term that matches the specified URI. 321 * 322 * @param term 323 * A {@code QName}-based representation of the term's URI. 324 * @return The {@code Term} that matches the specified URI. 325 * @see javax.xml.namespace.QName 326 */ 327 public static Term valueOf(QName term) { 328 return getInstance().fromValue(term); 329 } 330 331 /** 332 * Find the term that matches the specified URI. 333 * 334 * @param term 335 * A {@code URI}-based representation of the term's URI. 336 * @return The {@code LDPTerm} that matches the specified URI. 337 * @see java.net.URI 338 */ 339 public static Term valueOf(URI term) { 340 return getInstance().fromValue(term); 341 } 342 343}