001 /*
002 * Cobertura - http://cobertura.sourceforge.net/
003 *
004 * Copyright (C) 2003 jcoverage ltd.
005 * Copyright (C) 2005 Mark Doliner <thekingant@users.sourceforge.net>
006 *
007 * Cobertura is free software; you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published
009 * by the Free Software Foundation; either version 2 of the License,
010 * or (at your option) any later version.
011 *
012 * Cobertura is distributed in the hope that it will be useful, but
013 * WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with Cobertura; if not, write to the Free Software
019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020 * USA
021 */
022
023 package net.sourceforge.cobertura.coverage;
024
025 import java.io.Serializable;
026
027 /**
028 * <p>
029 * This class implements HasBeenInstrumented so that when cobertura
030 * instruments itself, it will omit this class. It does this to
031 * avoid an infinite recursion problem because instrumented classes
032 * make use of this class.
033 * </p>
034 */
035 public class LineInformation implements HasBeenInstrumented, Serializable
036 {
037 private static final long serialVersionUID = 1;
038
039 private long hits;
040 private boolean isConditional;
041 private final int lineNumber;
042 private String methodDescriptor;
043 private String methodName;
044
045 LineInformation(int lineNumber)
046 {
047 this(lineNumber, null, null);
048 }
049
050 LineInformation(int lineNumber, String methodName, String methodDescriptor)
051 {
052 this.hits = 0;
053 this.isConditional = false;
054 this.lineNumber = lineNumber;
055 this.methodName = methodName;
056 this.methodDescriptor = methodDescriptor;
057 }
058
059 long getHits()
060 {
061 return hits;
062 }
063
064 int getLineNumber()
065 {
066 return lineNumber;
067 }
068
069 String getMethodDescriptor()
070 {
071 return methodDescriptor;
072 }
073
074 String getMethodName()
075 {
076 return methodName;
077 }
078
079 boolean isConditional()
080 {
081 return isConditional;
082 }
083
084 public void setConditional(boolean isConditional)
085 {
086 this.isConditional = isConditional;
087 }
088
089 public void setMethodNameAndDescriptor(String name, String descriptor)
090 {
091 this.methodName = name;
092 this.methodDescriptor = descriptor;
093 }
094
095 void touch()
096 {
097 this.hits++;
098 }
099
100 }