Pacotemx.utils
Classepublic class URLUtil
HerançaURLUtil Inheritance Object

The URLUtil class is a static class with methods for working with full and relative URLs within Flex.

Veja também

mx.managers.BrowserManager


Propriedades Públicas
 PropriedadeDefinido por
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Métodos Públicos
 MétodoDefinido por
  
getFullURL(rootURL:String, url:String):String
[static] Converts a potentially relative URL to a fully-qualified URL.
URLUtil
  
[static] Returns the port number from the specified URL.
URLUtil
  
[static] Returns the protocol section of the specified URL.
URLUtil
  
[static] Returns the server name from the specified URL.
URLUtil
  
[static] Returns the domain and port information from the specified URL.
URLUtil
 Inherited
Indicates whether an object has a specified property defined.
Object
  
[static] If the LoaderConfig.url property is not available, the replaceTokens() method will not replace the server name and port properties properly.
URLUtil
  
[static] Determines if the URL uses the secure HTTPS protocol.
URLUtil
  
[static] Determines if the URL uses the HTTP, HTTPS, or RTMP protocol.
URLUtil
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
objectToString(object:Object, separator:String = "", encodeURL:Boolean):String
[static] Enumerates an object's dynamic properties (by using a for..in loop) and returns a String.
URLUtil
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
replacePort(uri:String, newPort:uint):String
[static] Returns a new String with the port replaced with the specified port.
URLUtil
  
replaceProtocol(uri:String, newProtocol:String):String
[static] Replaces the protocol of the specified URI with the given protocol.
URLUtil
  
[static] Returns a new String with the port and server tokens replaced with the port and server from the currently running application.
URLUtil
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
stringToObject(string:String, separator:String = "", decodeURL:Boolean):Object
[static] Returns an object from a String.
URLUtil
 Inherited
Returns the string representation of the specified object.
Object
  
[static] Tests whether two URI Strings are equivalent, ignoring case and differences in trailing slashes.
URLUtil
 Inherited
Returns the primitive value of the specified object.
Object
Constantes públicas
 ConstanteDefinido por
  SERVER_NAME_TOKEN : String = "{server.name}"
[static] The pattern in the String that is passed to the replaceTokens() method that is replaced by the application's server name.
URLUtil
  SERVER_PORT_TOKEN : String = "{server.port}"
[static] The pattern in the String that is passed to the replaceTokens() method that is replaced by the application's port.
URLUtil
Detalhes do método
getFullURL()método
public static function getFullURL(rootURL:String, url:String):String

Converts a potentially relative URL to a fully-qualified URL. If the URL is not relative, it is returned as is. If the URL starts with a slash, the host and port from the root URL are prepended. Otherwise, the host, port, and path are prepended.

Parâmetros

rootURL:String — URL used to resolve the URL specified by the url parameter, if url is relative.
 
url:String — URL to convert.

Retorna
String — Fully-qualified URL.
getPort()método 
public static function getPort(url:String):uint

Returns the port number from the specified URL.

Parâmetros

url:String — The URL to analyze.

Retorna
uint — The port number of the specified URL.
getProtocol()método 
public static function getProtocol(url:String):String

Returns the protocol section of the specified URL. The following examples show what is returned based on different URLs:

      getProtocol("https://localhost:2700/") returns "https"
      getProtocol("rtmp://www.myCompany.com/myMainDirectory/groupChatApp/HelpDesk") returns "rtmp"
      getProtocol("rtmpt:/sharedWhiteboardApp/June2002") returns "rtmpt"
      getProtocol("rtmp::1234/chatApp/room_name") returns "rtmp"
      

Parâmetros

url:String — String containing the URL to parse.

Retorna
String — The protocol or an empty String if no protocol is specified.
getServerName()método 
public static function getServerName(url:String):String

Returns the server name from the specified URL.

Parâmetros

url:String — The URL to analyze.

Retorna
String — The server name of the specified URL.
getServerNameWithPort()método 
public static function getServerNameWithPort(url:String):String

Returns the domain and port information from the specified URL.

Parâmetros

url:String — The URL to analyze.

Retorna
String — The server name and port of the specified URL.
hasUnresolvableTokens()método 
public static function hasUnresolvableTokens():Boolean

If the LoaderConfig.url property is not available, the replaceTokens() method will not replace the server name and port properties properly.

Retorna
Booleantrue if the LoaderConfig.url property is not available. Otherwise, false.
isHttpsURL()método 
public static function isHttpsURL(url:String):Boolean

Determines if the URL uses the secure HTTPS protocol.

Parâmetros

url:String — The URL to analyze.

Retorna
Booleantrue if the URL starts with "https://".
isHttpURL()método 
public static function isHttpURL(url:String):Boolean

Determines if the URL uses the HTTP, HTTPS, or RTMP protocol.

Parâmetros

url:String — The URL to analyze.

Retorna
Booleantrue if the URL starts with "http://", "https://", or "rtmp://".
objectToString()método 
public static function objectToString(object:Object, separator:String = "", encodeURL:Boolean):String

Enumerates an object's dynamic properties (by using a for..in loop) and returns a String. You typically use this method to convert an ActionScript object to a String that you then append to the end of a URL. By default, invalid URL characters are URL-encoded (converted to the %XX format).

For exemplo:

      var o:Object = { name: "Alex", age: 21 };
      var s:String = URLUtil.objectToString(o,";",true);
      trace(s);
      
Prints "name=Alex;age=21" to the trace log.

Parâmetros

object:Object — The object to convert to a String.
 
separator:String (default = "") — The character that separates each of the object's property:value pair in the String.
 
encodeURL:Boolean — Whether or not to URL-encode the String.

Retorna
String — The object that was passed to the method.
replacePort()método 
public static function replacePort(uri:String, newPort:uint):String

Returns a new String with the port replaced with the specified port. If there is no port in the specified URI, the port is inserted. This method expects that a protocol has been specified within the URI.

Parâmetros

uri:String — String containing the URI in which the port is replaced.
 
newPort:uint — uint containing the new port to subsitute.

Retorna
String — The URI with the new port.
replaceProtocol()método 
public static function replaceProtocol(uri:String, newProtocol:String):String

Replaces the protocol of the specified URI with the given protocol.

Parâmetros

uri:String — String containing the URI in which the protocol needs to be replaced.
 
newProtocol:String — String containing the new protocol to use.

Retorna
String — The URI with the protocol replaced, or an empty String if the URI does not contain a protocol.
replaceTokens()método 
public static function replaceTokens(url:String):String

Returns a new String with the port and server tokens replaced with the port and server from the currently running application.

Parâmetros

url:String — String containing the SERVER_NAME_TOKEN and/or SERVER_NAME_PORT which should be replaced by the port and server from the application.

Retorna
String — The URI with the port and server replaced.
stringToObject()método 
public static function stringToObject(string:String, separator:String = "", decodeURL:Boolean):Object

Returns an object from a String. The String contains name=value pairs, which become dynamic properties of the returned object. These property pairs are separated by the specified separator. This method converts Numbers and Booleans, Arrays (defined by "[]"), and sub-objects (defined by "{}"). By default, URL patterns of the format %XX are converted to the appropriate String character.

For exemplo:

      var s:String = "name=Alex;age=21";
      var o:Object = URLUtil.stringToObject(s, ";", true);
      
Returns the object: { name: "Alex", age: 21 }.

Parâmetros

string:String — The String to convert to an object.
 
separator:String (default = "") — The character that separates name=value pairs in the String.
 
decodeURL:Boolean — Whether or not to decode URL-encoded characters in the String.

Retorna
Object — The object containing properties and values extracted from the String passed to this method.
urisEqual()método 
public static function urisEqual(uri1:String, uri2:String):Boolean

Tests whether two URI Strings are equivalent, ignoring case and differences in trailing slashes.

Parâmetros

uri1:String — The first URI to compare.
 
uri2:String — The second URI to compare.

Retorna
Booleantrue if the URIs are equal. Otherwise, false.
Detalhes da constante
SERVER_NAME_TOKENConstante
public static const SERVER_NAME_TOKEN:String = "{server.name}"

The pattern in the String that is passed to the replaceTokens() method that is replaced by the application's server name.

SERVER_PORT_TOKENConstante 
public static const SERVER_PORT_TOKEN:String = "{server.port}"

The pattern in the String that is passed to the replaceTokens() method that is replaced by the application's port.