View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *  http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.any23.vocab;
19  
20  import org.openrdf.model.URI;
21  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  /**
26   * Vocabulary class for <a href="http://gmpg.org/xfn/11">XFN</a>, as per
27   * <a href="http://vocab.sindice.com/xfn/guide.html">Expressing XFN in RDF</a>.
28   *
29   * @author Richard Cyganiak (richard@cyganiak.de)
30   */
31  public class XFN extends Vocabulary {
32  
33      public static final String NS = "http://vocab.sindice.com/xfn#";
34  
35      private static XFN instance;
36  
37      public static XFN getInstance() {
38          if(instance == null) {
39              instance = new XFN();
40          }
41          return instance;
42      }
43  
44      public final URI contact      = createProperty("contact");
45      public final URI acquaintance = createProperty("acquaintance");
46      public final URI friend       = createProperty("friend");
47      public final URI met          = createProperty("met");
48      public final URI coWorker     = createProperty("co-worker");
49      public final URI colleague    = createProperty("colleague");
50      public final URI coResident   = createProperty("co-resident");
51      public final URI neighbor     = createProperty("neighbor");
52      public final URI child        = createProperty("child");
53      public final URI parent       = createProperty("parent");
54      public final URI spouse       = createProperty("spouse");
55      public final URI kin          = createProperty("kin");
56      public final URI muse         = createProperty("muse");
57      public final URI crush        = createProperty("crush");
58      public final URI date         = createProperty("date");
59      public final URI sweetheart   = createProperty("sweetheart");
60      public final URI me           = createProperty("me");
61  
62      public final URI mePage = createProperty(NS, "mePage");
63  
64      private  Map<String, URI> PeopleXFNProperties;
65  
66      private Map<String, URI> HyperlinkXFNProperties;
67  
68      public URI getPropertyByLocalName(String localName) {
69          return PeopleXFNProperties.get(localName);
70      }
71  
72      public URI getExtendedProperty(String localName) {
73          return HyperlinkXFNProperties.get(localName);
74      }
75  
76      public boolean isXFNLocalName(String localName) {
77          return PeopleXFNProperties.containsKey(localName);
78      }
79  
80      public boolean isExtendedXFNLocalName(String localName) {
81          return PeopleXFNProperties.containsKey(localName);
82      }
83  
84      private URI createProperty(String localName) {
85          if(HyperlinkXFNProperties == null) {
86              HyperlinkXFNProperties = new HashMap<String, URI>();
87          }
88          if(PeopleXFNProperties == null) {
89              PeopleXFNProperties =  new HashMap<String, URI>();
90          }
91  
92          URI result = createProperty(NS, localName + "-hyperlink");
93          HyperlinkXFNProperties.put(localName, result);
94  
95          result = createProperty(NS, localName);
96          PeopleXFNProperties.put(localName, result);
97          return result;
98      }
99  
100     private XFN(){
101         super(NS);
102     }
103 
104 }