Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 145   Methods: 21
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DocFile.java 50% 65.5% 57.1% 61.5%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    * * Redistributions of source code must retain the above copyright
 9    * notice, this list of conditions and the following disclaimer.
 10    * * Redistributions in binary form must reproduce the above copyright
 11    * notice, this list of conditions and the following disclaimer in the
 12    * documentation and/or other materials provided with the distribution.
 13    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 14    * names of its contributors may be used to endorse or promote products
 15    * derived from this software without specific prior written permission.
 16    *
 17    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 21    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 25    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 26    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 27    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28    *
 29    * This software is Open Source Initiative approved Open Source Software.
 30    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 31    *
 32    * This file is part of DrJava. Download the current version of this project
 33    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 34    *
 35    * END_COPYRIGHT_BLOCK*/
 36   
 37    package edu.rice.cs.drjava.project;
 38   
 39    import java.io.File;
 40    import java.io.IOException;
 41    import edu.rice.cs.util.AbsRelFile;
 42    import edu.rice.cs.plt.tuple.Pair;
 43   
 44    public class DocFile extends AbsRelFile {
 45   
 46    private Pair<Integer, Integer> _sel;
 47    private Pair<Integer, Integer> _scroll;
 48    private boolean _active;
 49    private String _package;
 50    private long _mod;
 51   
 52    /** Creates a docfile that has the same path as the given file, with default values for everything else. */
 53  0 public DocFile(File f) { this(f, null, null, false, null); }
 54   
 55    /** Creates a docfile from the given pathname with default values for everything else. */
 56  0 public DocFile(String pathname) { this(pathname, null, null, false, null); }
 57   
 58    /** Creates a docfile from the given parent and child with default values for everything else. */
 59  0 public DocFile(String parent, String child) { this(parent, child, null, null, false, null); }
 60   
 61  48 public DocFile(String pathname, Pair<Integer,Integer> selection, Pair<Integer,Integer> scroll, boolean active, String srcRoot) {
 62  48 super(pathname);
 63  48 init(selection, scroll, active, srcRoot);
 64    }
 65  82 public DocFile(File f, Pair<Integer,Integer> selection, Pair<Integer,Integer> scroll, boolean active, String srcRoot) {
 66  82 super(f, "");
 67  82 init(selection, scroll, active, srcRoot);
 68    }
 69   
 70  47 public DocFile(String parent, String child, Pair<Integer,Integer> selection, Pair<Integer,Integer> scroll, boolean active, String srcRoot) {
 71  47 super(parent, child);
 72  47 init(selection, scroll, active, srcRoot);
 73    }
 74   
 75  177 private void init(Pair<Integer,Integer> selection, Pair<Integer,Integer> scroll, boolean active, String pack) {
 76  177 _sel = selection;
 77  177 _scroll = scroll;
 78  177 _active = active;
 79  177 _package = pack;
 80    }
 81    ///////////////////// Overriden Methods //////////////////////
 82   
 83    /* Relying on equals and hashCode methods inherited from File. */
 84   
 85   
 86  40 public DocFile getAbsoluteFile() {
 87  40 if (isAbsolute()) return this;
 88    else
 89  0 return new DocFile(super.getAbsoluteFile(), _sel, _scroll, _active, _package);
 90    }
 91   
 92  57 public DocFile getCanonicalFile() throws IOException {
 93  57 return new DocFile(super.getCanonicalFile(), _sel, _scroll, _active, _package);
 94    }
 95    ///////////////////// Extra Data Methods /////////////////////
 96   
 97    /** @return the selection with the start and ending locations paired together. The cursor location is at the second
 98    * location in the pair while the selection is defined between the two.
 99    */
 100  55 public Pair<Integer,Integer> getSelection() { return _sel; }
 101   
 102    /** @param sel the pair to set the selection to */
 103  0 public void setSelection(Pair<Integer,Integer> sel) { _sel = sel; }
 104   
 105    /** @param start the start of the selection
 106    * @param end the end of the selection (and the cursor position)
 107    */
 108  0 public void setSelection(int start, int end) {
 109  0 _sel = new Pair<Integer,Integer>(Integer.valueOf(start), Integer.valueOf(end));
 110    }
 111    /** @return the selection with the first element being the vertical scroll and the second being the horizontal scroll. */
 112  54 public Pair<Integer,Integer> getScroll() { return _scroll; }
 113   
 114    /** @param scroll the pair to set the selection to */
 115  0 public void setScroll(Pair<Integer,Integer> scroll) { _scroll = scroll; }
 116   
 117    /** @param vert the vertical scroll of the scroll pane
 118    * @param horiz the horizonal scroll of the scroll pane
 119    */
 120  0 public void setScroll(int vert, int horiz) {
 121  0 _scroll = new Pair<Integer,Integer>(Integer.valueOf(vert), Integer.valueOf(horiz));
 122    }
 123   
 124    /** @return {@code true} if this file is supposed to be the active document when opened. */
 125  26 public boolean isActive() { return _active; }
 126   
 127    /** @param active Whether this file should be the active document when opened. */
 128   
 129  0 public void setActive(boolean active) { _active = active; }
 130    /** @return the package of the document stored in this file */
 131   
 132  54 public String getPackage() { return _package; }
 133   
 134    /** @param pkg The name of the package defined in the document text. */
 135  0 public void setPackage(String pkg) { _package = pkg; }
 136   
 137    /** Sets lastModified for this file to the time the including project file was saved. The <code>lastModified</code>
 138    * date any documents saved after the project file was written will not match the date recorded in the project file.
 139    * @param mod the last known modification date when the project was saved.
 140    */
 141  55 public void setSavedModDate(long mod) { _mod = mod; }
 142   
 143    /** @return The modification date of this file at the time the project file was generated. */
 144  11 public long getSavedModDate() { return _mod; }
 145    }