|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jdesktop.beans.AbstractBean
org.jdesktop.http.NameValuePair
org.jdesktop.http.Parameter
org.jdesktop.html.form.FileParameter
public class FileParameter
A special Parameter intended to be used as a Form Parameter on a
FormRequest for uploading files.
FileParameter adds the contentType and fileName properties. These properties are used to construct the multipart/form-data body of a form request. It is important that the fileName refer to an actual existing file object, and that the contentType be accurate. If either of these two constraints are not met, then the request will likely fail.
The fileName must be formatted such that creating a new File
will succeed in locating the file. We use the same rules as the URLConnection
class for determining the contentType automatically for the file. In the common
case, it will be unnecessary to indicate the contentType manually. However,
in special cases you may need to specify the content type manually. The format
of the contentType is a mime type, such as text/plain.
If the fileName is correctly specified, then the InputStream returned from getValueStream() will be non-null. You are responsible for closing this stream when finished reading from it.
The "value" of this Parameter is specified to be the fileName. This is enforced by overridding setValue to be a null-op, and by setFilename() calling super.setValue().
| Constructor Summary | |
|---|---|
FileParameter()
Create a new FileParameter. |
|
FileParameter(String name,
File file)
Create a new FileParameter using the given name as the name of this parameter (the key, if you will), and the given File as the file to be uploaded by the FormRequest. |
|
FileParameter(String name,
String fileName)
Create a new FileParameter using the given name as the name of this parameter (the key if you will) and the given fileName as the absolute path to the file to be uploaded by the FormRequest. |
|
| Method Summary | |
|---|---|
FileParameter |
clone()
Creates and returns a copy of this object. |
String |
getContentType()
Gets the content type of the data being uploaded. |
String |
getFilename()
Gets the absolute path of the file being uploaded. |
InputStream |
getValueStream()
Creates and returns a new InputStream based on the underlying file data. |
void |
setContentType(String contentType)
Sets the mime-type of the content being uploaded. |
void |
setFilename(String name)
Sets the absolute path to the file to be uploaded. |
void |
setValue(String value)
Sets the value. |
| Methods inherited from class org.jdesktop.http.NameValuePair |
|---|
getName, getValue, setName, toString |
| Methods inherited from class org.jdesktop.beans.AbstractBean |
|---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FileParameter()
public FileParameter(String name,
File file)
name - file - may be null.
public FileParameter(String name,
String fileName)
name - fileName - may be null.| Method Detail |
|---|
public void setContentType(String contentType)
contentType - if set to null, then the mime type "content/unknown" is
used.public final String getContentType()
public void setFilename(String name)
name - public final String getFilename()
public void setValue(String value)
NameValuePair
setValue in class NameValuePairvalue - The value to use. May be null.public InputStream getValueStream()
public FileParameter clone()
java.lang.Objectwill be true, and that the expression:x.clone() != x
will be true, but these are not absolute requirements. While it is typically the case that:x.clone().getClass() == x.getClass()
will be true, this is not an absolute requirement.x.clone().equals(x)
By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().
By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.
The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface Cloneable, so calling the clone method on an object whose class is Object will result in throwing an exception at run time.
clone in class ParameterCloneable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||