com.sapportals.portal.prt.service.soap.types

Class AnyURI

java.lang.Object
  extended bycom.sapportals.portal.prt.service.soap.types.AnyURI

public class AnyURI
extends Object

A class to represent a Uniform Resource Identifier (URI). This class is designed to handle the parsing of URIs and provide access to the various components (scheme, host, port, userinfo, path, query string and fragment) that may constitute a URI.


Constructor Summary
AnyURI()
          Construct a new and uninitialized URI.
AnyURI(String p_uriSpec)
          Construct a new URI from a URI specification string.
AnyURI(String p_scheme, String p_userinfo, String p_host, int p_port, String p_path, String p_queryString, String p_fragment)
          Construct a new URI that follows the generic URI syntax from its component parts.
 
Method Summary
 void appendPath(String p_addToPath)
          Append to the end of the path of this URI.
 boolean equals(Object p_test)
          Determines if the passed-in Object is equivalent to this URI.
 String getFragment()
          Get the fragment for this URI.
 String getHost()
          Get the host for this URI.
 String getPath()
          Get the path for this URI.
 String getPath(boolean p_includeQueryString, boolean p_includeFragment)
          Get the path for this URI (optionally with the query string and fragment).
 int getPort()
          Get the port for this URI.
 String getQueryString()
          Get the query string for this URI.
 String getScheme()
          Get the scheme for this URI.
 String getSchemeSpecificPart()
          Get the scheme-specific part for this URI (everything following the scheme and the first colon).
 String getUserinfo()
          Get the userinfo for this URI.
static boolean isConformantSchemeName(String p_scheme)
          Determine whether a scheme conforms to the rules for a scheme name.
 boolean isGenericURI()
          Get the indicator as to whether this URI uses the "generic URI" syntax.
static void main(String[] args)
           
 void setFragment(String p_fragment)
          Set the fragment for this URI.
 void setHost(String p_host)
          Set the host for this URI.
 void setPath(String p_path)
          Set the path for this URI.
 void setPort(int p_port)
          Set the port for this URI. -1 is used to indicate that the port is not specified, otherwise valid port numbers are between 0 and 65535.
 void setQueryString(String p_queryString)
          Set the query string for this URI.
 void setScheme(String p_scheme)
          Set the scheme for this URI.
 void setUserinfo(String p_userinfo)
          Set the userinfo for this URI.
 String toString()
          Get the URI as a string specification.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AnyURI

public AnyURI()
Construct a new and uninitialized URI.


AnyURI

public AnyURI(String p_uriSpec)
       throws MalformedURLException
Construct a new URI from a URI specification string.

Parameters:
p_uriSpec - the URI specification string (cannot be null or empty)
Throws:
MalformedURLException - if p_uriSpec violates any syntax rules

AnyURI

public AnyURI(String p_scheme,
              String p_userinfo,
              String p_host,
              int p_port,
              String p_path,
              String p_queryString,
              String p_fragment)
       throws MalformedURLException
Construct a new URI that follows the generic URI syntax from its component parts.

Parameters:
p_scheme - the URI scheme (cannot be null or empty)
p_userinfo - the URI userinfo (cannot be specified if host is null)
p_host - the hostname for the URI
p_port - the URI port (may be -1 for "unspecified"; cannot be specified if host is null)
p_path - the URI path
p_queryString - the URI query string (cannot be specified if path is null)
p_fragment - the URI fragment (cannot be specified if path is null)
Throws:
MalformedURLException - if any of the parameters violates syntax rules or semantic rules
Method Detail

getScheme

public String getScheme()
Get the scheme for this URI.

Returns:
the scheme for this URI

getSchemeSpecificPart

public String getSchemeSpecificPart()
Get the scheme-specific part for this URI (everything following the scheme and the first colon). See RFC 2396 Section 5.2 for spec.

Returns:
the scheme-specific part for this URI

getUserinfo

public String getUserinfo()
Get the userinfo for this URI.

Returns:
the userinfo for this URI (null if not specified).

getHost

public String getHost()
Get the host for this URI.

Returns:
the host for this URI (null if not specified).

getPort

public int getPort()
Get the port for this URI.

Returns:
the port for this URI (-1 if not specified).

getPath

public String getPath(boolean p_includeQueryString,
                      boolean p_includeFragment)
Get the path for this URI (optionally with the query string and fragment).

Parameters:
p_includeQueryString - if true (and query string is not null), then a "?" followed by the query string will be appended
p_includeFragment - if true (and fragment is not null), then a "#" followed by the fragment will be appended
Returns:
the path for this URI possibly including the query string and fragment

getPath

public String getPath()
Get the path for this URI. Note that the value returned is the path only and does not include the query string or fragment.

Returns:
the path for this URI.

getQueryString

public String getQueryString()
Get the query string for this URI.

Returns:
the query string for this URI. Null is returned if there was no "?" in the URI spec, empty string if there was a "?" but no query string following it.

getFragment

public String getFragment()
Get the fragment for this URI.

Returns:
the fragment for this URI. Null is returned if there was no "#" in the URI spec, empty string if there was a "#" but no fragment following it.

setScheme

public void setScheme(String p_scheme)
               throws MalformedURLException
Set the scheme for this URI. The scheme is converted to lowercase before it is set.

Parameters:
p_scheme - the scheme for this URI (cannot be null)
Throws:
MalformedURLException - if p_scheme is not a conformant scheme name

setUserinfo

public void setUserinfo(String p_userinfo)
                 throws MalformedURLException
Set the userinfo for this URI. If a non-null value is passed in and the host value is null, then an exception is thrown.

Parameters:
p_userinfo - the userinfo for this URI
Throws:
MalformedURLException - if p_userinfo contains invalid characters

setHost

public void setHost(String p_host)
             throws MalformedURLException
Set the host for this URI. If null is passed in, the userinfo field is also set to null and the port is set to -1.

Parameters:
p_host - the host for this URI
Throws:
MalformedURLException - if p_host is not a valid IP address or DNS hostname.

setPort

public void setPort(int p_port)
             throws MalformedURLException
Set the port for this URI. -1 is used to indicate that the port is not specified, otherwise valid port numbers are between 0 and 65535. If a valid port number is passed in and the host field is null, an exception is thrown.

Parameters:
p_port - the port number for this URI
Throws:
MalformedURLException - if p_port is not -1 and not a valid port number

setPath

public void setPath(String p_path)
             throws MalformedURLException
Set the path for this URI.

Parameters:
p_path - the path for this URI (may be null)
Throws:
MalformedURLException - if p_path contains invalid characters

appendPath

public void appendPath(String p_addToPath)
                throws MalformedURLException
Append to the end of the path of this URI. If the current path does not end in a slash and the path to be appended does not begin with a slash, a slash will be appended to the current path before the new segment is added. Also, if the current path ends in a slash and the new segment begins with a slash, the extra slash will be removed before the new segment is appended.

Parameters:
p_addToPath - the new segment to be added to the current path
Throws:
MalformedURLException - if p_addToPath contains syntax errors

setQueryString

public void setQueryString(String p_queryString)
                    throws MalformedURLException
Set the query string for this URI. A non-null value is valid only if this is an URI conforming to the generic URI syntax and the path value is not null.

Parameters:
p_queryString - the query string for this URI
Throws:
MalformedURLException - if p_queryString is not null and this URI does not conform to the generic URI syntax or if the path is null

setFragment

public void setFragment(String p_fragment)
                 throws MalformedURLException
Set the fragment for this URI. A non-null value is valid only if this is a URI conforming to the generic URI syntax and the path value is not null.

Parameters:
p_fragment - the fragment for this URI
Throws:
MalformedURLException - if p_fragment is not null and this URI does not conform to the generic URI syntax or if the path is null

equals

public boolean equals(Object p_test)
Determines if the passed-in Object is equivalent to this URI.

Parameters:
p_test - the Object to test for equality.
Returns:
true if p_test is a URI with all values equal to this URI, false otherwise

toString

public String toString()
Get the URI as a string specification. See RFC 2396 Section 5.2.

Returns:
the URI string specification

isGenericURI

public boolean isGenericURI()
Get the indicator as to whether this URI uses the "generic URI" syntax.

Returns:
true if this URI uses the "generic URI" syntax, false otherwise

isConformantSchemeName

public static boolean isConformantSchemeName(String p_scheme)
Determine whether a scheme conforms to the rules for a scheme name. A scheme is conformant if it starts with an alphanumeric, and contains only alphanumerics, '+','-' and '.'.

Parameters:
p_scheme - The sheme name to check
Returns:
true if the scheme is conformant, false otherwise

main

public static void main(String[] args)


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.