KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > forms > resource > ScriptResource


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH.
17  * Portions created by the Initial Developer are Copyright (C) 2006
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Felix Gnass [fgnass at neteye dot de]
22  *
23  * ***** END LICENSE BLOCK ***** */

24 package org.riotfamily.forms.resource;
25
26 import java.util.Arrays JavaDoc;
27 import java.util.Collection JavaDoc;
28
29 import org.springframework.util.Assert;
30
31 /**
32  *
33  */

34 public class ScriptResource implements FormResource {
35     
36     private String JavaDoc url;
37     
38     private String JavaDoc test;
39     
40     private Collection JavaDoc dependencies;
41     
42     public ScriptResource(String JavaDoc url) {
43         this(url, null);
44     }
45     
46     public ScriptResource(String JavaDoc url, String JavaDoc test) {
47         this(url, test, (FormResource[]) null);
48     }
49     
50     public ScriptResource(String JavaDoc src, String JavaDoc test, FormResource dependency) {
51         this(src, test, dependency != null
52                 ? new FormResource[] { dependency }
53                 : null);
54     }
55     
56     public ScriptResource(String JavaDoc url, String JavaDoc 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 JavaDoc getUrl() {
66         return this.url;
67     }
68
69     public String JavaDoc getTest() {
70         return this.test;
71     }
72
73     public Collection JavaDoc 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 JavaDoc 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