Class BodyParser<T extends Body>
java.lang.Object
de.craftsblock.craftsnet.api.http.body.BodyParser<T>
- Type Parameters:
T- The type of body that this parser can parse.
- Direct Known Subclasses:
MultipartFormBodyParser,StandardFormBodyParser,TypedBodyParser
This abstract class represents a parser for HTTP request or response bodies.
It provides methods to parse a body from an input stream and to check if a specific content type is parseable.
- Since:
- 3.0.4-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBodyParser(String contentType, String... contentTypes) Constructs a new BodyParser with the given content types. -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable list of supported content types as patterns.booleanisParseable(String contentType) Checks if this parser can parse the given content type.abstract Tparse(Request request, InputStream body) Parses the body from the provided input stream.
-
Constructor Details
-
BodyParser
Constructs a new BodyParser with the given content types.- Parameters:
contentType- The primary content type supported by this parser.contentTypes- Additional content types supported by this parser.
-
-
Method Details
-
parse
Parses the body from the provided input stream.- Parameters:
request- The HTTP request associated with the body.body- The input stream containing the body data.- Returns:
- The parsed body object, or null if parsing fails.
-
contentTypes
Returns an unmodifiable list of supported content types as patterns.- Returns:
- The list of supported content types as patterns.
-
isParseable
Checks if this parser can parse the given content type.- Parameters:
contentType- The content type to check.- Returns:
- true if the parser supports the given content type, false otherwise.
-