XMLElement.java

1
/* $Id: XMLElement.java 17832 2010-01-12 19:02:29Z linus $
2
 *****************************************************************************
3
 * Copyright (c) 2009 Contributors - see below
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    bobtarling
11
 *****************************************************************************
12
 *
13
 * Some portions of this file was previously release using the BSD License:
14
 */
15
16
// Copyright (c) 1996-2006 The Regents of the University of California. All
17
// Rights Reserved. Permission to use, copy, modify, and distribute this
18
// software and its documentation without fee, and without a written
19
// agreement is hereby granted, provided that the above copyright notice
20
// and this paragraph appear in all copies.  This software program and
21
// documentation are copyrighted by The Regents of the University of
22
// California. The software program and documentation are supplied "AS
23
// IS", without any accompanying services from The Regents. The Regents
24
// does not warrant that the operation of the program will be
25
// uninterrupted or error-free. The end-user understands that the program
26
// was developed for research purposes and is advised not to rely
27
// exclusively on the program for any reason.  IN NO EVENT SHALL THE
28
// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
29
// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
30
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
31
// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
32
// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
33
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
35
// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
36
// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
37
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
38
39
package org.argouml.persistence;
40
41
import org.xml.sax.Attributes;
42
import org.xml.sax.helpers.AttributesImpl;
43
44
/**
45
 * @author Jim Holt
46
 */
47
class XMLElement {
48
49
    ////////////////////////////////////////////////////////////////
50
    // instance variables
51
52
    private String        name       = null;
53
    private StringBuffer  text       = new StringBuffer(100);
54
    private Attributes    attributes = null;
55
56
    /**
57
     * Constructor.
58
     *
59
     * @param n The name of the element.
60
     * @param a The attributes.
61
     */
62
    public XMLElement(String n, Attributes a) {
63
	name = n;
64
	attributes = new AttributesImpl(a);
65
    }
66
67
    ////////////////////////////////////////////////////////////////
68
    // accessors
69
70
    /**
71
     * @return the name of this element
72
     */
73 1 1. getName : mutated return of Object value for org/argouml/persistence/XMLElement::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    public String getName()            { return name; }
74
    /**
75
     * @param n the name of this element
76
     */
77
    public void   setName(String n) { name = n; }
78
79
    /**
80
     * @param t the text to be appended
81
     */
82
    public void   addText(String t) { text = text.append(t); }
83
84
    /**
85
     * Append text to the end of the element.
86
     * @param c character array containing the text to be appended
87
     * @param offset starting offset of text
88
     * @param len length of text to append
89
     */
90
    public void addText(char[] c, int offset, int len) {
91
        text = text.append(c, offset, len);
92
    }
93
    
94
    /**
95
     * @param t the new text
96
     */
97
    public void   setText(String t) { text = new StringBuffer(t); }
98
99
    /**
100
     * Erase the text of this element.
101
     */
102 1 1. resetText : removed call to java/lang/StringBuffer::setLength → NO_COVERAGE
    public void   resetText()          { text.setLength(0); }
103
104
    /**
105
     * @return the text of this element
106
     */
107 1 1. getText : mutated return of Object value for org/argouml/persistence/XMLElement::getText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    public String getText()            { return text.toString(); }
108
109
    /**
110
     * Get the length of the text in the element.
111
     * @return the length of the text in this element
112
     */
113 1 1. length : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
    public int length()            { return text.length(); }
114
115
    /**
116
     * Change the attributes for this element.
117
     *
118
     * @param a The new list of attributes.
119
     */
120
    public void   setAttributes(Attributes a) {
121
	attributes = new AttributesImpl(a);
122
    }
123
124
    /**
125
     * @param attribute the attribute name
126
     * @return the attribute value
127
     */
128
    public String getAttribute(String attribute) {
129 1 1. getAttribute : mutated return of Object value for org/argouml/persistence/XMLElement::getAttribute to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
	return attributes.getValue(attribute);
130
    }
131
132
    /**
133
     * @param i the index for the list of attributes
134
     * @return the attribute name for the attribute at the given index
135
     */
136
    public String getAttributeName(int i) {
137 1 1. getAttributeName : mutated return of Object value for org/argouml/persistence/XMLElement::getAttributeName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return attributes.getLocalName(i);
138
    }
139
140
    /**
141
     * @param i the index for the list of attributes
142
     * @return the attribute value for the attribute at the given index
143
     */
144
    public String getAttributeValue(int i) {
145 1 1. getAttributeValue : mutated return of Object value for org/argouml/persistence/XMLElement::getAttributeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return attributes.getValue(i);
146
    }
147
148
    /**
149
     * @return the number of attributes
150
     */
151 1 1. getNumAttributes : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
    public int    getNumAttributes() { return attributes.getLength(); }
152
153
} /* end class XMLElement */

Mutations

73

1.1
Location : getName
Killed by : none
mutated return of Object value for org/argouml/persistence/XMLElement::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

102

1.1
Location : resetText
Killed by : none
removed call to java/lang/StringBuffer::setLength → NO_COVERAGE

107

1.1
Location : getText
Killed by : none
mutated return of Object value for org/argouml/persistence/XMLElement::getText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

113

1.1
Location : length
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

129

1.1
Location : getAttribute
Killed by : none
mutated return of Object value for org/argouml/persistence/XMLElement::getAttribute to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

137

1.1
Location : getAttributeName
Killed by : none
mutated return of Object value for org/argouml/persistence/XMLElement::getAttributeName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

145

1.1
Location : getAttributeValue
Killed by : none
mutated return of Object value for org/argouml/persistence/XMLElement::getAttributeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

151

1.1
Location : getNumAttributes
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 0.32