Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../img/srcFileCovDistChart7.png 67% of files have more coverage
24   106   16   2.18
10   60   0.67   11
11     1.45  
1    
 
  DefaultAtom       Line # 29 24 16 68.9% 0.6888889
 
  (54)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.dto.list;
17   
18    import org.qedeq.kernel.base.list.Atom;
19    import org.qedeq.kernel.base.list.Element;
20    import org.qedeq.kernel.base.list.ElementList;
21   
22   
23    /**
24    * An object of this class represents a text string.
25    *
26    * @version $Revision: 1.2 $
27    * @author Michael Meyling
28    */
 
29    public final class DefaultAtom implements Atom {
30   
31    /** The plain text. */
32    private final String text;
33   
34    /**
35    * Constructs an <code>Atom</code>.
36    *
37    * @param text Atom string.
38    * @throws IllegalArgumentException <code>text</code> is a NullPointer.
39    */
 
40  30390 toggle public DefaultAtom(final String text) {
41  30390 if (text == null) {
42  0 throw new IllegalArgumentException("a NullPointer is no valid text");
43    }
44  30390 this.text = text;
45    }
46   
 
47  99896 toggle public final String getString() {
48  99896 return text;
49    }
50   
 
51  152636 toggle public final boolean isAtom() {
52  152636 return true;
53    }
54   
 
55  135891 toggle public final Atom getAtom() {
56  135891 return this;
57    }
58   
 
59  139816 toggle public final boolean isList() {
60  139816 return false;
61    }
62   
 
63  0 toggle public final ElementList getList() {
64  0 throw new ClassCastException("this is no " + ElementList.class.getName()
65    + ", but a " + this.getClass().getName());
66    }
67   
 
68  0 toggle public final Element copy() {
69  0 return new DefaultAtom(text);
70    }
71   
 
72  0 toggle public final Element replace(final Element search, final Element replacement) {
73  0 if (this.equals(search)) {
74  0 return replacement.copy();
75    }
76  0 return this.copy();
77    }
78   
 
79  99318 toggle public final String toString() {
80  99318 StringBuffer result = new StringBuffer();
81  99318 result.append("\"");
82   
83  266751 for (int i = 0; i < text.length(); i++) {
84  167433 if (text.charAt(i) == '\"') {
85  0 result.append("\"\"");
86    } else {
87  167433 result.append(text.charAt(i));
88    }
89    }
90  99318 result.append('\"');
91  99318 return result.toString();
92   
93    }
94   
 
95  8132 toggle public final boolean equals(final Object object) {
96  8132 if (object instanceof DefaultAtom) {
97  8125 return ((DefaultAtom) object).text.equals(text);
98    }
99  7 return false;
100    }
101   
 
102  857 toggle public final int hashCode() {
103  857 return toString().hashCode();
104    }
105   
106    }