Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractOpenFileState |
|
| 1.0;1 |
1 | /** | |
2 | * Distribution License: | |
3 | * JSword is free software; you can redistribute it and/or modify it under | |
4 | * the terms of the GNU Lesser General Public License, version 2.1 or later | |
5 | * as published by the Free Software Foundation. This program is distributed | |
6 | * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
7 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
8 | * See the GNU Lesser General Public License for more details. | |
9 | * | |
10 | * The License is available on the internet at: | |
11 | * http://www.gnu.org/copyleft/lgpl.html | |
12 | * or by writing to: | |
13 | * Free Software Foundation, Inc. | |
14 | * 59 Temple Place - Suite 330 | |
15 | * Boston, MA 02111-1307, USA | |
16 | * | |
17 | * © CrossWire Bible Society, 2013 - 2016 | |
18 | * | |
19 | */ | |
20 | package org.crosswire.jsword.book.sword.state; | |
21 | ||
22 | import org.crosswire.jsword.book.BookMetaData; | |
23 | ||
24 | /** | |
25 | * | |
26 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
27 | * @author DM Smith | |
28 | */ | |
29 | public abstract class AbstractOpenFileState implements OpenFileState { | |
30 | /** | |
31 | * Create an AbstractOpenFileState tied to a BookMetaData. | |
32 | * | |
33 | * @param bmd the BookMetaData for this OpenFileState | |
34 | */ | |
35 | 0 | public AbstractOpenFileState(BookMetaData bmd) { |
36 | 0 | bookMetaData = bmd; |
37 | 0 | lastAccess = System.currentTimeMillis(); |
38 | 0 | } |
39 | ||
40 | /** | |
41 | * Allows us to decide whether to release the resources or continue using them | |
42 | */ | |
43 | public void close() { | |
44 | 0 | OpenFileStateManager.instance().release(this); |
45 | 0 | } |
46 | ||
47 | /** | |
48 | * Get the BookMetaData for this OpenFileState. | |
49 | * | |
50 | * @return the BookMetaData | |
51 | */ | |
52 | public BookMetaData getBookMetaData() { | |
53 | 0 | return bookMetaData; |
54 | } | |
55 | /** | |
56 | * @return latest access before releasing back to the pool | |
57 | */ | |
58 | public long getLastAccess() { | |
59 | 0 | return this.lastAccess; |
60 | } | |
61 | ||
62 | /** | |
63 | * @param lastAccess last time the file state was accessed | |
64 | */ | |
65 | public void setLastAccess(final long lastAccess) { | |
66 | 0 | this.lastAccess = lastAccess; |
67 | 0 | } |
68 | ||
69 | /** | |
70 | * The BookMetaData for this OpenFileState. Used to locate files. | |
71 | */ | |
72 | private BookMetaData bookMetaData; | |
73 | ||
74 | /** | |
75 | * The time of last access, used for LRU expiration of state. | |
76 | */ | |
77 | private long lastAccess; | |
78 | } |