com.electrotank.electroserver4.extensions.api.value
Class HttpResults

java.lang.Object
  extended by com.electrotank.electroserver4.extensions.api.value.HttpResults

public class HttpResults
extends Object

Contains the result of a call to a url, and a variety of methods to interact with the data directly as bytes, convert it to a string, or to even parse the results into a name/value pair map (like LoadVars in Flash).

See Also:
ElectroServerApi.blockAndCallUrl, HttpCallback

Field Summary
static String DEFAULT_ENCODING
           
static String UTF8
           
 
Constructor Summary
HttpResults()
          Constructs a new instance of HttpResults.
 
Method Summary
 byte[] getDataAsBytes()
          Gets the data from the url as an array of bytes.
 Map<String,String> getDataAsMap()
          Gets the data from the url as a name/value pair map (like LoadVars in Flash).
 Map<String,String> getDataAsMap(String encoding)
          Gets the data from the url as a name/value pair map (like LoadVars in Flash).
 String getDataAsString()
          Gets the data from the url as a string, using the default encoding.
 String getDataAsString(String encoding)
          Gets the data from the url as a string.
 String getErrorText()
          Gets the error message if the call was unsuccessful.
 void setDataAsBytes(byte[] dataAsBytes)
          Sets the data from the url to the given array of bytes.
 void setErrorText(String errorText)
          Sets the error message.
 void setSuccessful(boolean successful)
          Sets a flag indicating whether the call to a url was successful.
 boolean wasSuccessful()
          Gets a flag indicating whether the call to a url was successful.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8

public static final String UTF8
See Also:
Constant Field Values

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
See Also:
Constant Field Values
Constructor Detail

HttpResults

public HttpResults()
Constructs a new instance of HttpResults.

Method Detail

wasSuccessful

public boolean wasSuccessful()
Gets a flag indicating whether the call to a url was successful.

Returns:
true if successful

setSuccessful

public void setSuccessful(boolean successful)
Sets a flag indicating whether the call to a url was successful.

Parameters:
successful - true if the call to the url was successful

getDataAsBytes

public byte[] getDataAsBytes()
Gets the data from the url as an array of bytes.

Returns:
data as array of bytes

setDataAsBytes

public void setDataAsBytes(byte[] dataAsBytes)
Sets the data from the url to the given array of bytes.

Parameters:
dataAsBytes - data as an array of bytes

getDataAsString

public String getDataAsString(String encoding)
Gets the data from the url as a string.

Parameters:
encoding - encoding to be used for the string
Returns:
data as a string

getDataAsString

public String getDataAsString()
Gets the data from the url as a string, using the default encoding.

Returns:
data as a string

getDataAsMap

public Map<String,String> getDataAsMap(String encoding)
Gets the data from the url as a name/value pair map (like LoadVars in Flash).

Parameters:
encoding - string encoding
Returns:
name/value pair map

getDataAsMap

public Map<String,String> getDataAsMap()
Gets the data from the url as a name/value pair map (like LoadVars in Flash). Uses the default encoding.

Returns:
name/value pair map

getErrorText

public String getErrorText()
Gets the error message if the call was unsuccessful.

Returns:
error message

setErrorText

public void setErrorText(String errorText)
Sets the error message.

Parameters:
errorText - error message


Copyright © 2007 Electrotank, Inc. All Rights Reserved.