Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 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-2013, 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  579939 toggle public DefaultAtom(final String text) {
40  579939 if (text == null) {
41  1 throw new IllegalArgumentException("a NullPointer is no valid text");
42    }
43  579938 this.text = text;
44    }
45   
 
46  3010364 toggle public final String getString() {
47  3010364 return text;
48    }
49   
 
50  1434601 toggle public final boolean isAtom() {
51  1434601 return true;
52    }
53   
 
54  3049882 toggle public final Atom getAtom() {
55  3049882 return this;
56    }
57   
 
58  2300832 toggle public final boolean isList() {
59  2300832 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  794 toggle public final Element copy() {
68  794 return new DefaultAtom(text);
69    }
70   
 
71  478 toggle public final Element replace(final Element search, final Element replacement) {
72  478 if (this.equals(search)) {
73  3 return replacement.copy();
74    }
75  475 return this.copy();
76    }
77   
 
78  1347529 toggle public final String toString() {
79  1347529 StringBuffer result = new StringBuffer();
80  1347529 result.append("\"");
81   
82  2797339 for (int i = 0; i < text.length(); i++) {
83  1449810 if (text.charAt(i) == '\"') {
84  3 result.append("\"\"");
85    } else {
86  1449807 result.append(text.charAt(i));
87    }
88    }
89  1347529 result.append('\"');
90  1347529 return result.toString();
91   
92    }
93   
 
94  55384556 toggle public final boolean equals(final Object object) {
95  55384556 if (object instanceof DefaultAtom) {
96  55384050 return ((DefaultAtom) object).text.equals(text);
97    }
98  506 return false;
99    }
100   
 
101  1345 toggle public final int hashCode() {
102  1345 return toString().hashCode();
103    }
104   
105    }