public class URLDescriptor extends Object implements Comparable<URLDescriptor>
casa:// [ user @ ] [ host ] [ : port ] [ / [ [ dir / ]* [ file ] ] [# fragment] [? key [ = value ] [ & key [ = value ] ]* ] ] ----directory---- -------------------data-------------------- ---------path---------------where
agent12@www.cpsc.ucalgary.ca:8000 describes an agent called agent12 that is currently running and listening at port 8000URL strings are of two types:
136.159.2.4/canada/alberta/calgary?lac=9000 describes an agent instance ("calgary") of type "canada/alberta" that may or may not be running on an unknown port, but it can be started or its port number obtained from the LAC running on port 9000.
Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Modifier and Type | Field and Description |
---|---|
private static CasaLispOperator |
AGENT_IDENTIFIER
Lisp operator: (AGENT-IDENTIFIER)
|
private static boolean |
AMBIGUOUS_TAKEN_AS_LOCALHOST
If true, any URL which is ambiguous between a local and remote URL will silently resolve
to the local URL.
|
private Channel |
channel |
private String |
data |
private String |
fragment |
private InetAddress |
host |
private static List<URLDescriptor> |
knownURLs |
private int |
mark |
private static CasaLispOperator |
NEW_URL
Lisp operator: (NEW-URL STRING)
|
private String |
path |
private int |
port |
private long |
timeWithdrawn |
private static CasaLispOperator |
URL__GET
Lisp operator: (NEW-URL STRING)
Attempt to join the cooperation domain specified by the parameter URL. |
private static CasaLispOperator |
URLS__GET
Lisp operator: (URLS.GET)
Attempt to join the cooperation domain specified by the parameter URL. |
private String |
user |
private boolean |
withdrawn |
Modifier | Constructor and Description |
---|---|
private |
URLDescriptor(InetAddress host,
int port) |
private |
URLDescriptor(int port)
Create a URL for the local machine on port
|
private |
URLDescriptor(String url_string) |
private |
URLDescriptor(String user,
InetAddress host,
int port,
String path) |
private |
URLDescriptor(String user,
InetAddress host,
int port,
String path,
String data) |
private |
URLDescriptor(String user,
InetAddress host,
int port,
String path,
String data,
String fragment) |
private |
URLDescriptor(String host,
String port) |
private |
URLDescriptor(String host,
String port,
String user) |
private |
URLDescriptor(String user,
String host,
String port,
String path) |
private |
URLDescriptor(URLDescriptor url) |
Modifier and Type | Method and Description |
---|---|
private int |
compareHosts(InetAddress otherAddr) |
int |
compareTo(URLDescriptor o) |
boolean |
containsVia(URLDescriptor url)
Checks if the via data item contains the parameter url.
|
void |
copy(URLDescriptor url)
Copy the contents of the param url to this one.
|
String |
deleteDataValue(String key)
Removes a data key (and potentially a value) from the data part
of the url (after the "?", separated by "&"s).
|
private static URLDescriptor |
disambiguate(URLDescriptor target,
URLDescriptor x,
URLDescriptor y) |
boolean |
equals(Object object)
Determines whether the given object is a
URLDescriptor that
describes that same agent as this URLDescriptor . |
static URLDescriptor |
fromString(String url_string) |
static URLDescriptor |
fromString(TokenParser parser)
Constructs a URLDescriptor using the TokenParser input
|
(package private) Channel |
getChannel() |
String |
getData() |
String |
getDataValue(String key)
Check the data (after the "?") for the key and return the value
|
static boolean |
getDefaultAmbiguousURLtoLocal() |
String |
getDirectory() |
String |
getFile() |
String |
getFragment() |
String |
getFullAddress(URLDescriptor relativeTo) |
InetAddress |
getHost() |
String |
getHostAndPort() |
String |
getHostString() |
boolean |
getIndirect() |
static URLDescriptor[] |
getKnownURLs() |
int |
getLACport() |
int |
getMark() |
String |
getPath() |
int |
getPort() |
String |
getShortestName() |
String |
getUser()
GET
|
Stack<URLDescriptor> |
getViaStack()
Builds a stack of
URLDescriptor s from the via
data item in this url |
boolean |
hasChannel() |
boolean |
hasData() |
boolean |
hasDataValue(String key)
Check the data (after the "?") for the existence of the key.
|
boolean |
hasFragment() |
int |
hashCode() |
boolean |
hasLACport() |
boolean |
hasPath() |
boolean |
hasPort() |
boolean |
hasUser() |
private void |
initialize(String user,
InetAddress host,
int port,
String path,
String data,
String fragment) |
boolean |
isResolvable() |
boolean |
isResolved() |
boolean |
isWithdrawn() |
boolean |
local(URLDescriptor relativeTo)
Determine if this address is local relative to 'relativeTo'.
|
static void |
main(String[] args) |
static URLDescriptor |
make(InetAddress host,
int port) |
static URLDescriptor |
make(int port)
Create a URL for the local machine on port
|
static URLDescriptor |
make(String url_string) |
static URLDescriptor |
make(String user,
InetAddress host,
int port,
String path) |
static URLDescriptor |
make(String user,
InetAddress host,
int port,
String path,
String data) |
static URLDescriptor |
make(String user,
InetAddress host,
int port,
String path,
String data,
String fragment) |
static URLDescriptor |
make(String host,
String port) |
static URLDescriptor |
make(String host,
String port,
String user) |
static URLDescriptor |
make(String user,
String host,
String port,
String path) |
static URLDescriptor |
make(URLDescriptor url) |
int |
mark() |
private void |
mergeWith(URLDescriptor url) |
static URLset |
peakURL(String s) |
static String |
popURL(String s) |
URLDescriptor |
popViaAtEnd()
Removes the last url from the via data item in the url ("?via=").
|
static String |
pushURL(String s,
String url) |
static String |
pushURL(String s,
String[] url) |
void |
pushViaAtEnd(URLDescriptor endURL)
Appends the endURL url to the end of the via data item in the
url ("?via=").
|
void |
putViaStack(Stack<URLDescriptor> stack)
Replaces the via data item with one constructed from the
stack parameter.
|
static URLAndInt |
readFirstURL(String s,
int startAt) |
void |
resetMark() |
private static URLDescriptor |
resolve(URLDescriptor url) |
Status |
sendMessage(AbstractProcess sender,
MLMessage message) |
void |
setChannel(Channel channel) |
void |
setData(String data)
Replace the entire data section in the URL.
|
void |
setDataValue(String key,
String value)
Inserts a data key (and potentially a value) in to the data part
of the url (after the "?", separated by "&"s).
|
static void |
setDefaultAmbiguousURLtoLocal(boolean b)
If b is true, any URL which is ambiguous between a local and remote URL will silently resolve
to the local URL.
|
void |
setDirectory(String dir) |
private void |
setFile(String file) |
void |
setFragment(String frag) |
private void |
setHost(InetAddress host) |
private void |
setHost(String host) |
void |
setIndirect(boolean val) |
void |
setLACport(int lac_port) |
private void |
setPath(String path) |
void |
setPort(int port) |
void |
setPort(String port) |
void |
setUser(String user) |
long |
timeOfWithdrawal() |
String |
toString()
Simply calls #getFullAddress(null)
|
String |
toString(URLDescriptor relativeTo)
Simply calls #getFullAddress(relativeTo)
|
String |
toStringAgentIdentifier(boolean shortForm) |
void |
unresolve()
SET
|
void |
withdraw() |
private static List<URLDescriptor> knownURLs
private static boolean AMBIGUOUS_TAKEN_AS_LOCALHOST
URLDescriptorException
to
be thrown.private String user
private InetAddress host
private int port
private String path
private String fragment
private String data
private int mark
private boolean withdrawn
private long timeWithdrawn
private static final CasaLispOperator NEW_URL
private static final CasaLispOperator AGENT_IDENTIFIER
private static final CasaLispOperator URLS__GET
private static final CasaLispOperator URL__GET
private Channel channel
private URLDescriptor(String user, InetAddress host, int port, String path)
user
- is an alphanumeric string (e.g., agent1, 007) which is the name of the agenthost
- is an IP address or name, e.g., 136.159.2.4, www.cpsc.ucalgary.caport
- is a numeric value, e.g., 9000, 8080path
- is a slash-divided sequence of alphanumeric strings, e.g., canada/alberta/calgaryprivate URLDescriptor(String user, InetAddress host, int port, String path, String data)
private URLDescriptor(String user, InetAddress host, int port, String path, String data, String fragment)
private URLDescriptor(URLDescriptor url)
private URLDescriptor(InetAddress host, int port)
private URLDescriptor(int port)
port
- The port for the url (the trailing : part)UnknownHostException
- If we can't get the IP address of the local machine for some reasonprivate URLDescriptor(String host, String port) throws URLDescriptorException
URLDescriptorException
private URLDescriptor(String host, String port, String user) throws URLDescriptorException
URLDescriptorException
private URLDescriptor(String url_string) throws URLDescriptorException
URLDescriptorException
private URLDescriptor(String user, String host, String port, String path) throws URLDescriptorException
URLDescriptorException
private static URLDescriptor resolve(URLDescriptor url) throws AmbiguousURLException
AmbiguousURLException
private void mergeWith(URLDescriptor url)
public static void setDefaultAmbiguousURLtoLocal(boolean b)
AmbiguousURLException
to
be thrown.b
- public static boolean getDefaultAmbiguousURLtoLocal()
URLDescriptorException
to
be thrown, returns false.private static URLDescriptor disambiguate(URLDescriptor target, URLDescriptor x, URLDescriptor y) throws AmbiguousURLException
AmbiguousURLException
public static URLDescriptor[] getKnownURLs()
public static URLDescriptor make(String user, InetAddress host, int port, String path) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(String user, InetAddress host, int port, String path, String data) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(String user, InetAddress host, int port, String path, String data, String fragment) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(URLDescriptor url) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(InetAddress host, int port) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(int port) throws URLDescriptorException
port
- The port for the url (the trailing : part)URLDescriptorException
UnknownHostException
- If we can't get the IP address of the local machine for some reasonpublic static URLDescriptor make(String host, String port) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(String host, String port, String user) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(String url_string) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor fromString(String url_string) throws URLDescriptorException
URLDescriptorException
public static URLDescriptor make(String user, String host, String port, String path) throws URLDescriptorException
URLDescriptorException
private void initialize(String user, InetAddress host, int port, String path, String data, String fragment)
public void copy(URLDescriptor url)
url
- public boolean hasUser()
public boolean hasPath()
public boolean hasPort()
public boolean hasLACport()
public boolean hasFragment()
public boolean hasData()
public boolean isResolved()
public boolean isResolvable()
public void unresolve()
public void setUser(String user)
user
- is passed in order to set the Agent's name, i.e. Agent1private void setHost(InetAddress host)
host
- private void setHost(String host) throws URLDescriptorException
URLDescriptorException
public void setPort(String port) throws URLDescriptorException
port
- URLDescriptorException
public void setPort(int port)
port
- private void setPath(String path)
path
- public void setLACport(int lac_port)
public void setIndirect(boolean val)
public void setDirectory(String dir)
private void setFile(String file)
public void setData(String data)
setDataValue(String,String)
or deleteDataValue(String)
.data
- public void setFragment(String frag)
frag
- public void setDataValue(String key, String value)
key
- value
- may be null, indicating no value (just the key)public String deleteDataValue(String key)
key
- guiValue
- may be null, indicating no value (just the key)public String getUser()
public InetAddress getHost()
public String getHostString()
public int getPort()
public String getPath()
public String getHostAndPort()
public int getLACport()
public boolean getIndirect()
public String getDirectory()
public String getFile()
public String getData()
public String getFragment()
public String getShortestName()
public String getDataValue(String key)
key
- the key string, eg: ...?key=value&key2=value2public boolean hasDataValue(String key)
key
- the key string, eg: ...?key=value&key2=value2true
if the key is found in the data; false
otherwise.public boolean local(URLDescriptor relativeTo)
relativeTo
- public String getFullAddress(URLDescriptor relativeTo)
public String toString(URLDescriptor relativeTo)
public String toString()
public String toStringAgentIdentifier(boolean shortForm)
public static URLDescriptor fromString(TokenParser parser) throws URLDescriptorException
parser
- URLDescriptorException
public static URLset peakURL(String s) throws URLDescriptorException
URLDescriptorException
public static URLAndInt readFirstURL(String s, int startAt) throws URLDescriptorException
URLDescriptorException
public static void main(String[] args)
private int compareHosts(InetAddress otherAddr)
public boolean equals(Object object)
URLDescriptor
that
describes that same agent as this URLDescriptor
. The argument
object may be a string, in which case, an attempt is made to parse it,
and if it is a legitimate URLDescriptor, then it is compared as such.public int compareTo(URLDescriptor o)
compareTo
in interface Comparable<URLDescriptor>
public int mark()
public int getMark()
public void resetMark()
public boolean isWithdrawn()
public long timeOfWithdrawal()
public void withdraw()
public Stack<URLDescriptor> getViaStack()
URLDescriptor
s from the via
data item in this urlURLDescriptor
s.public void putViaStack(Stack<URLDescriptor> stack)
stack
- the stack from which to construct the new via data item.public void pushViaAtEnd(URLDescriptor endURL)
endURL
- the url to append to the via data item.public URLDescriptor popViaAtEnd()
public boolean containsVia(URLDescriptor url)
url
- the url to search forpublic void setChannel(Channel channel)
Channel getChannel()
public boolean hasChannel()
public Status sendMessage(AbstractProcess sender, MLMessage message) throws IOException, URLDescriptorException
IOException
URLDescriptorException