Clover Coverage Report
Coverage timestamp: Fri Feb 14 2014 07:28:57 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
24   105   16   2.18
10   60   0.67   11
11     1.45  
1    
 
  DefaultAtom       Line # 28 24 16 100% 1.0
 
  (15)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2014, 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.se.dto.list;
17   
18    import org.qedeq.kernel.se.base.list.Atom;
19    import org.qedeq.kernel.se.base.list.Element;
20    import org.qedeq.kernel.se.base.list.ElementList;
21   
22   
23    /**
24    * An object of this class represents a text string.
25    *
26    * @author Michael Meyling
27    */
 
28    public final class DefaultAtom implements Atom {
29   
30    /** The plain text. */
31    private final String text;
32   
33    /**
34    * Constructs an <code>Atom</code>.
35    *
36    * @param text Atom string.
37    * @throws IllegalArgumentException <code>text</code> is a NullPointer.
38    */
 
39  608625 toggle public DefaultAtom(final String text) {
40  608625 if (text == null) {
41  1 throw new IllegalArgumentException("a NullPointer is no valid text");
42    }
43  608624 this.text = text;
44    }
45   
 
46  3125973 toggle public final String getString() {
47  3125973 return text;
48    }
49   
 
50  1509380 toggle public final boolean isAtom() {
51  1509380 return true;
52    }
53   
 
54  3179617 toggle public final Atom getAtom() {
55  3179617 return this;
56    }
57   
 
58  2508824 toggle public final boolean isList() {
59  2508824 return false;
60    }
61   
 
62  2 toggle public final ElementList getList() {
63  2 throw new ClassCastException("this is no " + ElementList.class.getName()
64    + ", but a " + this.getClass().getName());
65    }
66   
 
67  822 toggle public final Element copy() {
68  822 return new DefaultAtom(text);
69    }
70   
 
71  495 toggle public final Element replace(final Element search, final Element replacement) {
72  495 if (this.equals(search)) {
73  3 return replacement.copy();
74    }
75  492 return this.copy();
76    }
77   
 
78  1425167 toggle public final String toString() {
79  1425167 StringBuffer result = new StringBuffer();
80  1425167 result.append("\"");
81   
82  2952819 for (int i = 0; i < text.length(); i++) {
83  1527652 if (text.charAt(i) == '\"') {
84  3 result.append("\"\"");
85    } else {
86  1527649 result.append(text.charAt(i));
87    }
88    }
89  1425167 result.append('\"');
90  1425167 return result.toString();
91   
92    }
93   
 
94  55390645 toggle public final boolean equals(final Object object) {
95  55390645 if (object instanceof DefaultAtom) {
96  55390122 return ((DefaultAtom) object).text.equals(text);
97    }
98  523 return false;
99    }
100   
 
101  1345 toggle public final int hashCode() {
102  1345 return toString().hashCode();
103    }
104   
105    }