/** * Returns the absolute base URI of this node or null if the implementation * wasn't able to obtain an absolute URI. Note: If the URI is malformed, a * null is returned. * * @return The absolute base URI of this node or null. * @since DOM Level 3 */ public String getBaseURI() { if (fDocumentURI != null && fDocumentURI.length() != 0 ) {// attribute value is always empty string try { return new URI(fDocumentURI).toString(); } catch (org.apache.xerces.util.URI.MalformedURIException e){ // REVISIT: what should happen in this case? return null; } } return fDocumentURI; }
/** * Initialize all fields of this URI from another URI. * * @param p_other the URI to copy (cannot be null) */ private void initialize(URI p_other) { m_scheme = p_other.getScheme(); m_userinfo = p_other.getUserinfo(); m_host = p_other.getHost(); m_port = p_other.getPort(); m_regAuthority = p_other.getRegBasedAuthority(); m_path = p_other.getPath(); m_queryString = p_other.getQueryString(); m_fragment = p_other.getFragment(); }
/** * Returns true if the hostAndPort matches at least one context endpoint. * @param hostAndPortString a host and port location. * @return true if the hostAndPort matches at least one context endpoint. * @throws WSIException if given hostandPort String does not convert to URI. */ public boolean hasHostAndPort(String hostAndPortString) throws WSIException { URI hostAndPort; try { hostAndPort = new URI(hostAndPortString); } catch (Exception e) { throw new WSIException( "Could not convert string to URI: " + hostAndPortString); } String host = hostAndPort.getHost(); int port = hostAndPort.getPort(); for (int i = 0; i < this.endPoints.length; i++) { if (this.endPoints[i].getHost().equals(host) && this.endPoints[i].getPort() == port) { return true; } } return false; // for now }
throws URI.MalformedURIException { URI systemURI = new URI(systemId, true); if (systemURI.isAbsoluteURI()) { return systemId; baseURI = new URI(baseSystemId, true); if (!baseURI.isAbsoluteURI()) { baseURI.absolutize(getUserDir()); systemURI.absolutize(baseURI); return systemURI.toString();
URI base = new URI(fParentRelativeURI, true); URI uri = new URI(base, relativeURI); final String baseScheme = base.getScheme(); final String literalScheme = uri.getScheme(); if (!isEqual(baseScheme, literalScheme)) { return relativeURI; final String baseAuthority = base.getAuthority(); final String literalAuthority = uri.getAuthority(); if (!isEqual(baseAuthority, literalAuthority)) { return uri.getSchemeSpecificPart(); final String literalPath = uri.getPath(); final String literalQuery = uri.getQueryString(); final String literalFragment = uri.getFragment(); if (literalQuery != null || literalFragment != null) { StringBuffer buffer = new StringBuffer();
if (getScheme() == null || p_uriSpec.charAt(start) == '/') { !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Path contains invalid escape sequence!"); else if (!isPathCharacter(testChar)) { if (testChar == '?' || testChar == '#') { break; !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Opaque part contains invalid escape sequence!"); else if (!isURICharacter(testChar)) { throw new MalformedURIException( "Opaque part contains invalid character: " + testChar); !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Query string contains invalid escape sequence!"); else if (!isURICharacter(testChar)) { throw new MalformedURIException( "Query string contains invalid character: " + testChar);
/** * Returns a relative URI, which when resolved against the base URI at the * specified depth, will create the current base URI. * This is accomplished by merged the literal system IDs. * @param depth the depth at which to start creating the relative URI * @return a relative URI to convert the base URI at the given depth to the current * base URI */ public String getRelativeURI(int depth) throws MalformedURIException { // The literal system id at the location given by "start" is *in focus* at // the given depth. So we need to adjust it to the next scope, so that we // only process out of focus literal system ids int start = scopeOfBaseURI(depth) + 1; if (start == fBaseURIScope.size()) { // If that is the last system id, then we don't need a relative URI return ""; } URI uri = new URI("file", (String)fLiteralSystemID.elementAt(start)); for (int i = start + 1; i < fBaseURIScope.size(); i++) { uri = new URI(uri, (String)fLiteralSystemID.elementAt(i)); } return uri.getPath(); }
/** * Returns the endPoints matching the specified host and port. * @param hostAndPort host and port location. * @return URI[] if matched, null otherwise. */ public URI[] getEndPoints(String hostAndPort) { // get list of matching endpoints associated with service, // having the specified host and port configuration String port; Vector matchedEndpoints = new Vector(); for (int i = 0; i < endPoints.length; i++) { // PB: If the endpoint does not contain a port number, then default it to "80" port = (endPoints[i].getPort() == -1) ? "80" : String.valueOf(endPoints[i].getPort()); if (hostAndPort.equals(endPoints[i].getHost() + ":" + port)) { matchedEndpoints.add(endPoints[i]); } } return (URI[]) matchedEndpoints.toArray(new URI[0]); }
hrefURI = new URI(href, true); if (hrefURI.getFragment() != null) { reportFatalError("HrefFragmentIdentifierIllegal", new Object[] {href}); href = newHref; try { hrefURI = new URI(href, true); if (hrefURI.getFragment() != null) { reportFatalError("HrefFragmentIdentifierIllegal", new Object[] {href});
for (int i = 0; i < endpoints.length; i++) if (endpoints[i].toString().endsWith(requestPath))
throws URI.MalformedURIException { URI systemURI = new URI(systemId, true); if (systemURI.isAbsoluteURI()) { if (systemURI.getScheme().length() > 1) { return systemId; baseURI = new URI(baseSystemId, true); if (!baseURI.isAbsoluteURI()) { baseURI.absolutize(getUserDir()); systemURI.absolutize(baseURI); return systemURI.toString();
/** * Returns true if the hostAndPort matches at least one context endpoint. * @param hostAndPortString a host and port location. * @return true if the hostAndPort matches at least one context endpoint. * @throws WSIException if given hostandPort String does not convert to URI. */ public boolean hasHostAndPort(String hostAndPortString) throws WSIException { URI hostAndPort; try { hostAndPort = new URI(hostAndPortString); } catch (Exception e) { throw new WSIException( "Could not convert string to URI: " + hostAndPortString); } String host = hostAndPort.getHost(); int port = hostAndPort.getPort(); for (int i = 0; i < this.endPoints.length; i++) { if (this.endPoints[i].getHost().equals(host) && this.endPoints[i].getPort() == port) { return true; } } return false; // for now }
/** * Returns the endPoints matching the specified host and port. * @param hostAndPort host and port location. * @return URI[] if matched, null otherwise. */ public URI[] getEndPoints(String hostAndPort) { // get list of matching endpoints associated with service, // having the specified host and port configuration String port; Vector matchedEndpoints = new Vector(); for (int i = 0; i < endPoints.length; i++) { // PB: If the endpoint does not contain a port number, then default it to "80" port = (endPoints[i].getPort() == -1) ? "80" : String.valueOf(endPoints[i].getPort()); if (hostAndPort.equals(endPoints[i].getHost() + ":" + port)) { matchedEndpoints.add(endPoints[i]); } } return (URI[]) matchedEndpoints.toArray(new URI[0]); }
for (int i = 0; i < endpoints.length; i++) if (endpoints[i].toString().endsWith(requestPath))
/** * Returns the absolute base URI of this node or null if the implementation * wasn't able to obtain an absolute URI. Note: If the URI is malformed, a * null is returned. * * @return The absolute base URI of this node or null. * @since DOM Level 3 */ public String getBaseURI() { if (needsSyncData()) { synchronizeData(); } if (baseURI != null && baseURI.length() != 0 ) {// attribute value is always empty string try { return new URI(baseURI).toString(); } catch (org.apache.xerces.util.URI.MalformedURIException e){ // REVISIT: what should happen in this case? return null; } } return baseURI; }
if (uri.length() != 0) {// attribute value is always empty string try { URI _uri = new URI(uri, true); if (_uri.isAbsoluteURI()) { return _uri.toString(); if (parentBaseURI != null) { try { URI _parentBaseURI = new URI(parentBaseURI); _uri.absolutize(_parentBaseURI); return _uri.toString();