
package simple.xml.stream;

import javax.xml.stream.events.XMLEvent;
import javax.xml.stream.Location;

public class InputPosition implements Position {

   private XMLEvent source;
        
   public InputPosition(XMLEvent source) {
      this.source = source;
   }        

   public int getLine() {
      if(source != null) {
         return getLocation().getLineNumber();
      }   
      return -1;
   }

   private Location getLocation() {
      return source.getLocation();           
   }

   public String toString() {
      return String.format("line=%s", getLine());           
   }
}

@@ -1,194 +1,1645 @@
-%0Apackage simple.xml.stream;%0A%0Aimport javax.xml.stream.events.XMLEvent;%0Aimport javax.xml.stream.Location;%0A%0Apublic class InputPosition implements Position %7B%0A%0A   private XMLEvent source;%0A       
+/*%0A * InputPosition.java July 2006%0A *%0A * Copyright (C) 2006, Niall Gallagher %3Cniallg@users.sf.net%3E%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the %0A * GNU Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General %0A * Public License along with this library; if not, write to the %0A * Free Software Foundation, Inc., 59 Temple Place, Suite 330, %0A * Boston, MA  02111-1307  USA%0A */%0A%0Apackage simple.xml.stream;%0A%0Aimport javax.xml.stream.events.XMLEvent;%0Aimport javax.xml.stream.Location;%0A%0A/**%0A * The %3Ccode%3EInputPosition%3C/code%3E object is used to acquire the line%0A * number within the XML document. This allows debugging to be done%0A * when a problem occurs with the source document. This object can %0A * be converted to a string using the %3Ccode%3EtoString%3C/code%3E method.%0A *%0A * @author Niall Gallagher%0A */ %0Aclass InputPosition implements Position %7B%0A%0A   /**%0A    * This is the XML event that the position is acquired for.%0A    */         %0A   private XMLEvent source;%0A        %0A   /**%0A    * Constructor for the %3Ccode%3EInputPosition%3C/code%3E object. This is%0A    * used to create a position description if the provided event %0A    * is not null. If the event is null the position given is -1.%0A    *%0A    * @param source this is the XML event to get the position of%0A    */
  %0A  
@@ -1715,239 +1715,1124 @@
    %7D
+%0A%0A
    
-     %0A%0A   public int getLine() %7B%0A      if(source != null) %7B%0A         return getLocation().getLineNumber();%0A      %7D   %0A      return -1;%0A   %7D%0A%0A   private Location getLocation() %7B%0A      return source.getLocation();           %0A   %7D%0A
+/**%0A    * This is the actual line number within the read XML document. %0A    * The line number allows any problems within the source XML%0A    * document to be debugged if it does not match the schema. %0A    * This will return -1 if the line number cannot be determined.%0A    *%0A    * @return this returns the line number of an XML event %0A    */ %0A   public int getLine() %7B%0A      if(source != null) %7B%0A         return getLocation().getLineNumber();%0A      %7D   %0A      return -1;%0A   %7D%0A%0A   /**%0A    * This is used to acquire the location information from the%0A    * provided XML event. This is called only if the provided XML%0A    * event is not null. This provides the StAX line numbering.%0A    * %0A    * @return this returns the StAX location information%0A    */ %0A   private Location getLocation() %7B%0A      return source.getLocation();           %0A   %7D%0A%0A   /**%0A    * This provides a textual description of the position the %0A    * read cursor is at within the XML document. This allows the%0A    * position to be embedded within the exception thrown.%0A    *%0A    * @return this returns a textual description of the position%0A    */    
 %0A   

Update documentation.