Class PathParams

java.lang.Object
dev.relism.flash.models.PathParams

public class PathParams extends Object
Path parameters captured during routing, stored as byte offsets into the path view. get(java.lang.String) allocates a String on call (in one allocation when source is The public constructor below builds a one-shot, fixed-size instance (used by AbstractWsRouter and by tests) — names.length is taken as the exact param count. FastPathRouterImpl's per-connection scratch instead owns a single long-lived PathParams whose backing arrays are grown to the connection's high-water mark and never reallocated after warmup; because those arrays can be larger than the current request's actual param count, that path uses reset(dev.relism.fpr.core.ByteView, int), which — unlike the constructor — takes the live count explicitly rather than inferring it from array length. Both this constructor and reset(dev.relism.fpr.core.ByteView, int) are public rather than package-private (matching Http1HeaderMap.reset(byte[], int, int)'s own precedent for a reusable buffer-backed object): the router implementation that owns the reusable instance lives in a different package (dev.relism.flash.routing.routers.fastpathrouter), and PathParams.inject's own doc explains why this codebase prefers a small public surface here over a cross-package friend-access workaround. A PathParams obtained this way has the same "do not retain past the handler" lifetime contract as Http1HeaderMap's buffer-backed views: the next request on the same connection repositions the same arrays.
  • Constructor Details

    • PathParams

      public PathParams(dev.relism.fpr.core.ByteView source, String[] names, int[] starts, int[] lens)
    • PathParams

      public PathParams(String[] names, int[] starts, int[] lens)
      Builds an instance meant only for reset(dev.relism.fpr.core.ByteView, int): no source yet, and count starts at 0 until the first reset(dev.relism.fpr.core.ByteView, int) call. names/starts/lens may be larger than any single request's param count — see the class Javadoc.
  • Method Details

    • reset

      public void reset(dev.relism.fpr.core.ByteView source, int count)
      Repositions this instance over a new request: count (which may be less than names.length — see the class Javadoc) params are now valid, read out of the same backing arrays the constructor was given, against the new source. Zero allocation.
    • inject

      public static void inject(Request request, PathParams params)
      Injects path parameters into a request. The cross-package bridge from AbstractRouter — keeps Request.setPathParams(dev.relism.flash.models.PathParams) package-private while allowing the router to set params without a public setter.
    • get

      public String get(String name)