Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart7.png 62% of files have more coverage
24   108   16   2,18
10   60   0,67   11
11     1,45  
1    
 
  DefaultAtom       Line # 31 24 16 68,9% 0.6888889
 
  (41)
 
1    /* $Id: DefaultAtom.java,v 1.2 2008/03/27 05:16:26 m31 Exp $
2    *
3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
4    *
5    * Copyright 2000-2008, 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.list;
19   
20    import org.qedeq.kernel.base.list.Atom;
21    import org.qedeq.kernel.base.list.Element;
22    import org.qedeq.kernel.base.list.ElementList;
23   
24   
25    /**
26    * An object of this class represents a text string.
27    *
28    * @version $Revision: 1.2 $
29    * @author Michael Meyling
30    */
 
31    public final class DefaultAtom implements Atom {
32   
33    /** The plain text. */
34    private final String text;
35   
36    /**
37    * Constructs an <code>Atom</code>.
38    *
39    * @param text Atom string.
40    * @throws IllegalArgumentException <code>text</code> is a NullPointer.
41    */
 
42  28323 toggle public DefaultAtom(final String text) {
43  28323 if (text == null) {
44  0 throw new IllegalArgumentException("a NullPointer is no valid text");
45    }
46  28323 this.text = text;
47    }
48   
 
49  93533 toggle public final String getString() {
50  93533 return text;
51    }
52   
 
53  147383 toggle public final boolean isAtom() {
54  147383 return true;
55    }
56   
 
57  128670 toggle public final Atom getAtom() {
58  128670 return this;
59    }
60   
 
61  131996 toggle public final boolean isList() {
62  131996 return false;
63    }
64   
 
65  0 toggle public final ElementList getList() {
66  0 throw new ClassCastException("this is no " + ElementList.class.getName()
67    + ", but a " + this.getClass().getName());
68    }
69   
 
70  0 toggle public final Element copy() {
71  0 return new DefaultAtom(text);
72    }
73   
 
74  0 toggle public final Element replace(final Element search, final Element replacement) {
75  0 if (this.equals(search)) {
76  0 return replacement.copy();
77    }
78  0 return this.copy();
79    }
80   
 
81  92123 toggle public final String toString() {
82  92123 StringBuffer result = new StringBuffer();
83  92123 result.append("\"");
84   
85  216219 for (int i = 0; i < text.length(); i++) {
86  124096 if (text.charAt(i) == '\"') {
87  0 result.append("\"\"");
88    } else {
89  124096 result.append(text.charAt(i));
90    }
91    }
92  92123 result.append('\"');
93  92123 return result.toString();
94   
95    }
96   
 
97  7469 toggle public final boolean equals(final Object object) {
98  7469 if (object instanceof DefaultAtom) {
99  7462 return ((DefaultAtom) object).text.equals(text);
100    }
101  7 return false;
102    }
103   
 
104  409 toggle public final int hashCode() {
105  409 return toString().hashCode();
106    }
107   
108    }