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.eclipse.rdf4j.model.IRI;
    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 IRI contact = createProperty("contact");
    45      public final IRI acquaintance = createProperty("acquaintance");
    46      public final IRI friend = createProperty("friend");
    47      public final IRI met = createProperty("met");
    48      public final IRI coWorker = createProperty("co-worker");
    49      public final IRI colleague = createProperty("colleague");
    50      public final IRI coResident = createProperty("co-resident");
    51      public final IRI neighbor = createProperty("neighbor");
    52      public final IRI child = createProperty("child");
    53      public final IRI parent = createProperty("parent");
    54      public final IRI spouse = createProperty("spouse");
    55      public final IRI kin = createProperty("kin");
    56      public final IRI muse = createProperty("muse");
    57      public final IRI crush = createProperty("crush");
    58      public final IRI date = createProperty("date");
    59      public final IRI sweetheart = createProperty("sweetheart");
    60      public final IRI me = createProperty("me");
    61
    62      public final IRI mePage = createProperty(NS, "mePage");
    63
    64      private Map<String, IRI> PeopleXFNProperties;
    65
    66      private Map<String, IRI> HyperlinkXFNProperties;
    67
    68      public IRI getPropertyByLocalName(String localName) {
    69          return PeopleXFNProperties.get(localName);
    70      }
    71
    72      public IRI 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 IRI createProperty(String localName) {
    85          if (HyperlinkXFNProperties == null) {
    86              HyperlinkXFNProperties = new HashMap<String, IRI>();
    87          }
    88          if (PeopleXFNProperties == null) {
    89              PeopleXFNProperties = new HashMap<String, IRI>();
    90          }
    91
    92          IRI 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 }