All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wings.header.Link Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2000,2005 wingS development team.
 *
 * This file is part of wingS (http://wingsframework.org).
 *
 * wingS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * Please see COPYING for the complete licence.
 */
package org.wings.header;

import org.wings.SimpleURL;
import org.wings.URLResource;
import org.wings.io.Device;

import java.io.IOException;
import java.io.Serializable;

/**
 * Include a <LINK>-element inside the HTML header of rendered page.
 *
 * 

Example usage to include a customer stylesheet.
* frame.addHeader(new Link("stylesheet", null, "text/css", null, new DefaultURLResource("../css/appstyles.css"))); * * @author Holger Engels */ public class Link implements Header, Serializable { protected String rel = null; protected String rev = null; protected String type = null; protected String target = null; protected URLResource urlSource = null; /** * Example usage to include a customer stylesheet.
* frame.addHeader(new Link("stylesheet", null, "text/css", null, new DefaultURLResource("../css/appstyles.css"))); * @param rel * @param rev * @param type * @param target * @param urlSource */ public Link(String rel, String rev, String type, String target, URLResource urlSource) { this.rel = rel; this.rev = rev; this.type = type; this.target = target; this.urlSource = urlSource; } public void setRel(String rel) { this.rel = rel; } public String getRel() { return rel; } public void setRev(String rev) { this.rev = rev; } public String getRev() { return rev; } public void setType(String type) { this.type = type; } public String getType() { return type; } public SimpleURL getURL() { return urlSource.getURL(); } public void setTarget(String target) { this.target = target; } public String getTarget() { return target; } @Override public void write(Device d) throws IOException { d.print(""); } /* * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj == this) return true; if (obj == null) return false; if (!(obj instanceof Link)) return false; Link testObj = (Link) obj; if (testObj.rel == null) { if (rel != null) { return false; } } else { if (!testObj.rel.equals(rel)) { return false; } } if (testObj.rev == null) { if (rev != null) { return false; } } else { if (!testObj.rev.equals(rev)) { return false; } } if (testObj.type == null) { if (type != null) { return false; } } else { if (!testObj.type.equals(type)) { return false; } } if (testObj.target == null) { if (target != null) { return false; } } else { if (!testObj.target.equals(target)) { return false; } } if (testObj.getURL() == null) { if (getURL() != null) { return false; } } else { if (!testObj.getURL().toString().equals(getURL().toString())) { return false; } } return true; } public int hashCode() { int hashCode = 17; int dispersionFactor = 37; hashCode = hashCode * dispersionFactor + ((rel == null) ? 0 : rel.hashCode()); hashCode = hashCode * dispersionFactor + ((rev == null) ? 0 : rev.hashCode()); hashCode = hashCode * dispersionFactor + ((type == null) ? 0 : type.hashCode()); hashCode = hashCode * dispersionFactor + ((target == null) ? 0 : target.hashCode()); hashCode = hashCode * dispersionFactor + ((getURL() == null) ? 0 : getURL().hashCode()); return hashCode; } public String toString() { return urlSource.getURL().toString(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy