org.apache.cocoon.util.location
Class LocationImpl

java.lang.Object
  extended byorg.apache.cocoon.util.location.LocationImpl
All Implemented Interfaces:
Location, Serializable

public class LocationImpl
extends Object
implements Location, Serializable

A simple immutable and serializable implementation of Location.

Since:
2.1.8
Version:
$Id: LocationImpl.html 1304280 2012-03-23 11:18:01Z ilgrosso $
See Also:
Serialized Form

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

Constructor Detail

LocationImpl

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

Parameters:
uri - the resource URI

LocationImpl

public LocationImpl(String description,
                    String uri,
                    int line,
                    int column)
Build a location for a given URI and line and columb 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(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 String getDescription()
Get the description of this location

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

getURI

public 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)

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

toString

public String toString()


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.