Coverage Report - org.argouml.util.FileFilters
 
Classes in this File Line Coverage Branch Coverage Complexity
FileFilters
75%
12/16
0%
0/2
3
 
 1  
 /* $Id: FileFilters.java 17887 2010-01-12 21:17:18Z 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  
  *    tfmorris
 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.util;
 40  
 
 41  
 import javax.swing.filechooser.FileFilter;
 42  
 
 43  
 import org.argouml.i18n.Translator;
 44  
 
 45  
 /** This class handles the the various file extensions.
 46  
  * It's not clear whether all of these are supported
 47  
  * for input or output or a mixture of both.
 48  
  * There is no file open>pgml/svg/xmi/log/gif
 49  
  * and there is no known way to save only a log or
 50  
  * an xmi out of Argo.
 51  
  */
 52  0
 public class FileFilters {
 53  
 
 54  
     /**
 55  
      * This is a filter for uncompressed project format.
 56  
      */
 57  75
     public static final SuffixFilter UNCOMPRESSED_FILE_FILTER = new
 58  
         SuffixFilter(FileConstants.UNCOMPRESSED_FILE_EXT.substring(1),
 59  
                      "Argo uncompressed project file");
 60  
 
 61  
     /**
 62  
      * This is a filter for compressed project format.
 63  
      */
 64  75
     public static final SuffixFilter COMPRESSED_FILE_FILTER = new
 65  
         SuffixFilter(FileConstants.COMPRESSED_FILE_EXT.substring(1),
 66  
                      "Argo compressed project file");
 67  
 
 68  
     /**
 69  
      * This is a filter for xmi files.
 70  
      */
 71  75
     public static final SuffixFilter XMI_FILTER = new
 72  
         SuffixFilter("xmi", "XML Metadata Interchange");
 73  
 
 74  
     /** This is for Precision Graphics Markup Language
 75  
      * a very old and now mostly dead standard.
 76  
      * see W3C.org for more info
 77  
      */
 78  75
     public static final SuffixFilter PGML_FILTER = new
 79  
         SuffixFilter("pgml", "Argo diagram");
 80  
 
 81  
     /** This should read or write a config file
 82  
      * but as yet not fully implemented.
 83  
      */
 84  75
     public static final SuffixFilter CONFIG_FILTER = new
 85  
         SuffixFilter("config", "Argo configutation file");
 86  
 
 87  
     /** History Filter...Argo has trouble with remembering
 88  
      * things at times. Maybe this filter helps.
 89  
      * status is unknown. last reveiwed 8 months ago.
 90  
      */
 91  75
     public static final SuffixFilter HIST_FILTER = new
 92  
         SuffixFilter("hist", "Argo history file");
 93  
 
 94  
     /**
 95  
      * Log file filter.
 96  
      */
 97  75
     public static final SuffixFilter LOG_FILTER = new
 98  
         SuffixFilter("log", "Argo usage log");
 99  
 
 100  
     /** 
 101  
      * This writes the GIF file.
 102  
      */
 103  75
     public static final SuffixFilter GIF_FILTER = new
 104  
         SuffixFilter("gif", Translator.localize("combobox.filefilter.gif"));
 105  
 
 106  
     /**
 107  
      * Filter for portable network graphics (png) files.
 108  
      */
 109  75
     public static final SuffixFilter PNG_FILTER = new
 110  
         SuffixFilter("png", Translator.localize("combobox.filefilter.png"));
 111  
 
 112  
     /**
 113  
      * This writes a Postscript file.
 114  
      */
 115  75
     public static final SuffixFilter PS_FILTER = new
 116  
         SuffixFilter("ps", Translator.localize("combobox.filefilter.ps"));
 117  
 
 118  
     /**
 119  
      * This writes an E-Postscript file.
 120  
      */
 121  75
     public static final SuffixFilter EPS_FILTER = new
 122  
         SuffixFilter("eps", Translator.localize("combobox.filefilter.eps"));
 123  
 
 124  
     /** SVG is the standard set by the W3C re vector graphics
 125  
      * The current output for SVG goes through GEF.
 126  
      * The output is considered to be 'poor' in
 127  
      * quality and builds multiple duplicate artifacts
 128  
      * in the SVG output.
 129  
      *
 130  
      * SVG is considered very useful for documentation
 131  
      * generation over standard raster images like
 132  
      * gif (a patented format), jpg and png.
 133  
      *
 134  
      * It is possible to embed links within SVG to
 135  
      * other areas in the svg or on the web. This
 136  
      * means that javadocs generated with SVG based
 137  
      * diagrams will have links to the classes from
 138  
      * within the diagram!
 139  
      * Not too mention zooming and animation (animation
 140  
      * is considered very useful for modeling the
 141  
      * behaviors of a class for example in state or
 142  
      * sequence diagrams.
 143  
      */
 144  75
     public static final SuffixFilter SVG_FILTER = new
 145  
         SuffixFilter("svg", Translator.localize("combobox.filefilter.svg"));
 146  
 
 147  
     /**
 148  
      * Returns the suffix for which a FileFilter filters.
 149  
      * @param filter The FileFilter from which we want to know the suffix
 150  
      * @return String The suffix of the FileFilter.
 151  
      * Returns null if the FileFilter is not an instance of SuffixFilter.
 152  
      */
 153  
     public static String getSuffix(FileFilter filter) {
 154  0
         if (filter instanceof SuffixFilter) {
 155  0
             return ((SuffixFilter) filter).getSuffix();
 156  
         }
 157  0
         return null;
 158  
     }
 159  
 
 160  
 }