View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.common.content;
20  
21  import java.io.File;
22  import java.io.IOException;
23  import java.io.InputStream;
24  import java.io.OutputStream;
25  import java.nio.channels.ReadableByteChannel;
26  import java.nio.file.CopyOption;
27  import java.nio.file.Path;
28  
29  import javax.xml.transform.Source;
30  
31  import org.apache.logging.log4j.LogManager;
32  import org.apache.logging.log4j.Logger;
33  import org.jdom2.Document;
34  import org.jdom2.JDOMException;
35  import org.mycore.datamodel.ifs.MCRContentInputStream;
36  import org.xml.sax.InputSource;
37  import org.xml.sax.SAXException;
38  
39  /**
40   * @author Thomas Scheffler (yagee)
41   *
42   */
43  public abstract class MCRWrappedContent extends MCRContent {
44  
45      private static final Logger LOGGER = LogManager.getLogger(MCRWrappedContent.class);
46  
47      private MCRContent baseContent;
48  
49      public MCRContent getBaseContent() {
50          return baseContent;
51      }
52  
53      protected void setBaseContent(MCRContent baseContent) {
54          LOGGER.debug("Wrapped {}: {}", baseContent.getClass().getCanonicalName(), baseContent.getSystemId());
55          this.baseContent = baseContent;
56      }
57  
58      /* (non-Javadoc)
59       * @see org.mycore.common.content.MCRContent#getInputStream()
60       */
61      @Override
62      public InputStream getInputStream() throws IOException {
63          return getBaseContent().getInputStream();
64      }
65  
66      @Override
67      void setSystemId(String systemId) {
68          getBaseContent().setSystemId(systemId);
69      }
70  
71      @Override
72      public String getSystemId() {
73          return getBaseContent().getSystemId();
74      }
75  
76      @Override
77      public MCRContentInputStream getContentInputStream() throws IOException {
78          return getBaseContent().getContentInputStream();
79      }
80  
81      @Override
82      public Source getSource() throws IOException {
83          return getBaseContent().getSource();
84      }
85  
86      @Override
87      public void sendTo(OutputStream out) throws IOException {
88          getBaseContent().sendTo(out);
89      }
90  
91      @Override
92      public void sendTo(OutputStream out, boolean close) throws IOException {
93          getBaseContent().sendTo(out, close);
94      }
95  
96      @Override
97      public void sendTo(Path target, CopyOption... options) throws IOException {
98          getBaseContent().sendTo(target, options);
99      }
100 
101     @Override
102     public InputSource getInputSource() throws IOException {
103         return getBaseContent().getInputSource();
104     }
105 
106     @Override
107     public void sendTo(File target) throws IOException {
108         getBaseContent().sendTo(target);
109     }
110 
111     @Override
112     public byte[] asByteArray() throws IOException {
113         return getBaseContent().asByteArray();
114     }
115 
116     @Override
117     public String asString() throws IOException {
118         return getBaseContent().asString();
119     }
120 
121     @Override
122     public Document asXML() throws JDOMException, IOException, SAXException {
123         return getBaseContent().asXML();
124     }
125 
126     @Override
127     public MCRContent ensureXML() throws IOException, JDOMException, SAXException {
128         return getBaseContent().ensureXML();
129     }
130 
131     @Override
132     public String getDocType() throws IOException {
133         return getBaseContent().getDocType();
134     }
135 
136     @Override
137     public boolean isReusable() {
138         return getBaseContent().isReusable();
139     }
140 
141     @Override
142     public MCRContent getReusableCopy() throws IOException {
143         return getBaseContent().getReusableCopy();
144     }
145 
146     @Override
147     public long length() throws IOException {
148         return getBaseContent().length();
149     }
150 
151     @Override
152     public long lastModified() throws IOException {
153         return getBaseContent().lastModified();
154     }
155 
156     @Override
157     public void setLastModified(long lastModified) {
158         getBaseContent().setLastModified(lastModified);
159     }
160 
161     @Override
162     public String getETag() throws IOException {
163         return getBaseContent().getETag();
164     }
165 
166     @Override
167     public ReadableByteChannel getReadableByteChannel() throws IOException {
168         return getBaseContent().getReadableByteChannel();
169     }
170 
171     @Override
172     public void setDocType(String docType) {
173         getBaseContent().setDocType(docType);
174     }
175 
176     @Override
177     public String getMimeType() throws IOException {
178         return getBaseContent().getMimeType();
179     }
180 
181     @Override
182     public void setMimeType(String mimeType) {
183         getBaseContent().setMimeType(mimeType);
184     }
185 
186     @Override
187     public String getName() {
188         return getBaseContent().getName();
189     }
190 
191     @Override
192     public void setName(String name) {
193         getBaseContent().setName(name);
194     }
195 
196     @Override
197     public boolean isUsingSession() {
198         return getBaseContent().isUsingSession();
199     }
200 
201     @Override
202     public void setUsingSession(boolean usingSession) {
203         getBaseContent().setUsingSession(usingSession);
204     }
205 
206 }