Author: thorsten
Date: Thu Sep 25 03:21:38 2008
New Revision: 698916
URL: http://svn.apache.org/viewvc?rev=698916&view=rev
Log:
Extracting a common method to a helper class
Added:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/StreamHelper.java
(with props)
Modified:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
Added:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/StreamHelper.java
URL:
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/StreamHelper.java?rev=698916&view=auto
==============================================================================
---
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/StreamHelper.java
(added)
+++
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/StreamHelper.java
Thu Sep 25 03:21:38 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.dispatcher.impl.helper;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+public class StreamHelper {
+ /**
+ * @param out
+ * @return
+ */
+ public static BufferedInputStream switchStream(ByteArrayOutputStream out) {
+ return new BufferedInputStream(new
ByteArrayInputStream(out.toByteArray()));
+ }
+}
Propchange:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/StreamHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
URL:
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java?rev=698916&r1=698915&r2=698916&view=diff
==============================================================================
---
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
(original)
+++
forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/helper/XSLContractHelper.java
Thu Sep 25 03:21:38 2008
@@ -16,8 +16,6 @@
*/
package org.apache.forrest.dispatcher.impl.helper;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -116,9 +114,10 @@
*/
public InputStream createEmptyXml() throws XMLStreamException {
ByteArrayOutputStream out = createEmptyXmlOutput();
- return (out !=null)?new BufferedInputStream(new
ByteArrayInputStream(out.toByteArray())):null;
+ return (out !=null)?StreamHelper.switchStream(out):null;
}
+
/**
* This method sets the xslSource, name, description and usage information of
* the contract.
@@ -205,8 +204,7 @@
}
writer.flush();
log.debug(out.toString());
- Source source = new StreamSource(new BufferedInputStream(
- new ByteArrayInputStream(out.toByteArray())));
+ Source source = new StreamSource(StreamHelper.switchStream(out));
return source;
}