001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 */
017
018package org.nuxeo.ecm.platform.preview.restlet;
019
020import java.util.Calendar;
021
022import org.nuxeo.ecm.platform.preview.api.HtmlPreviewAdapter;
023
024/**
025 * Manage cache entry for computed previews.
026 * <p>
027 * This avoids the needs of rebuilding the preview on each access. This is particularly important when the generated
028 * HTML references images
029 *
030 * @author tiry
031 */
032public class PreviewCacheEntry {
033
034    protected Calendar modified;
035
036    protected HtmlPreviewAdapter adapter;
037
038    protected final long timeStamp;
039
040    protected String xpath;
041
042    public PreviewCacheEntry(Calendar modified, HtmlPreviewAdapter adapter, String xpath) {
043        this.modified = modified;
044        this.adapter = adapter;
045        this.xpath = xpath;
046        timeStamp = System.currentTimeMillis();
047    }
048
049    public long getTimeStamp() {
050        return timeStamp;
051    }
052
053    public Calendar getModified() {
054        return modified;
055    }
056
057    public void setModified(Calendar modified) {
058        this.modified = modified;
059    }
060
061    public HtmlPreviewAdapter getAdapter() {
062        return adapter;
063    }
064
065    public void setAdapter(HtmlPreviewAdapter adapter) {
066        this.adapter = adapter;
067    }
068
069    public String getXpath() {
070        return xpath;
071    }
072
073    public void setXpath(String xpath) {
074        this.xpath = xpath;
075    }
076
077}