Package org.apache.juneau.swaps
Class ParsedReaderSwap
- Direct Known Subclasses:
ParsedReaderSwap.Html,ParsedReaderSwap.Json,ParsedReaderSwap.PlainText,ParsedReaderSwap.Uon,ParsedReaderSwap.UrlEncoding,ParsedReaderSwap.Xml
Transforms the contents of a
Reader into an Object.
Description
TheReader must contain JSON, Juneau-generated XML (output from XmlSerializer), or Juneau-generated
HTML (output from JsonSerializer) in order to be parsed correctly.
Useful for serializing models that contain Readers created by RestCall instances.
This is a one-way transform, since Readers cannot be reconstituted.
Behavior-specific subclasses
The following direct subclasses are provided for convenience:ParsedReaderSwap.Json- Parses JSON text.ParsedReaderSwap.Xml- Parses XML text.ParsedReaderSwap.Html- Parses HTML text.ParsedReaderSwap.PlainText- Parses plain text.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classReader transform for reading HTML text.static classReader transform for reading JSON text.static classReader transform for reading plain text.static classReader transform for reading plain text.static classReader transform for reading plain text.static classReader transform for reading XML text. -
Field Summary
Fields inherited from class org.apache.juneau.swap.ObjectSwap
NULL -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.juneau.swap.ObjectSwap
forMediaTypes, forMediaTypes, getNormalClass, getSwapClass, getSwapClassMeta, isNormalObject, isSwappedObject, match, swap, toString, unswap, unswap, withTemplate, withTemplate
-
Constructor Details
-
ParsedReaderSwap
- Parameters:
parser- The parser to use to convert the contents of the reader to Java objects.
-
-
Method Details
-
swap
- Overrides:
swapin classObjectSwap<Reader,Object> - Parameters:
session- The bean session to use to get the class meta. This is always going to be the same bean context that created this swap.o- The object to be transformed.- Returns:
- The transformed object.
- Throws:
Exception- If a problem occurred trying to convert the output.
-