EMMA Coverage Report (generated Sun Mar 01 22:06:14 CET 2015)
[all classes][org.h2.util]

COVERAGE SUMMARY FOR SOURCE FILE [CacheObject.java]

nameclass, %method, %block, %line, %
CacheObject.java100% (1/1)86%  (6/7)87%  (34/39)83%  (10/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CacheObject100% (1/1)86%  (6/7)87%  (34/39)83%  (10/12)
isStream (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
setPos (int): void 100% (1/1)83%  (15/18)80%  (4/5)
CacheObject (): void 100% (1/1)100% (3/3)100% (1/1)
compareTo (CacheObject): int 100% (1/1)100% (6/6)100% (1/1)
getPos (): int 100% (1/1)100% (3/3)100% (1/1)
isChanged (): boolean 100% (1/1)100% (3/3)100% (1/1)
setChanged (boolean): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (http://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6package org.h2.util;
7 
8import org.h2.engine.SysProperties;
9import org.h2.message.DbException;
10 
11/**
12 * The base object for all cached objects.
13 */
14public abstract class CacheObject implements Comparable<CacheObject> {
15 
16    /**
17     * The previous element in the LRU linked list. If the previous element is
18     * the head, then this element is the most recently used object.
19     */
20    public CacheObject cachePrevious;
21 
22    /**
23     * The next element in the LRU linked list. If the next element is the head,
24     * then this element is the least recently used object.
25     */
26    public CacheObject cacheNext;
27 
28    /**
29     * The next element in the hash chain.
30     */
31    public CacheObject cacheChained;
32 
33    private int pos;
34    private boolean changed;
35 
36    /**
37     * Check if the object can be removed from the cache.
38     * For example pinned objects can not be removed.
39     *
40     * @return true if it can be removed
41     */
42    public abstract boolean canRemove();
43 
44    /**
45     * Get the estimated used memory.
46     *
47     * @return number of words (one word is 4 bytes)
48     */
49    public abstract int getMemory();
50 
51    public void setPos(int pos) {
52        if (SysProperties.CHECK) {
53            if (cachePrevious != null || cacheNext != null || cacheChained != null) {
54                DbException.throwInternalError("setPos too late");
55            }
56        }
57        this.pos = pos;
58    }
59 
60    public int getPos() {
61        return pos;
62    }
63 
64    /**
65     * Check if this cache object has been changed and thus needs to be written
66     * back to the storage.
67     *
68     * @return if it has been changed
69     */
70    public boolean isChanged() {
71        return changed;
72    }
73 
74    public void setChanged(boolean b) {
75        changed = b;
76    }
77 
78    @Override
79    public int compareTo(CacheObject other) {
80        return MathUtils.compareInt(getPos(), other.getPos());
81    }
82 
83    public boolean isStream() {
84        return false;
85    }
86 
87}

[all classes][org.h2.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov