001 /** 002 * Do we want to use this space for anything? Eg, revision history? 003 */ 004 package edu.nrao.sss.model.proposal; 005 006 import edu.nrao.sss.util.EnumerationUtility; 007 008 /** <i>Placeholder for time when we integrate proposal work.</i> 009 * An enumeration of file types for justification files. 010 * <p> 011 * TODO Should we think about making this more general by 012 * removing the "Justification" label an putting this 013 * in a different package?</p> 014 * 015 * @version 1.1 016 * @since 2006-03-03 017 */ 018 public enum JustificationFileType 019 { 020 /** Represents a 021 * <a href="http://en.wikipedia.org/wiki/PostScript">postscript</a> file. 022 * <p> 023 * The acceptable names of this element (for use with 024 * {@code getInstanceFromName(String)}) are 025 * <i>PS</i> and <i>application/postscript</i>.</p> 026 */ 027 PS("application/postscript"), 028 029 /** Represents a 030 * <a href="http://en.wikipedia.org/wiki/Pdf">PDF</a> file. 031 * <p> 032 * The acceptable names of this element (for use with 033 * {@code getInstanceFromName(String)}) are 034 * <i>PDF</i> and <i>application/pdf</i>.</p> 035 */ 036 PDF("application/pdf"), 037 038 /** Represents a file octal codes. 039 * <p> 040 * The acceptable names of this element (for use with 041 * {@code getInstanceFromName(String)}) are 042 * <i>TXT_OCTET</i> and <i>application/octet-stream</i>.</p> 043 */ 044 TXT_OCTET("application/octet-stream"), 045 046 /** Represents a plain text file. 047 * <p> 048 * The acceptable names of this element (for use with 049 * {@code getInstanceFromName(String)}) are 050 * <i>TXT_PLAIN</i> and <i>text/plain</i>.</p> 051 */ 052 TXT_PLAIN("text/plain"), 053 054 /** Represents a justification file of unknown type. 055 * <p> 056 * This element is used to implement the 057 * <i>Null Object Pattern</i>. In situations where a method might 058 * be tempted to return <i>null</i>, this element is returned instead.</p> 059 */ 060 UNKNOWN("unknown"); 061 062 private String name; 063 064 private JustificationFileType(String name) 065 { 066 this.name = name; 067 } 068 069 /** 070 * Returns a default justification file type. 071 * @return a default justification file type. 072 */ 073 public static JustificationFileType getDefault() 074 { 075 return TXT_PLAIN; 076 } 077 078 public String toString() 079 { 080 return name; 081 } 082 083 /** 084 * Returns the justification file type represented by {@code text}. 085 * <p> 086 * For details about the transformation, see 087 * {@link EnumerationUtility#enumFromString(Class, String)}.</p> 088 * 089 * @param text a text representation of a justification file type. 090 * 091 * @return the justification file type represented by {@code text}. 092 */ 093 public static JustificationFileType fromString(String text) 094 { 095 return EnumerationUtility.getSharedInstance() 096 .enumFromString(JustificationFileType.class, text); 097 } 098 }