The eLandings Look-up Codes files (i.e. Species Codes, Stat Areas Codes, Condition Codes, Gear Codes, etc.) are available for download at:
eLandings Look-up Code Files in XML format and eLandings Look-up Code Files in Human readable format
Download the species.xml file from https://elandings.alaska.gov/elandings/XmlCodesLookup?event=xml&xml=species and save it to a file called species.xml within your Netbeans eLandingsClient project.
Within eLandings, we use these lookup code files to:
...
Open the ELandingsClient.java file.
Within the main method copy and paste in the following code:
Code Block |
---|
//Create a generatic unmarshaller
javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance("generated");
javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
//Read in the species.xml file and parse it into a Codes object.
FileInputStream input = new FileInputStream("species.xml" );
Codes codes =(Codes)unmarshaller.unmarshal(input);
//Get the list of species contained within the codes object, iterate over the list and display the species codes and names found therein.
List<SpeciesDef> species = codes.getSpeciesDef();
for(SpeciesDef speciesDef:species){
System.out.println("Species "+speciesDef.getSpecies().getName()+" -- "+speciesDef.getSpecies().getValue().toString());
}
|