com.opensymphony.xwork2.util.location
Class LocationImpl

java.lang.Object
  extended by com.opensymphony.xwork2.util.location.LocationImpl
All Implemented Interfaces:
Location, java.io.Serializable

public class LocationImpl
extends java.lang.Object
implements Location, java.io.Serializable

A simple immutable and serializable implementation of Location.

See Also:
Serialized Form

Constructor Summary
LocationImpl(Location location)
          Copy constructor.
LocationImpl(java.lang.String description, Location location)
          Create a location from an existing one, but with a different description
LocationImpl(java.lang.String description, java.lang.String uri)
          Build a location for a given URI, with unknown line and column numbers.
LocationImpl(java.lang.String description, java.lang.String uri, int line, int column)
          Build a location for a given URI and line and column numbers.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
static LocationImpl get(Location location)
          Obtain a LocationImpl from a Location.
 int getColumnNumber()
          Get the column number of this location
 java.lang.String getDescription()
          Get the description of this location
 int getLineNumber()
          Get the line number of this location
 java.util.List<java.lang.String> getSnippet(int padding)
          Gets a source code snippet with the default padding
 java.lang.String getURI()
          Get the URI of this location
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocationImpl

public LocationImpl(java.lang.String description,
                    java.lang.String uri)
Build a location for a given URI, with unknown line and column numbers.

Parameters:
uri - the resource URI

LocationImpl

public LocationImpl(java.lang.String description,
                    java.lang.String uri,
                    int line,
                    int column)
Build a location for a given URI and line and column numbers.

Parameters:
uri - the resource URI
line - the line number (starts at 1)
column - the column number (starts at 1)

LocationImpl

public LocationImpl(Location location)
Copy constructor.

Parameters:
location - the location to be copied

LocationImpl

public LocationImpl(java.lang.String description,
                    Location location)
Create a location from an existing one, but with a different description

Method Detail

get

public static LocationImpl get(Location location)
Obtain a LocationImpl from a Location. If location is already a LocationImpl, it is returned, otherwise it is copied.

This method is useful when an immutable and serializable location is needed, such as in locatable exceptions.

Parameters:
location - the location
Returns:
an immutable and serializable version of location

getDescription

public java.lang.String getDescription()
Get the description of this location

Specified by:
getDescription in interface Location
Returns:
the description (can be null)

getURI

public java.lang.String getURI()
Get the URI of this location

Specified by:
getURI in interface Location
Returns:
the URI (null if unknown).

getLineNumber

public int getLineNumber()
Get the line number of this location

Specified by:
getLineNumber in interface Location
Returns:
the line number (-1 if unknown)

getColumnNumber

public int getColumnNumber()
Get the column number of this location

Specified by:
getColumnNumber in interface Location
Returns:
the column number (-1 if unknown)

getSnippet

public java.util.List<java.lang.String> getSnippet(int padding)
Gets a source code snippet with the default padding

Specified by:
getSnippet in interface Location
Parameters:
padding - The amount of lines before and after the error to include
Returns:
A list of source lines

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.