001/*
002 * Shredzone Commons - pdb
003 *
004 * Copyright (C) 2009 Richard "Shred" Körber
005 *   http://commons.shredzone.org
006 *
007 * This program is free software: you can redistribute it and/or modify
008 * it under the terms of the GNU Library General Public License as
009 * published by the Free Software Foundation, either version 3 of the
010 * License, or (at your option) any later version.
011 *
012 * This program is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015 * GNU General Public License for more details.
016 *
017 * You should have received a copy of the GNU Library General Public License
018 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
019 */
020package org.shredzone.commons.pdb;
021
022import java.util.ArrayList;
023import java.util.Calendar;
024import java.util.List;
025
026import org.shredzone.commons.pdb.appinfo.AppInfo;
027import org.shredzone.commons.pdb.record.Record;
028
029/**
030 * Represents the contents of a PDB database file.
031 */
032public class PdbDatabase<T extends Record, U extends AppInfo> {
033
034    public static final int ATTR_RESDB = 0x0001;
035    public static final int ATTR_READONLY = 0x0002;
036    public static final int ATTR_APPINFODIRTY = 0x0004;
037    public static final int ATTR_BACKUP = 0x0008;
038    public static final int ATTR_OKINSTALLNEWER = 0x0010;
039    public static final int ATTR_RESET = 0x0020;
040    public static final int ATTR_COPYPREVENTION = 0x0040;
041    public static final int ATTR_STREAM = 0x0080;
042    public static final int ATTR_HIDDEN = 0x0100;
043    public static final int ATTR_LAUNCHABLE_DATA = 0x0200;
044    public static final int ATTR_RECYCLABLE = 0x0400;
045    public static final int ATTR_BUNDLE = 0x0800;
046    public static final int ATTR_OPEN = 0x8000;
047
048    private String name;
049    private int attributes;
050    private int version;
051    private Calendar creationTime;
052    private Calendar modificationTime;
053    private Calendar backupTime;
054    private int modificationNumber;
055    private String type;
056    private String creator;
057    private U appInfo;
058    private List<T> records = new ArrayList<>();
059
060    /**
061     * Gets the database name (for example "CalendarDB-PDat").
062     */
063    public String getName()             { return name; }
064    public void setName(String name)    { this.name = name; }
065
066    /**
067     * Gets the attributes of the database. See ATTR constants, which are or'ed.
068     */
069    public int getAttributes()          { return attributes; }
070    public void setAttributes(int attributes) { this.attributes = attributes; }
071
072    /**
073     * Gets the database version.
074     */
075    public int getVersion()             { return version; }
076    public void setVersion(int version) { this.version = version; }
077
078    /**
079     * Gets the creation time of the database. Should not be {@code null}.
080     */
081    public Calendar getCreationTime()   { return creationTime; }
082    public void setCreationTime(Calendar creationTime) { this.creationTime = creationTime; }
083
084    /**
085     * Gets the modification time of the database. Should not be {@code null}.
086     */
087    public Calendar getModificationTime() { return modificationTime; }
088    public void setModificationTime(Calendar modificationTime) { this.modificationTime = modificationTime; }
089
090    /**
091     * Gets the backup time of the database. Is {@code null} if the database has not
092     * been backed up yet.
093     */
094    public Calendar getBackupTime()     { return backupTime; }
095    public void setBackupTime(Calendar backupTime) { this.backupTime = backupTime; }
096
097    /**
098     * Gets the modification number.
099     */
100    public int getModificationNumber()  { return modificationNumber; }
101    public void setModificationNumber(int modificationNumber) { this.modificationNumber = modificationNumber; }
102
103    /**
104     * Gets the database type.
105     */
106    public String getType()             { return type; }
107    public void setType(String type)    { this.type = type; }
108
109    /**
110     * Gets the database creator. For example "PDAT".
111     */
112    public String getCreator()          { return creator; }
113    public void setCreator(String creator) { this.creator = creator; }
114
115    /**
116     * Gets the {@link AppInfo} of this database. {@code null} if no appinfo area was
117     * available.
118     */
119    public U getAppInfo()               { return appInfo; }
120    public void setAppInfo(U appInfo)   { this.appInfo = appInfo; }
121
122    /**
123     * Gets all records of this database.
124     */
125    public List<T> getRecords()         { return records; }
126
127}