All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.apicatalog.jsonld.document.Document Maven / Gradle / Ivy

There is a newer version: 1.4.1
Show newest version
/*
 * Copyright 2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.apicatalog.jsonld.document;

import java.net.URI;
import java.util.Optional;

import com.apicatalog.jsonld.http.media.MediaType;
import com.apicatalog.rdf.RdfDataset;

import jakarta.json.JsonStructure;

/**
 * A document that can be processed by the processor.
 *
 * This can either be {@link JsonStructure}, representing JSON-LD or JSON document,
 * or {@link RdfDataset}
 *
 * Implemented by {@link JsonDocument}, {@link RdfDocument}, and provided by {@link DocumentParser}.
 *
 */
public interface Document {

    /**
     * The Content-Type
     * of the loaded document, exclusive of any optional parameters.
     *
     * @return Content-Type of the loaded document, never null
     */
    MediaType getContentType();

    /**
     * The value of the HTTP Link header when profile attribute matches http://www.w3.org/ns/json-ld#context.
     *
     * @return attached {@link URI} referencing document context or null if not available
     */
    URI getContextUrl();

    void setContextUrl(URI contextUrl);

    /**
     * The final {@link URI} of the loaded document.
     *
     * @return {@link URI} of the loaded document or null if not available
     */
    URI getDocumentUrl();

    void setDocumentUrl(URI documentUrl);

    /**
     * The value of any profile parameter retrieved as part of the
     * original {@link #getContentType()}.
     *
     * @return document profile or {@link Optional#empty()}
     */
    Optional getProfile();

    /**
     * Get the document content as parsed {@link JsonStructure}.
     *
     * @return {@link JsonStructure} or {@link Optional#empty()} if document content is not JSON based
     */
    public default  Optional getJsonContent() {
        return Optional.empty();
    }

    /**
     * Get the document content as parsed {@link RdfDataset}.
     *
     * @return {@link RdfDataset} or {@link Optional#empty()} if document content is not in application/n-quads representation
     */
    public default Optional getRdfContent() {
        return Optional.empty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy