001 /* 002 * Copyright 2009 - 2010 JEuclid, http://jeuclid.sf.net 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 /* $Id $ */ 018 019 package net.sourceforge.jeuclid.biparser; 020 021 /** 022 * Tree search result (used for the cursor). 023 * 024 * @version $Revision: cbff5bfffc35 $ 025 */ 026 public class TextPosition { 027 028 /** 029 * total position index (offset). 030 */ 031 private int totalOffset; 032 033 /** 034 * node length. 035 */ 036 private int length; 037 038 /** 039 * standard constructor. 040 * 041 * @param offset 042 * total position index 043 * @param len 044 * node length 045 */ 046 public TextPosition(final int offset, final int len) { 047 this.totalOffset = offset; 048 this.length = len; 049 } 050 051 /** 052 * gets total offset. 053 * 054 * @return the totalOffset 055 */ 056 public final int getTotalOffset() { 057 return this.totalOffset; 058 } 059 060 /** 061 * sets total offset. 062 * 063 * @param offset 064 * the totalOffset to set 065 */ 066 public final void setTotalOffset(final int offset) { 067 this.totalOffset = offset; 068 } 069 070 /** 071 * gets length. 072 * 073 * @return the length 074 */ 075 public final int getLength() { 076 return this.length; 077 } 078 079 /** 080 * sets length. 081 * 082 * @param len 083 * the length to set 084 */ 085 public final void setLength(final int len) { 086 this.length = len; 087 } 088 089 /** 090 * gets search result's string representation. 091 * 092 * @return string representation 093 */ 094 @Override 095 public final String toString() { 096 final StringBuilder sb = new StringBuilder(); 097 sb.append("Offset="); 098 sb.append(this.totalOffset); 099 sb.append(", Length="); 100 sb.append(this.length); 101 return sb.toString(); 102 } 103 }