/******************************************************************* * MalformedURIExceptions are thrown in the process of building a URI * or setting fields on a URI when an operation would result in an * invalid URI specification. * ********************************************************************/ public static class MalformedURIException extends IOException { /****************************************************************** * Constructs a <code>MalformedURIException</code> with no specified * detail message. ******************************************************************/ public MalformedURIException() { super(); } /***************************************************************** * Constructs a <code>MalformedURIException</code> with the * specified detail message. * * @param p_msg the detail message. ******************************************************************/ public MalformedURIException(String p_msg) { super(p_msg); } }
/** * Get the URI as a string specification. See RFC 2396 Section 5.2. * * @return the URI string specification */ @Override public String toString() { StringBuilder uriSpecString = new StringBuilder(); if (m_scheme != null) { uriSpecString.append(m_scheme); uriSpecString.append(':'); } uriSpecString.append(getSchemeSpecificPart()); return uriSpecString.toString(); }
/** * Construct a new URI from a base URI and a URI specification string. * The URI specification string may be a relative URI. * * @param p_base the base URI (cannot be null if p_uriSpec is null or * empty) * @param p_uriSpec the URI specification string (cannot be null or * empty if p_base is null) * * @exception MalformedURIException if p_uriSpec violates any syntax * rules */ public JaxmURI(JaxmURI p_base, String p_uriSpec) throws MalformedURIException { initialize(p_base, p_uriSpec); }
initializeScheme(uriSpec); index = m_scheme.length()+1; initializeAuthority(uriSpec.substring(startPos, index)); m_userinfo = p_base.getUserinfo(); m_host = p_base.getHost(); m_port = p_base.getPort(); String basePath = p_base.getPath();
m_fragment = null; else if (!isGenericURI()) { throw new MalformedURIException( "Fragment can only be set for a generic URI!"); else if (getPath() == null) { throw new MalformedURIException( "Fragment cannot be set when path is null!"); else if (!isURIString(p_fragment)) { throw new MalformedURIException( "Fragment contains invalid character!");
/** * Set the scheme for this URI. The scheme is converted to lowercase * before it is set. * * @param p_scheme the scheme for this URI (cannot be null) * * @exception MalformedURIException if p_scheme is not a conformant * scheme name */ public void setScheme(String p_scheme) throws MalformedURIException { if (p_scheme == null) { throw new MalformedURIException( "Cannot set scheme from null string!"); } if (!isConformantSchemeName(p_scheme)) { throw new MalformedURIException("The scheme is not conformant."); } m_scheme = p_scheme.toLowerCase(); }