|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.idoox.transport.client.Endpoint
This class is a client URI implementation. Simple client examples of the transport usage with Endpoint class:
// HTTP GET
Endpoint endpoint = new Endpoint("http://www.idoox.com/");
ClientConnection connection = endpoint.newConnection(TransportMethod.GET);
InputMessage in = connection.getInputMessage();
byte[] buffer = new byte[2000];
int length;
while((length = in.read(buffer, 0, buffer.length)) >= 0) {
System.out.print(new String(buffer, 0, length));
}
in.close();
// HTTP POST
Endpoint endpoint = new Endpoint("http://my.post.site/");
ClientConnection connection = endpoint.newConnection(TransportMethod.POST);
OutputMessage out = connection.getOutputMessage();
out.setContentType("text/plain");
out.write("Where do you want to go today?".getBytes("UTF-8"));
out.close();
InputMessage in = connection.getInputMessage();
if(in.getStatusCode() != Message.SC_OK) {
throw new IOException("ERROR: " + in.getStatusCode());
}
in.read(...);
in.close();
Constructor Summary | |
Endpoint(java.lang.String endpoint)
Creates new endpoint from the string |
|
Endpoint(java.lang.String scheme,
java.lang.String userinfo,
java.lang.String host,
int port,
java.lang.String context_path,
java.lang.String location)
Creates new endpoint from the specified scheme, userinfo, host, port, context path, and location. |
|
Endpoint(java.lang.String scheme,
java.lang.String userinfo,
java.lang.String host,
int port,
java.lang.String context_path,
java.lang.String path,
java.lang.String fragment,
java.util.Map paramMap)
Creates new endpoint from the specified scheme, userinfo, host, port, context path, path, parameters map and fragment. |
|
Endpoint(java.lang.String scheme,
java.lang.String userinfo,
java.lang.String host,
int port,
java.lang.String context_path,
java.lang.String path,
java.lang.String fragment,
java.lang.String query)
Creates new endpoint from the specified scheme, userinfo, host, port, context path, path, query and fragment. |
|
Endpoint(URI uri)
Creates new endpoint from the URI. |
|
Endpoint(URI context,
java.lang.String location)
Creates new endpoint from some context and a new location. |
Method Summary | |
boolean |
equals(java.lang.Object other)
|
java.lang.String |
getContextPath()
Gets context path. |
java.lang.String |
getFragment()
Gets fragment. |
java.lang.String |
getHost()
Gets host. |
java.lang.String |
getLocation()
Gets location. |
java.lang.String |
getParameter(java.lang.String name)
Gets parameter. |
java.util.Set |
getParameterNames()
Gets parameter names. |
java.lang.String[] |
getParameters(java.lang.String name)
Gets parameters. |
java.lang.String |
getPath()
Gets path. |
int |
getPort()
Gets port. |
java.lang.String |
getQuery()
Gets query. |
java.lang.String |
getScheme()
Gets scheme. |
java.lang.String |
getUserinfo()
Gets user info. |
boolean |
hasHandler()
Returns true if this URI has handler on the
TransportRepository. |
int |
hashCode()
|
ClientConnection |
newConnection(TransportMethod method)
Creates new connection without properties. |
ClientConnection |
newConnection(TransportMethod method,
java.util.Map properties)
Creates new connection. |
URI |
normalize()
Returns normalized URI (or this if it is already in
normalized form). |
void |
setContextPath(java.lang.String context_path)
Sets context path. |
void |
setFragment(java.lang.String fragment)
Sets fragment. |
void |
setHost(java.lang.String host)
Sets host. |
void |
setLocation(java.lang.String location)
Sets location. |
void |
setParameter(java.lang.String name,
java.lang.String value)
Sets parameter. |
void |
setParameters(java.lang.String name,
java.lang.String[] values)
Sets parameters. |
void |
setPath(java.lang.String path)
Sets path. |
void |
setPort(int port)
Sets port. |
void |
setQuery(java.lang.String query)
Sets query string. |
void |
setScheme(java.lang.String scheme)
Sets scheme. |
void |
setUserinfo(java.lang.String userinfo)
Sets user info. |
java.lang.String |
toExternalForm()
Constructs a string representation of this endpoint. |
java.lang.String |
toString()
Constructs a string representation of this endpoint. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Endpoint(java.lang.String endpoint) throws java.net.MalformedURLException
endpoint
- endpoint string
java.net.MalformedURLException
- if an URL is malformedpublic Endpoint(java.lang.String scheme, java.lang.String userinfo, java.lang.String host, int port, java.lang.String context_path, java.lang.String location)
scheme
- the schemeuserinfo
- the user infohost
- the hostport
- the portcontext_path
- the context pathlocation
- the locationpublic Endpoint(java.lang.String scheme, java.lang.String userinfo, java.lang.String host, int port, java.lang.String context_path, java.lang.String path, java.lang.String fragment, java.lang.String query)
scheme
- the schemeuserinfo
- the user infohost
- the hostport
- the portcontext_path
- the context pathpath
- the pathquery
- the query stringfragment
- the fragmentpublic Endpoint(java.lang.String scheme, java.lang.String userinfo, java.lang.String host, int port, java.lang.String context_path, java.lang.String path, java.lang.String fragment, java.util.Map paramMap)
scheme
- the schemeuserinfo
- the user infohost
- the hostport
- the portcontext_path
- the context pathpath
- the pathparamMap
- the parameters map where keys - parameter
names, values - parameter values (ArrayList of
String)fragment
- the fragmentpublic Endpoint(URI uri)
uri
- the URIpublic Endpoint(URI context, java.lang.String location) throws java.net.MalformedURLException
context
- the contextlocation
- the location
java.net.MalformedURLException
- if an URL is malformedMethod Detail |
public java.lang.String getScheme()
getScheme
in interface URI
null
public void setScheme(java.lang.String scheme)
scheme
- the schemepublic java.lang.String getUserinfo()
getUserinfo
in interface URI
null
public void setUserinfo(java.lang.String userinfo)
userinfo
- the user infopublic java.lang.String getHost()
getHost
in interface URI
null
public void setHost(java.lang.String host)
host
- the hostpublic int getPort()
getPort
in interface URI
-1
public void setPort(int port)
port
- the portpublic java.lang.String getContextPath()
getContextPath
in interface URI
null
public void setContextPath(java.lang.String context_path)
context_path
- the context pathpublic java.lang.String getLocation()
getLocation
in interface URI
null
public void setLocation(java.lang.String location)
location
- the locationpublic java.lang.String getPath()
getPath
in interface URI
null
public void setPath(java.lang.String path)
path
- the pathpublic java.lang.String getQuery()
getQuery
in interface URI
null
public void setQuery(java.lang.String query)
query
- the query stringpublic java.util.Set getParameterNames()
getParameterNames
in interface URI
public java.lang.String getParameter(java.lang.String name)
getParameter
in interface URI
name
- the parameter name
null
public void setParameter(java.lang.String name, java.lang.String value)
name
- the parameter namevalue
- the parameter valuepublic java.lang.String[] getParameters(java.lang.String name)
getParameters
in interface URI
name
- the parameter name
null
public void setParameters(java.lang.String name, java.lang.String[] values)
name
- the parameter namevalues
- the array of parameter valuespublic java.lang.String getFragment()
getFragment
in interface URI
null
public void setFragment(java.lang.String fragment)
fragment
- the fragmentpublic java.lang.String toExternalForm()
toExternalForm
in interface URI
public java.lang.String toString()
public boolean hasHandler()
true
if this URI has handler on the
TransportRepository.
true
or false
public ClientConnection newConnection(TransportMethod method) throws java.net.MalformedURLException, java.io.IOException
method
- the method for connection initialization
java.io.IOException
- if an I/O error occurs
java.net.MalformedURLException
- if an URL is malformednewConnection(TransportMethod, Map)
public ClientConnection newConnection(TransportMethod method, java.util.Map properties) throws java.net.MalformedURLException, java.io.IOException
Context
getScheme()
and checks if this one is
CLIENT
type
method
- the method for connection initializationproperties
- properties for the transport
java.io.IOException
- if an I/O error occurs
java.net.MalformedURLException
- if an URL is malformedpublic int hashCode()
public boolean equals(java.lang.Object other)
public URI normalize()
this
if it is already in
normalized form). Normalized URI is uri with normalized path.
Normalized path does not contain any empty or "." segments or
".." segments preceded by other segment than "..".
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |