Show
Ignore:
Timestamp:
2008-02-13 23:08:27 (9 months ago)
Author:
mosipov
Message:

rewrite of FileType to ResourceType and more

Files:
1 moved

Legend:

Unmodified
Added
Removed
  • FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/ResourceType.java

    r1455 r1509  
    2121package net.fckeditor; 
    2222 
    23  
    2423/** 
    2524 * The different types of files to work with. 
    26  * 
     25 *  
    2726 * @version $Id$ 
    2827 */ 
    29 public enum FileType { 
    30         FILE,           // the defaults 
    31         IMAGE, 
    32         FLASH, 
    33         MEDIA 
     28public enum ResourceType { 
     29 
     30        Image, File, Flash, Media; 
     31 
     32        public String getPath() { 
     33                return "/" + name().toLowerCase(); 
     34        } 
     35 
     36        public static ResourceType getDefaultResourceType(String name) { 
     37 
     38                ResourceType rt = getResourceType(name); 
     39 
     40                return rt == null ? File : rt; 
     41 
     42        } 
     43 
     44        public static ResourceType getResourceType(String name) { 
     45 
     46                try { 
     47                        return ResourceType.valueOf(name); 
     48                } catch (IllegalArgumentException e) { 
     49                        return null; 
     50                } catch (NullPointerException e) { 
     51                        return null; 
     52                } 
     53        } 
     54 
     55        public static boolean isValid(final String name) { 
     56                return getResourceType(name) == null ? false : true; 
     57        } 
     58 
    3459}