Previous Next        Current Page: NeXtMidas Training / File Handlers / Lab 1 / Part 1 (ctd.)
back
+ Start Here   
+ Background   
+ Common Midas Concepts   
+ Getting Started - Part 1   
+ Getting Started - Part 2   
+ Working with Files   
+ Option Trees   
+ Macros - Part 1 (Basics)   
+ Macros - Part 2 (Graphics)   
+ NetBeans - Part 1 (Setup)   
+ NetBeans - Part 2 (GUIs)   
+ NetBeans - Part 3 (Profiler)   
+ Eclipse - Part 1 (Setup)   
+ Eclipse - Part 2 (GUIs)   
+ Primitives   
+ WebStart   
+ Maps & Imagery   
+ X-Midas Interoperability   
+ RMIF & Remoting   
+ Installing NeXtMidas   
+ Support & Maintenance   
- File Handlers   
   + Introduction   
   - Lab 1   
      - File Format   
      - Part 1   
      - Part 1 (ctd.)   
      - Part 1 (ctd.)   
      - Part 2   
      - Part 3   
      - Part 4   
      - Solution   
   + Lab 2   


  • Part 1 - The File Header (continued):
    • Providing set/get methods for the header fields.
      • We need to make set and get methods for each of the fields in the header. If you look back two pages you will see a table that details the structure of the header.
      • When reading or unpacking data from a buffer, we want to use the unpack methods provided by Convert. These methods take in the buffer to access (header) and the byte offset into the buffer (see the table). When unpacking a string, it is necessary to provide the length of the string to read. When unpacking a numeric value, it is necessary to indicate what byte representation is being used (here we are using EEEI).
      • When writing or packing data into a buffer, we want to use the pack methods provided by Convert. These methods are similar to the unpack methods, except that they have an additional parameter for the value that is to be set.
      • For example, here are the set and get methods for XDelta:
          public double getXDelta () {
            return Convert.unpackD(header, 16, EEEI);
          }
          
          public void setXDelta (double val) {
            Convert.packD(header, 16, val, EEEI);
          }
        
      • The set and get methods for Version, Format, and XStart are left for you to do.
  • continued on next page

back