Worldwind public release 0.2.1
[worldwind-tracker.git] / gov / nasa / worldwind / formats / rpf / RpfProducer.java
blobd4fc827731fa869601a42315ec51ddaee6a405d3
1 /*
2 Copyright (C) 2001, 2006 United States Government as represented by
3 the Administrator of the National Aeronautics and Space Administration.
4 All Rights Reserved.
5 */
6 package gov.nasa.worldwind.formats.rpf;
8 import gov.nasa.worldwind.*;
10 import static java.util.logging.Level.*;
12 /**
13 * @author dcollins
14 * @version $Id: RpfProducer.java 1896 2007-05-29 00:16:25Z dcollins $
16 public enum RpfProducer
18 /* [Section 5.2.1, MIL-STD-2411-1] */
19 Producer1('1', "AFACC", "Air Force Air Combat Command"),
20 Producer2('2', "AFESC", "Air Force Electronic Systems Center"),
21 Producer3('3', "NIMA", "National Imagery and Mapping Agency, Primary"),
22 Producer4('4', "NIMA1", "NIMA, Alternate Site 1"),
23 Producer5('5', "NIMA2", "NIMA, Alternate Site 2"),
24 Producer6('6', "NIMA3", "NIMA, Alternate Site 3"),
25 Producer7('7', "SOCAF", "Air Force Special Operations Command"),
26 Producer8('8', "SOCOM", "United States Special Operations Command"),
27 Producer9('9', "PACAF", "Pacific Air Forces"),
28 ProducerA('A', "USAFE", "United States Air Force, Europe"),
29 ProducerB('B', "Non-DoD (NonDD)", "US producer outside the Department of Defense"),
30 ProducerC('C', "Non-US (NonUS)", "Non-US producer"),
31 ProducerD('D', "NIMA", "DCHUM (DCHUM) NIMA produced Digital CHUM file"),
32 ProducerE('E', "Non-NIMA DCHUM (DCHMD)", "DoD producer of Digital CHUM file otherthan NIMA "),
33 ProducerF('F', "Non-US DCHUM (DCHMF)", "Non-US (foreign)producer of Digital CHUMfiles"),
34 ProducerG('G', "Non-DoD DCHUM (DCHMG)", "US producer of Digital CHUM files outsideDoD"),
35 ProducerH('H', "IMG2RPF", "Non-specified, Imagery formatted to RPF"),
36 // Producer?('I'-'Z', "", "Reserved for future standardization"),
39 public final Character id;
40 public final String producerCode;
41 public final String producer;
43 private RpfProducer(Character id, String producerCode, String producer)
45 this.id = id;
46 this.producer = producer;
47 this.producerCode = producerCode;
50 private static RpfProducer[] enumConstantAlphabet = null;
52 private static RpfProducer[] enumConstantAlphabet()
54 if (enumConstantAlphabet == null)
56 RpfProducer[] universe = RpfProducer.class.getEnumConstants();
57 enumConstantAlphabet = new RpfProducer[36];
58 for (RpfProducer producer : universe)
60 enumConstantAlphabet[indexFor(producer.id)] = producer;
63 return enumConstantAlphabet;
66 private static int indexFor(Character id)
68 if (id >= '0' && id <= '9')
69 return id - '0';
70 else if (id >= 'A' && id <= 'Z')
71 return 10 + id - 'A';
72 return -1;
75 public static boolean isProducerId(Character id)
77 if (id == null)
79 String message = WorldWind.retrieveErrMsg("nullValue.CharacterIsNull");
80 WorldWind.logger().log(FINE, message);
81 throw new IllegalArgumentException(message);
83 RpfProducer[] alphabet = enumConstantAlphabet();
84 int index = indexFor(Character.toUpperCase(id));
85 return (index >= 0) && (index < alphabet.length) && (alphabet[index] != null);
88 public static RpfProducer producerFor(Character id)
90 if (id == null)
92 String message = WorldWind.retrieveErrMsg("nullValue.CharacterIsNull");
93 WorldWind.logger().log(FINE, message);
94 throw new IllegalArgumentException(message);
96 RpfProducer producer;
97 RpfProducer[] alphabet = enumConstantAlphabet();
98 int index = indexFor(Character.toUpperCase(id));
99 if (index < 0 || index >= alphabet.length || (producer = alphabet[index]) == null)
101 String message = WorldWind.retrieveErrMsg("generic.EnumNotFound") + id;
102 WorldWind.logger().log(FINE, message);
103 throw new EnumConstantNotPresentException(RpfZone.class, message);
105 return producer;