Interface Segment

All Superinterfaces:
Normalisable<Segment>, org.wiremock.stringparser.ParsedString, PercentEncoded<Segment>

public interface Segment extends PercentEncoded<Segment>, org.wiremock.stringparser.ParsedString
Represents a single segment of a path.

A path segment is a portion of a path between forward slashes. Special segments include the empty segment, the dot segment (.), and the dot-dot segment (..) used for relative path resolution.

Implementations must be immutable and thread-safe.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Segment
    A dot segment (.) representing the current directory.
    static final Segment
    A dot-dot segment (..) representing the parent directory.
    static final Segment
    An empty path segment.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static Segment
    encode(String unencoded)
    Encodes a string into a valid path segment with proper percent-encoding.
    static Segment
    parse(String segment)
    Parses a string into a path segment.

    Methods inherited from interface org.wiremock.url.Normalisable

    isNormalForm, normalise

    Methods inherited from interface org.wiremock.stringparser.ParsedString

    toString

    Methods inherited from interface org.wiremock.url.PercentEncoded

    decode, isEmpty, length
  • Field Details

    • EMPTY

      static final Segment EMPTY
      An empty path segment.
    • DOT

      static final Segment DOT
      A dot segment (.) representing the current directory.
    • DOT_DOT

      static final Segment DOT_DOT
      A dot-dot segment (..) representing the parent directory.
  • Method Details

    • parse

      static Segment parse(String segment) throws IllegalSegment
      Parses a string into a path segment.
      Parameters:
      segment - the string to parse
      Returns:
      the parsed segment
      Throws:
      IllegalSegment - if the string is not a valid segment
    • encode

      static Segment encode(String unencoded)
      Encodes a string into a valid path segment with proper percent-encoding.
      Parameters:
      unencoded - the unencoded string
      Returns:
      the encoded segment