Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 113   Methods: 12
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AtomImpl.java 60% 68% 66,7% 66%
coverage coverage
 1    /* $Id: AtomImpl.java,v 1.5 2006/10/20 20:23:08 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2006, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.dto.elli;
 19   
 20    import org.qedeq.kernel.base.elli.Atom;
 21    import org.qedeq.kernel.base.elli.Element;
 22    import org.qedeq.kernel.base.elli.ElementList;
 23    import org.qedeq.kernel.base.elli.Visitor;
 24   
 25   
 26    /**
 27    * An object of this class represents a text string.
 28    *
 29    * @version $Revision: 1.5 $
 30    * @author Michael Meyling
 31    */
 32    public final class AtomImpl implements Atom {
 33   
 34    /** The plain text. */
 35    private final String text;
 36   
 37    /**
 38    * Constructs an <code>Atom</code>.
 39    *
 40    * @param text Atom string.
 41    * @throws IllegalArgumentException <code>text</code> is a NullPointer.
 42    */
 43  8597 public AtomImpl(final String text) {
 44  8597 if (text == null) {
 45  0 throw new IllegalArgumentException("a NullPointer is no valid text");
 46    }
 47  8597 this.text = text;
 48    }
 49   
 50  2528 public final String getString() {
 51  2528 return text;
 52    }
 53   
 54  0 public final boolean isAtom() {
 55  0 return true;
 56    }
 57   
 58  2528 public final Atom getAtom() {
 59  2528 return this;
 60    }
 61   
 62  0 public final boolean isList() {
 63  0 return false;
 64    }
 65   
 66  0 public final ElementList getList() {
 67  0 throw new ClassCastException("this is no " + ElementList.class.getName()
 68    + ", but a " + this.getClass().getName());
 69    }
 70   
 71  3836 public final Element copy() {
 72  3836 return new AtomImpl(text);
 73    }
 74   
 75  0 public final Element replace(final Element search, final Element replacement) {
 76  0 if (this.equals(search)) {
 77  0 return replacement.copy();
 78    }
 79  0 return this.copy();
 80    }
 81   
 82  1383 public final String toString() {
 83  1383 StringBuffer result = new StringBuffer();
 84  1383 result.append("\"");
 85   
 86  1383 for (int i = 0; i < text.length(); i++) {
 87  68334 if (text.charAt(i) == '\"') {
 88  0 result.append("\"\"");
 89    } else {
 90  68334 result.append(text.charAt(i));
 91    }
 92    }
 93  1383 result.append('\"');
 94  1383 return result.toString();
 95   
 96    }
 97   
 98  824 public final boolean equals(final Object object) {
 99  824 if (object instanceof AtomImpl) {
 100  816 return ((AtomImpl) object).text.equals(text);
 101    }
 102  8 return false;
 103    }
 104   
 105  798 public final int hashCode() {
 106  798 return toString().hashCode();
 107    }
 108   
 109  5 public final void accept(final Visitor visitor) {
 110  5 visitor.visit(this);
 111    }
 112   
 113    }