com.opensymphony.xwork2.util.location

## Class LocationImpl

- java.lang.Object
- - com.opensymphony.xwork2.util.location.LocationImpl

- All Implemented Interfaces:
    Location, Serializable

      public class LocationImpl
      extends Object
      implements Location, Serializable

  A simple immutable and serializable implementation of `Location`.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `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 column numbers.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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
    `List<String>` | `getSnippet(int padding)` Gets a source code snippet with the default padding
    `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:
        `description` - description for location
        `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 column numbers.
      Parameters:
        `description` - description for location
        `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
      Parameters:
        `description` - description for location
        `location` - location object

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

    - #### getSnippet

          public List<String> getSnippet(int padding)

      Description copied from interface: `Location`
      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 source code snippet with the default padding

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2000–2022 Apache Software Foundation. All rights reserved.