jaxp/src/com/sun/org/apache/xml/internal/utils/URI.java
changeset 17538 d8d911c4e5d4
parent 12458 d601e4bba306
equal deleted inserted replaced
17537:50528ec0ea37 17538:d8d911c4e5d4
    25 import java.io.IOException;
    25 import java.io.IOException;
    26 import java.io.Serializable;
    26 import java.io.Serializable;
    27 
    27 
    28 import com.sun.org.apache.xml.internal.res.XMLErrorResources;
    28 import com.sun.org.apache.xml.internal.res.XMLErrorResources;
    29 import com.sun.org.apache.xml.internal.res.XMLMessages;
    29 import com.sun.org.apache.xml.internal.res.XMLMessages;
       
    30 import java.util.Objects;
    30 
    31 
    31 /**
    32 /**
    32  * A class to represent a Uniform Resource Identifier (URI). This class
    33  * A class to represent a Uniform Resource Identifier (URI). This class
    33  * is designed to handle the parsing of URIs and provide access to
    34  * is designed to handle the parsing of URIs and provide access to
    34  * the various components (scheme, host, port, userinfo, path, query
    35  * the various components (scheme, host, port, userinfo, path, query
   881    * @return the scheme-specific part for this URI
   882    * @return the scheme-specific part for this URI
   882    */
   883    */
   883   public String getSchemeSpecificPart()
   884   public String getSchemeSpecificPart()
   884   {
   885   {
   885 
   886 
   886     StringBuffer schemespec = new StringBuffer();
   887     final StringBuilder schemespec = new StringBuilder();
   887 
   888 
   888     if (m_userinfo != null || m_host != null || m_port != -1)
   889     if (m_userinfo != null || m_host != null || m_port != -1)
   889     {
   890     {
   890       schemespec.append("//");
   891       schemespec.append("//");
   891     }
   892     }
   973    */
   974    */
   974   public String getPath(boolean p_includeQueryString,
   975   public String getPath(boolean p_includeQueryString,
   975                         boolean p_includeFragment)
   976                         boolean p_includeFragment)
   976   {
   977   {
   977 
   978 
   978     StringBuffer pathString = new StringBuffer(m_path);
   979     final StringBuilder pathString = new StringBuilder(m_path);
   979 
   980 
   980     if (p_includeQueryString && m_queryString != null)
   981     if (p_includeQueryString && m_queryString != null)
   981     {
   982     {
   982       pathString.append('?');
   983       pathString.append('?');
   983       pathString.append(m_queryString);
   984       pathString.append(m_queryString);
  1339    * @param p_test the Object to test for equality.
  1340    * @param p_test the Object to test for equality.
  1340    *
  1341    *
  1341    * @return true if p_test is a URI with all values equal to this
  1342    * @return true if p_test is a URI with all values equal to this
  1342    *         URI, false otherwise
  1343    *         URI, false otherwise
  1343    */
  1344    */
       
  1345   @Override
  1344   public boolean equals(Object p_test)
  1346   public boolean equals(Object p_test)
  1345   {
  1347   {
  1346 
  1348 
  1347     if (p_test instanceof URI)
  1349     if (p_test instanceof URI)
  1348     {
  1350     {
  1361     }
  1363     }
  1362 
  1364 
  1363     return false;
  1365     return false;
  1364   }
  1366   }
  1365 
  1367 
       
  1368   @Override
       
  1369   public int hashCode() {
       
  1370     int hash = 7;
       
  1371     hash = 59 * hash + Objects.hashCode(this.m_scheme);
       
  1372     hash = 59 * hash + Objects.hashCode(this.m_userinfo);
       
  1373     hash = 59 * hash + Objects.hashCode(this.m_host);
       
  1374     hash = 59 * hash + this.m_port;
       
  1375     hash = 59 * hash + Objects.hashCode(this.m_path);
       
  1376     hash = 59 * hash + Objects.hashCode(this.m_queryString);
       
  1377     hash = 59 * hash + Objects.hashCode(this.m_fragment);
       
  1378     return hash;
       
  1379   }
       
  1380 
  1366   /**
  1381   /**
  1367    * Get the URI as a string specification. See RFC 2396 Section 5.2.
  1382    * Get the URI as a string specification. See RFC 2396 Section 5.2.
  1368    *
  1383    *
  1369    * @return the URI string specification
  1384    * @return the URI string specification
  1370    */
  1385    */
       
  1386   @Override
  1371   public String toString()
  1387   public String toString()
  1372   {
  1388   {
  1373 
  1389 
  1374     StringBuffer uriSpecString = new StringBuffer();
  1390     final StringBuilder uriSpecString = new StringBuilder();
  1375 
  1391 
  1376     if (m_scheme != null)
  1392     if (m_scheme != null)
  1377     {
  1393     {
  1378       uriSpecString.append(m_scheme);
  1394       uriSpecString.append(m_scheme);
  1379       uriSpecString.append(':');
  1395       uriSpecString.append(':');