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

no.hasmac.jsonld.document.Document Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2020 APICATALOG and HASMAC.
 *
 * 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.
 * 
 * SPDX-License-Identifier: Apache-2.0
 */

package no.hasmac.jsonld.document;

import jakarta.json.JsonStructure;
import no.hasmac.jsonld.http.media.MediaType;
import no.hasmac.rdf.RdfDataset;

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

/**
 * 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