Package org.apache.struts2.util.location
Class LocationImpl
java.lang.Object
org.apache.struts2.util.location.LocationImpl
- All Implemented Interfaces:
Serializable
,Location
A simple immutable and serializable implementation of
Location
.- See Also:
-
Constructor Summary
ConstructorDescriptionLocationImpl
(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 column numbers.LocationImpl
(String description, Location location) Create a location from an existing one, but with a different descriptionLocationImpl
(Location location) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static LocationImpl
Obtain aLocationImpl
from aLocation
.int
Get the column number of this locationGet the description of this locationint
Get the line number of this locationgetSnippet
(int padding) Gets a source code snippet with the default paddinggetURI()
Get the URI of this locationint
hashCode()
toString()
-
Constructor Details
-
LocationImpl
Build a location for a given URI, with unknown line and column numbers.- Parameters:
description
- description for locationuri
- the resource URI
-
LocationImpl
Build a location for a given URI and line and column numbers.- Parameters:
description
- description for locationuri
- the resource URIline
- the line number (starts at 1)column
- the column number (starts at 1)
-
LocationImpl
Copy constructor.- Parameters:
location
- the location to be copied
-
LocationImpl
Create a location from an existing one, but with a different description- Parameters:
description
- description for locationlocation
- location object
-
-
Method Details
-
get
Obtain aLocationImpl
from aLocation
. Iflocation
is already aLocationImpl
, 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
Get the description of this location- Specified by:
getDescription
in interfaceLocation
- Returns:
- the description (can be
null
)
-
getURI
Get the URI of this location -
getLineNumber
public int getLineNumber()Get the line number of this location- Specified by:
getLineNumber
in interfaceLocation
- Returns:
- the line number (
-1
if unknown)
-
getColumnNumber
public int getColumnNumber()Get the column number of this location- Specified by:
getColumnNumber
in interfaceLocation
- Returns:
- the column number (
-1
if unknown)
-
getSnippet
Description copied from interface:Location
Gets a source code snippet with the default padding- Specified by:
getSnippet
in interfaceLocation
- Parameters:
padding
- The amount of lines before and after the error to include- Returns:
- a source code snippet with the default padding
-
equals
-
hashCode
public int hashCode() -
toString
-