Package org.javalite.activeweb
Class FormItem
java.lang.Object
org.javalite.activeweb.FormItem
- Direct Known Subclasses:
FileItem
Represents an form item from a multi-part form.
- Author:
- Igor Polevoy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getBytes()
Reads contents of a file into a byte array at once.Content type of this form field.Form field name.File name.Returns input stream to read uploaded file contents from.getName()
File name.Converts entire content of this item to String.boolean
isFile()
Returns true if this is a file, false if not.boolean
returns true if this is a form field, false if not.void
Saves content of this item to a file.
-
Constructor Details
-
FormItem
This constructor is used for testing.- Parameters:
name
- name of a file.fieldName
- name of a field.isFile
- true if this is a file, false if not.contentType
- content type for this file.content
- content in bytes.
-
-
Method Details
-
getName
File name.- Returns:
- file name.
-
getFileName
File name.- Returns:
- file name.
-
getFieldName
Form field name.- Returns:
- form field name
-
isFile
public boolean isFile()Returns true if this is a file, false if not.- Returns:
- true if this is a file, false if not.
-
getContentType
Content type of this form field.- Returns:
- content type of this form field.
-
isFormField
public boolean isFormField()returns true if this is a form field, false if not.- Returns:
- true if this is a form field, false if not.
-
getInputStream
Returns input stream to read uploaded file contents from.- Returns:
- input stream to read uploaded file contents from.
-
getStreamAsString
Converts entire content of this item to String.- Returns:
- content streamed from this field as string.
-
getBytes
public byte[] getBytes()Reads contents of a file into a byte array at once.- Returns:
- contents of a file as byte array.
-
saveTo
Saves content of this item to a file.- Parameters:
path
- to file- Throws:
IOException
-