001/*
002 * #%L
003 * Netarchivesuite - common
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023package dk.netarkivet.common.utils.archive;
024
025import java.io.File;
026import java.util.Date;
027import java.util.Map;
028import java.util.Set;
029
030/**
031 * Utility class for presenting the same interface record header API for both ARC and WARC record headers.
032 */
033public abstract class ArchiveHeaderBase {
034
035    /** Is this record from an ARC file. */
036    public boolean bIsArc;
037
038    /** Is this record from a WARC file. */
039    public boolean bIsWarc;
040
041    /**
042     * Return a header value object.
043     *
044     * @param key header key
045     * @return header value object
046     */
047    public abstract Object getHeaderValue(String key);
048
049    /**
050     * Return a header value string.
051     *
052     * @param key header key
053     * @return header value string
054     */
055    public abstract String getHeaderStringValue(String key);
056
057    /**
058     * Return a <code>Set</code> of header keys.
059     *
060     * @return <code>Set</code> of header keys.
061     */
062    public abstract Set<String> getHeaderFieldKeys();
063
064    /**
065     * Return a <code>Map</code> of all header key/value pairs.
066     *
067     * @return <code>Map</code> of all header key/value pairs.
068     */
069    public abstract Map<String, Object> getHeaderFields();
070
071    /**
072     * Return the header date as a <code>Date</code> object.
073     *
074     * @return header date as a <code>Date</code> object
075     */
076    public abstract Date getDate();
077
078    /**
079     * Return the header date in the ARC string format for use in CDX output.
080     *
081     * @return header date in the ARC string format
082     */
083    public abstract String getArcDateStr();
084
085    /**
086     * Get the record length from the header.
087     *
088     * @return the record length
089     */
090    public abstract long getLength();
091
092    /**
093     * Get the URL from the header.
094     *
095     * @return the URL from the header
096     */
097    public abstract String getUrl();
098
099    /**
100     * Get the IP-Address from the header.
101     *
102     * @return the IP-Address from the header
103     */
104    public abstract String getIp();
105
106    /**
107     * Get the content-type from the header and not the payload.
108     *
109     * @return the content-type from the header
110     */
111    public abstract String getMimetype();
112
113    /**
114     * Get record version.
115     *
116     * @return record version
117     */
118    public abstract String getVersion();
119
120    /**
121     * Get record offset.
122     *
123     * @return record offset
124     */
125    public abstract long getOffset();
126
127    /**
128     * Return the reader identifier.
129     *
130     * @return reader identifier
131     */
132    public abstract String getReaderIdentifier();
133
134    /**
135     * Return the record identifier.
136     *
137     * @return record identifier
138     */
139    public abstract String getRecordIdentifier();
140
141    /**
142     * Return the archive <code>File</code< object.
143     *
144     * @return archive <code>File</code< object
145     */
146    public abstract File getArchiveFile();
147
148}