001/*
002 * Cobertura - http://cobertura.sourceforge.net/
003 *
004 * Copyright (C) 2011 Piotr Tabor
005 *
006 * Note: This file is dual licensed under the GPL and the Apache
007 * Source License (so that it can be used from both the main
008 * Cobertura classes and the ant tasks).
009 *
010 * Cobertura is free software; you can redistribute it and/or modify
011 * it under the terms of the GNU General Public License as published
012 * by the Free Software Foundation; either version 2 of the License,
013 * or (at your option) any later version.
014 *
015 * Cobertura is distributed in the hope that it will be useful, but
016 * WITHOUT ANY WARRANTY; without even the implied warranty of
017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018 * General Public License for more details.
019 *
020 * You should have received a copy of the GNU General Public License
021 * along with Cobertura; if not, write to the Free Software
022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
023 * USA
024 */
025
026package net.sourceforge.cobertura.instrument.tp;
027
028import java.util.concurrent.atomic.AtomicInteger;
029
030import net.sourceforge.cobertura.coveragedata.LineData;
031
032/**
033 * Class representing a touch-point connected to a single line of source-code
034 * 
035 * <p>A LINE touch-point have assigned only one counter.</p>
036 * 
037 * <p>We also storing a {@link #methodName} and a {@link #methodSignature} (consider to move this fields into {@link TouchPointDescriptor}).
038 * Those fields are needed to properly create instance of {@link LineData}. </p> 
039 *    
040 * @author piotr.tabor@gmail.com
041 */
042public class LineTouchPointDescriptor extends TouchPointDescriptor{     
043        private Integer counterId;
044        
045        /**
046         * Name of a method, the line belongs to
047         */
048        private String methodName;
049        
050        /**
051         * Signature (description) of a method, the line belongs to. 
052         */
053        private String methodSignature;
054        
055        public LineTouchPointDescriptor(int eventId, int lineNumber,String methodName,String methodSignature) {
056                super(eventId, lineNumber);
057                this.methodName=methodName;
058                this.methodSignature=methodSignature;
059        }
060
061        @Override
062        public int assignCounters(AtomicInteger idGenerator) {
063                counterId=idGenerator.incrementAndGet();
064                return 1;
065        }
066                
067        public Integer getCounterId() {
068                return counterId;
069        }
070        
071        public String getMethodName() {
072                return methodName;
073        }
074        
075        public String getMethodSignature() {
076                return methodSignature;
077        }
078}