Java Doc for URI.java in  » Web-Server » simple » simple » util » net » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » simple » simple.util.net 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


simple.util.net.URI

All known Subclasses:   simple.util.parse.URIParser,
URI
public interface URI (Code)
The URI interface is used to represent a generic uniform resource identifier . This interface allows each section of the uniform resource identifier to be represented. A generic uniform resource identifier syntax is represented in RFC 2616 section 3.2.2 for the HTTP protocol, this allows similar URI's for example ftp, gopher, https, tftp. The syntax is
 URI = [scheme "://"] host [ ":" port ] [ path [ "?" query ]]
 
This interface reprenents the host, port, path and query part of the uniform resource identifier. The parameters are also represented by the URI. The parameters in a URI consist of name and value pairs in the path segment of the URI.

This will normalize the path part of the uniform resource identifier. A normalized path is one that contains no back references like "./" and "../". The normalized path will not contain the path parameters.

The setPath method is used to reset the path this uniform resource identifier has, it also resets the parameters. The parameters are extracted from the new path given.
author:
   Niall Gallagher





Method Summary
public  StringgetDomain()
     This is used to retrive the domain of this URI.
public  StringgetParameter(String name)
     This will return the value of the parameter with the given name. The parameters stored by this URI will bve unique so this will produce the parameter found deepest within the path segment, see getParameterNames.
public  EnumerationgetParameterNames()
     This extracts the parameter names from the uniform resource identifier represented by this object.
public  PathgetPath()
     This is used to retrive the path of this URI.
public  intgetPort()
     This is used to retrive the port of the uniform resource identifier.
public  ParametersgetQuery()
     This is used to retrive the query of this URI.
public  StringgetScheme()
     This allows the scheme of the URL given to be returned. If the URI does not contain a scheme then this will return null.
public  voidsetDomain(String domain)
     This will set the domain to whatever value is in the string parameter.
public  voidsetPath(String path)
     This will set the path to whatever value it is given.
public  voidsetPath(Path path)
     This will set the path to whatever value it is given.
public  voidsetPort(int port)
     This will set the port to whatever value it is given.
public  voidsetQuery(String query)
     This will set the query to whatever value it is given.
public  voidsetQuery(Parameters query)
     This will set the query to whatever value it is given.
public  voidsetScheme(String scheme)
     This allows the scheme for the uri to be specified.
public  StringtoString()
     This is used to convert this URI object into a String object.



Method Detail
getDomain
public String getDomain()(Code)
This is used to retrive the domain of this URI. The domain part in the URI is an optional part, an example http://domain/path?querypart. This will return the value of the domain part. If there is no domain part then this will return null otherwise the domain value found in the uniform resource identifier. the domain part of this uniform resource identifier this represents



getParameter
public String getParameter(String name)(Code)
This will return the value of the parameter with the given name. The parameters stored by this URI will bve unique so this will produce the parameter found deepest within the path segment, see getParameterNames. This will return null if the parameter does not exist. The setPath method will reset the parameters the URI contains.
Parameters:
  name - this is the name of the parameter to be retrived this will return the parameter value or null if the parameter does not exist



getParameterNames
public Enumeration getParameterNames()(Code)
This extracts the parameter names from the uniform resource identifier represented by this object. The parameters that a uniform resource identifier contains are embedded in the path part of the URI. If the path contains no parameters then this will return an empty Enumeration.

This will produce unique name and value parameters. Thus if the URI contains several path segments with similar parameter names this will return the deepest parameter. For example if the URI represented was http://domain/path1;x=y/path2;x=z the value for the parameter named x would be z. this will return the parameter names found in the URI




getPath
public Path getPath()(Code)
This is used to retrive the path of this URI. The path part is the most fundemental part of the URI. This will return the value of the path. If there is no path part then this will return a Path implementation that represents the root path represented by /. the path that this URI contains, this value will notcontain any back references such as "./" and "../" or anypath parameters



getPort
public int getPort()(Code)
This is used to retrive the port of the uniform resource identifier. The port part in this is an optional part, an example http://host:port/path?querypart. This will return the value of the port. If there is no port then this will return -1 because this represents an impossible uniform resource identifier port. The port is an optional part. this returns the port of the uniform resourceidentifier



getQuery
public Parameters getQuery()(Code)
This is used to retrive the query of this URI. The query part in the URI is an optional part. This will return the value of the query part. If there is no query part then this will return an empty Parameters object. The query is an optional member of a URI and comes after the path part, it is preceeded by a question mark, ? character. For example the following URI contains query for its query part, http://host:port/path?query.

This returns a simple.util.net.Parameters object that can be used to interact directly with the query values. The Parameters object is a read-only interface to the query parameters, and so will not affect the URI. a Parameters object for the query part




getScheme
public String getScheme()(Code)
This allows the scheme of the URL given to be returned. If the URI does not contain a scheme then this will return null. The scheme of the URI is the part that specifies the type of protocol that the URI is used for, an example gopher://domain/path is a URI that is intended for the gopher protocol. The scheme is the string gopher. this returns the scheme tag for the URI ifthere is one specified for it



setDomain
public void setDomain(String domain)(Code)
This will set the domain to whatever value is in the string parameter. If the string is null then this URI objects toString method will not contain the domain. The result of the toString method will be /path/path?query. If the path is non-null this URI will contain the path.
Parameters:
  domain - this will be the new domain of this uniform resource identifier, if it is not null



setPath
public void setPath(String path)(Code)
This will set the path to whatever value it is given. If the value is null then this URI.toString method will not contain the path, that is if path is null then it will be interpreted as /.

This will reset the parameters this URI has. If the value given to this method has embedded parameters these will form the parameters of this URI. The value given may not be the same value that the getPath produces. The path will have all back references and parameters stripped.
Parameters:
  path - the path that this URI is to be set with




setPath
public void setPath(Path path)(Code)
This will set the path to whatever value it is given. If the value is null then this URI.toString method will not contain the path, that is if path is null then it will be interpreted as /.

This will reset the parameters this URI has. If the value given to this method has embedded parameters these will form the parameters of this URI. The value given may not be the same value that the getPath produces. The path will have all back references and parameters stripped.
Parameters:
  path - the path that this URI is to be set with




setPort
public void setPort(int port)(Code)
This will set the port to whatever value it is given. If the value is 0 or less then the toString will will not contain the optional port. If port number is above 0 then the toString method will produce a URI like http://host:123/path but only if there is a valid domain.
Parameters:
  port - the port value that this URI is to have



setQuery
public void setQuery(String query)(Code)
This will set the query to whatever value it is given. If the value is null then this URI.toString method will not contain the query. If the query was abc then the toString method would produca a string like http://host:port/path?abc. If the query is null this URI would have no query part.
Parameters:
  query - the query that this uniform resource identifieris to be set to if it is non-null



setQuery
public void setQuery(Parameters query)(Code)
This will set the query to whatever value it is given. If the value is null then this URI.toString method will not contain the query. If the Parameters.toString returns null then the query will be empty. This is basically the setQuery(String) method with the string value from the issued Parameters.toString method.
Parameters:
  query - a Parameters object that contains the name value parameters for the query



setScheme
public void setScheme(String scheme)(Code)
This allows the scheme for the uri to be specified. If the URI does not contain a scheme then this will attach the scheme and the :// identifier to ensure that the URI.toString will produce the correct syntax.

Caution must be taken to ensure that the port and the scheme are consistant. So if the original URI was http://domain:80/path and the scheme was changed to ftp the port number that remains is the standard HTTP port not the FTP port.
Parameters:
  scheme - this specifies the protocol this URIis intended for




toString
public String toString()(Code)
This is used to convert this URI object into a String object. This will only convert the parts of the URI that exist, so the URI may not contain the domain or the query part and it will not contain the path parameters. If the URI contains all these parts then it will return somthing like
 scheme://host:port/path/path?querypart
 

It can return /path/path?querypart style relative URI's. If any of the parts are set to null then that part will be missing, for example if setDomain method is invoked with a null parameter then the domain and port will be missing from the resulting URI. If the path part is set to null using the setPath then the path will be /. An example URI with the path part of null would be

 scheme://host:port/?querypart
 
the URI with only the path part and the non-null optionalparts of the uniform resource identifier



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.