001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.util.resource;
018
019import java.io.IOException;
020import java.io.InputStream;
021import java.time.Instant;
022import java.util.Locale;
023import org.apache.wicket.util.lang.Args;
024import org.apache.wicket.util.lang.Bytes;
025
026/**
027 * A IResourceStream that wraps another resource stream
028 */
029public class ResourceStreamWrapper implements IResourceStream
030{
031        private static final long serialVersionUID = 1L;
032
033        private final IResourceStream delegate;
034
035        /**
036         * Creates the wrapper around the {@code delegate} resource stream.
037         * 
038         * @param delegate
039         */
040        public ResourceStreamWrapper(IResourceStream delegate)
041        {
042                this.delegate = Args.notNull(delegate, "delegate");
043        }
044
045        /**
046         * Returns the wrapped delegate.
047         * 
048         * @return the wrapped delegate.
049         */
050        public IResourceStream getDelegate()
051        {
052                return delegate;
053        }
054
055        @Override
056        public String getContentType()
057        {
058                return delegate.getContentType();
059        }
060
061        @Override
062        public Bytes length()
063        {
064                return delegate.length();
065        }
066
067        @Override
068        public InputStream getInputStream() throws ResourceStreamNotFoundException
069        {
070                return delegate.getInputStream();
071        }
072
073        @Override
074        public void close() throws IOException
075        {
076                delegate.close();
077        }
078
079        @Override
080        public Locale getLocale()
081        {
082                return delegate.getLocale();
083        }
084
085        @Override
086        public void setLocale(Locale locale)
087        {
088                delegate.setLocale(locale);
089        }
090
091        @Override
092        public String getStyle()
093        {
094                return delegate.getStyle();
095        }
096
097        @Override
098        public void setStyle(String style)
099        {
100                delegate.setStyle(style);
101        }
102
103        @Override
104        public String getVariation()
105        {
106                return delegate.getVariation();
107        }
108
109        @Override
110        public void setVariation(String variation)
111        {
112                delegate.setVariation(variation);
113        }
114
115        @Override
116        public Instant lastModifiedTime()
117        {
118                return delegate.lastModifiedTime();
119        }
120}