Source: xxe/res/ResourceStorage.js

/**
 * The base class of objects used to load --possibly prompting user to do so-- 
 * and store {@linkplain Resource document resources}.
 */
export class ResourceStorage {
    /**
     * Constructs a document resource storage object. 
     *
     * @param {XMLEditor} xmlEditor - the XML editor using this storage object.
     */
    constructor(xmlEditor) {
        this._xmlEditor = xmlEditor;
    }

    /**
     * Returns the XML editor using this storage object.
     */
    get xmlEditor() {
        return this._xmlEditor;
    }
    
    /**
     * Load resource having specified URI.
     * <p>Default implementation returns a <code>Promise</code> rejected
     * with a "not implemented" error.
     * 
     * @param {string} uri - absolute URI of the resource to be loaded.
     * @return {Promise} A Promise containing a {@link Resource} 
     * or <code>null</code> if specified URI is unknown to this storage object
     * or an <code>Error</code>.
     */
    loadResource(uri) {
        return Promise.reject(new Error("'loadResource' not implemented"));
    }

    /**
     * Create (or overwrite if it already exists) resource having specified URI.
     * <p>Any parent directory of specified URI which does not already exist
     * is automatically created.
     * <p>Default implementation returns a <code>Promise</code> rejected
     * with a "not implemented" error.
     * 
     * @param {Blob} data - the data to be stored.
     * @param {string} uri - absolute URI of the resource to be created
     * (or overwritten if it already exists).
     * @return {Promise} A Promise containing a {@link Resource} 
     * or <code>null</code> if specified URI is unknown to this storage object
     * or an <code>Error</code>.
     */
    storeResource(data, uri) {
        return Promise.reject(new Error("'storeResource' not implemented"));
    }
    
    /**
     * Prompt user to choose an existing resource.
     * <p>Default implementation returns a <code>Promise</code> rejected
     * with a "not implemented" error.
     *
     * @param {Object} options - options for use by the resource chooser 
     * dialog box. See description in {@link XMLEditor#openResource}.
     * @return {Promise} A Promise containing a ready-to-use {@link Resource} 
     * or <code>null</code> if user canceled this operation or 
     * an <code>Error</code>.
     */
    openResource(options) {
        return Promise.reject(new Error("'openResource' not implemented"));
    }
}