1 24 package org.riotfamily.forms.resource; 25 26 import java.util.Arrays ; 27 import java.util.Collection ; 28 29 import org.springframework.util.Assert; 30 31 34 public class ScriptResource implements FormResource { 35 36 private String url; 37 38 private String test; 39 40 private Collection dependencies; 41 42 public ScriptResource(String url) { 43 this(url, null); 44 } 45 46 public ScriptResource(String url, String test) { 47 this(url, test, (FormResource[]) null); 48 } 49 50 public ScriptResource(String src, String test, FormResource dependency) { 51 this(src, test, dependency != null 52 ? new FormResource[] { dependency } 53 : null); 54 } 55 56 public ScriptResource(String url, String test, FormResource[] dependencies) { 57 Assert.notNull(url); 58 this.url = url; 59 this.test = test; 60 if (dependencies != null && dependencies.length > 0) { 61 this.dependencies = Arrays.asList(dependencies); 62 } 63 } 64 65 public String getUrl() { 66 return this.url; 67 } 68 69 public String getTest() { 70 return this.test; 71 } 72 73 public Collection getDependencies() { 74 return this.dependencies; 75 } 76 77 public void accept(ResourceVisitor vistor) { 78 vistor.visitScript(this); 79 } 80 81 public int hashCode() { 82 return url.hashCode(); 83 } 84 85 public boolean equals(Object obj) { 86 if (obj == null) { 87 return false; 88 } 89 if (obj == this) { 90 return true; 91 } 92 if (obj instanceof ScriptResource) { 93 ScriptResource other = (ScriptResource) obj; 94 return this.url.equals(other.url); 95 } 96 return false; 97 } 98 } 99 | Popular Tags |