org.apache.cayenne.resource.URLResource Maven / Gradle / Ivy
/*****************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
****************************************************************/
package org.apache.cayenne.resource;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.cayenne.CayenneRuntimeException;
/**
* A {@link Resource} implementation wrapping a resource URL.
*
* @since 3.1
*/
public class URLResource implements Resource {
private URL url;
public URLResource(URL url) {
this.url = url;
}
public Resource getRelativeResource(String relativePath) {
try {
return new URLResource(new URL(url, relativePath));
}
catch (MalformedURLException e) {
throw new CayenneRuntimeException(
"Error creating relative resource '%s' : '%s'",
e,
url,
relativePath);
}
}
public URL getURL() {
return url;
}
@Override
public String toString() {
String urlString = String.valueOf(url);
return "";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy