View Javadoc

1   // Copyright 2006-2007, by the California Institute of Technology.
2   // ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged.
3   // Any commercial use must be negotiated with the Office of Technology Transfer
4   // at the California Institute of Technology.
5   //
6   // This software is subject to U. S. export control laws and regulations
7   // (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software
8   // is subject to U.S. export control laws and regulations, the recipient has
9   // the responsibility to obtain export licenses or other export authority as
10  // may be required before exporting such information to foreign countries or
11  // providing access to foreign nationals.
12  //
13  // $Id$ 
14  //
15  
16  package gov.nasa.pds.tools.label;
17  
18  import java.nio.ByteBuffer;
19  
20  /***
21   * @author pramirez
22   * @version $Revision$
23   * 
24   */
25  public class SFDULabel {
26      private String sfdu;
27      private String controlAuthorityId;
28      private String versionId;
29      private String classId;
30      private String delimiterType;
31      private String spare;
32      private String descriptionDataUnitId;
33      private String length;
34  
35      public SFDULabel(byte[] label) throws MalformedSFDULabel {
36          if (label.length != 20)
37              throw new MalformedSFDULabel("SFDU Label is not the correct length. Must be 20 bytes long");
38          ByteBuffer sfdu = ByteBuffer.wrap(label);
39          this.sfdu = new String(label);
40          byte [] controlAuthorityId = new byte[4];
41          byte [] versionId = new byte[1];
42          byte [] classId = new byte[1];
43          byte [] delimiterType = new byte[1];
44          byte [] spare = new byte[1];
45          byte [] descriptionDataUnitId = new byte[4];
46          byte [] length = new byte[8];
47  
48          sfdu.get(controlAuthorityId, 0, 4);
49          this.controlAuthorityId = new String(controlAuthorityId);
50          sfdu.get(versionId, 0, 1);
51          this.versionId = new String(versionId);
52          sfdu.get(classId, 0, 1);
53          this.classId = new String(classId);
54          sfdu.get(delimiterType, 0, 1);
55          this.delimiterType = new String(delimiterType);
56          sfdu.get(spare, 0, 1);
57          this.spare = new String(spare);
58          sfdu.get(descriptionDataUnitId, 0, 4);
59          this.descriptionDataUnitId = new String(descriptionDataUnitId);
60          sfdu.get(length, 0, 8);
61          this.length = new String(length);
62      }
63  
64      public String getControlAuthorityId() {
65          return controlAuthorityId;
66      }
67  
68      public String getVersionId() {
69          return versionId;
70      }
71  
72      public String getClassId() {
73          return classId;
74      }
75  
76      public String getDelimiterType() {
77          return delimiterType;
78      }
79  
80      public String getSpare() {
81          return spare;
82      }
83  
84      public String getDescriptionDataUnitId() {
85          return descriptionDataUnitId;
86      }
87      
88      public String getLength() {
89          return length;
90      }
91      
92      public String toString() {
93          return sfdu;
94      }
95  }