001    package edu.nrao.sss.model.parameter;
002    
003    import java.util.ArrayList;
004    import java.util.Collections;
005    import java.util.HashMap;
006    import java.util.List;
007    
008    /**
009     * Simple routines for Entities: done as a singleton only because
010     * the others that are similar are.
011     * <p>
012     * <b>Version Info:</b> <table style="margin-left:2em">
013     * <tr>
014     * <td>$Revision: 329 $</td>
015     * </tr>
016     * <tr>
017     * <td>$Date: 2007-02-06 11:43:05 -0700 (Tue, 06 Feb 2007) $</td>
018     * </tr>
019     * <tr>
020     * <td>$Author: switz $</td>
021     * </tr>
022     * </table>
023     * </p>
024     *
025     * @author Stephan Witz
026     * @since 2007-09-10
027     */
028    public class EntityTypes {
029        private static EntityTypes SINGLETON;
030    
031        private static int[] padNumbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 24, 28,
032                                            32, 36, 40, 48, 56, 64, 72 };
033    
034        private static HashMap<String, EntityType> map;
035    
036        private EntityTypes() {
037            map = new HashMap<String, EntityType>();
038            // The pad parameters, no bands required
039            for (EntityType eType : EntityType.values())
040                map.put(eType.getName(), eType);
041        }
042    
043        /**
044         * Returns an instance of this Entities utility.
045         *
046         * @return Entities.
047         */
048        public static EntityTypes getInstance() {
049            // Just-in-time creation
050            if (SINGLETON == null)
051                SINGLETON = new EntityTypes();
052            return SINGLETON;
053        }
054    
055        public List<String> getPadNamesList() {
056            List<String> result = new ArrayList<String>();
057            String[] arms = {"E", "N", "W"};
058            result.add("MAS");
059            result.add("AAB");
060            for (String arm: arms) {
061                for (int padNumber: padNumbers) {
062                    result.add(arm + String.format("%02d", padNumber));
063                }
064            }
065            return result;
066        }
067    
068        public List<String> getAntennaNamesList() {
069            List<String> result = new ArrayList<String>();
070            String[] instrumentCodes = {"EA", "VA"};
071            for (String instrumentCode: instrumentCodes) {
072                for (int i = 1; i <= 28; i++) {
073                    result.add(instrumentCode + String.format("%02d", i));
074                }
075            }
076            return result;
077        }
078    
079        public List<String> getEntityTypesNamesList() {
080            List<String> result = new ArrayList<String>();
081            for (EntityType eType: map.values()) {
082                result.add(eType.getName());
083            }
084            Collections.sort(result);
085            return result;
086        }
087    }