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 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.0
024 *   Bundle      : ldp4j-application-api-0.2.0.jar
025 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
026 */
027package org.ldp4j.application.vocabulary;
028
029import java.net.URI;
030
031import javax.xml.namespace.QName;
032
033/**
034 * W3C Linked Data Platform (LDP) Vocabulary.
035 * <p>
036 * This vocabulary provides an informal representation of the terms as defined
037 * in the LDP specification. Check the LDP specification for normative
038 * reference.
039 * <p>
040 *
041 * <b>Namespace:</b> {@code <http://www.w3.org/ns/ldp#>} <br/>
042 * <b>Prefix:</b> {@code ldp}
043 *
044 * @version 1.0
045 * @since 1.0.0
046 * @author Miguel Esteban Guti&eacute;rrez
047 *
048 * @see <a href="http://www.w3.org/TR/ldp/">http://www.w3.org/TR/ldp/</a>
049 */
050public final class LDP extends AbstractImmutableVocabulary<ImmutableTerm> {
051
052  private static final long serialVersionUID = -7172036547604166277L;
053
054  /** The namespace of the vocabulary ({@code http://www.w3.org/ns/ldp#}) **/
055  public static final String NAMESPACE = "http://www.w3.org/ns/ldp#";
056
057  /** The preferred prefix of the vocabulary ({@code ldp}) **/
058  public static final String NS_PREFIX = "ldp";
059
060  /* ---------------------------------------------------------------------- */
061  /* PROPERTIES                                                             */
062  /* ---------------------------------------------------------------------- */
063
064  /**
065   * CONTAINS
066   * <p>
067   * {@code http://www.w3.org/ns/ldp#contains}.
068   * <p>
069   * Links a container with resources created through the container.
070   *
071   * @see <a href="http://www.w3.org/ns/ldp#contains">ldp:contains</a>
072   */
073  public static final Term CONTAINS;
074
075  /**
076   * MEMBER
077   * <p>
078   * {@code http://www.w3.org/ns/ldp#member}.
079   * <p>
080   * LDP servers should use this predicate as the membership predicate if
081   * there is no obvious predicate from an application vocabulary to use.
082   *
083   * @see <a href="http://www.w3.org/ns/ldp#member">ldp:member</a>
084   */
085  public static final Term MEMBER;
086
087  /**
088   * MEMBERSHIP_RESOURCE
089   * <p>
090   * {@code http://www.w3.org/ns/ldp#membershipResource}.
091   * <p>
092   * Indicates the membership-constant-URI in a membership triple. Depending
093   * upon the membership triple pattern a container uses, as indicated by the
094   * presence of {@code ldp:hasMemberRelation} or
095   * {@code ldp:isMemberOfRelation}, the membership-constant-URI might occupy
096   * either the subject or object position in membership triples.
097   *
098   * @see <a
099   *      href="http://www.w3.org/ns/ldp#membershipResource">ldp:membershipResource</a>
100   */
101  public static final Term MEMBERSHIP_RESOURCE;
102
103  /**
104   * HAS_MEMBER_RELATION
105   * <p>
106   * {@code http://www.w3.org/ns/ldp#hasMemberRelation}.
107   * <p>
108   * Indicates which predicate is used in membership triples, and that the
109   * membership triple pattern is {@code <membership-constant-URI,
110   * object-of-hasMemberRelation, member-URI>}.
111   *
112   * @see <a
113   *      href="http://www.w3.org/ns/ldp#hasMemberRelation">ldp:hasMemberRelation</a>
114   */
115  public static final Term HAS_MEMBER_RELATION;
116
117  /**
118   * IS_MEMBER_OF_RELATION
119   * <p>
120   * {@code http://www.w3.org/ns/ldp#isMemberOfRelation}.
121   * <p>
122   * Indicates which predicate is used in membership triples, and that the
123   * membership triple pattern is
124   * {@code <member-URI, object-of-isMemberOfRelation,
125   * membership-constant-URI>}.
126   *
127   * @see <a
128   *      href="http://www.w3.org/ns/ldp#isMemberOfRelation">ldp:isMemberOfRelation</a>
129   */
130  public static final Term IS_MEMBER_OF_RELATION;
131
132  /**
133   * INSERTED_CONTENT_RELATION
134   * <p>
135   * {@code http://www.w3.org/ns/ldp#insertedContentRelation}.
136   * <p>
137   * Indicates which triple in a creation request should be used as the
138   * member-URI value in the membership triple added when the creation request
139   * is successful.
140   *
141   * @see <a
142   *      href="http://www.w3.org/ns/ldp#insertedContentRelation">ldp:insertedContentRelation</a>
143   */
144  public static final Term INSERTED_CONTENT_RELATION;
145
146  /**
147   * CONSTRAINED_BY
148   * <p>
149   * {@code http://www.w3.org/ns/ldp#constrainedBy}.
150   * <p>
151   * Indicates that the resource has publishing constraints. The object of the
152   * triple should be the URL that provides the constraints that apply.
153   *
154   * @see <a
155   *      href="http://www.w3.org/ns/ldp#constrainedBy">ldp:constrainedBy</a>
156   */
157  public static final Term CONSTRAINED_BY;
158
159  /* ---------------------------------------------------------------------- */
160  /* CLASSES                                                                */
161  /* ---------------------------------------------------------------------- */
162
163  /**
164   * XML_LITERAL
165   * <p>
166   * {@code http://www.w3.org/ns/ldp#Resource}.
167   * <p>
168   * A HTTP-addressable resource whose lifecycle is managed by a LDP server.
169   *
170   * @see <a href="http://www.w3.org/ns/ldp#Resource">ldp:Resource</a>
171   */
172  public static final Term RESOURCE;
173
174  /**
175   * NON_RDF_SOURCE
176   * <p>
177   * {@code http://www.w3.org/ns/ldp#NonRDFSource}.
178   * <p>
179   * A Linked Data Platform Resource (LDPR) whose state is NOT represented as
180   * RDFS.
181   *
182   * @see <a href="http://www.w3.org/ns/ldp#NonRDFSource">ldp:NonRDFSource</a>
183   */
184    public static final Term NON_RDF_SOURCE;
185
186  /**
187   * RDF_SOURCE
188   * <p>
189   * {@code http://www.w3.org/ns/ldp#RDFSource}.
190   * <p>
191   * A Linked Data Platform Resource (LDPR) whose state is represented as RDFS.
192   *
193   * @see <a href="http://www.w3.org/ns/ldp#RDFSource">ldp:RDFSource</a>
194   */
195    public static final Term RDF_SOURCE;
196
197    /**
198   * SEQ
199   * <p>
200   * {@code http://www.w3.org/ns/ldp#Container}.
201   * <p>
202   * A Linked Data Platform RDFS Source (LDP-RS) that also conforms to
203   * additional patterns and conventions for managing membership. Readers
204   * should refer to the specification defining this ontology for the list of
205   * behaviors associated with it.
206   *
207   * @see <a href="http://www.w3.org/ns/ldp#Container">ldp:Container</a>
208   */
209  public static final Term CONTAINER;
210
211  /**
212   * BASIC_CONTAINER
213   * <p>
214   * {@code http://www.w3.org/ns/ldp#BasicContainer}.
215   * <p>
216   * An LDPC that uses a predefined predicate to simply link to its contained
217   * resources.
218   *
219   * @see <a href="http://www.w3.org/ns/ldp#BasicContainer">ldp:BasicContainer</a>
220   */
221  public static final Term BASIC_CONTAINER;
222
223  /**
224   * DIRECT_CONTAINER
225   * <p>
226   * {@code http://www.w3.org/ns/ldp#DirectContainer}.
227   * <p>
228   * An LDPC that is similar to a LDP-DC but it allows an indirection with the
229   * ability to list as member a resource, such as a URI representing a
230   * real-world object, that is different from the resource that is created.
231   *
232   * @see <a
233   *      href="http://www.w3.org/ns/ldp#DirectContainer">ldp:DirectContainer</a>
234   */
235  public static final Term DIRECT_CONTAINER;
236
237  /**
238   * INDIRECT_CONTAINER
239   * <p>
240   * {@code http://www.w3.org/ns/ldp#IndirectContainer}.
241   * <p>
242   * An LDPC that has the flexibility of choosing what form the membership
243   * triples take.
244   *
245   * @see <a
246   *      href="http://www.w3.org/ns/ldp#IndirectContainer">ldp:IndirectContainer</a>
247   */
248  public static final Term INDIRECT_CONTAINER;
249
250  /* ---------------------------------------------------------------------- */
251  /* INDIVIDUALS                                                            */
252  /* ---------------------------------------------------------------------- */
253
254  /**
255   * MEMBER_SUBJECT
256   * <p>
257   * {@code http://www.w3.org/ns/ldp#MemberSubject}.
258   * <p>
259   * Used to indicate default and typical behavior for
260   * {@code ldp:insertedContentRelation}, where the member-URI value in the membership
261   * triple added when a creation request is successful is the URI assigned to
262   * the newly created resource.
263   *
264   * @see <a href="http://www.w3.org/ns/ldp#MemberSubject">ldp:MemberSubject</a>
265   */
266  public static final Term MEMBER_SUBJECT;
267
268  /**
269   * PREFER_CONTAINMENT
270   * <p>
271   * {@code http://www.w3.org/ns/ldp#PreferContainment}.
272   * <p>
273   * LDPTerm identifying a LDPC's containment triples, for example to allow
274   * clients to express interest in receiving them.
275   *
276   * @see <a
277   *      href="http://www.w3.org/ns/ldp#PreferContainment">ldp:PreferContainment</a>
278   */
279  public static final Term PREFER_CONTAINMENT;
280
281  /**
282   * PREFER_EMPTY_CONTAINER
283   * <p>
284   * {@code http://www.w3.org/ns/ldp#PreferEmptyContainer}.
285   * <p>
286   * LDPTerm identifying the subset of a LDPC's triples present in an empty LDPC,
287   * for example to allow clients to express interest in receiving them.
288   * Currently this excludes containment and membership triples, but in the
289   * future other exclusions might be added. This definition is written to
290   * automatically exclude those new classes of triples.
291   *
292   * @see <a
293   *      href="http://www.w3.org/ns/ldp#PreferEmptyContainer">ldp:PreferEmptyContainer</a>
294   */
295  public static final Term PREFER_EMPTY_CONTAINER;
296
297  /**
298   * PREFER_MINIMAL_CONTAINER
299   * <p>
300   * {@code http://www.w3.org/ns/ldp#PreferMinimalContainer}.
301   * <p>
302   * LDPTerm identifying the subset of a LDPC's triples present in an empty LDPC,
303   * for example to allow clients to express interest in receiving them.
304   * Currently this excludes containment and membership triples, but in the
305   * future other exclusions might be added. This definition is written to
306   * automatically exclude those new classes of triples.
307   *
308   * @see <a
309   *      href="http://www.w3.org/ns/ldp#PreferMinimalContainer">ldp:PreferMinimalContainer</a>
310   */
311  public static final Term PREFER_MINIMAL_CONTAINER;
312
313  /**
314   * PREFER_MEMBERSHIP
315   * <p>
316   * {@code http://www.w3.org/ns/ldp#PreferMembership}.
317   * <p>
318   * LDPTerm identifying a LDPC's membership triples, for example to allow
319   * clients to express interest in receiving them.
320   *
321   * @see <a
322   *      href="http://www.w3.org/ns/ldp#PreferMembership">ldp:PreferMembership</a>
323   */
324  public static final Term PREFER_MEMBERSHIP;
325
326  /** The unique instance of the vocabulary **/
327  private static final LDP VOCABULARY=new LDP();
328
329  static {
330    // Initialize properties
331    CONTAINS=term("contains");
332    MEMBER=term("member");
333    MEMBERSHIP_RESOURCE=term("membershipResource");
334    HAS_MEMBER_RELATION=term("hasMemberRelation");
335    IS_MEMBER_OF_RELATION=term("isMemberOfRelation");
336    INSERTED_CONTENT_RELATION=term("insertedContentRelation");
337    CONSTRAINED_BY=term("constrainedBy");
338    // Initialize classes
339    RESOURCE=term("Resource");
340    NON_RDF_SOURCE=term("NonRDFSource");
341    RDF_SOURCE=term("RDFSource");
342    CONTAINER=term("Container");
343    BASIC_CONTAINER=term("BasicContainer");
344    DIRECT_CONTAINER=term("DirectContainer");
345    INDIRECT_CONTAINER=term("IndirectContainer");
346    // Initialize individuals
347    MEMBER_SUBJECT=term("MemberSubject");
348    PREFER_CONTAINMENT=term("PreferContainment");
349    PREFER_EMPTY_CONTAINER=term("PreferEmptyContainer");
350    PREFER_MINIMAL_CONTAINER=term("PreferMinimalContainer");
351    PREFER_MEMBERSHIP=term("PreferMembership");
352    VOCABULARY.initialize();
353  }
354
355  private LDP() {
356    super(ImmutableTerm.class,LDP.NAMESPACE,LDP.NS_PREFIX);
357  }
358
359  /**
360   * Create a term
361   *
362   * @param localPart
363   *            The local part of the term's URI
364   * @return A {@code LDPTerm} instance that represents the term.
365   */
366  private static Term term(String localPart) {
367    return new ImmutableTerm(VOCABULARY,localPart);
368  }
369
370  /**
371   * Retrieve the LDP vocabulary instance.
372   * @return Return the unique instance of the vocabulary.
373   */
374  public static LDP getInstance() {
375    return LDP.VOCABULARY;
376  }
377
378  /**
379   * Get the terms of the vocabulary
380   *
381   * @return An array with all the terms of the vocabulary.
382   */
383  public static Term[] values() {
384    return getInstance().terms();
385  }
386
387  /**
388   * Find the term that matches the specified name.
389   *
390   * @param term
391   *            A {@code String}-based representation of the term's name.
392   * @return The {@code Term} that matches the specified name.
393   */
394  public static Term valueOf(String term) {
395    return getInstance().fromName(term);
396  }
397
398  /**
399   * Find the term that matches the specified URI.
400   *
401   * @param term
402   *            A {@code QName}-based representation of the term's URI.
403   * @return The {@code Term} that matches the specified URI.
404   * @see javax.xml.namespace.QName
405   */
406  public static Term valueOf(QName term) {
407    return getInstance().fromValue(term);
408  }
409
410  /**
411   * Find the term that matches the specified URI.
412   *
413   * @param term
414   *            A {@code URI}-based representation of the term's URI.
415   * @return The {@code LDPTerm} that matches the specified URI.
416   * @see java.net.URI
417   */
418  public static Term valueOf(URI term) {
419    return getInstance().fromValue(term);
420  }
421
422}