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
ConstructorsConstructorDescriptionLocationImpl(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 TypeMethodDescriptionbooleanstatic LocationImplObtain aLocationImplfrom aLocation.intGet the column number of this locationGet the description of this locationintGet the line number of this locationgetSnippet(int padding) Gets a source code snippet with the default paddinggetURI()Get the URI of this locationinthashCode()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 aLocationImplfrom aLocation. Iflocationis 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:
getDescriptionin 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:
getLineNumberin interfaceLocation- Returns:
- the line number (
-1if unknown)
-
getColumnNumber
public int getColumnNumber()Get the column number of this location- Specified by:
getColumnNumberin interfaceLocation- Returns:
- the column number (
-1if unknown)
-
getSnippet
Description copied from interface:LocationGets a source code snippet with the default padding- Specified by:
getSnippetin 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
-