001 package edu.nrao.sss.model.source.parser; 002 003 import edu.nrao.sss.util.EnumerationUtility; 004 005 /** 006 * Text formats for the import and export of a source catalog. 007 * <p> 008 * <b>Version Info:</b> 009 * <table style="margin-left:2em"> 010 * <tr><td>$Revision: 877 $</td></tr> 011 * <tr><td>$Date: 2007-09-18 11:02:30 -0600 (Tue, 18 Sep 2007) $</td></tr> 012 * <tr><td>$Author: jrochfor $</td></tr> 013 * </table></p> 014 * 015 * @author David M. Harland 016 * @since 2007-05-16 017 */ 018 public enum SourceCatalogTextFormat 019 { 020 XML(true, true) 021 { 022 public SourceCatalogReader makeNewReader() 023 { 024 return new XmlSourceCatalogReader(); 025 } 026 027 public SourceCatalogWriter makeNewWriter() 028 { 029 return new XmlSourceCatalogWriter(); 030 } 031 }, 032 033 VLA(true, false) 034 { 035 public SourceCatalogReader makeNewReader() 036 { 037 return new VlaCalibDbHtmlReader(); 038 } 039 040 public SourceCatalogWriter makeNewWriter() 041 { 042 return null; 043 } 044 }, 045 046 VLBA(true, false) 047 { 048 public SourceCatalogReader makeNewReader() 049 { 050 return new VlbaSourceCatalogReader(); 051 } 052 053 public SourceCatalogWriter makeNewWriter() 054 { 055 return null; 056 } 057 }, 058 059 GBT(true, false) 060 { 061 public SourceCatalogReader makeNewReader() 062 { 063 return new GbtSourceCatalogReader(); 064 } 065 066 public SourceCatalogWriter makeNewWriter() 067 { 068 return null; 069 } 070 }, 071 072 PST(true, true) 073 { 074 public SourceCatalogReader makeNewReader() 075 { 076 return new PstSourceCatalogReader(); 077 } 078 079 public SourceCatalogWriter makeNewWriter() 080 { 081 return new PstSourceCatalogWriter(); 082 } 083 }; 084 085 private boolean supportImport; 086 private boolean supportExport; 087 088 private SourceCatalogTextFormat(boolean supportIn, boolean supportOut) 089 { 090 supportImport = supportIn; 091 supportExport = supportOut; 092 } 093 094 /** 095 * Configures this format to either support, or not support, the 096 * import of a source catalog from this type of text. 097 * 098 * @param isSupported <i>true</i> if the import of this format should 099 * be supported. 100 */ 101 public void setImportSupported(boolean isSupported) 102 { 103 supportImport = isSupported; 104 } 105 106 /** 107 * Configures this format to either support, or not support, the 108 * export of a source catalog into this type of text. 109 * 110 * @param isSupported <i>true</i> if the export of this format should 111 * be supported. 112 */ 113 public void setExportSupported(boolean isSupported) 114 { 115 supportImport = isSupported; 116 } 117 118 /** 119 * Returns <i>true</i> if the import of a catalog from this text format 120 * is supported. 121 * 122 * @return <i>true</i> if the import of a catalog from this text format 123 * is supported. 124 */ 125 public boolean isImportSupported() { return supportImport; } 126 127 /** 128 * Returns <i>true</i> if the export of a catalog into this text format 129 * is supported. 130 * 131 * @return <i>true</i> if the export of a catalog into this text format 132 * is supported. 133 */ 134 public boolean isExportSupported() { return supportExport; } 135 136 /** 137 * Returns a new source catalog reader that understands this format. 138 * @return a new source catalog reader that understands this format. May 139 * return null if reading is not supported. 140 */ 141 public abstract SourceCatalogReader makeNewReader(); 142 143 /** 144 * Returns a new source catalog writer that understands this format. 145 * @return a new source catalog writer that understands this format. May 146 * return null if writing is not supported. 147 */ 148 public abstract SourceCatalogWriter makeNewWriter(); 149 150 /** 151 * Returns a text representation of this enumeration constant. 152 * @return a text representation of this enumeration constant. 153 */ 154 public String toString() 155 { 156 return EnumerationUtility.getSharedInstance().enumToUpperString(this); 157 } 158 }