// Path: marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicSesameException.java
// @SuppressWarnings("serial")
// public class MarkLogicSesameException extends RepositoryException {
// 
//     public MarkLogicSesameException(String message) {
//         super(message);
//     }
// 
//     public MarkLogicSesameException(Exception e) {
//         super(e);
//     }
// 
//     public MarkLogicSesameException(String message, Exception e) {
//         super(message,e);
//     }
// }


import com.marklogic.semantics.sesame.MarkLogicSesameException;
import org.openrdf.model.Model;
import org.openrdf.model.Resource;
import org.openrdf.model.URI;
import org.openrdf.model.Value;
import org.openrdf.model.impl.LinkedHashModel;
import org.openrdf.query.MalformedQueryException;
import org.openrdf.query.UpdateExecutionException;
import org.openrdf.repository.RepositoryException;
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFParseException;
import org.openrdf.rio.Rio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.TimerTask;
/*
 * Copyright 2015-2016 MarkLogic Corporation
 *
 * 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.
 */
/**
 * A timer that flushes a cache of triple add statements
 * periodically. The cache is represented as a Model.
 */
package com.marklogic.semantics.sesame.client;




/**
 * Timer implements write cache for efficient adding of triples
 *
 * @author James Fuller
 */
public abstract class TripleCache extends TimerTask {

    private static final Logger log = LoggerFactory.getLogger(TripleCache.class);

    protected Model cache;
    protected MarkLogicClient client;

    public static final long DEFAULT_CACHE_SIZE = 750;

    public static final long DEFAULT_CACHE_MILLIS = 800;
    public static final long DEFAULT_INITIAL_DELAY = 50;

    protected RDFFormat format = RDFFormat.NQUADS;

    protected long cacheSize;

    protected long cacheMillis;

    protected Date lastCacheAccess = new Date();

    /**
     * constructor
     *
     * @param client
     */
    public TripleCache(MarkLogicClient client) {
        super();
        this.client = client;
        this.cache = new LinkedHashModel();
        this.cacheSize = DEFAULT_CACHE_SIZE;
        this.cacheMillis = DEFAULT_CACHE_MILLIS;
    }

    public TripleCache(MarkLogicClient client, long cacheSize) {
        super();
        this.client = client;
        this.cache = new LinkedHashModel();
        setCacheSize(cacheSize);
    }

    /**
     * return cacheSize
     *
     * @return
     */
    public long getCacheSize() {
        return this.cacheSize;
    }

    /**
     *  set cacheSize
     *
     * @param cacheSize
     */
// Path: marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicSesameException.java
// @SuppressWarnings("serial")
// public class MarkLogicSesameException extends RepositoryException {
// 
//     public MarkLogicSesameException(String message) {
//         super(message);
//     }
// 
//     public MarkLogicSesameException(Exception e) {
//         super(e);
//     }
// 
//     public MarkLogicSesameException(String message, Exception e) {
//         super(message,e);
//     }
// }


// Path: marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/client/TripleCache.java
import com.marklogic.semantics.sesame.MarkLogicSesameException;
import org.openrdf.model.Model;
import org.openrdf.model.Resource;
import org.openrdf.model.URI;
import org.openrdf.model.Value;
import org.openrdf.model.impl.LinkedHashModel;
import org.openrdf.query.MalformedQueryException;
import org.openrdf.query.UpdateExecutionException;
import org.openrdf.repository.RepositoryException;
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFParseException;
import org.openrdf.rio.Rio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.TimerTask;

/*
 * Copyright 2015-2016 MarkLogic Corporation
 *
 * 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.
 */
/**
 * A timer that flushes a cache of triple add statements
 * periodically. The cache is represented as a Model.
 */
package com.marklogic.semantics.sesame.client;




/**
 * Timer implements write cache for efficient adding of triples
 *
 * @author James Fuller
 */
public abstract class TripleCache extends TimerTask {

    private static final Logger log = LoggerFactory.getLogger(TripleCache.class);

    protected Model cache;
    protected MarkLogicClient client;

    public static final long DEFAULT_CACHE_SIZE = 750;

    public static final long DEFAULT_CACHE_MILLIS = 800;
    public static final long DEFAULT_INITIAL_DELAY = 50;

    protected RDFFormat format = RDFFormat.NQUADS;

    protected long cacheSize;

    protected long cacheMillis;

    protected Date lastCacheAccess = new Date();

    /**
     * constructor
     *
     * @param client
     */
    public TripleCache(MarkLogicClient client) {
        super();
        this.client = client;
        this.cache = new LinkedHashModel();
        this.cacheSize = DEFAULT_CACHE_SIZE;
        this.cacheMillis = DEFAULT_CACHE_MILLIS;
    }

    public TripleCache(MarkLogicClient client, long cacheSize) {
        super();
        this.client = client;
        this.cache = new LinkedHashModel();
        setCacheSize(cacheSize);
    }

    /**
     * return cacheSize
     *
     * @return
     */
    public long getCacheSize() {
        return this.cacheSize;
    }

    /**
     *  set cacheSize
     *
     * @param cacheSize
     */
    public void setCacheSize(long cacheSize) {