001/* 002// $Id: //open/util/resgen/src/org/eigenbase/xom/Location.java#2 $ 003// Package org.eigenbase.xom is an XML Object Mapper. 004// Copyright (C) 2008-2008 The Eigenbase Project 005// Copyright (C) 2008-2008 Disruptive Tech 006// Copyright (C) 2008-2008 LucidEra, Inc. 007// 008// This library is free software; you can redistribute it and/or modify it 009// under the terms of the GNU Lesser General Public License as published by the 010// Free Software Foundation; either version 2 of the License, or (at your 011// option) any later version approved by The Eigenbase Project. 012// 013// This library is distributed in the hope that it will be useful, 014// but WITHOUT ANY WARRANTY; without even the implied warranty of 015// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016// GNU Lesser General Public License for more details. 017// 018// You should have received a copy of the GNU Lesser General Public License 019// along with this library; if not, write to the Free Software 020// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 021*/ 022package org.eigenbase.xom; 023 024/** 025 * Represents the location of a node within its document. 026 * 027 * <p>Location is a span from a starting line and column to an ending line 028 * and column; or alternatively, from a starting character position to an 029 * ending character position. 030 * 031 * @author jhyde 032 * @version $Id: //open/util/resgen/src/org/eigenbase/xom/Location.java#2 $ 033 * @since Jun 6, 2008 034 */ 035public interface Location { 036 /** 037 * Returns the line where this node starts. 038 * The first line in the document is 1. 039 * 040 * @return Line of the start of this node 041 */ 042 int getStartLine(); 043 044 /** 045 * Returns the column where this node starts. 046 * The first column in the document is 1. 047 * 048 * @return column of the start of this node 049 */ 050 int getStartColumn(); 051 052 /** 053 * Returns the character position where this node starts. 054 * The first character in the document is 0. 055 * 056 * @return Character position of the start of this node 057 */ 058 int getStartPos(); 059 060 /** 061 * Returns the line where this node ends. 062 * The first line in the document is 1. 063 * 064 * @return Line of the end of this node 065 */ 066 int getEndLine(); 067 068 /** 069 * Returns the column where this node ends. 070 * The first column in the document is 1. 071 * 072 * @return column of the end of this node 073 */ 074 int getEndColumn(); 075 076 /** 077 * Returns the character position where this node ends. 078 * The first character in the document is 0. 079 * 080 * @return Character position of the end of this node 081 */ 082 int getEndPos(); 083 084 /** 085 * Returns the text of this location. 086 * 087 * <p>If this location is an element 088 * and <code>headOnly</code> is true, returns only the text of the head 089 * of the element. For example, 090 * 091 * <blockquote><pre> 092 * <Foo a="1" b="2"> 093 * <Bar c="3"> 094 * </Foo> 095 * </pre></blockquote> 096 * 097 * returns "<Foo a='1' b='2'><Bar c='3'></Foo>" 098 * if <code>headOnly</code> is false, "<Foo a='1' b='2'>" if it is 099 * true. 100 * 101 * @param headOnly Whether to return only the head of elements 102 * @return Source text underlying a location 103 */ 104 String getText(boolean headOnly); 105} 106 107// End Location.java