Class PojoWalker

java.lang.Object
org.apache.juneau.marshall.stream.PojoWalker

public final class PojoWalker extends Object
Format-neutral POJO walker that re-emits an arbitrary object graph through a TokenWriter.

Used by TokenWriter.object(Object) on every format that supports the cursor-level POJO bridge: the walker introspects the value (null / scalar / array / collection / map / bean) and recursively emits startObject / fieldName / string / number / bool / nil / binary events on the calling writer. No raw bytes are written by the walker; per-format encoding is the TokenWriter's job.

Notes:
  • Object swaps and @Schema annotations are applied during the walk via MarshallingContext.toBeanMap(Object) (e.g. java.time types are emitted as ISO-8601 strings). This is the explicit carve-out from the cursor's "purely structural" rule for the object bridge. The bean introspection uses the live session's MarshallingContext (threaded through PojoWalker.Options.context()) so swaps / bean-filters / locale / timezone honor the same per-invocation configuration as serialize(...); it falls back to MarshallingContext.DEFAULT only when no context is supplied.
  • Self-referencing graphs are guarded by an identity-based ancestor check: re-entering an object already on the current walk path throws IllegalStateException rather than recursing until the stack overflows. (Shared but acyclic references — the same node reachable by two distinct paths — are permitted.)
  • Method Details

    • walk

      public static void walk(TokenWriter w, Object value) throws IOException
      Walks the given value and emits its structure through the given writer using default options.
      Parameters:
      w - The token writer to emit events to. Must not be null.
      value - The value to walk. May be null.
      Throws:
      IOException - If the writer's underlying stream fails.
    • walk

      public static void walk(TokenWriter w, Object value, PojoWalker.Options options) throws IOException
      Walks the given value and emits its structure through the given writer using the supplied options.
      Parameters:
      w - The token writer to emit events to. Must not be null.
      value - The value to walk. May be null.
      options - The walker's databind-level options. Must not be null.
      Throws:
      IOException - If the writer's underlying stream fails.