/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This abstract class is a generic URL context that accepts as the
* name argument either a string URL or a Name whose first component
* is a URL. It resolves the URL to a target context and then continues
* the operation using the remaining name in the target context as if
* the first component names a junction.
*
* A subclass must define getRootURLContext()
* URL strings are parsed and compared for the rename() operation, then
* it should override getNonRootURLSuffixes() and urlEquals().
*
* @author Scott Seligman
* @author Rosanna Lee
*/
// context that is not tied to any specific URL
}
}
return ""; // %%% check this out: A URL context's name is ""
}
/**
* Resolves 'name' into a target context with remaining name.
* this method resolves "jndi://dnsname/" to a target context,
* and returns the target context with "rest_name".
* The definition of "root URL" and how much of the URL to
* consume is implementation specific.
* If rename() is supported for a particular URL scheme,
* getRootURLContext(), getURLPrefix(), and getURLSuffix()
* must be in sync wrt how URLs are parsed and returned.
*/
/**
* Returns the suffix of the url. The result should be identical to
* that of calling getRootURLContext().getRemainingName(), but
* without the overhead of doing anything with the prefix like
* creating a context.
*<p>
* This method returns a Name instead of a String because to give
* the provider an opportunity to return a Name (for example,
* for weakly separated naming systems like COS naming).
*<p>
* The default implementation uses skips 'prefix', calls
* UrlUtil.decode() on it, and returns the result as a single component
* CompositeName.
* Subclass should override if this is not appropriate.
* This method is used only by rename().
* If rename() is supported for a particular URL scheme,
* getRootURLContext(), getURLPrefix(), and getURLSuffix()
* must be in sync wrt how URLs are parsed and returned.
*<p>
* For many URL schemes, this method is very similar to URL.getFile(),
* except getFile() will return a leading slash in the
* 2nd, 3rd, and 4th cases. For schemes like "ldap" and "iiop",
* the leading slash must be skipped before the name is an acceptable
* format for operation by the Context methods. For schemes that treat the
* leading slash as significant (such as "file"),
* the subclass must override getURLSuffix() to get the correct behavior.
* Remember, the behavior must match getRootURLContext().
*
* URL Suffix
* foo://host:port <empty string>
*/
return new CompositeName();
}
}
try {
} catch (MalformedURLException e) {
throw new InvalidNameException(e.getMessage());
}
}
/**
* Finds the prefix of a URL.
* Default implementation looks for slashes and then extracts
* prefixes using String.substring().
* Subclass should override if this is not appropriate.
* This method is used only by rename().
* If rename() is supported for a particular URL scheme,
* getRootURLContext(), getURLPrefix(), and getURLSuffix()
* must be in sync wrt how URLs are parsed and returned.
*<p>
* URL Prefix
* foo://host:port foo://host:port
*/
if (start < 0) {
}
++start; // skip ':'
// find last slash
if (posn >= 0) {
} else {
}
}
// else 0 or 1 iniitial slashes; start is unchanged
}
/**
* Determines whether two URLs are the same.
* Default implementation uses String.equals().
* Subclass should override if this is not appropriate.
* This method is used by rename().
*/
}
/**
* Gets the context in which to continue the operation. This method
* is called when this context is asked to process a multicomponent
* Name in which the first component is a URL.
* Treat the first component like a junction: resolve it and then use
* NamingManager.getContinuationContext() to get the target context in
* which to operate on the remainder of the name (n.getSuffix(1)).
*/
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
throw new OperationNotSupportedException(
"Renaming using different URL prefixes not supported : " +
}
try {
} finally {
}
}
throw new OperationNotSupportedException(
"Renaming to a Name with more components not supported: " + newName);
}
} else {
// > 1 component with 1st one being URL
// URLs must be identical; cannot deal with diff URLs
throw new OperationNotSupportedException(
"Renaming using different URLs as first components not supported: " +
}
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
throws NamingException {
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
try {
} finally {
}
}
} else {
try {
} finally {
}
}
}
throws NamingException {
return name;
return prefix;
} else {
}
}
return result;
}
throws NamingException {
return null;
}
}
throws NamingException {
}
} else {
}
}
/*
// To test, declare getURLPrefix and getURLSuffix static.
public static void main(String[] args) throws Exception {
String[] tests = {"file://host:port",
for (int i = 0; i < tests.length; i++) {
String pre = getURLPrefix(tests[i]);
System.out.println(pre);
System.out.println(getURLSuffix(pre, tests[i]));
}
}
*/
}