JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

expand all

Profile: desktop, common

Overview

An API to make asynchronous HTTP requests. Can also be to invoke RESTful Web Services.

HttpRequest allows one to specify a location and method and start a HTTP operation with the function start(). Various variables such as started, connecting, writing, reading and done will change state as the operation progresses. For operations that transfer large amounts of data, the percentage progress can be computed using the read, toread, written and towrite variables. Callback functions are also called to indicate changes in state as the operation progresses.

Performing a GET request

The example snippet below performs a HTTP GET request and prints changes in state to the console.

def getRequest: HttpRequest = HttpRequest {

    location: "http://www.wikipedia.org";

    onStarted: function() {
        println("onStarted - started performing method: {getRequest.method} on location: {getRequest.location}");
    }

    onConnecting: function() { println("onConnecting") }
    onDoneConnect: function() { println("onDoneConnect") }
    onReadingHeaders: function() { println("onReadingHeaders") }
    onResponseCode: function(code:Integer) { println("onResponseCode - responseCode: {code}") }
    onResponseMessage: function(msg:String) { println("onResponseMessage - responseMessage: {msg}") }

    onResponseHeaders: function(headerNames: String[]) {
        println("onResponseHeaders - there are {headerNames.size()} response headers:");
        for (name in headerNames) {
            println("    {name}: {getRequest.getResponseHeaderValue(name)}");
        }
    }

    onReading: function() { println("onReading") }

    onToRead: function(bytes: Long) {
        if (bytes < 0) {
            println("onToRead - Content length not specified by server; bytes: {bytes}");
        } else {
            println("onToRead - total number of content bytes to read: {bytes}");
        }
    }

    // The onRead callback is called when some data has been read.  If an
    // output stream is provided in the sink variable, onRead shows the progress
    // of bytes read from location and written to the sink.  If no value is
    // specified for the sink variable, the onRead callback shows the progress of
    // bytes read from location to a buffer allocated by HttpRequest.  These bytes
    // will be made available when the reading is complete, in the form of an
    // input stream provided by the onInput callback.
    onRead: function(bytes: Long) {
        // The toread variable is non negative only if the server provides the content length
        def progress =
        if (getRequest.toread > 0) "({(bytes * 100 / getRequest.toread)}%)" else "";
        println("onRead - bytes read: {bytes} {progress}");
    }

    // The content of a response can be accessed in the onInput callback function.
    // Be sure to close the input sream when finished with it in order to allow
    // the HttpRequest implementation to clean up resources related to this
    // request as promptly as possible.
    onInput: function(is: java.io.InputStream) {
        // use input stream to access content here.
        // can use input.available() to see how many bytes are available.
        try {
            println("onInput - bytes of content available: {is.available()}");
        } finally {
            is.close();
        }
    }

    onException: function(ex: java.lang.Exception) {
        println("onException - exception: {ex.getClass()} {ex.getMessage()}");
    }

    onDoneRead: function() { println("onDoneRead") }
    onDone: function() { println("onDone") }
}

getRequest.start();

The above snippet would print on the console -

onStarted - started performing method: GET on location: http://www.wikipedia.org
onConnecting
onDoneConnect
onReadingHeaders
onResponseCode - responseCode: 200
onResponseMessage - responseMessage: OK
onResponseHeaders - there are 12 response headers:
    date: Wed, 17 Dec 2008 19:26:37 GMT
    server: Apache
    x-powered-by: PHP/5.2.4-2ubuntu5wm1
    cache-control: s-maxage=3600, must-revalidate, max-age=0
    last-modified: Thu, 11 Dec 2008 09:19:49 GMT
    content-type: text/html; charset=utf-8
    content-length: 51605
    x-cache: HIT from sq17.wikimedia.org
    x-cache-lookup: HIT from sq17.wikimedia.org:80
    age: 2
    via: 1.0 sq27.wikimedia.org:3128 (squid/2.6.STABLE21), 1.0 sq17.wikimedia.org:80 (squid/2.6.STABLE21)
    connection: keep-alive
onReading
onToRead - total number of content bytes to read: 51605
onRead - bytes read: 2023 (3%)
onRead - bytes read: 4631 (8%)
onRead - bytes read: 5935 (11%)
onRead - bytes read: 7239 (14%)
onRead - bytes read: 9847 (19%)
onRead - bytes read: 12455 (24%)
onRead - bytes read: 15063 (29%)
onRead - bytes read: 18975 (36%)
onRead - bytes read: 22887 (44%)
onRead - bytes read: 24191 (46%)
onRead - bytes read: 26799 (51%)
onRead - bytes read: 28103 (54%)
onRead - bytes read: 32015 (62%)
onRead - bytes read: 35927 (69%)
onRead - bytes read: 37231 (72%)
onRead - bytes read: 41327 (80%)
onRead - bytes read: 42447 (82%)
onRead - bytes read: 46543 (90%)
onRead - bytes read: 47663 (92%)
onRead - bytes read: 50271 (97%)
onRead - bytes read: 51605 (100%)
onInput - bytes of content available: 51605
onDoneRead
onDone

If the user enters a puposefully unknown host in the URL, such as: http://www.sun.comunknown.host/, the resulting output will look like this:

onStarted - started performing method: GET on location: http://www.sun.comunknown.host/
onConnecting
onException - exception: class java.net.UnknownHostException www.sun.comunknown.host
onDone

Life cycle

Progress of the HttpRequest operation life cycle is tracked by changes in variable values and associated callback variables, if specified.

Sequence of changes to variable values for a HTTP GET request operation.

variable name and callback function variable name initial or previous variable value new value description
1 started, onStarted false true Indicates that the HTTP request has started execution.
2 connecting, onConnecting false true Indicates that the HTTP request will now attempt to connect to location.
3 doneConnect, onDoneConnect false true HTTP connection to location has been opened successfully.
4 readingHeaders, onReadingHeaders false true Indicates that the HTTP request will now attempt to read HTTP response headers from location.
5 responseCode, onResponseCode 0 HTTP Response code (Integer) The HTTP response code has been read.
6 responseMessage, onResponseMessage null HTTP Response message (String) The HTTP response message has been read.
[6.a] error, onError null error stream (InputStream) An error response is available (only if provided in HTTP response).
7 doneHeaders, onDoneHeaders false true HTTP response headers have been read.
8 reading, onReading false true About to start reading the HTTP response body.
[8.a] toread, onToRead 0 bytes to read (Long) toread bytes of content available to be read.
[8.b] read, onRead 0 bytes read (Long) read bytes of content that has just been read. (shows read progress)
9 input, onInput null response body (InputStream) An InputStream providing access to the HTTP response body.
10 doneRead, onDoneRead false true The entire HTTP response body has been read.
11 done, onDone false true The HTTP operation has finished.

Peforming a POST request

The example snippet below performs a HTTP POST request and prints changes in state to the console. It posts some abitrary content to a fictitious Servlet (TestServlet) that runs on the local host.


def testContent: String = "test content";
def testContentSize: Integer = testContent.getBytes().length;

def postRequest: HttpRequest = HttpRequest {

    location: "http://localhost:8080/TestServlet/";

    method: HttpRequest.POST;

    headers: [
        HttpHeader {
            name: HttpHeader.CONTENT_TYPE;
            value: "somecontent/type";
        },
        HttpHeader {
            name: HttpHeader.CONTENT_LENGTH;
            value: "{testContentSize}";
        }
    ];

    onStarted: function() {
        println("onStarted - started performing method: {postRequest.method} on location: {postRequest.location}");
    }

    onConnecting: function() { println("onConnecting") }
    onDoneConnect: function() { println("onDoneConnect") }
    onWriting: function() { println("onWriting") }

    // The content of a PUT or POST can be specified in the onOutput callback function.
    // Be sure to close the output sream when finished with it in order to allow
    // the HttpRequest implementation to clean up resources related to this
    // request as promptly as possible.  The calling next callback (onToWrite) depends
    // the output stream being closed.
    onOutput: function(os: java.io.OutputStream) {
        try {
            println("onOutput - about to write {testContentSize} bytes to output stream");
            os.write(testContent.getBytes());
        } finally {
            println("onOutput - about to close output stream.");
            os.close();
        }
    }

    onToWrite: function(bytes: Long) { println("onToWrite - entire content to be written: {bytes} bytes") }
    onWritten: function(bytes: Long) { println("onWritten - {bytes} bytes has now been written") }
    onDoneWrite: function() { println("doneWrite") }
    onReadingHeaders: function() { println("onReadingHeaders") }
    onResponseCode: function(code:Integer) { println("onResponseCode - responseCode: {code}") }
    onResponseMessage: function(msg:String) { println("onResponseMessage - responseMessage: {msg}") }

    onResponseHeaders: function(headerNames: String[]) {
        println("onResponseHeaders - there are {headerNames.size()} response headers:");
        for (name in headerNames) {
            println("    {name}: {postRequest.getResponseHeaderValue(name)}");
        }
    }

    onReading: function() { println("onReading") }

    onToRead: function(bytes: Long) {
        if (bytes < 0) {
            println("onToRead - Content length not specified by server; bytes: {bytes}");
        } else {
            println("onToRead - total number of content bytes to read: {bytes}");
        }
    }

    // The onRead callback is called when some more data has been read into
    // the input stream's buffer.  The input stream will not be available until
    // the onInput call back is called, but onRead can be used to show the
    // progress of reading the content from the location.
    onRead: function(bytes: Long) {
        // The toread variable is non negative only if the server provides the content length
        def progress =
        if (postRequest.toread > 0) "({(bytes * 100 / postRequest.toread)}%)" else "";
        println("onRead - bytes read: {bytes} {progress}");
    }

    // The content of a response can be accessed in the onInput callback function.
    // Be sure to close the input sream when finished with it in order to allow
    // the HttpRequest implementation to clean up resources related to this
    // request as promptly as possible.
    onInput: function(is: java.io.InputStream) {
        // use input stream to access content here.
        // can use input.available() to see how many bytes are available.
        try {
            println("onInput - bytes of content available: {is.available()}");
        } finally {
            is.close();
        }
    }

    onException: function(ex: java.lang.Exception) {
        println("onException - exception: {ex.getClass()} {ex.getMessage()}");
    }

    onDoneRead: function() { println("onDoneRead") }
    onDone: function() { println("onDone") }
};

postRequest.start();

The above snippet would print on the console -


onStarted - started performing method: POST on location: http://localhost:8080/TestServlet/
onConnecting
onDoneConnect
onWriting
onOutput() about to write 12 bytes to output stream
onOutput() about to close output stream.
onToWrite - entire content to be written: 12 bytes
onWritten - 12 bytes has now been written
doneWrite
onReadingHeaders
onResponseCode - responseCode: 200
onResponseMessage - responseMessage: OK
onResponseHeaders - there are 6 response headers:
    x-powered-by: JSP/2.1
    server: GlassFish/v3
    set-cookie: JSESSIONID=c7356338c17a201e00f3acf90271; Path=/TestServlet
    content-type: text/html;charset=UTF-8
    content-length: 325
    date: Mon, 15 Dec 2008 21:00:38 GMT
onReading
onToRead - total number of content bytes to read: 325
onRead - bytes read: 325 (100%)
onInput - bytes of content available: 325
onDoneRead
onDone

Sequence of changes to variable values for a HTTP POST or PUT request operation.

variable name and callback function variable name initial or previous variable value new value description
1 started, onStarted false true Indicates that the HTTP request has started execution.
2 connecting, onConnecting false true Indicates that the HTTP connection to location has started.
3 doneConnect, onDoneConnect false true HTTP connection to location has been opened successfully.
4 writing, onWriting false true The writing of request content is about to start.
[4.a] output, onOutput null an OutputStream Output stream availalbe for writing request content. Writing of content to the HTTP connection will only happen after OutputStream.close() is called.
[4.b] towrite, onToWrite 0 bytes to write (Long) towrite bytes of content is about to be written to location. This is the number of bytes contained in the output stream output at the time OutputStream.close() is called.
[4.c] written, onWritten 0 bytes written (Long) written bytes of content has been written (shows write progress).
[4.d] doneWrite, onDoneWrite false true The entire HTTP request body has been written
5 readingHeaders, onReadingHeaders false true Indicates that the HTTP request will now attempt to read HTTP response headers from location.
6 responseCode, onResponseCode 0 HTTP Response code (Integer) The HTTP response code has been read.
7 responseMessage, onResponseMessage null HTTP Response message (String) The HTTP response message has been read.
[7.a] error, onError null error stream (InputStream) An error response is available (only if provided in HTTP response).
8 doneHeaders, onDoneHeaders false true HTTP response headers have been read.
9 reading, onReading false true About to start reading the HTTP response body.
[9.a] toread, onToRead 0 bytes to read (Long) toread bytes of content available to be read.
[9.b] read, onRead 0 bytes read (Long) read bytes of content that has just been read. (shows read progress)
10 input, onInput null response body (InputStream) An InputStream providing access to the HTTP response body.
11 doneRead, onDoneRead false true The entire HTTP response body has been read.
12 done, onDone false true The HTTP operation has finished.

Sequence of changes to variable values for a HTTP DELETE request operation.

variable name and callback function variable name initial or previous variable value new value description
1 started, onStarted false true Indicates that the HTTP request has started execution.
2 connecting, onConnecting false true Indicates that the HTTP connection to location has started.
3 doneConnect, onDoneConnect false true HTTP connection to location has been opened successfully.
4 readingHeaders, onReadingHeaders false true Indicates that the HTTP request will now attempt to read HTTP response headers from location.
5 responseCode, onResponseCode 0 HTTP Response code (Integer) The HTTP response code has been read.
6 responseMessage, onResponseMessage null HTTP Response message (String) The HTTP response message has been read.
[6.a] error, onError null error stream (InputStream) An error response is available (only if provided in HTTP response).
7 doneHeaders, onDoneHeaders false true HTTP response headers have been read.
8 done, onDone false true The HTTP operation has finished.

Error Handling

At any time after calling start(), the exception variable can be assigned an exception. This indicates that there has been an error in the processing of the HttpRequest's operation. Subsequently, the done variable will be assigned the value true, indicating the end of execution of the HttpRequest's operation. In all cases after start() has been called, the last event to happen will be the assignment of true to the done variable.

Canceling a HTTP operation

A request's HTTP operation can be cancelled by calling cancel() at any time after start() has been called. This removes the request from the queue if it is queued, or interrupts the request if it has started executing. Both of these cases will cause the done variable to change value to true.

Profile: common

Script Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicDELETEString

HTTP DELETE method value.

HTTP DELETE method value. Can be assigned to method

 
publicGETString

HTTP GET method value.

HTTP GET method value. Can be assigned to method

 
publicPOSTString

HTTP POST method value.

HTTP POST method value. Can be assigned to method

 
publicPUTString

HTTP PUT method value.

HTTP PUT method value. Can be assigned to method

 

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-read protectedconnectingBooleansubclasssubclassfalse

Indicates that the request is attempting to connect to location.

publiccontextObjectnull

Context object provided by appliction.

Context object provided by appliction. To be provided by and used by the application during asynchronus events as this request progresses. If context is assigned another HttPRequest object, it can be accessed from a trigger for the done variable to "chain" HTTP operations. Once this HttpRequest's operation is done, the one contained in context can be #start()ed.

null

See Also:
start(), done

 
public-read protecteddoneConnectBooleansubclasssubclassfalse

Indicates that the HTTP connection to location has been opened successfully.

public-read protecteddoneHeadersBooleansubclasssubclassfalse

Indicates that the HTTP headers have successfully been read from location.

Indicates that the HTTP headers have successfully been read from location. These HTTP headers are availalbe via getResponseHeaderNames() and getResponseHeaderValue(String) if the value is true.

false

See Also:
onDoneHeaders

 
public-read protecteddoneReadBooleansubclasssubclassfalse

Indicates if reading of response content from location has finished.

Indicates if reading of response content from location has finished. The content has been stored in input if the value is true.

false  
public-read protecteddoneWriteBooleansubclasssubclassfalse

Indicates that the contents of output have been successfully written to location.

public-read protectederrorInputStreamsubclasssubclassnull

Contains the error content for this request.

Contains the error content for this request. This variable gets assigned an input stream only if error content has been received from location.

null  
public-read protectedexceptionExceptionsubclasssubclassnull

Contains an exception indicating an error occured with this request.

Contains an exception indicating an error occured with this request. This variable gets assigned an excception only if an exception is encountered during communication with location for this request. If this variable gets assigned an exception, the done variable will subsequently get assigned the value true.

null  
publicheadersHttpHeader[]null

A map of HTTP request headers to send to the location.

public-read protectedidIntegersubclasssubclass0

Unique HTTP operation identifier for this request.

Unique HTTP operation identifier for this request. Assigned only as a result of calling the start() function.

0  
public-read protectedinputInputStreamsubclasssubclassnull

Contains the response content for this request.

Contains the response content for this request. This variable gets assigned an input stream only after the entire content of the request has been received from location, unless sink is specified. The calling of onInput indicates that this variable contains a valid input stream to read. For the transfer of large amounts of data, use sink.

null

See Also:
onInput, sink, onReading, onDoneRead

 
publiclocationStringnull

Target location for this HttpRequest.

Target location for this HttpRequest. URL format.

null  
publicmethodStringGET

Method to use for this request.

Method to use for this request. One of GET, POST, PUT, DELETE

GET  
publiconConnectingfunction():Voidnull

Callback that is invoked once to indicate that the request is attempting to connect to location.

publiconDoneConnectfunction():Voidnull

Callback that is invoked once to indicate that the request is now connected to location.

publiconDoneHeadersfunction():Voidnull

Callback that is invoked once to indicate that the request is done reading response headers.

Callback that is invoked once to indicate that the request is done reading response headers. responseCode, responseMessage and error, if sent, are also available at this time.

null  
publiconDoneReadfunction():Voidnull

Callback that is invoked once to indicate that the request is done reading the response body.

publiconDoneWritefunction():Voidnull

Callback that is invoked once to indicate that the request is done writing and all of the data in output has been sent to location.

publiconErrorfunction(:InputStream):Voidnull

Callback that is invoked once to indicate that an InputStream containing an error response from the server is now available.

Callback that is invoked once to indicate that an InputStream containing an error response from the server is now available. The provided InputStream must be closed when done reading in a finally block -

 try {
     // read from input
 } finally {
     input.close();
 }
 

null  
publiconExceptionfunction(:Exception):Voidnull

Callback that is invoked once to provide an application with an exception that occurred, if any, during the execution of this request.

publiconInputfunction(:InputStream):Voidnull

Callback that is invoked once to indicate that the request body is now available.

Callback that is invoked once to indicate that the request body is now available. This function is not called if sink is specified. The provided InputStream is also contained in the input variable. The provided InputStream must be closed when done reading in a finally block -

 try {
     // read from input, hand-off to a parser, etc
 } finally {
     input.close();
 }
 

null

See Also:
input, sink

 
publiconOutputfunction(:OutputStream):Voidnull

Callback that is invoked once to provide an application with an opportunity to write data that is to be sent to location.

Callback that is invoked once to provide an application with an opportunity to write data that is to be sent to location. Valid when method contains POST or PUT. This function is not called if source is specified. To keep the application from blocking, the data is first accumulated in memory and sent after an application closes the OutputStream provided. This OutputStream is also contained in the output variable. Wrapping the writes to the OutputStream in a finally block is recommended -

 try {
     // write to output
 } finally {
     output.close();
 }
 

null

See Also:
output, source

 
publiconReadfunction(:long):Voidnull

Callback that is invoked to indicate the number of bytes read so far.

publiconReadingfunction():Voidnull

Callback that is invoked once to indicate that the request is starting to read the response body.

publiconReadingHeadersfunction():Voidnull

Callback that is invoked once to indicate that the request is starting to read HTTP reponse headers, responseCode, responseMessage and error, if any.

publiconResponseCodefunction(:int):Voidnull

Callback that is invoked once to indicate that the HTTP response code from the server is now available.

Callback that is invoked once to indicate that the HTTP response code from the server is now available. Some commonly used HTTP response codes are defined in HttpStatus and can be used to compare with.

null  
publiconResponseHeadersfunction(:Sequence):Voidnull

Callback that is invoked once to indicate that HTTP response headers from the server are now available.

Callback that is invoked once to indicate that HTTP response headers from the server are now available. Some commonly used HTTP headers are defined in HttpHeader and can be used to compare with.

null  
publiconResponseMessagefunction(:String):Voidnull

Callback that is invoked once to indicate that the HTTP response message from the server is now available.

publiconStartedfunction():Voidnull

Callback that is invoked once to indicate that the request has started execution.

publiconToReadfunction(:long):Voidnull

Callback that is invoked once to indicate the total number of bytes to read, if available.

Callback that is invoked once to indicate the total number of bytes to read, if available. This is usually the value of the content-length HTTP header, if set by the server.

null

See Also:
toread

 
publiconToWritefunction(:long):Voidnull

Callback that is invoked once to indicate the total number of bytes to write.

publiconWritingfunction():Voidnull

Callback that is invoked once to indicate that the request has started writing the data previously written to output or about to be transferred from source by the application to location.

publiconWrittenfunction(:long):Voidnull

Callback that is invoked to indicate the number of bytes written so far.

public-read protectedoutputOutputStreamsubclasssubclassnull

Contains data to be written to location during HTTP operations where method contains POST or PUT.

Contains data to be written to location during HTTP operations where method contains POST or PUT. The calling of onOutput indicates that this variable contains a valid output stream to write to. Closing this output stream will initiate the transfer of its data to location. This output stream is ignored if source is specified. For the transfer of large amounts of data, use source.

null

See Also:
onOutput, source, onWriting, onDoneWrite

 
public-read protectedreadLongsubclasssubclass0

Number bytes read from the location into input.

public-read protectedreadingBooleansubclasssubclassfalse

Indicates if reading response content from location is about to start.

public-read protectedreadingHeadersBooleansubclasssubclassfalse

Indicates that the reading of HTTP headers from location has started.

public-read protectedresponseCodeIntegersubclasssubclassnull

The HTTP response code to the request method from location.

The HTTP response code to the request method from location. Usually included in responseMessage

null  
public-read protectedresponseHeadersHttpHeader[]subclasssubclassnull

A map of HTTP headers provided in response to the request method from location.

public-read protectedresponseMessageStringsubclasssubclassnull

The HTTP response message to the request method from location.

The HTTP response message to the request method from location. Usually includes the text representation of the responseCode

null  
public-init protectedsinkOutputStreamsubclassnull

Sink for response content for this request.

Sink for response content for this request.

The use of input works well for reading small amounts of data. sink is provided to allow the reading of large amounts of data from location without compromising an application's user interface responsiveness or requiring all of the data to be in memory at once. The alternative is to read all of the data transferred from input. This is typically done on the JavaFX event dispatch thread which may hinder the processing of application events.

If this output stream is specified, input is ignored. Methods of this output stream are called from a thread other than the JavaFX event dispatch thread as data is available from location. No JavaFX code should be called from the methods of this output stream. Data is read from location and written to this stream until EOF is reached (-1 is returned) or an exception is encountered. In either case, the stream is subsequently closed. The toread and read variables are updated as data is transferred.

null

See Also:
input, onReading, onDoneRead, toread, read

 
public-init protectedsourceInputStreamsubclassnull

Source of data to be written to location during HTTP operations where method contains POST or PUT.

Source of data to be written to location during HTTP operations where method contains POST or PUT.

The use of output works well for writing small amounts of data. source is provided to allow the writing of large amounts of data to location without compromising an application's user interface responsiveness or requiring all of the data to be in memory at once. The alternative is to write all of the data to be transferred to output. This is typically done on the JavaFX event dispatch thread which may hinder the processing of application events.

If this input stream is specified, output is ignored. Methods of this input stream are called from a thread other than the JavaFX event dispatch thread as data is needed to write to location. No JavaFX code should be called from the methods of this input stream. Data is read from this stream and written to location until EOF is reached (-1 is returned) or an exception is encountered. In either case, the stream is subsequently closed. The towrite and written variables are updated as data is transferred.

null

See Also:
output, onWriting, onDoneWrite, towrite, written

 
public-read protectedtoreadLongsubclasssubclass0

Number of bytes expected to be read from input.

Number of bytes expected to be read from input. The number of bytes available in input when input is first made available, if content-length is set.

0

See Also:
onToRead

 
public-read protectedtowriteLongsubclasssubclass0

The number of bytes already in output that are going to be written to location.

public-read protectedwritingBooleansubclasssubclassfalse

Indicates that the contents of output are about to be written to location.

public-read protectedwrittenLongsubclasssubclass0

Number of bytes in output that have been written to location.

Inherited Variables

javafx.async.Task

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-read protectedcauseOfFailureObjectsubclasssubclassnull

Indicates the cause of failure of this task.

Indicates the cause of failure of this task. If this variable's value is null, there is no known cause of failure, even if the failed variable is set to true. If this variable's value is not null, it will most likely contain an exception that describes the cause of failure.

null

See Also:
failed

Profile: common

 
public-read protecteddoneBooleansubclasssubclassfalse

Indicates if this task has completed.

Indicates if this task has completed. This is the last of the variables started, stopped, failed, succeeded and causeOfFailure to be modified. This variable is to be set to true upon completion of this task, without respect to success or failure of the task..

false

Profile: common

 
public-read protectedfailedBooleansubclasssubclassfalse

Indicates if this task has failed.

Indicates if this task has failed. This variable is set to true as a result of the task executing and failing by means of an exception. This exception could be the result of the task being stopped by the stop() function being called. causeOfFailure will contian the failure cause if the failure was caused by an exception during execution.

false

See Also:
stop(), causeOfFailure

Profile: common

 
public-read protectedmaxProgressLongsubclasssubclass-1

Indicates a maximum value for the progress variable.

Indicates a maximum value for the progress variable. If set to zero or a negative value, there is no known maximum and the percentDone variable will not change during the course of execution of this task.

-1

See Also:
progress, percentDone

Profile: common

 
publiconDonefunction():Voidnull

Callback that is invoked once to indicate that the task execution has completed (successfully, or unsuccessfully).

Callback that is invoked once to indicate that the task execution has completed (successfully, or unsuccessfully). This task's implemenation will not modify this task's variables during or after a call to this function. Once the start() function has been called, this function will eventually be called, if it is non-null.

null

See Also:
done, start(), stop()

Profile: common

 
publiconStartfunction():Voidnull

Callback that is invoked once to indicate that the task is about to start execution.

Callback that is invoked once to indicate that the task is about to start execution. This function is not called as a result of the queueing of this task for execution.

null

See Also:
started, start()

Profile: common

 
public-readpercentDoneNumber-1

Indicates the current progress of this task in terms of percent complete.

Indicates the current progress of this task in terms of percent complete. A value between zero and one indicates progress toward completion. This variable's value may or may not change from its default value depending on the specific Task implementation.

-1

See Also:
maxProgress, progress

Profile: common

 
public-read protectedprogressLongsubclasssubclass-1

Indicates the current progress toward completion of this task.

Indicates the current progress toward completion of this task. Zero or a positive value indicate progress toward completion. This variable's value may or may not change from its default value depending on the specific Task implementation.

-1

See Also:
maxProgress, percentDone

Profile: common

 
public-read protectedstartedBooleansubclasssubclassfalse

Indicates if this task has started.

Indicates if this task has started. Once this task's start() function has been called, the task may or may not be queued before it executes. This variable is set to true just before the task starts executing.

false

See Also:
onStart

Profile: common

 
public-read protectedstoppedBooleansubclasssubclassfalse

Indicates if this task has been stopped.

Indicates if this task has been stopped. This variable is set to true as a result of the stop() function being called. A value of true means that the task did not execute to completion, and possibly not at all if the task was queued for execution by stop() and stopped by stop() before execution.

false

See Also:
stop()

Profile: common

 
public-read protectedsucceededBooleansubclasssubclassfalse

Indicates if this task has successfully completed.

Indicates if this task has successfully completed. This variable is to be set to true upon successful completion of this task, but before the done variable is set to to true.

false

See Also:
done

Profile: common

 

Function Summary

public getResponseHeaderNames() : java.lang.String[]

Get the names of HTTP headers set on the HTTP response.

Get the names of HTTP headers set on the HTTP response.

See Also:
doneHeaders

Returns
String[]
a sequence of names of HTTP headers set on the HTTP response. Will be an empty sequence if HTTP response headers are not available yet.
 
public getResponseHeaderValue(name: java.lang.String) : java.lang.String

Retrieve the value of the specified HTTP header name.

Retrieve the value of the specified HTTP header name. Must be one of the names in the sequence returned from getResponseHeaderNames(). Returns the empty string ("") if the specifed HTTP header is not set on the HTTP response.

Parameters
name
the HTTP response header name whose value is to be retrieved
Returns
String
 
public setHeader(name: java.lang.String, value: java.lang.String) : Void

Set the specified header and value as HTTP header on the outgoing HTTP request.

Set the specified header and value as HTTP header on the outgoing HTTP request. Existing headers of the same name, if any, are overwritten. Some commonly-used header names and values are defined in HttpHeader

Parameters
name
the HTTP header name
value
the HTTP header value
 
public start() : Void

Starts a HTTP operation.

Starts a HTTP operation. Queues this request so that it can be processed. See the overview for how the operation can progress.

 
public stop() : Void

Cancel this request's HTTP operation.

Cancel this request's HTTP operation. If the request is queued or executing, calling this function will subsequently cause cause the done variable to change value to true.

 

Inherited Functions

javafx.async.Task

public abstract start() : Void

Initiates execution of this task.

Initiates execution of this task. Calling this function will either queue this task for future execution or start execution. The execution of the task happens on a thread other than the JavaFX event dispatch thread. The onStart function may not be called before this function returns. This function is expected to be called a maximum of once per instance of Task.

See Also:
onStart

Profile: common

 
public abstract stop() : Void

Terminates execution of this task.

Terminates execution of this task. Calling this function will either remove this task from the execution queue or stop execution. Subsequent calls to this function have no effect. The onDone function will be called as a result of calling this function, if it is non-null. The onDone function may not be called before this function returns. This function is expected to be called a maximum of once per instance of Task.

See Also:
stopped, onDone

Profile: common

 



Spec-Zone.ru - all specs in one place