Esempio n. 1
0
  /**
   * Creates a predicate node using the given string as a lookup in the dictionary.
   *
   * @param key The key into the dictionary
   * @param elementFactory The factory for creating nodes
   * @return The predicate as a node
   * @throws MetaDataException
   */
  public static PredicateNode createPredicate(String key, GraphElementFactory elementFactory)
      throws MetaDataException {

    try {

      // Create the type node
      return (PredicateNode) elementFactory.createResource(RDF.TYPE);
    } catch (GraphElementFactoryException graphElementFactoryException) {

      throw new MetaDataException(
          "Failed to create predicate node for key: " + key, graphElementFactoryException);
    }
  }
Esempio n. 2
0
  /**
   * Creates an object node using a literal value.
   *
   * @param value The value of the literal
   * @param elementFactory The factory for creating nodes
   * @return The object node representing the literal
   * @throws MetaDataException
   */
  public static ObjectNode createObjectLiteral(String value, GraphElementFactory elementFactory)
      throws MetaDataException {

    try {

      // The default type is file
      return (ObjectNode) elementFactory.createLiteral(value);
    } catch (GraphElementFactoryException graphElementFactoryException) {

      throw new MetaDataException(
          "Failed to create object node for " + value, graphElementFactoryException);
    }
  }
Esempio n. 3
0
  /**
   * Creates a predicate node using the given given uri.
   *
   * @param reference The URI reference to use as the predicate
   * @param elementFactory The factory for creating nodes
   * @return The predicate as a node
   * @throws MetaDataException
   */
  public static PredicateNode createPredicateFromURI(
      URI reference, GraphElementFactory elementFactory) throws MetaDataException {

    try {

      // Create the type node
      return (PredicateNode) elementFactory.createResource(reference);
    } catch (GraphElementFactoryException graphElementFactoryException) {

      throw new MetaDataException(
          "Failed to create predicate node for URI " + reference.toString(),
          graphElementFactoryException);
    }
  }