Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Dez 29 2005 18:38:29 CET
file stats: LOC: 113   Methods: 12
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AtomImpl.java 60% 64% 58,3% 61,7%
coverage coverage
 1    /* $Id: AtomImpl.java,v 1.4 2005/08/14 06:57:00 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2005, 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.4 $
 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  1148 public AtomImpl(final String text) {
 44  1148 if (text == null) {
 45  0 throw new IllegalArgumentException("a NullPointer is no valid text");
 46    }
 47  1148 this.text = text;
 48    }
 49   
 50  332 public final String getString() {
 51  332 return text;
 52    }
 53   
 54  0 public final boolean isAtom() {
 55  0 return true;
 56    }
 57   
 58  332 public final Atom getAtom() {
 59  332 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  0 public final Element copy() {
 72  0 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  1143 public final String toString() {
 83  1143 StringBuffer result = new StringBuffer();
 84  1143 result.append("\"");
 85   
 86  1143 for (int i = 0; i < text.length(); i++) {
 87  56190 if (text.charAt(i) == '\"') {
 88  0 result.append("\"\"");
 89    } else {
 90  56190 result.append(text.charAt(i));
 91    }
 92    }
 93  1143 result.append('\"');
 94  1143 return result.toString();
 95   
 96    }
 97   
 98  676 public final boolean equals(final Object object) {
 99  676 if (object instanceof AtomImpl) {
 100  668 return ((AtomImpl) object).text.equals(text);
 101    }
 102  8 return false;
 103    }
 104   
 105  646 public final int hashCode() {
 106  646 return toString().hashCode();
 107    }
 108   
 109  5 public final void accept(final Visitor visitor) {
 110  5 visitor.visit(this);
 111    }
 112   
 113    }