KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > app > HttpImageReference


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.app;
31
32 /**
33  * A reference to an image that may be retrieved through an HTTP request.
34  */

35 public class HttpImageReference
36 implements ImageReference {
37
38     private String JavaDoc uri;
39     private Extent width, height;
40     private String JavaDoc id;
41     
42     /**
43      * Creates a reference to an image at the specified URI of unknown size.
44      *
45      * @param uri a URI from which the image data may be obtained
46      */

47     public HttpImageReference(String JavaDoc uri) {
48         this(uri, null, null);
49     }
50     
51     /**
52      * Creates a reference to an image at the specified URI of the given width
53      * and height. If the image is not of the given width and height, it will
54      * be scaled to the given width and height.
55      *
56      * @param uri a URI from which the image data may be obtained
57      * @param width The width at which to render the image
58      * @param height The height at which to render the image
59      */

60     public HttpImageReference(String JavaDoc uri, Extent width, Extent height) {
61         super();
62         this.uri = uri;
63         this.width = width;
64         this.height = height;
65         id = ApplicationInstance.generateSystemId();
66     }
67
68     /**
69      * @see java.lang.Object#equals(java.lang.Object)
70      */

71     public boolean equals(Object JavaDoc o) {
72         if (!(o instanceof HttpImageReference)) {
73             return false;
74         }
75         HttpImageReference that = (HttpImageReference) o;
76         if (!(this.uri == that.uri || (this.uri != null && this.uri.equals(that.uri)))) {
77             return false;
78         }
79         if (!(this.width == that.width || (this.width != null && this.width.equals(that.width)))) {
80             return false;
81         }
82         if (!(this.height == that.height || (this.height != null && this.height.equals(that.height)))) {
83             return false;
84         }
85         return true;
86     }
87
88     /**
89      * @see nextapp.echo2.app.ImageReference#getHeight()
90      */

91     public Extent getHeight() {
92         return height;
93     }
94     
95     /**
96      * @see nextapp.echo2.app.RenderIdSupport#getRenderId()
97      */

98     public String JavaDoc getRenderId() {
99         return id;
100     }
101
102     /**
103      * Returns the URI from which the image may be obtained.
104      *
105      * @return the URI of the image
106      */

107     public String JavaDoc getUri() {
108         return uri;
109     }
110     
111     /**
112      * @see nextapp.echo2.app.ImageReference#getWidth()
113      */

114     public Extent getWidth() {
115         return width;
116     }
117 }
118
Popular Tags