![JAR search and dependency download from the Maven repository](/logo.png)
net.sourceforge.wurfl.spring.SpringResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wurfl Show documentation
Show all versions of wurfl Show documentation
Wireless Universal Resource File core API
The newest version!
/**
* Copyright (c) 2011 ScientiaMobile Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Refer to the COPYING file distributed with this package.
*/
package net.sourceforge.wurfl.spring;
import net.sourceforge.wurfl.core.resource.ResourceData;
import net.sourceforge.wurfl.core.resource.WURFLResource;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.core.io.Resource;
/**
* Decorator of WURFLResource to build from Spring Resource.
*
* @author Fantayeneh Asres Gizaw
* @author Filippo De Luca
* @deprecated Use SpringResourceAdapter
* @version $Id: SpringResource.java 644 2011-05-14 22:08:16Z ermanno.franco $
*/
public abstract class SpringResource implements WURFLResource {
/** Delegate WURFLResource */
protected WURFLResource delegate;
/**
* Build resource from Spring Resource.
*
* @param resource
* The Spring Resource to build resource from.
*/
public SpringResource(Resource resource) {
delegate = createDelegate(resource);
}
/**
* Create delegate WURFLResource from Spring Resource.
*
* @param resource
* The Spring Resource from that build WURFLResource.
* @return WURFLResource delegate.
*/
protected abstract WURFLResource createDelegate(Resource resource);
// Delegate methods ***************************************************
/**
* {@inheritDoc}
*/
public ResourceData getData() {
return delegate.getData();
}
/**
* {@inheritDoc}
*/
public String getInfo() {
return delegate.getInfo();
}
/**
* {@inheritDoc}
*/
public void release() {
delegate.release();
}
// Commons methods ****************************************************
public String toString() {
return new ToStringBuilder(this).append(delegate).toString();
}
public int hashCode() {
return new HashCodeBuilder().append(getClass()).append(delegate)
.toHashCode();
}
public boolean equals(Object obj) {
EqualsBuilder eb = new EqualsBuilder();
eb.appendSuper(getClass().isInstance(obj));
if (eb.isEquals()) {
SpringXMLResource other = (SpringXMLResource) obj;
eb.append(delegate, other.delegate);
}
return eb.isEquals();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy