当前位置: 首页>>代码示例>>Java>>正文


Java RDFLanguages类代码示例

本文整理汇总了Java中org.apache.jena.riot.RDFLanguages的典型用法代码示例。如果您正苦于以下问题:Java RDFLanguages类的具体用法?Java RDFLanguages怎么用?Java RDFLanguages使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RDFLanguages类属于org.apache.jena.riot包,在下文中一共展示了RDFLanguages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeAction

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Override
protected void executeAction(DeltaAction action) throws IOException {
    LOG.info("GET "+action.getURL());
    Id dsRef = Id.fromString(action.httpArgs.datasourceName);
    String filenameIRI = determineData(action, dsRef);
    ContentType ct = RDFLanguages.guessContentType(filenameIRI) ;
    String fn = IRILib.IRIToFilename(filenameIRI);
    Path path = Paths.get(fn);
    try ( InputStream in = Files.newInputStream(path) ) {
        action.response.setStatus(HttpSC.OK_200);
        action.response.setContentType(ct.getContentType());
        IOUtils.copy(in, action.response.getOutputStream());
    } catch (NoSuchFileException | FileNotFoundException ex) {
        throw new DeltaNotFoundException(action.getURL());
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:17,代码来源:S_Data.java

示例2: analyze

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Override
public Iterator<byte[]> analyze(CrawleableUri curi, File data, Sink sink) {
    FileInputStream fin = null;
    try {
        // First, try to get the language of the data
        Lang lang = null;
        String contentType = (String) curi.getData(HttpHeaders.CONTENT_TYPE);
        if (contentType != null) {
            lang = RDFLanguages.contentTypeToLang(contentType);
        } else {
            lang = RDFLanguages.filenameToLang(data.getName(), null);
        }
        FilterSinkRDF filtered = new FilterSinkRDF(curi, sink);
        RDFDataMgr.parse(filtered, data.getAbsolutePath(), lang);
    } catch (Exception e) {
        LOGGER.error("Exception while analyzing. Aborting.");
    } finally {
        IOUtils.closeQuietly(fin);
    }
    return collector.getUris(curi);
}
 
开发者ID:dice-group,项目名称:Squirrel,代码行数:22,代码来源:RDFAnalyzer.java

示例3: onNext

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Override
public void onNext(String message) {
  try {
    long startTimestamp = System.currentTimeMillis();
    Model description = ModelFactory.createDefaultModel().read(
        new StringReader(message), null, RDFLanguages.strLangJSONLD);
    if (description != null && !description.isEmpty()) {
      String systemId = getSystemId(description);
      if (StringUtils.isNoneBlank(systemId)) {
        subscribeToDeviceTopic(systemId);
        logger.debug("Subscription topic is made in {} seconds",
            System.currentTimeMillis() - startTimestamp);
      } else {
        logger.error("Can'f find a ssn:System in device description!");
      }
    } else {
      logger.warn("Received an empty message or in a wrong format!");
    }
  } catch (Throwable ex) {
    logger.error(ex.getMessage(), ex);
  }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:23,代码来源:NewDeviceListener.java

示例4: testToRDF1

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Test
public void testToRDF1() {
  Observation observation = new Observation("123123", "123123-humidity",
      "2016-03-31T16:39:57+01:00",
      "http://qudt.org/vocab/quantity#ThermodynamicTemperature",
      null, "3.4");

  Model model = observation.toRDF();

  model.write(System.out, RDFLanguages.strLangTurtle);

  assertTrue(model.contains(
      null,
      SSN.observationResultTime,
      ResourceFactory.createTypedLiteral("2016-03-31T16:39:57+01:00",
          XSDDatatype.XSDdateTime)));
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:18,代码来源:ObservationTest.java

示例5: testToRDF2

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Test
public void testToRDF2() {
  Observation observation = new Observation("123123", "123123-humidity",
      "2016-03-31T16:39:57+01:00",
      "http://qudt.org/vocab/quantity#ThermodynamicTemperature",
      null, "3.4");

  Model model = observation.toRDF();

  model.write(System.out, RDFLanguages.strLangTurtle);

  assertTrue(model.contains(
      null,
      SSN.observationResultTime,
      ResourceFactory.createTypedLiteral("2016-03-31T16:39:57+01:00",
          XSDDatatype.XSDdateTime)));
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:18,代码来源:ObservationTest.java

示例6: listResourcesWithProperty

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Test
public void listResourcesWithProperty() {
  Model model = ModelFactory.createDefaultModel();
  RDFDataMgr.read(model, this.getClass().getResourceAsStream(PATH_PREFIX + "system.ttl"),
      RDFLanguages.TURTLE);

  List<Resource> actual = RDFUtils.listResourcesWithProperty(
      model, RDF.type, SSN.System, Proto.Individual);

  List<Resource> expected = new ArrayList<>();
  expected.add(ResourceFactory.createResource("http://localhost/systems/3503522021"));

  assertEquals(expected, actual);

  assertEquals(0, RDFUtils.listResourcesWithProperty(
      model, RDF.type, OWL.Class).size());
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:18,代码来源:RDFUtilsTest.java

示例7: readFrom

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Override
   public Model readFrom(Class<Model> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException
   {
if (log.isTraceEnabled()) log.trace("Reading Model with HTTP headers: {} MediaType: {}", httpHeaders, mediaType);

Model model = ModelFactory.createDefaultModel();	

       MediaType formatType = new MediaType(mediaType.getType(), mediaType.getSubtype()); // discard charset param        
       Lang lang = RDFLanguages.contentTypeToLang(formatType.toString());
       if (lang == null)
       {
           if (log.isErrorEnabled()) log.error("MediaType '{}' not supported by Jena", formatType);
           throw new NoReaderForLangException("MediaType not supported: " + formatType);
       }
if (log.isDebugEnabled()) log.debug("RDF language used to read Model: {}", lang);
       
       return read(model, entityStream, lang, getUriInfo().getBaseUri().toString());
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:19,代码来源:BasedModelProvider.java

示例8: writeTo

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Override
   public void writeTo(Model model, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException
   {
if (log.isTraceEnabled()) log.trace("Writing Model with HTTP headers: {} MediaType: {}", httpHeaders, mediaType);

       MediaType formatType = new MediaType(mediaType.getType(), mediaType.getSubtype()); // discard charset param        
       Lang lang = RDFLanguages.contentTypeToLang(formatType.toString());
       if (lang == null)
       {
           if (log.isErrorEnabled()) log.error("MediaType '{}' not supported by Jena", formatType);
           throw new NoWriterForLangException("MediaType not supported: " + formatType);
       }
if (log.isDebugEnabled()) log.debug("RDF language used to read Model: {}", lang);
       
write(model, entityStream, lang, getUriInfo().getBaseUri().toString());
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:17,代码来源:BasedModelProvider.java

示例9: setUpBeforeClass

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
	// create engine
	String[] cachefiles = { "src/test/data3/index/cache/uriToLabelCache_1.object",
			"src/test/data3/index/cache/uriToLabelCache_2.object", 
			"src/test/data3/index/cache/uriToLabelCache_3.object"
	};
	String modelfile = "src/test/data3/index/model/probAlgState.object";
	String corpusfile = "src/test/data3/index/model/lodStats_final_noFilter.corpus";
	String rdfMetaDataFile = "src/test/data3/index/model/lodstats.nt";
	int elasticport = 9300;
	engine = new SearchEngineBean( cachefiles, modelfile, corpusfile, rdfMetaDataFile, elasticport );
	
	// create model
	InputStream stream = new FileInputStream( new File( "src/test/data3/metadata/34.nt" ) );
	model = ModelFactory.createDefaultModel();
	RDFDataMgr.read( model, stream, RDFLanguages.nameToLang( "N-TRIPLES" ) );
	stream.close();
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:20,代码来源:SearchEngineBeanTest.java

示例10: test00GetVoidInformation

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * 0.nt
 */
@Test
public final void test00GetVoidInformation() {
	// set input file
	String inFile = "src/test/data/0.nt";
	// run extraction
	try {
		// setup
		InputStream inStream = new FileInputStream( inFile );
		PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
		PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
		// run
		RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
		VoidParsingExtractor extractor = new VoidParsingExtractor();
		extractor.extract( iter );
		// print
		System.out.println( "0.nt\n  " + extractor.getVoidInformation().toString() );
		// test
		assertEquals( 0, extractor.getVoidInformation().size() );
	}
	catch( Exception e ) {
		fail( e.toString() );
	}
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例11: test051GetVoidInformation

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * 5.nt
 */
@Test
public final void test051GetVoidInformation() {
	// set input file
	String inFile = "src/test/data/5.nt";
	// run extraction
	try {
		// setup
		InputStream inStream = new FileInputStream( inFile );
		PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
		PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
		// run
		RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
		VoidParsingExtractor extractor = new VoidParsingExtractor();
		extractor.extract( iter );
		// print
		System.out.println( "5.nt:\n  " + extractor.getVoidInformation().toString() );
		// test
		assertEquals( 0, extractor.getVoidInformation().size() );
	}
	catch( Exception e ) {
		fail( e.toString() );
	}
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例12: test052GetVoidInformation

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * expected_5.nt
 */
@Test
public final void test052GetVoidInformation() {
	// set input file
	String inFile = "src/test/data/expected_5.nt";
	// run extraction
	try {
		// setup
		InputStream inStream = new FileInputStream( inFile );
		PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
		PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
		// run
		RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
		VoidParsingExtractor extractor = new VoidParsingExtractor();
		extractor.extract( iter );
		// print
		System.out.println( "expected_5.nt:\n  " + extractor.getVoidInformation().toString() );
		// test
		assertEquals( 11, extractor.getVoidInformation().size() );
	}
	catch( Exception e ) {
		fail( e.toString() );
	}		
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例13: readStatResults

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
/**
 * Read statResults file
 * 
 * @param statResultsFile
 *            statresults.nt
 * @return StatResults in extractor
 */
private IntObjectOpenHashMap<StatResult> readStatResults(String statResultsFile) {
	StatResultsExtractor extractor = new StatResultsExtractor();
	FileInputStream fin = null;
	try {
		fin = new FileInputStream(statResultsFile);
		streamer.runExtraction(fin, LOD_STATS_STAT_RESULT_BASE_URI, RDFLanguages.filenameToLang(statResultsFile),
				extractor);
	} catch (Exception e) {
		LOGGER.error("Error while parsing file \"" + statResultsFile + "\". Aborting.", e);
		return null;
	} finally {
		IOUtils.closeQuietly(fin);
	}
	return extractor.statResults;
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:23,代码来源:StatResultsReader.java

示例14: getMashup

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
private Mashup getMashup(final JsonObject obj) {
  final JsonValue val = obj.get(mashup);
  if (val == null || !(val instanceof JsonObject)) {
    throw new IllegalArgumentException("expecting a mashup description");
  }
  final JsonObject mashupObj = (JsonObject) val;
  final Lang lang;
  final String data;
  if (mashupObj.containsKey(mediaType)) {
    // XXX accept any supported language, although the request schema only allows a subset (application/rdf+json,
    // application/rdf+xml, text/turtle).
    lang = RDFLanguages.nameToLang(mashupObj.getString(mediaType));
    if (lang == null) {
      throw new IllegalArgumentException("unsupported media type");
    }
    data = mashupObj.getString(content);
    if (Strings.isNullOrEmpty(data)) {
      throw new IllegalArgumentException("expecting non-empty mashup content");
    }
  } else {
    data = stringify(mashupObj);
    lang = Lang.RDFJSON;
  }
  return parseMashup(data, lang);
}
 
开发者ID:ewie,项目名称:cobalt,代码行数:26,代码来源:JsonPlannerRequestDeserializer.java

示例15: createDefaultLoaders

import org.apache.jena.riot.RDFLanguages; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
protected Map<String, ContentStreamLoader> createDefaultLoaders(final NamedList parameters) {
	final Map<String, ContentStreamLoader> registry = new HashMap<String, ContentStreamLoader>();
	final ContentStreamLoader loader = new RdfDataLoader();
	for (final Lang language : RDFLanguages.getRegisteredLanguages()) {
		registry.put(language.getContentType().toHeaderString(), loader);
	}
	registry.put(WebContent.contentTypeSPARQLUpdate, new Sparql11UpdateRdfDataLoader());

	if (log.isDebugEnabled()) {
		prettyPrint(registry);
	}
	
	return registry;
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:17,代码来源:RdfBulkUpdateRequestHandler.java


注:本文中的org.apache.jena.riot.RDFLanguages类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。