View Javadoc

1   /*
2    * Copyright 2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.resteasy.hypermedia.relations;
17  
18  /**
19   * Defines constants for relations used in this application.
20   */
21  public final class Relations
22  {
23    // ********************************* Fields *********************************
24  
25    // --- constants ------------------------------------------------------------
26  
27    /**
28     * The relation home for IANA.
29     * <p>
30     * The value of this constant is {@value}.
31     * </p>
32     */
33    public static final String IANA_HOME =
34        "http://www.iana.org/assignments/relation";
35  
36    /**
37     * The relation home for Microformats.
38     * <p>
39     * The value of this constant is {@value}.
40     * </p>
41     */
42    public static final String MICROFORMATS_HOME =
43        "http://microformats.org/wiki/rel-";
44  
45    /**
46     * Relation to self, not allowed as "self" in HTML 5.
47     */
48    public static final String SELF = IANA_HOME + '/' + "self";
49  
50    /**
51     * Relation to up, not allowed as "up" in HTML 5.
52     */
53    public static final String UP = IANA_HOME + '/' + "up";
54  
55    /**
56     * Relation to home, not allowed as "home" in HTML 5.
57     */
58    public static final String HOME = MICROFORMATS_HOME + "home";
59  
60    // --- members --------------------------------------------------------------
61  
62    // ****************************** Initializer *******************************
63  
64    // ****************************** Constructors ******************************
65  
66    private Relations()
67    {
68    }
69  
70    // ****************************** Inner Classes *****************************
71  
72    // ********************************* Methods ********************************
73  
74    // --- init -----------------------------------------------------------------
75  
76    // --- get&set --------------------------------------------------------------
77  
78    // --- business -------------------------------------------------------------
79  
80    /**
81     * The name of the relation to create in the context of IANA.
82     *
83     * @param name the name without leading slash.
84     * @return the relation prefixed with {@link #IANA_HOME}.
85     */
86    public static String createIanaRelation(final String name)
87    {
88      return IANA_HOME + '/' + name;
89    }
90  
91    /**
92     * The name of the relation to create in the context of Microformats.
93     *
94     * @param name the name.
95     * @return the relation prefixed with {@link #MICROFORMATS_HOME}.
96     */
97    public static String createMicroformatsRelation(final String name)
98    {
99      return MICROFORMATS_HOME + name;
100   }
101 
102   // --- object basics --------------------------------------------------------
103 
104 }