Ejemplo n.º 1
0
 /**
  * This method takes a string conatining data and adds the parsed data to this model.
  *
  * @param string $str The string containing the data to be parsed and loaded.
  * @param type $type The type of the string, currently only 'json' is supported.
  */
 function loadFromString($str, $type)
 {
     switch ($type) {
         case 'json':
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_JSON;
             $parser = new JsonParser();
             break;
         case 'n3':
         case 'nt':
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
             $parser = new N3Parser();
             break;
         case 'rdf':
         case 'rdfxml':
         case 'xml':
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
             $parser = new RdfParser();
             break;
         case 'grddl':
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_GRDDL;
             $parser = new GRDDLParser();
             break;
         case 'rss':
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RSS;
             $parser = new RssParser();
             break;
         default:
             trigger_error('(class: Model; method: loadFromString): type ' . $type . 'is currently not supported', E_USER_ERROR);
     }
     if ($parser instanceof JsonParser) {
         $parser->generateModelFromString($str, $this);
     } else {
         $parser->generateModel($str, false, $this);
     }
 }