001 package edu.nrao.sss.model.project.scan; 002 003 import edu.nrao.sss.util.EnumerationUtility; 004 import edu.nrao.sss.util.StringUtil; 005 006 /** 007 * An enumeration of the reasons for which a scan is made. 008 * <p> 009 * <b>Version Info:</b> 010 * <table style="margin-left:2em"> 011 * <tr><td>$Revision: 1646 $</td></tr> 012 * <tr><td>$Date: 2008-10-27 13:55:18 -0600 (Mon, 27 Oct 2008) $</td></tr> 013 * <tr><td>$Author: dharland $</td></tr> 014 * </table></p> 015 * 016 * @author David M. Harland 017 * @since 2006-07-10 018 */ 019 public enum ScanIntent 020 { 021 OBSERVE_TARGET ("ObsTgt", "TARGET"), 022 023 CALIBRATE_BANDPASS ("CalBP", "BANDPASS"), 024 025 CALIBRATE_FLUX_DENSITY_SCALE ("CalFlux", "AMPLI_CAL"), 026 027 CALIBRATE_COMPLEX_GAIN ("CalGain", "PHASE_CAL"), 028 029 CALIBRATE_POLARIZATION_ANGLE ("CalPolAng", "POLARIZATION"), 030 031 CALIBRATE_POLARIZATION_LEAKAGE ("CalPolLeak", "UNSPECIFIED"), 032 033 CALIBRATE_ABSOLUTE_POSITION ("CalPos", "ANTENNA_POSITIONS"), 034 035 CALIBRATE_OFFSET_POINTING ("CalOffPtg", "POINTING"), 036 037 DETERMINE_AUTOPHASE ("DetAutoPh", "UNSPECIFIED"), 038 039 DETERMINE_RFI ("DetRFI", "UNSPECIFIED") 040 { 041 public String toString() 042 { 043 return "Determine RFI"; 044 } 045 }, 046 047 CALIBRATE_DELAY_AMPLITUDE_STYLE ("CalDelAmp", "UNSPECIFIED"), 048 049 CALIBRATE_DELAY_PHASE_STYLE ("CalDelPhs", "DELAY"), 050 051 DETERMINE_ANTENNA_GLOBAL_POINTING_MODEL("CalGlbPtg", "POINTING_MODEL"), 052 053 MAP_ANTENNA_SURFACE ("MapSurf", "HOLOGRAPHY"), 054 055 CALIBRATE_FOCUS ("CalFocus", "FOCUS"), 056 057 DETERMINE_SINGLE_DISH_POINTING ("DetSDPtg", "UNSPECIFIED"), 058 059 DETERMINE_OPACITY_TIPPING_STYLE ("DetTau", "SKYDIP"), 060 061 OBSERVE_PULSAR ("ObsPsr", "UNSPECIFIED"), 062 063 TIME_PULSAR ("TimePsr", "UNSPECIFIED"), 064 065 OTHER ("Other", "UNSPECIFIED"); 066 067 private String abbr; 068 private String sdmText; 069 070 private ScanIntent(String abbreviation, String sdmName) 071 { 072 abbr = abbreviation; 073 sdmText = sdmName; 074 } 075 076 /** 077 * Returns a default scan intent. 078 * @return a default scan intent. 079 */ 080 public static ScanIntent getDefault() 081 { 082 return OBSERVE_TARGET; 083 } 084 085 /** 086 * Returns a short version of this intent's name. 087 * @return a short version of this intent's name. 088 */ 089 public String getAbbreviation() 090 { 091 return abbr; 092 } 093 094 /** 095 * Returns a valid Science Data Model (SDM) string for this intent. 096 * @return a valid Science Data Model (SDM) string for this intent. 097 */ 098 public String getSdmText() 099 { 100 return sdmText; 101 } 102 103 /** 104 * Returns a text representation of this enumeration constant. 105 * @return a text representation of this enumeration constant. 106 */ 107 public String toString() 108 { 109 return EnumerationUtility.getSharedInstance().enumToString(this); 110 } 111 112 /** 113 * Returns the scan intent represented by {@code text}. 114 * <p> 115 * For details about the transformation, see 116 * {@link EnumerationUtility#enumFromString(Class, String)}. 117 * In addition to using the {@code name} and {@code toString} 118 * methods, the abbreviations of the intents are also used 119 * in the search for a matching intent.</p> 120 * 121 * @param text a text representation of a scan intent. 122 * 123 * @return the scan intent represented by {@code text}. 124 */ 125 public static ScanIntent fromString(String text) 126 { 127 ScanIntent result = 128 EnumerationUtility.getSharedInstance() 129 .enumFromString(ScanIntent.class, text); 130 131 //If no match found, search abbreviations 132 if (result == null) 133 { 134 text = StringUtil.getInstance().normalizeString(text); 135 for (ScanIntent si : ScanIntent.values()) 136 { 137 if (text.equalsIgnoreCase(si.getAbbreviation())) 138 { 139 result = si; 140 break; 141 } 142 } 143 } 144 145 return result; 146 } 147 }