Package com.oopsclick.silk.file
Class FormField
- java.lang.Object
-
- com.oopsclick.silk.file.FormField
-
public class FormField extends java.lang.Object
The Class FormField stores the information of a data form's item.- Author:
- Italo Osorio
-
-
Constructor Summary
Constructors Constructor Description FormField()
Instantiates an empty form fieldFormField(java.lang.String fieldName, java.lang.String fieldValue)
Instantiates a form field with name and value.FormField(java.lang.String fieldName, java.lang.String fieldValue, java.io.InputStream inputStream)
Instantiates a form field with name, file name, and file's stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStream
getInputStream()
Returns the file's stream.java.lang.String
getName()
Returns the field' name.java.lang.String
getSavedFileName()
Returns the saved field's name.java.lang.String
getValue()
Returns the field's value.boolean
isFile()
Returns if the field is a file.int
saveFile(java.lang.String folder)
Saves the file stream to a folder using the uploaded file's name.int
saveFile(java.lang.String fileName, java.lang.String folder)
Saves the file stream to a folder using the provided file's name.
-
-
-
Constructor Detail
-
FormField
public FormField()
Instantiates an empty form field
-
FormField
public FormField(java.lang.String fieldName, java.lang.String fieldValue)
Instantiates a form field with name and value.- Parameters:
fieldName
- The name of the field.fieldValue
- The value received.
-
FormField
public FormField(java.lang.String fieldName, java.lang.String fieldValue, java.io.InputStream inputStream)
Instantiates a form field with name, file name, and file's stream.- Parameters:
fieldName
- - The name of the field.fieldValue
- - The file name as the value.inputStream
- - The file stream.
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the field' name.- Returns:
- The field' name.
-
getValue
public java.lang.String getValue()
Returns the field's value.- Returns:
- The field's value.
-
isFile
public boolean isFile()
Returns if the field is a file.- Returns:
- 0 if it is a string field. 1 if is a file.
-
getSavedFileName
public java.lang.String getSavedFileName()
Returns the saved field's name.- Returns:
- The saved field's name.
-
getInputStream
public java.io.InputStream getInputStream()
Returns the file's stream.- Returns:
- The file's stream.
-
saveFile
public int saveFile(java.lang.String folder) throws java.io.IOException
Saves the file stream to a folder using the uploaded file's name. It will create the folders is not existent.- Parameters:
folder
- The folder in which the file will be saved.- Returns:
- 0 if the field is not a file. 1 if successful. 2 if it have errors.
- Throws:
java.io.IOException
- An exception
-
saveFile
public int saveFile(java.lang.String fileName, java.lang.String folder) throws java.io.IOException
Saves the file stream to a folder using the provided file's name. It will create the folders is not existent.- Parameters:
fileName
- The provided name for the file.folder
- The folder in which the file will be saved.- Returns:
- 0 if the field is not a file. 1 if successful. 2 if it have errors.
- Throws:
java.io.IOException
- An exception
-
-