Class TokenReaderArg

java.lang.Object
org.apache.juneau.rest.server.arg.SimpleRestOperationArg
org.apache.juneau.rest.server.arg.TokenReaderArg
All Implemented Interfaces:
RestOpArg

Resolves method parameters of type TokenReader (or any subtype) on RestOp-annotated Java methods.

Implements the two-layer resolution for token-cursor parameters:

  1. Static parameter type filters eligible parsers — e.g. JsonlTokenReader param means only JsonlParser is eligible.
  2. Request Content-Type negotiates among the eligible parsers (the matched parser must accept the incoming media type).

The parameter value is resolved by:

  1. Negotiating the request's Content-Type to a matched Parser.
  2. Building a request-configured ParserSession and calling readTokens(input) on it — so the cursor honors the same locale / timezone / schema / charset as a normal parsed body.
  3. Verifying the returned cursor is assignable to the declared parameter type.

Rejection paths (all surfaced as HTTP 415 / 406):

  • No parser matched the Content-Type — resolution returns null and the framework rejects the request (415/406 via the empty match).
  • Matched parser does not implement TokenReadable (the format cannot serve the token-reader surface) — throws UnsupportedMediaType (415).
  • Matched parser produces a cursor not assignable to the declared parameter type — throws UnsupportedMediaType (415).
See Also:
  • Constructor Details

    • TokenReaderArg

      protected TokenReaderArg(Class<?> declaredType)
      Constructor.
      Parameters:
      declaredType - The declared parameter type.
  • Method Details

    • create

      public static TokenReaderArg create(ParameterInfo paramInfo)
      Static creator.
      Parameters:
      paramInfo - The Java method parameter being resolved. Must not be null.
      Returns:
      A new TokenReaderArg, or null if the parameter type is not TokenReader or a subtype.
    • getDeclaredType

      public Class<?> getDeclaredType()
      Returns the declared parameter type for diagnostic / introspection use.