Class MultipartField
String representations of its value, and other attributes as encoded according to the multipart/form-data specification.
Instances can be acquired via these builder factory methods:
withName(String)(with form element name)with(String, byte[])(with form element name and value)
Equality and hashing include the name, filename, content type, explicitly configured charset, and binary contents. The lazily decoded string value does not participate. A null or empty data array represents an absent value. Backing bytes are retained without defensive copying; callers must not modify them after the field is built.
Full documentation is available at https://www.soklet.com/docs/request-handling#multipart-form-data.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classBuilder used to copy instances ofMultipartFieldviacopy(). -
Method Summary
Modifier and TypeMethodDescriptioncopy()Vends a mutable copier seeded with this instance's data, suitable for building new instances.booleanThe charset used to encode this field, if applicable.The content type for this field, if available (for example,image/pngfor an image file).getData()The binary value of this field, if available.The value of this field represented as a string, if available.The filename associated with this field, if available.getName()The name of this field.inthashCode()toString()static @NonNull MultipartField.BuilderAcquires a builder forMultipartFieldinstances.static @NonNull MultipartField.BuilderAcquires a builder forMultipartFieldinstances.
-
Method Details
-
withName
Acquires a builder forMultipartFieldinstances.- Parameters:
name- the name of this field- Returns:
- the builder
-
with
Acquires a builder forMultipartFieldinstances.- Parameters:
name- the name of this fieldvalue- the optional value for this field- Returns:
- the builder
-
copy
Vends a mutable copier seeded with this instance's data, suitable for building new instances.- Returns:
- a copier for this instance
-
toString
-
equals
-
hashCode
-
getDataAsString
The value of this field represented as a string, if available.Decodes strictly using
getCharset(), or UTF-8 when no charset is specified. Malformed or unmappable byte sequences are rejected without substituting replacement characters. UsegetData()for binary field data or application-defined decoding.- Returns:
- the string value, or
Optional.empty()if not available - Throws:
IllegalRequestBodyException- if the data cannot be decoded using its selected charset
-
getName
-
getFilename
The filename associated with this field, if available.This is untrusted client input, not a safe filesystem path. It may contain directory components or other unsafe characters (including decoded HTML entities). Applications must validate it and select their own storage path; do not resolve it directly against an upload directory.
- Returns:
- the filename, or
Optional.empty()if not available
-
getContentType
The content type for this field, if available (for example,image/pngfor an image file).- Returns:
- the content type, or
Optional.empty()if not available
-
getCharset
The charset used to encode this field, if applicable.- Returns:
- the charset, or
Optional.empty()if not available
-
getData
The binary value of this field, if available.Returns the backing array without defensive copying. Callers must not modify it, because string decoding, equality and hashing depend on these bytes.
- Returns:
- the binary value, or
Optional.empty()if not available
-