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
030/**
031 * Class representing a touch-point connected to a JUMP instruction in source-code.
032 * 
033 * <p>A JUMP touch-point have assigned two counters:
034 * <ul>
035 *   <li>TRUE - touched in case when jump condition is meet</li>
036 *   <li>FALSE - touched when jump condition is not meet</li> 
037 * </ul></p>
038 *  
039 * @author piotr.tabor@gmail.com
040 */
041public class JumpTouchPointDescriptor extends TouchPointDescriptor{
042        private int counterIdForTrue;
043        private int counterIdForFalse;
044        
045        public JumpTouchPointDescriptor(int eventId, int currentLine) {
046                super(eventId,currentLine);
047        }
048
049        public int getCounterIdForFalse() {
050                return counterIdForFalse;
051        }
052        
053        public int getCounterIdForTrue() {
054                return counterIdForTrue;
055        }
056        
057        public void setCounterIdForFalse(int counterIdForFalse) {
058                this.counterIdForFalse = counterIdForFalse;
059        }
060        
061        public void setCounterIdForTrue(int counterIdForTrue) {
062                this.counterIdForTrue = counterIdForTrue;
063        }
064        
065        @Override
066        public int assignCounters(AtomicInteger idGenerator) {
067                counterIdForFalse=idGenerator.incrementAndGet();
068                counterIdForTrue=idGenerator.incrementAndGet();
069                return 2;
070        }       
071        
072}