filetype.java

来自「FuncPlotter is a combined Java applicati」· Java 代码 · 共 141 行

JAVA
141
字号
/*====================================================================*\FileType.javaFile type enumeration.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program.  If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// IMPORTSimport util.FilenameSuffixFilter;//----------------------------------------------------------------------// FILE TYPE ENUMERATIONenum FileType{//////////////////////////////////////////////////////////////////////////  Constants////////////////////////////////////////////////////////////////////////    XML ( "xml",    "XML",  AppConstants.XML_FILE_SUFFIX,   AppConstants.XML_FILES_STR ),    TEXT( "text",   "Text", AppConstants.TEXT_FILE_SUFFIX,  AppConstants.TEXT_FILES_STR );//////////////////////////////////////////////////////////////////////////  Constructors////////////////////////////////////////////////////////////////////////    private FileType( String key,                      String text,                      String suffix,                      String description )    {        this.key = key;        this.text = text;        filter = new FilenameSuffixFilter( suffix, description );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Class methods////////////////////////////////////////////////////////////////////////    public static FileType get( String key )    {        for ( FileType value : values( ) )        {            if ( value.key.equals( key ) )                return value;        }        return null;    }    //------------------------------------------------------------------    public static FileType get( FilenameSuffixFilter filter )    {        for ( FileType value : values( ) )        {            if ( value.filter.equals( filter ) )                return value;        }        return null;    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods : overriding methods////////////////////////////////////////////////////////////////////////    public String toString( )    {        return text;    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods////////////////////////////////////////////////////////////////////////    public String getKey( )    {        return key;    }    //------------------------------------------------------------------    public String getText( )    {        return text;    }    //------------------------------------------------------------------    public FilenameSuffixFilter getFilter( )    {        return filter;    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance variables////////////////////////////////////////////////////////////////////////    private String                  key;    private String                  text;    private FilenameSuffixFilter    filter;}//----------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?