You are here

class EasyRdf_Serialiser_Rapper in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Rapper.php \EasyRdf_Serialiser_Rapper

Class to serialise an EasyRdf_Graph to RDF using the 'rapper' command line tool.

Note: the built-in N-Triples serialiser is used to pass data to Rapper.

@package EasyRdf @copyright Copyright (c) 2009-2013 Nicholas J Humfrey @license http://www.opensource.org/licenses/bsd-license.php

Hierarchy

Expanded class hierarchy of EasyRdf_Serialiser_Rapper

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Rapper.php, line 48

View source
class EasyRdf_Serialiser_Rapper extends EasyRdf_Serialiser_Ntriples {
  private $rapperCmd = null;

  /**
   * Constructor
   *
   * @param string $rapperCmd Optional path to the rapper command to use.
   * @return object EasyRdf_Serialiser_Rapper
   */
  public function __construct($rapperCmd = 'rapper') {
    $result = exec("{$rapperCmd} --version 2>/dev/null", $output, $status);
    if ($status != 0) {
      throw new EasyRdf_Exception("Failed to execute the command '{$rapperCmd}': {$result}");
    }
    else {
      $this->rapperCmd = $rapperCmd;
    }
  }

  /**
   * Serialise an EasyRdf_Graph to the RDF format of choice.
   *
   * @param EasyRdf_Graph $graph   An EasyRdf_Graph object.
   * @param string        $format  The name of the format to convert to.
   * @param array         $options
   * @return string The RDF in the new desired format.
   */
  public function serialise($graph, $format, array $options = array()) {
    parent::checkSerialiseParams($graph, $format);
    $ntriples = parent::serialise($graph, 'ntriples');

    // Hack to produce more concise RDF/XML
    if ($format == 'rdfxml') {
      $format = 'rdfxml-abbrev';
    }
    return EasyRdf_Utils::execCommandPipe($this->rapperCmd, array(
      '--quiet',
      '--input',
      'ntriples',
      '--output',
      $format,
      '-',
      'unknown://',
    ), $ntriples);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EasyRdf_Serialiser::$prefixes protected property
EasyRdf_Serialiser::addPrefix protected function Keep track of the prefixes used while serialising @ignore
EasyRdf_Serialiser::checkSerialiseParams protected function Check and cleanup parameters passed to serialise() method @ignore
EasyRdf_Serialiser::reversePropertyCount protected function Protected method to get the number of reverse properties for a resource If a resource only has a single property, the number of values for that property is returned instead. @ignore
EasyRdf_Serialiser_Ntriples::$escChars private property
EasyRdf_Serialiser_Ntriples::escapedChar protected function @ignore
EasyRdf_Serialiser_Ntriples::escapeString protected function @ignore
EasyRdf_Serialiser_Ntriples::serialiseResource protected function @ignore
EasyRdf_Serialiser_Ntriples::serialiseValue public function Serialise an RDF value into N-Triples
EasyRdf_Serialiser_Ntriples::unicodeCharNo protected function @ignore
EasyRdf_Serialiser_Rapper::$rapperCmd private property
EasyRdf_Serialiser_Rapper::serialise public function Serialise an EasyRdf_Graph to the RDF format of choice. Overrides EasyRdf_Serialiser_Ntriples::serialise
EasyRdf_Serialiser_Rapper::__construct public function Constructor Overrides EasyRdf_Serialiser::__construct