PersistenceManager.java

1
/* $Id: PersistenceManager.java 19876 2012-03-14 07:14:53Z mvw $
2
 *****************************************************************************
3
 * Copyright (c) 2009-2012 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
 *    Michiel van der Wulp
12
 *****************************************************************************
13
 *
14
 * Some portions of this file was previously release using the BSD License:
15
 */
16
17
// Copyright (c) 2004-2008 The Regents of the University of California. All
18
// Rights Reserved. Permission to use, copy, modify, and distribute this
19
// software and its documentation without fee, and without a written
20
// agreement is hereby granted, provided that the above copyright notice
21
// and this paragraph appear in all copies.  This software program and
22
// documentation are copyrighted by The Regents of the University of
23
// California. The software program and documentation are supplied "AS
24
// IS", without any accompanying services from The Regents. The Regents
25
// does not warrant that the operation of the program will be
26
// uninterrupted or error-free. The end-user understands that the program
27
// was developed for research purposes and is advised not to rely
28
// exclusively on the program for any reason.  IN NO EVENT SHALL THE
29
// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
30
// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
31
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
32
// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
33
// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
34
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
36
// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
37
// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
38
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
39
40
package org.argouml.persistence;
41
42
import java.awt.Component;
43
import java.io.ByteArrayOutputStream;
44
import java.io.File;
45
import java.io.PrintStream;
46
import java.io.UnsupportedEncodingException;
47
import java.net.URI;
48
import java.net.URISyntaxException;
49
import java.util.ArrayList;
50
import java.util.Collection;
51
import java.util.Iterator;
52
import java.util.List;
53
54
import javax.swing.JFileChooser;
55
import javax.swing.JOptionPane;
56
import javax.swing.filechooser.FileFilter;
57
58
import org.argouml.application.api.Argo;
59
import org.argouml.configuration.Configuration;
60
import org.argouml.configuration.ConfigurationKey;
61
import org.argouml.i18n.Translator;
62
import org.argouml.kernel.Project;
63
import org.tigris.gef.util.UnexpectedException;
64
65
66
/**
67
 * This class shall be the only one that knows in which file formats
68
 * ArgoUML is able to save and load. And all that knowledge is
69
 * concentrated in the constructor... <p>
70
 *
71
 * The PersisterManager manages the list of persisters. <p>
72
 *
73
 * This class is a singleton, since this allows external modules to
74
 * add extra persisters to the ArgoUML application.
75
 *
76
 * @author mvw@tigris.org
77
 */
78
public final class PersistenceManager {
79
    /**
80
     * The singleton instance.
81
     */
82
    private static final PersistenceManager INSTANCE =
83
        new PersistenceManager();
84
85
    private AbstractFilePersister defaultPersister;
86
    private List<AbstractFilePersister> otherPersisters = 
87
        new ArrayList<AbstractFilePersister>();
88
    private UmlFilePersister quickViewDump;
89
    private XmiFilePersister xmiPersister;
90
    private XmiFilePersister xmlPersister;
91
    private UmlFilePersister umlPersister;
92
    private ZipFilePersister zipPersister;
93
94
    private AbstractFilePersister savePersister;
95
    
96
    /**
97
     * The configuration key for the project file location.
98
     */
99
    public static final ConfigurationKey KEY_PROJECT_NAME_PATH =
100
        Configuration.makeKey("project", "name", "path");
101
102
    /**
103
     * The configuration key for the "open project" file location.
104
     */
105
    public static final ConfigurationKey KEY_OPEN_PROJECT_PATH =
106
        Configuration.makeKey("project", "open", "path");
107
108
    /**
109
     * The configuration key for the "import xmi" file location.
110
     */
111
    public static final ConfigurationKey KEY_IMPORT_XMI_PATH =
112
        Configuration.makeKey("xmi", "import", "path");
113
    
114
    /**
115
     * The configuration to do safe saves, i.e. retain the 
116
     * previous project file even when the save operation 
117
     * crashes in the middle. Also create a backup file after saving.
118
     * This works with a project file ending in "~" for the backup 
119
     * file, and a file ending in "#" for a temporary file during saving.
120
     */
121
    public static final ConfigurationKey USE_SAFE_SAVES =
122
            Configuration.makeKey("project", "use", "safe-saves");
123
124
    /**
125
     * Create the default diagram persister.
126
     */
127
    private DiagramMemberFilePersister diagramMemberFilePersister
128
        = new DiagramMemberFilePersister();
129
130
    /**
131
     * @return returns the singleton
132
     */
133
    public static PersistenceManager getInstance() {
134 1 1. getInstance : mutated return of Object value for org/argouml/persistence/PersistenceManager::getInstance to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return INSTANCE;
135
    }
136
137
    /**
138
     * The constructor.
139
     */
140
    private PersistenceManager() {
141
        // These are the file formats I know about:
142
        defaultPersister = new OldZargoFilePersister();
143
        quickViewDump = new UmlFilePersister();
144
        xmiPersister = new XmiFilePersister();
145
        otherPersisters.add(xmiPersister);
146
        xmlPersister = new XmlFilePersister();
147
        otherPersisters.add(xmlPersister);
148
        umlPersister = new UmlFilePersister();
149
        otherPersisters.add(umlPersister);
150
        zipPersister = new ZipFilePersister();
151
        otherPersisters.add(zipPersister);
152
    }
153
154
    /**
155
     * This function allows to add new persisters. This can be done e.g.
156
     * by plugins/modules.
157
     *
158
     * @param fp the persister
159
     */
160
    public void register(AbstractFilePersister fp) {
161
        otherPersisters.add(fp);
162
    }
163
164
    /**
165
     * @param name the filename
166
     * @return the persister
167
     */
168
    public AbstractFilePersister getPersisterFromFileName(String name) {
169 1 1. getPersisterFromFileName : negated conditional → NO_COVERAGE
        if (defaultPersister.isFileExtensionApplicable(name)) {
170 1 1. getPersisterFromFileName : mutated return of Object value for org/argouml/persistence/PersistenceManager::getPersisterFromFileName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
            return defaultPersister;
171
        }
172 1 1. getPersisterFromFileName : negated conditional → NO_COVERAGE
        for (AbstractFilePersister persister : otherPersisters) {
173 1 1. getPersisterFromFileName : negated conditional → NO_COVERAGE
            if (persister.isFileExtensionApplicable(name)) {
174 1 1. getPersisterFromFileName : mutated return of Object value for org/argouml/persistence/PersistenceManager::getPersisterFromFileName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
                return persister;
175
            }
176
        }
177 1 1. getPersisterFromFileName : mutated return of Object value for org/argouml/persistence/PersistenceManager::getPersisterFromFileName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return null;
178
    }
179
180
    /**
181
     * @param chooser the filechooser of which the filters will be set
182
     * @param fileName the filename of the file to be saved (optional)
183
     */
184
    public void setSaveFileChooserFilters(JFileChooser chooser, 
185
            String fileName) {
186
        
187 1 1. setSaveFileChooserFilters : removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE
        chooser.addChoosableFileFilter(defaultPersister);
188
        AbstractFilePersister defaultFileFilter = defaultPersister;
189
        
190 1 1. setSaveFileChooserFilters : negated conditional → NO_COVERAGE
        for (AbstractFilePersister fp : otherPersisters) {
191 1 1. setSaveFileChooserFilters : negated conditional → NO_COVERAGE
            if (fp.isSaveEnabled()
192 1 1. setSaveFileChooserFilters : negated conditional → NO_COVERAGE
                    && !fp.equals(xmiPersister)
193 1 1. setSaveFileChooserFilters : negated conditional → NO_COVERAGE
                    && !fp.equals(xmlPersister)) {
194 1 1. setSaveFileChooserFilters : removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE
                chooser.addChoosableFileFilter(fp);
195 1 1. setSaveFileChooserFilters : negated conditional → NO_COVERAGE
                if (fileName != null 
196 1 1. setSaveFileChooserFilters : negated conditional → NO_COVERAGE
                        && fp.isFileExtensionApplicable(fileName)) {
197
                    defaultFileFilter = fp;
198
                }
199
            }
200
        }
201 1 1. setSaveFileChooserFilters : removed call to javax/swing/JFileChooser::setFileFilter → NO_COVERAGE
        chooser.setFileFilter(defaultFileFilter);
202
    }
203
204
    /**
205
     * @param chooser the filechooser of which the filters will be set
206
     */
207
    public void setOpenFileChooserFilter(JFileChooser chooser) {
208
        MultitypeFileFilter mf = new MultitypeFileFilter();
209 1 1. setOpenFileChooserFilter : removed call to org/argouml/persistence/MultitypeFileFilter::add → NO_COVERAGE
        mf.add(defaultPersister);
210 1 1. setOpenFileChooserFilter : removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE
        chooser.addChoosableFileFilter(mf);
211 1 1. setOpenFileChooserFilter : removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE
        chooser.addChoosableFileFilter(defaultPersister);
212
        Iterator iter = otherPersisters.iterator();
213 1 1. setOpenFileChooserFilter : negated conditional → NO_COVERAGE
        while (iter.hasNext()) {
214
            AbstractFilePersister ff = (AbstractFilePersister) iter.next();
215 1 1. setOpenFileChooserFilter : negated conditional → NO_COVERAGE
            if (ff.isLoadEnabled()) {
216 1 1. setOpenFileChooserFilter : removed call to org/argouml/persistence/MultitypeFileFilter::add → NO_COVERAGE
                mf.add(ff);
217 1 1. setOpenFileChooserFilter : removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE
                chooser.addChoosableFileFilter(ff);
218
            }
219
        }
220 1 1. setOpenFileChooserFilter : removed call to javax/swing/JFileChooser::setFileFilter → NO_COVERAGE
        chooser.setFileFilter(mf);
221
    }
222
223
    /**
224
     * @param chooser the filechooser of which the filters will be set
225
     */
226
    public void setXmiFileChooserFilter(JFileChooser chooser) {
227 1 1. setXmiFileChooserFilter : removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE
        chooser.addChoosableFileFilter(xmiPersister);
228 1 1. setXmiFileChooserFilter : removed call to javax/swing/JFileChooser::setFileFilter → NO_COVERAGE
        chooser.setFileFilter(xmiPersister);
229
    }
230
231
    /**
232
     * @return the extension of the default persister
233
     *         (just the text, not the ".")
234
     */
235
    public String getDefaultExtension() {
236 1 1. getDefaultExtension : mutated return of Object value for org/argouml/persistence/PersistenceManager::getDefaultExtension to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return defaultPersister.getExtension();
237
    }
238
239
    /**
240
     * @return the extension of the xmi persister
241
     *         (just the text, not the ".")
242
     */
243
    public String getXmiExtension() {
244 1 1. getXmiExtension : mutated return of Object value for org/argouml/persistence/PersistenceManager::getXmiExtension to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return xmiPersister.getExtension();
245
    }
246
247
    /**
248
     * @param in the input file or path name which may or may not
249
     *           have a recognised extension
250
     * @return the amended file or pathname, guaranteed to have
251
     *         a recognised extension
252
     */
253
    public String fixExtension(String in) {
254 1 1. fixExtension : negated conditional → NO_COVERAGE
        if (getPersisterFromFileName(in) == null) {
255
            in += "." + getDefaultExtension();
256
        }
257 1 1. fixExtension : mutated return of Object value for org/argouml/persistence/PersistenceManager::fixExtension to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return in;
258
    }
259
260
    /**
261
     * @param in the input file or path name which may or may not
262
     *           have a "xmi" extension
263
     * @return the amended file or pathname, guaranteed to have
264
     *         a "xmi" extension
265
     */
266
    public String fixXmiExtension(String in) {
267 1 1. fixXmiExtension : negated conditional → NO_COVERAGE
        if (getPersisterFromFileName(in) != xmiPersister) {
268
            in += "." + getXmiExtension();
269
        }
270 1 1. fixXmiExtension : mutated return of Object value for org/argouml/persistence/PersistenceManager::fixXmiExtension to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return in;
271
    }
272
273
274
    /**
275
     * @param in the input uri which may or may not have a recognised extension
276
     * @return the uri with default extension added,
277
     *         if it did not have a valid extension yet
278
     */
279
    public URI fixUriExtension(URI in) {
280
        URI newUri;
281
        String n = in.toString();
282
        n = fixExtension(n);
283
        try {
284
            newUri = new URI(n);
285
        } catch (java.net.URISyntaxException e) {
286
            throw new UnexpectedException(e);
287
        }
288 1 1. fixUriExtension : mutated return of Object value for org/argouml/persistence/PersistenceManager::fixUriExtension to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return newUri;
289
    }
290
291
    /**
292
     * Find the base name of the given filename.<p>
293
     *
294
     * This is the name minus any valid file extension.
295
     * Invalid extensions are left alone.
296
     *
297
     * @param n the given file name
298
     * @return the name (a String) without extension
299
     */
300
    public String getBaseName(String n) {
301
        AbstractFilePersister p = getPersisterFromFileName(n);
302 1 1. getBaseName : negated conditional → NO_COVERAGE
        if (p == null) {
303 1 1. getBaseName : mutated return of Object value for org/argouml/persistence/PersistenceManager::getBaseName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
            return n;
304
        }
305 1 1. getBaseName : Replaced integer addition with subtraction → NO_COVERAGE
        int extLength = p.getExtension().length() + 1;
306 2 1. getBaseName : Replaced integer subtraction with addition → NO_COVERAGE
2. getBaseName : mutated return of Object value for org/argouml/persistence/PersistenceManager::getBaseName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return n.substring(0, n.length() - extLength);
307
    }
308
309
    /**
310
     * @param p the project
311
     * @return the basename of the project
312
     */
313
    public String getProjectBaseName(Project p) {
314
        URI uri = p.getUri();
315
        String name = Translator.localize("label.projectbrowser-title");
316 1 1. getProjectBaseName : negated conditional → NO_COVERAGE
        if (uri != null) {
317
            name = new File(uri).getName();
318
        }
319 1 1. getProjectBaseName : mutated return of Object value for org/argouml/persistence/PersistenceManager::getProjectBaseName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return getBaseName(name);
320
    }
321
322
    /**
323
     * @param n the new project name
324
     * @param p the project that receives the name
325
     * @throws URISyntaxException if the URI is malformed
326
     */
327
    public void setProjectName(final String n, Project p)
328
        throws URISyntaxException {
329
        String s = "";
330 1 1. setProjectName : negated conditional → NO_COVERAGE
        if (p.getURI() != null) {
331
            s = p.getURI().toString();
332
        }
333 1 1. setProjectName : Replaced integer addition with subtraction → NO_COVERAGE
        s = s.substring(0, s.lastIndexOf("/") + 1) + n;
334 1 1. setProjectName : removed call to org/argouml/persistence/PersistenceManager::setProjectURI → NO_COVERAGE
        setProjectURI(new URI(s), p);
335
    }
336
337
    /**
338
     * @param theUri the URI for the project
339
     * @param p the project that receives the URI
340
     */
341
    public void setProjectURI(URI theUri, Project p) {
342 1 1. setProjectURI : negated conditional → NO_COVERAGE
        if (theUri != null) {
343
            theUri = fixUriExtension(theUri);
344
        }
345 1 1. setProjectURI : removed call to org/argouml/kernel/Project::setUri → NO_COVERAGE
        p.setUri(theUri);
346
    }
347
348
    /**
349
     * Generates a String dump of the current model for quick viewing.
350
     *
351
     * @param project The project to generate.
352
     * @return The whole model in a String.
353
     */
354
    public String getQuickViewDump(Project project) {
355
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
356
        try {
357 1 1. getQuickViewDump : removed call to org/argouml/persistence/UmlFilePersister::writeProject → NO_COVERAGE
            quickViewDump.writeProject(project, stream, null);
358
        } catch (Exception e) {
359
            // If anything goes wrong return the stack
360
            // trace as a string so that we get some
361
            // useful feedback.
362 1 1. getQuickViewDump : removed call to java/lang/Exception::printStackTrace → NO_COVERAGE
            e.printStackTrace(new PrintStream(stream));
363
        }
364
        try {
365 1 1. getQuickViewDump : mutated return of Object value for org/argouml/persistence/PersistenceManager::getQuickViewDump to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
            return stream.toString(Argo.getEncoding());
366
        } catch (UnsupportedEncodingException e) {
367 1 1. getQuickViewDump : mutated return of Object value for org/argouml/persistence/PersistenceManager::getQuickViewDump to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
            return e.toString();
368
        }
369
    }
370
371
    /**
372
     * Get the file persister for diagrams.
373
     *
374
     * @return the diagram file persister.
375
     */
376
    DiagramMemberFilePersister getDiagramMemberFilePersister() {
377 1 1. getDiagramMemberFilePersister : mutated return of Object value for org/argouml/persistence/PersistenceManager::getDiagramMemberFilePersister to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
    	return diagramMemberFilePersister;
378
    }
379
380
    /**
381
     * Set an alternative file persister for diagrams.
382
     *
383
     * @param persister the persister to use instead of the default
384
     */
385
    public void setDiagramMemberFilePersister(
386
            DiagramMemberFilePersister persister) {
387
    	diagramMemberFilePersister = persister;
388
    }
389
390
    /**
391
     * Returns true if we are allowed to overwrite the given file.
392
     *
393
     * @param overwrite if true, then the user is not asked
394
     * @param file the given file
395
     * @return true if we are allowed to overwrite the given file
396
     * @param frame the Component to display the confirmation dialog on
397
     */
398
    public boolean confirmOverwrite(Component frame, 
399
            boolean overwrite, File file) {
400 2 1. confirmOverwrite : negated conditional → NO_COVERAGE
2. confirmOverwrite : negated conditional → NO_COVERAGE
        if (file.exists() && !overwrite) {
401
            String sConfirm =
402
                Translator.messageFormat(
403
                    "optionpane.confirm-overwrite",
404
                    new Object[] {file});
405
            int nResult =
406
                JOptionPane.showConfirmDialog(
407
                        frame,
408
                        sConfirm,
409
                        Translator.localize(
410
                            "optionpane.confirm-overwrite-title"),
411
                        JOptionPane.YES_NO_OPTION,
412
                        JOptionPane.QUESTION_MESSAGE);
413 1 1. confirmOverwrite : negated conditional → NO_COVERAGE
            if (nResult != JOptionPane.YES_OPTION) {
414 1 1. confirmOverwrite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
                return false;
415
            }
416
        }
417 1 1. confirmOverwrite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return true;
418
    }
419
420
421
    /**
422
     * Sets the currently used persister for saving.
423
     * 
424
     * @param persister the persister
425
     */
426
    public void setSavePersister(AbstractFilePersister persister) {
427
        savePersister = persister;
428
    }
429
    
430
    /**
431
     * Gets the currently used persister for saving.
432
     * 
433
     * @return the persister or null
434
     */
435
    public AbstractFilePersister getSavePersister() {
436 1 1. getSavePersister : mutated return of Object value for org/argouml/persistence/PersistenceManager::getSavePersister to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return savePersister;
437
    }
438
    
439
    /**
440
     * Figs are stored by class name and recreated by reflection. If the class
441
     * name changes or moves this provides a simple way of translating from
442
     * class name at time of save to the current class name without need for
443
     * XSL.
444
     * @param originalClassName The class name that may be in the save file
445
     * @param newClassName The class name to use in preference
446
     */
447
    public void addTranslation(
448
            final String originalClassName,
449
            final String newClassName) {
450 1 1. addTranslation : removed call to org/argouml/persistence/DiagramMemberFilePersister::addTranslation → NO_COVERAGE
        getDiagramMemberFilePersister().addTranslation(
451
                originalClassName,
452
                newClassName);
453
    }
454
    
455
}
456
457
/**
458
 * Composite file filter which will accept any
459
 * file type added to it.
460
 */
461
class MultitypeFileFilter extends FileFilter {
462
    private ArrayList<FileFilter> filters;
463
    private ArrayList<String> extensions;
464
    private String desc;
465
466
    /**
467
     * Constructor
468
     */
469
    public MultitypeFileFilter() {
470
        super();
471
        filters = new ArrayList<FileFilter>();
472
        extensions = new ArrayList<String>();
473
    }
474
475
    /**
476
     * Add a FileFilter to list of file filters to be accepted
477
     * 
478
     * @param filter FileFilter to be added
479
     */
480
    public void add(AbstractFilePersister filter) {
481
        filters.add(filter);
482
        String extension = filter.getExtension();
483 1 1. add : negated conditional → NO_COVERAGE
        if (!extensions.contains(extension)) {
484
            extensions.add(filter.getExtension());
485
            desc =
486 1 1. add : negated conditional → NO_COVERAGE
                ((desc == null)
487
                    ? ""
488
                    : desc + ", ")
489
                + "*." + extension;
490
        }
491
    }
492
493
    /**
494
     * Return all added FileFilters.
495
     * 
496
     * @return collection of FileFilters
497
     */
498
    public Collection<FileFilter> getAll() {
499 1 1. getAll : mutated return of Object value for org/argouml/persistence/MultitypeFileFilter::getAll to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return filters;
500
    }
501
502
    /**
503
     * Accept any file that any of our filters will accept.
504
     *
505
     * {@inheritDoc}
506
     */
507
    @Override
508
    public boolean accept(File arg0) {
509 1 1. accept : negated conditional → NO_COVERAGE
        for (FileFilter ff : filters) {
510 1 1. accept : negated conditional → NO_COVERAGE
            if (ff.accept(arg0)) {
511 1 1. accept : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
                return true;
512
            }
513
        }
514 1 1. accept : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return false;
515
    }
516
517
    /*
518
     * @see javax.swing.filechooser.FileFilter#getDescription()
519
     */
520
    @Override
521
    public String getDescription() {
522
        Object[] s = {desc};
523 1 1. getDescription : mutated return of Object value for org/argouml/persistence/MultitypeFileFilter::getDescription to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return Translator.messageFormat("filechooser.all-types-desc", s);
524
    }
525
}

Mutations

134

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

169

1.1
Location : getPersisterFromFileName
Killed by : none
negated conditional → NO_COVERAGE

170

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

172

1.1
Location : getPersisterFromFileName
Killed by : none
negated conditional → NO_COVERAGE

173

1.1
Location : getPersisterFromFileName
Killed by : none
negated conditional → NO_COVERAGE

174

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

177

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

187

1.1
Location : setSaveFileChooserFilters
Killed by : none
removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE

190

1.1
Location : setSaveFileChooserFilters
Killed by : none
negated conditional → NO_COVERAGE

191

1.1
Location : setSaveFileChooserFilters
Killed by : none
negated conditional → NO_COVERAGE

192

1.1
Location : setSaveFileChooserFilters
Killed by : none
negated conditional → NO_COVERAGE

193

1.1
Location : setSaveFileChooserFilters
Killed by : none
negated conditional → NO_COVERAGE

194

1.1
Location : setSaveFileChooserFilters
Killed by : none
removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE

195

1.1
Location : setSaveFileChooserFilters
Killed by : none
negated conditional → NO_COVERAGE

196

1.1
Location : setSaveFileChooserFilters
Killed by : none
negated conditional → NO_COVERAGE

201

1.1
Location : setSaveFileChooserFilters
Killed by : none
removed call to javax/swing/JFileChooser::setFileFilter → NO_COVERAGE

209

1.1
Location : setOpenFileChooserFilter
Killed by : none
removed call to org/argouml/persistence/MultitypeFileFilter::add → NO_COVERAGE

210

1.1
Location : setOpenFileChooserFilter
Killed by : none
removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE

211

1.1
Location : setOpenFileChooserFilter
Killed by : none
removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE

213

1.1
Location : setOpenFileChooserFilter
Killed by : none
negated conditional → NO_COVERAGE

215

1.1
Location : setOpenFileChooserFilter
Killed by : none
negated conditional → NO_COVERAGE

216

1.1
Location : setOpenFileChooserFilter
Killed by : none
removed call to org/argouml/persistence/MultitypeFileFilter::add → NO_COVERAGE

217

1.1
Location : setOpenFileChooserFilter
Killed by : none
removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE

220

1.1
Location : setOpenFileChooserFilter
Killed by : none
removed call to javax/swing/JFileChooser::setFileFilter → NO_COVERAGE

227

1.1
Location : setXmiFileChooserFilter
Killed by : none
removed call to javax/swing/JFileChooser::addChoosableFileFilter → NO_COVERAGE

228

1.1
Location : setXmiFileChooserFilter
Killed by : none
removed call to javax/swing/JFileChooser::setFileFilter → NO_COVERAGE

236

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

244

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

254

1.1
Location : fixExtension
Killed by : none
negated conditional → NO_COVERAGE

257

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

267

1.1
Location : fixXmiExtension
Killed by : none
negated conditional → NO_COVERAGE

270

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

288

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

302

1.1
Location : getBaseName
Killed by : none
negated conditional → NO_COVERAGE

303

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

305

1.1
Location : getBaseName
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

306

1.1
Location : getBaseName
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

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

316

1.1
Location : getProjectBaseName
Killed by : none
negated conditional → NO_COVERAGE

319

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

330

1.1
Location : setProjectName
Killed by : none
negated conditional → NO_COVERAGE

333

1.1
Location : setProjectName
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

334

1.1
Location : setProjectName
Killed by : none
removed call to org/argouml/persistence/PersistenceManager::setProjectURI → NO_COVERAGE

342

1.1
Location : setProjectURI
Killed by : none
negated conditional → NO_COVERAGE

345

1.1
Location : setProjectURI
Killed by : none
removed call to org/argouml/kernel/Project::setUri → NO_COVERAGE

357

1.1
Location : getQuickViewDump
Killed by : none
removed call to org/argouml/persistence/UmlFilePersister::writeProject → NO_COVERAGE

362

1.1
Location : getQuickViewDump
Killed by : none
removed call to java/lang/Exception::printStackTrace → NO_COVERAGE

365

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

367

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

377

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

400

1.1
Location : confirmOverwrite
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : confirmOverwrite
Killed by : none
negated conditional → NO_COVERAGE

413

1.1
Location : confirmOverwrite
Killed by : none
negated conditional → NO_COVERAGE

414

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

417

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

436

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

450

1.1
Location : addTranslation
Killed by : none
removed call to org/argouml/persistence/DiagramMemberFilePersister::addTranslation → NO_COVERAGE

483

1.1
Location : add
Killed by : none
negated conditional → NO_COVERAGE

486

1.1
Location : add
Killed by : none
negated conditional → NO_COVERAGE

499

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

509

1.1
Location : accept
Killed by : none
negated conditional → NO_COVERAGE

510

1.1
Location : accept
Killed by : none
negated conditional → NO_COVERAGE

511

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

514

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

523

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

Active mutators

Tests examined


Report generated by PIT 0.32