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: PointerStatement.java 2606 2007-04-18 19:35:09Z pramirez $ 
14  //
15  
16  package gov.nasa.pds.tools.label;
17  
18  /***
19   * This class is the object representation of a pointer statement in a label.
20   * 
21   * @author pramirez
22   * @version $Revision: 2606 $
23   * 
24   */
25  public class PointerStatement extends Statement implements PointerType {
26      protected Value value;
27      private CommentStatement comment;
28      private int pointerType;
29  
30      /***
31       * Constructs essentially a null pointer
32       * @param lineNumber at which the statement occurs
33       * @param identifier of the statement
34       */
35      protected PointerStatement(int pointerType, int lineNumber, String identifier) {
36          this(pointerType, lineNumber, identifier, null);
37      }
38      
39      /***
40       * Constructs a pointer with a value on the right hand side
41       * @param lineNumber at which the statement occurs
42       * @param identifier of the statement
43       * @param value of the assignment
44       */
45      protected PointerStatement(int pointerType, int lineNumber, String identifier, Value value) {
46          super(lineNumber, identifier);
47          this.value = value; 
48          this.pointerType = pointerType;
49          comment = null;  
50      }
51      
52      /***
53       * Constructs a pointer with an unknown line number.
54       * @param identifier of the statement
55       * @param value of the assignment
56       */
57      protected PointerStatement(String identifier, Value value) {
58          this(UNDEFINED, -1, identifier, value);
59      }
60      
61      /***
62       * Returns the value portion (right hand side) of the statement.
63       * @return value
64       */
65      public Value getValue() { 
66          return value;
67      }
68  
69      /***
70       * Attaches a comment to this pointer
71       * @param comment that occurs on same line as this pointer statement
72       */
73      public void attachComment(CommentStatement comment) {
74          this.comment = comment;
75      }
76      
77      /***
78       * Returns the comment that occurs on the same line as this pointer assigment
79       * @return comment
80       */
81      public CommentStatement getComment() {
82          return comment;
83      }
84      
85      /***
86       * Indicates the type of pointer that this pointer statement represents. See {@link PointerType}
87       * @return type of pointer
88       */
89      public int getPointerType() {
90          return pointerType;
91      }
92  
93  }