001: /*
002: * $Id: MarkupResourceStream.java 458378 2005-12-27 16:29:53Z jdonnerstag $
003: * $Revision: 458378 $ $Date: 2005-12-27 17:29:53 +0100 (Tue, 27 Dec 2005) $
004: *
005: * ==============================================================================
006: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007: * use this file except in compliance with the License. You may obtain a copy of
008: * the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015: * License for the specific language governing permissions and limitations under
016: * the License.
017: */
018: package wicket.markup;
019:
020: import java.io.IOException;
021: import java.io.InputStream;
022: import java.util.Locale;
023:
024: import wicket.util.resource.IResourceStream;
025: import wicket.util.resource.ResourceStreamNotFoundException;
026: import wicket.util.time.Time;
027:
028: /**
029: * An IResourceStream implementation with specific extensions for markup
030: * resource streams.
031: *
032: * @author Juergen Donnerstag
033: */
034: public class MarkupResourceStream implements IResourceStream {
035: private static final long serialVersionUID = 1846489965076612828L;
036:
037: /** The associated markup resource stream */
038: private final IResourceStream resourceStream;
039:
040: /**
041: * Container info like Class, locale and style which were used to locate the
042: * resource
043: */
044: private final ContainerInfo containerInfo;
045:
046: /**
047: * The actual component class the markup is directly associated with. It
048: * might be super class of the component class
049: */
050: private final Class markupClass;
051:
052: /**
053: * Construct.
054: *
055: * @param resourceStream
056: * @param containerInfo
057: * @param markupClass
058: */
059: public MarkupResourceStream(final IResourceStream resourceStream,
060: final ContainerInfo containerInfo, final Class markupClass) {
061: this .resourceStream = resourceStream;
062: this .containerInfo = containerInfo;
063: this .markupClass = markupClass;
064:
065: if (resourceStream == null) {
066: throw new IllegalArgumentException(
067: "Parameter 'resourceStream' must not be null");
068: }
069: }
070:
071: /**
072: *
073: * @see wicket.util.resource.IResourceStream#close()
074: */
075: public void close() throws IOException {
076: resourceStream.close();
077: }
078:
079: /**
080: *
081: * @see wicket.util.resource.IResourceStream#getContentType()
082: */
083: public String getContentType() {
084: return resourceStream.getContentType();
085: }
086:
087: /**
088: *
089: * @see wicket.util.resource.IResourceStream#getInputStream()
090: */
091: public InputStream getInputStream()
092: throws ResourceStreamNotFoundException {
093: return resourceStream.getInputStream();
094: }
095:
096: /**
097: *
098: * @see wicket.util.resource.IResourceStream#getLocale()
099: */
100: public Locale getLocale() {
101: return resourceStream.getLocale();
102: }
103:
104: /**
105: *
106: * @see wicket.util.watch.IModifiable#lastModifiedTime()
107: */
108: public Time lastModifiedTime() {
109: return resourceStream.lastModifiedTime();
110: }
111:
112: /**
113: *
114: * @see wicket.util.resource.IResourceStream#length()
115: */
116: public long length() {
117: return resourceStream.length();
118: }
119:
120: /**
121: *
122: * @see wicket.util.resource.IResourceStream#setLocale(java.util.Locale)
123: */
124: public void setLocale(Locale locale) {
125: resourceStream.setLocale(locale);
126: }
127:
128: /**
129: * Get the actual component class the markup is directly associated with.
130: * Note: it not necessarily must be the container class.
131: *
132: * @return The directly associated class
133: */
134: public Class getMarkupClass() {
135: return markupClass;
136: }
137:
138: /**
139: * Get the container infos associated with the markup
140: *
141: * @return ContainerInfo
142: */
143: public ContainerInfo getContainerInfo() {
144: return containerInfo;
145: }
146:
147: /**
148: *
149: * @see java.lang.Object#toString()
150: */
151: public String toString() {
152: return resourceStream.toString();
153: }
154: }
|