AI2 Component
(Version nb184)
|
Classes | |
class | BuildRequestDataException |
Public Member Functions | |
Web (ComponentContainer container) | |
String | Url () |
void | Url (String url) |
YailList | RequestHeaders () |
void | RequestHeaders (YailList list) |
boolean | AllowCookies () |
void | AllowCookies (boolean allowCookies) |
boolean | SaveResponse () |
void | SaveResponse (boolean saveResponse) |
String | ResponseFileName () |
void | ResponseFileName (String responseFileName) |
int | Timeout () |
void | Timeout (int timeout) |
void | ClearCookies () |
void | Get () |
void | PostText (final String text) |
void | PostTextWithEncoding (final String text, final String encoding) |
void | PostFile (final String path) |
void | PutText (final String text) |
void | PutTextWithEncoding (final String text, final String encoding) |
void | PutFile (final String path) |
void | Delete () |
void | GotText (String url, int responseCode, String responseType, String responseContent) |
void | GotFile (String url, int responseCode, String responseType, String fileName) |
void | TimedOut (String url) |
String | BuildRequestData (YailList list) |
String | UriEncode (String text) |
String | UriDecode (String text) |
Object | JsonTextDecode (String jsonText) |
Object | JsonTextDecodeWithDictionaries (String jsonText) |
String | JsonObjectEncode (Object jsonObject) |
Object | XMLTextDecodeAsDictionary (String XmlText) |
Object | XMLTextDecode (String XmlText) |
String | HtmlTextDecode (String htmlText) |
Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent | |
HandlesEventDispatching | getDispatchDelegate () |
Protected Member Functions | |
Web () | |
Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent | |
AndroidNonvisibleComponent (Form form) | |
Additional Inherited Members | |
Static Public Attributes inherited from com.google.appinventor.components.runtime.Component | |
static final String | ASSET_DIRECTORY = "component" |
static final int | ALIGNMENT_NORMAL = 0 |
static final int | ALIGNMENT_CENTER = 1 |
static final int | ALIGNMENT_OPPOSITE = 2 |
static final int | ACCELEROMETER_SENSITIVITY_WEAK = 1 |
static final int | ACCELEROMETER_SENSITIVITY_MODERATE = 2 |
static final int | ACCELEROMETER_SENSITIVITY_STRONG = 3 |
static final int | BUTTON_SHAPE_DEFAULT = 0 |
static final int | BUTTON_SHAPE_ROUNDED = 1 |
static final int | BUTTON_SHAPE_RECT = 2 |
static final int | BUTTON_SHAPE_OVAL = 3 |
static final int | COLOR_NONE = 0x00FFFFFF |
static final int | COLOR_BLACK = 0xFF000000 |
static final int | COLOR_BLUE = 0xFF0000FF |
static final int | COLOR_CYAN = 0xFF00FFFF |
static final int | COLOR_DKGRAY = 0xFF444444 |
static final int | COLOR_GRAY = 0xFF888888 |
static final int | COLOR_GREEN = 0xFF00FF00 |
static final int | COLOR_LTGRAY = 0xFFCCCCCC |
static final int | COLOR_MAGENTA = 0xFFFF00FF |
static final int | COLOR_ORANGE = 0xFFFFC800 |
static final int | COLOR_PINK = 0xFFFFAFAF |
static final int | COLOR_RED = 0xFFFF0000 |
static final int | COLOR_WHITE = 0xFFFFFFFF |
static final int | COLOR_YELLOW = 0xFFFFFF00 |
static final int | COLOR_DEFAULT = 0x00000000 |
static final String | DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF" |
static final String | DEFAULT_VALUE_COLOR_BLACK = "&HFF000000" |
static final String | DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF" |
static final String | DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF" |
static final String | DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444" |
static final String | DEFAULT_VALUE_COLOR_GRAY = "&HFF888888" |
static final String | DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00" |
static final String | DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC" |
static final String | DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF" |
static final String | DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800" |
static final String | DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF" |
static final String | DEFAULT_VALUE_COLOR_RED = "&HFFFF0000" |
static final String | DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF" |
static final String | DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00" |
static final String | DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000" |
static final float | FONT_DEFAULT_SIZE = 14 |
static final int | LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL |
static final int | LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL |
static final int | SCALING_SCALE_PROPORTIONALLY = 0 |
static final int | SCALING_SCALE_TO_FIT = 1 |
static final int | TYPEFACE_DEFAULT = 0 |
static final int | TYPEFACE_SANSSERIF = 1 |
static final int | TYPEFACE_SERIF = 2 |
static final int | TYPEFACE_MONOSPACE = 3 |
static final int | LENGTH_PREFERRED = -1 |
static final int | LENGTH_FILL_PARENT = -2 |
static final int | LENGTH_UNKNOWN = -3 |
static final int | LENGTH_PERCENT_TAG = -1000 |
static final int | TOAST_LENGTH_SHORT = 0 |
static final int | TOAST_LENGTH_LONG = 1 |
static final int | DIRECTION_NORTH = 1 |
static final int | DIRECTION_NORTHEAST = 2 |
static final int | DIRECTION_EAST = 3 |
static final int | DIRECTION_SOUTHEAST = 4 |
static final int | DIRECTION_SOUTH = -1 |
static final int | DIRECTION_SOUTHWEST = -2 |
static final int | DIRECTION_WEST = -3 |
static final int | DIRECTION_NORTHWEST = -4 |
static final int | DIRECTION_NONE = 0 |
static final int | DIRECTION_MIN = -4 |
static final int | DIRECTION_MAX = 4 |
static float | SLIDER_MIN_VALUE = 10 |
static float | SLIDER_MAX_VALUE = 50 |
static float | SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f |
static final String | DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = "" |
static final String | DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = "" |
Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent | |
final Form | form |
Non-visible component that provides functions for HTTP GET, POST, PUT, and DELETE requests.
com.google.appinventor.components.runtime.Web.Web | ( | ComponentContainer | container | ) |
|
protected |
boolean com.google.appinventor.components.runtime.Web.AllowCookies | ( | ) |
void com.google.appinventor.components.runtime.Web.AllowCookies | ( | boolean | allowCookies | ) |
String com.google.appinventor.components.runtime.Web.BuildRequestData | ( | YailList | list | ) |
void com.google.appinventor.components.runtime.Web.ClearCookies | ( | ) |
void com.google.appinventor.components.runtime.Web.Delete | ( | ) |
Performs an HTTP DELETE request using the Url property and retrieves the response.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
void com.google.appinventor.components.runtime.Web.Get | ( | ) |
Performs an HTTP GET request using the Url property and retrieves the response.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
void com.google.appinventor.components.runtime.Web.GotFile | ( | String | url, |
int | responseCode, | ||
String | responseType, | ||
String | fileName | ||
) |
void com.google.appinventor.components.runtime.Web.GotText | ( | String | url, |
int | responseCode, | ||
String | responseType, | ||
String | responseContent | ||
) |
String com.google.appinventor.components.runtime.Web.HtmlTextDecode | ( | String | htmlText | ) |
Decodes the given HTML text value.
HTML Character Entities such as &
, <
, >
, '
, and "
are changed to &
, <
, >
, ‘’, and
". Entities such as
&#xhhhh;, and
&#nnnn;` are changed to the appropriate characters.
htmlText | the HTML text to decode |
String com.google.appinventor.components.runtime.Web.JsonObjectEncode | ( | Object | jsonObject | ) |
Returns the value of a built-in type (i.e., boolean, number, text, list, dictionary) in its JavaScript Object Notation representation. If the value cannot be represented as JSON, the Screen's ErrorOccurred event will be run, if any, and the Web component will return the empty string.
jsonObject | the object to turn into JSON |
Object com.google.appinventor.components.runtime.Web.JsonTextDecode | ( | String | jsonText | ) |
Decodes the given JSON encoded value to produce a corresponding AppInventor value. A JSON list [x, y, z]
decodes to a list (x y z)
, A JSON object with key A and value B, (denoted as {A:B}
) decodes to a list ((A B))
, that is, a list containing the two-element list (A B)
.
Use the method JsonTextDecodeWithDictionaries if you would prefer to get back dictionary objects rather than lists-of-lists in the result.
jsonText | the JSON text to decode |
Object com.google.appinventor.components.runtime.Web.JsonTextDecodeWithDictionaries | ( | String | jsonText | ) |
void com.google.appinventor.components.runtime.Web.PostFile | ( | final String | path | ) |
Performs an HTTP POST request using the Url property and data from the specified file.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
path | the path of the file for the POST request |
void com.google.appinventor.components.runtime.Web.PostText | ( | final String | text | ) |
Performs an HTTP POST request using the Url property and the specified text.
The characters of the text are encoded using UTF-8 encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
text | the text data for the POST request |
void com.google.appinventor.components.runtime.Web.PostTextWithEncoding | ( | final String | text, |
final String | encoding | ||
) |
Performs an HTTP POST request using the Url property and the specified text.
The characters of the text are encoded using the given encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
text | the text data for the POST request |
encoding | the character encoding to use when sending the text. If encoding is empty or null, UTF-8 encoding will be used. |
void com.google.appinventor.components.runtime.Web.PutFile | ( | final String | path | ) |
Performs an HTTP PUT request using the Url property and data from the specified file.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
path | the path of the file for the PUT request |
void com.google.appinventor.components.runtime.Web.PutText | ( | final String | text | ) |
Performs an HTTP PUT request using the Url property and the specified text.
The characters of the text are encoded using UTF-8 encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
text | the text data for the PUT request |
void com.google.appinventor.components.runtime.Web.PutTextWithEncoding | ( | final String | text, |
final String | encoding | ||
) |
Performs an HTTP PUT request using the Url property and the specified text.
The characters of the text are encoded using the given encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.
text | the text data for the PUT request |
encoding | the character encoding to use when sending the text. If encoding is empty or null, UTF-8 encoding will be used. |
YailList com.google.appinventor.components.runtime.Web.RequestHeaders | ( | ) |
The request headers, as a list of two-element sublists. The first element of each sublist represents the request header field name. The second element of each sublist represents the request header field values, either a single value or a list containing multiple values.
void com.google.appinventor.components.runtime.Web.RequestHeaders | ( | YailList | list | ) |
String com.google.appinventor.components.runtime.Web.ResponseFileName | ( | ) |
void com.google.appinventor.components.runtime.Web.ResponseFileName | ( | String | responseFileName | ) |
boolean com.google.appinventor.components.runtime.Web.SaveResponse | ( | ) |
void com.google.appinventor.components.runtime.Web.SaveResponse | ( | boolean | saveResponse | ) |
void com.google.appinventor.components.runtime.Web.TimedOut | ( | String | url | ) |
int com.google.appinventor.components.runtime.Web.Timeout | ( | ) |
void com.google.appinventor.components.runtime.Web.Timeout | ( | int | timeout | ) |
String com.google.appinventor.components.runtime.Web.UriDecode | ( | String | text | ) |
String com.google.appinventor.components.runtime.Web.UriEncode | ( | String | text | ) |
String com.google.appinventor.components.runtime.Web.Url | ( | ) |
void com.google.appinventor.components.runtime.Web.Url | ( | String | url | ) |
Object com.google.appinventor.components.runtime.Web.XMLTextDecode | ( | String | XmlText | ) |
Decodes the given XML string to produce a list structure. <tag>string</tag>
decodes to a list that contains a pair of tag and string. More generally, if obj1, obj2, ... are tag-delimited XML strings, then <tag>obj1 obj2 ...</tag>
decodes to a list that contains a pair whose first element is tag and whose second element is the list of the decoded obj's, ordered alphabetically by tags.
Examples:
<foo><123/foo>
decodes to a one-item list containing the pair (foo 123)
<foo>1 2 3</foo>
decodes to a one-item list containing the pair (foo "1 2 3")
<a><foo>1 2 3</foo><bar>456</bar></a>
decodes to a list containing the pair (a X)
where X is a 2-item list that contains the pair (bar 123)
and the pair (foo "1 2 3")
.If the sequence of obj's mixes tag-delimited and non-tag-delimited items, then the non-tag-delimited items are pulled out of the sequence and wrapped with a "content" tag. For example, decoding <a><bar>456</bar>many<foo>1 2 3</foo>apples<a></code>
is similar to above, except that the list X is a 3-item list that contains the additional pair whose first item is the string "content", and whose second item is the list (many, apples). This method signals an error and returns the empty list if the result is not well-formed XML.
XmlText | the XML text to decode |
Object com.google.appinventor.components.runtime.Web.XMLTextDecodeAsDictionary | ( | String | XmlText | ) |
Decodes the given XML string to produce a dictionary structure. The dictionary includes the special keys $tag
, $localName
, $namespace
, $namespaceUri
, $attributes
, and $content
, as well as a key for each unique tag for every node, which points to a list of elements of the same structure as described here.
The $tag
key is the full tag name, e.g., foo:bar. The $localName
is the local portion of the name (everything after the colon :
character). If a namespace is given (everything before the colon :
character), it is provided in $namespace
and the corresponding URI is given in $namespaceUri
. The attributes are stored in a dictionary in $attributes
and the child nodes are given as a list under $content
.
More Information on Special Keys
Consider the following XML document:
When parsed, the $tag
key will be "ex:Book"
, the $localName
key will be "Book"
, the $namespace
key will be "ex"
, $namespaceUri
will be "http://example.com/"
, the $attributes
key will be a dictionary {}
(xmlns is removed for the namespace), and the $content
will be a list of two items representing the decoded <ex:title>
and <ex:author>
elements. The first item, which corresponds to the <ex:title>
element, will have an $attributes
key containing the dictionary {"xml:lang": "en"}
. For each name=value
attribute on an element, a key-value pair mapping name
to value
will exist in the $attributes
dictionary. In addition to these special keys, there will also be "ex:title"
and "ex:author"
to allow lookups faster than having to traverse the $content
list.
XmlText | the JSON text to decode |