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

COVERAGE SUMMARY FOR SOURCE FILE [FilePathWrapper.java]

nameclass, %method, %block, %line, %
FilePathWrapper.java100% (1/1)100% (26/26)93%  (177/191)95%  (35/37)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FilePathWrapper100% (1/1)100% (26/26)93%  (177/191)95%  (35/37)
create (String, FilePath): FilePathWrapper 100% (1/1)48%  (13/27)67%  (4/6)
FilePathWrapper (): void 100% (1/1)100% (3/3)100% (1/1)
canWrite (): boolean 100% (1/1)100% (4/4)100% (1/1)
createDirectory (): void 100% (1/1)100% (4/4)100% (2/2)
createFile (): boolean 100% (1/1)100% (4/4)100% (1/1)
createTempFile (String, boolean, boolean): FilePath 100% (1/1)100% (9/9)100% (1/1)
delete (): void 100% (1/1)100% (4/4)100% (2/2)
exists (): boolean 100% (1/1)100% (4/4)100% (1/1)
getBase (): FilePath 100% (1/1)100% (3/3)100% (1/1)
getParent (): FilePath 100% (1/1)100% (6/6)100% (1/1)
getPath (String): FilePathWrapper 100% (1/1)100% (7/7)100% (1/1)
getPrefix (): String 100% (1/1)100% (10/10)100% (1/1)
isAbsolute (): boolean 100% (1/1)100% (4/4)100% (1/1)
isDirectory (): boolean 100% (1/1)100% (4/4)100% (1/1)
lastModified (): long 100% (1/1)100% (4/4)100% (1/1)
moveTo (FilePath, boolean): void 100% (1/1)100% (8/8)100% (2/2)
newDirectoryStream (): List 100% (1/1)100% (26/26)100% (4/4)
newInputStream (): InputStream 100% (1/1)100% (4/4)100% (1/1)
newOutputStream (boolean): OutputStream 100% (1/1)100% (5/5)100% (1/1)
open (String): FileChannel 100% (1/1)100% (5/5)100% (1/1)
setReadOnly (): boolean 100% (1/1)100% (4/4)100% (1/1)
size (): long 100% (1/1)100% (4/4)100% (1/1)
toRealPath (): FilePath 100% (1/1)100% (6/6)100% (1/1)
unwrap (): FilePath 100% (1/1)100% (5/5)100% (1/1)
unwrap (String): FilePath 100% (1/1)100% (9/9)100% (1/1)
wrap (FilePath): FilePathWrapper 100% (1/1)100% (18/18)100% (1/1)

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.store.fs;
7 
8import java.io.IOException;
9import java.io.InputStream;
10import java.io.OutputStream;
11import java.nio.channels.FileChannel;
12import java.util.List;
13 
14/**
15 * The base class for wrapping / delegating file systems such as
16 * the split file system.
17 */
18public abstract class FilePathWrapper extends FilePath {
19 
20    private FilePath base;
21 
22    @Override
23    public FilePathWrapper getPath(String path) {
24        return create(path, unwrap(path));
25    }
26 
27    /**
28     * Create a wrapped path instance for the given base path.
29     *
30     * @param base the base path
31     * @return the wrapped path
32     */
33    public FilePathWrapper wrap(FilePath base) {
34        return base == null ? null : create(getPrefix() + base.name, base);
35    }
36 
37    @Override
38    public FilePath unwrap() {
39        return unwrap(name);
40    }
41 
42    private FilePathWrapper create(String path, FilePath base) {
43        try {
44            FilePathWrapper p = getClass().newInstance();
45            p.name = path;
46            p.base = base;
47            return p;
48        } catch (Exception e) {
49            throw new IllegalArgumentException("Path: " + path, e);
50        }
51    }
52 
53    protected String getPrefix() {
54        return getScheme() + ":";
55    }
56 
57    /**
58     * Get the base path for the given wrapped path.
59     *
60     * @param path the path including the scheme prefix
61     * @return the base file path
62     */
63    protected FilePath unwrap(String path) {
64        return FilePath.get(path.substring(getScheme().length() + 1));
65    }
66 
67    protected FilePath getBase() {
68        return base;
69    }
70 
71    @Override
72    public boolean canWrite() {
73        return base.canWrite();
74    }
75 
76    @Override
77    public void createDirectory() {
78        base.createDirectory();
79    }
80 
81    @Override
82    public boolean createFile() {
83        return base.createFile();
84    }
85 
86    @Override
87    public void delete() {
88        base.delete();
89    }
90 
91    @Override
92    public boolean exists() {
93        return base.exists();
94    }
95 
96    @Override
97    public FilePath getParent() {
98        return wrap(base.getParent());
99    }
100 
101    @Override
102    public boolean isAbsolute() {
103        return base.isAbsolute();
104    }
105 
106    @Override
107    public boolean isDirectory() {
108        return base.isDirectory();
109    }
110 
111    @Override
112    public long lastModified() {
113        return base.lastModified();
114    }
115 
116    @Override
117    public FilePath toRealPath() {
118        return wrap(base.toRealPath());
119    }
120 
121    @Override
122    public List<FilePath> newDirectoryStream() {
123        List<FilePath> list = base.newDirectoryStream();
124        for (int i = 0, len = list.size(); i < len; i++) {
125            list.set(i, wrap(list.get(i)));
126        }
127        return list;
128    }
129 
130    @Override
131    public void moveTo(FilePath newName, boolean atomicReplace) {
132        base.moveTo(((FilePathWrapper) newName).base, atomicReplace);
133    }
134 
135    @Override
136    public InputStream newInputStream() throws IOException {
137        return base.newInputStream();
138    }
139 
140    @Override
141    public OutputStream newOutputStream(boolean append) throws IOException {
142        return base.newOutputStream(append);
143    }
144 
145    @Override
146    public FileChannel open(String mode) throws IOException {
147        return base.open(mode);
148    }
149 
150    @Override
151    public boolean setReadOnly() {
152        return base.setReadOnly();
153    }
154 
155    @Override
156    public long size() {
157        return base.size();
158    }
159 
160    @Override
161    public FilePath createTempFile(String suffix, boolean deleteOnExit,
162            boolean inTempDir) throws IOException {
163        return wrap(base.createTempFile(suffix, deleteOnExit, inTempDir));
164    }
165 
166}

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