Java Code Examples for org.apache.jena.riot.Lang#TRIG

The following examples show how to use org.apache.jena.riot.Lang#TRIG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RDFReader.java    From marklogic-contentpump with Apache License 2.0 6 votes vote down vote up
public boolean nextStreamingKeyValue() throws IOException, InterruptedException {
    if(rdfIter == null) return false;
    if (!rdfIter.hasNext() && collectionHash.size() == 0) {
        if(compressed) {
            hasNext = false;
            return false;
        } else {
            if (iterator!=null && iterator.hasNext()) {
                close();
                initStream(iterator.next());
            } else {
                hasNext = false;
                return false;
            }
        }
    }

    if (lang == Lang.NQUADS || lang == Lang.TRIG) {
        return nextStramingQuadKeyValue();
    } else {
        return nextStreamingTripleKeyValue();
    }
}
 
Example 2
Source File: LangUtils.java    From hypergraphql with Apache License 2.0 5 votes vote down vote up
public static Lang forName(final String rdfFormat) {

        final String ucRdfFormat = rdfFormat.toUpperCase();
        switch(ucRdfFormat) {

            case "N3":
            case "TTL":
            case "TURTLE":
                return Lang.TURTLE;
            case "NT":
            case "NTRIPLES":
                return Lang.NTRIPLES;
            case "NQ":
            case "NQUADS":
                return Lang.NQUADS;
            case "TRIG":
                return Lang.TRIG;
            case "TRIX":
                return Lang.TRIX;
            case "RDFXML":
                return Lang.RDFXML;
            case "RDFJSON":
                return Lang.RDFJSON;
            case "JSONLD":
            case "JSON-LD":
            case "LD+JSON":
                return Lang.JSONLD;
            default:
                throw new RuntimeException(rdfFormat + " is not currently supported");
        }
    }
 
Example 3
Source File: RDFReader.java    From marklogic-contentpump with Apache License 2.0 5 votes vote down vote up
public boolean nextInMemoryKeyValue() throws IOException, InterruptedException {
    if (lang == Lang.NQUADS || lang == Lang.TRIG) {
        return nextInMemoryQuadKeyValue();
    } else {
        return nextInMemoryTripleKeyValue();
    }
}
 
Example 4
Source File: RdfBulkUpdateRequestHandler.java    From SolRDF with Apache License 2.0 4 votes vote down vote up
@Override
public void load(
		final SolrQueryRequest request, 
		final SolrQueryResponse response,
		final ContentStream stream, 
		final UpdateRequestProcessor processor) throws Exception {
	
	// Default ContentStream implementation starts reading the stream and
	// if it starts with '<' then it assumes a content type of "application/xml", 
	// if it starts with '{' then it assumes a content type of "application/json" 			
	// This behaviour is wrong is SolRDF and maybe we need a custom ContentStream here
	// At the moment this is just a workaround:
	final String contentType = stream.getContentType() != null 
			&& !"application/xml".equals(stream.getContentType())
			&& !"application/json".equals(stream.getContentType()) 
				? stream.getContentType() 
				: request.getParams().get(UpdateParams.ASSUME_CONTENT_TYPE);
	
	log.debug(MessageCatalog._00094_BULK_LOADER_CT, contentType);			
				
	final Lang lang = RDFLanguages.contentTypeToLang(contentType);
	if (lang == null) {
		final String message = MessageFactory.createMessage(MessageCatalog._00095_INVALID_CT, contentType);
		log.error(message);							
		throw new SolrException(ErrorCode.BAD_REQUEST, message);
	}
	
	final ContentStreamLoader delegate = 
			(lang == Lang.NQ || lang == Lang.NQUADS || lang == Lang.TRIG)
				? quadsLoader
				: triplesLoader;
	
	log.debug(MessageCatalog._00096_SELECTED_BULK_LOADER, contentType, delegate);
	
	delegate.load(
			request, 
			response, 
			new ContentStream() {	
				@Override
				public InputStream getStream() throws IOException {
					return stream.getStream();
				}
				
				@Override
				public String getSourceInfo() {
					return stream.getSourceInfo();
				}
				
				@Override
				public Long getSize() {
					return stream.getSize();
				}
				
				@Override
				public Reader getReader() throws IOException {
					return stream.getReader();
				}
				
				@Override
				public String getName() {
					return stream.getName();
				}
				
				@Override
				public String getContentType() {
					return contentType;
				}
			}, 
		processor);
}