View Javadoc

1   /*
2    * Copyright 2009 - 2010 JEuclid, http://jeuclid.sf.net
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /* $Id $ */
18  
19  package net.sourceforge.jeuclid.biparser;
20  
21  /**
22   * Tree search result (used for the cursor).
23   * 
24   * @version $Revision: cbff5bfffc35 $
25   */
26  public class TextPosition {
27  
28      /**
29       * total position index (offset).
30       */
31      private int totalOffset;
32  
33      /**
34       * node length.
35       */
36      private int length;
37  
38      /**
39       * standard constructor.
40       * 
41       * @param offset
42       *            total position index
43       * @param len
44       *            node length
45       */
46      public TextPosition(final int offset, final int len) {
47          this.totalOffset = offset;
48          this.length = len;
49      }
50  
51      /**
52       * gets total offset.
53       * 
54       * @return the totalOffset
55       */
56      public final int getTotalOffset() {
57          return this.totalOffset;
58      }
59  
60      /**
61       * sets total offset.
62       * 
63       * @param offset
64       *            the totalOffset to set
65       */
66      public final void setTotalOffset(final int offset) {
67          this.totalOffset = offset;
68      }
69  
70      /**
71       * gets length.
72       * 
73       * @return the length
74       */
75      public final int getLength() {
76          return this.length;
77      }
78  
79      /**
80       * sets length.
81       * 
82       * @param len
83       *            the length to set
84       */
85      public final void setLength(final int len) {
86          this.length = len;
87      }
88  
89      /**
90       * gets search result's string representation.
91       * 
92       * @return string representation
93       */
94      @Override
95      public final String toString() {
96          final StringBuilder sb = new StringBuilder();
97          sb.append("Offset=");
98          sb.append(this.totalOffset);
99          sb.append(", Length=");
100         sb.append(this.length);
101         return sb.toString();
102     }
103 }