1 | /*
|
---|
2 | * Copyright 2002,2004-2005 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 | package org.apache.tools.ant.taskdefs.cvslib;
|
---|
18 |
|
---|
19 | import java.io.ByteArrayOutputStream;
|
---|
20 | import java.io.IOException;
|
---|
21 | import org.apache.tools.ant.BuildException;
|
---|
22 | import org.apache.tools.ant.taskdefs.PumpStreamHandler;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * A dummy stream handler that just passes stuff to the parser.
|
---|
26 | *
|
---|
27 | */
|
---|
28 | class RedirectingStreamHandler
|
---|
29 | extends PumpStreamHandler {
|
---|
30 | RedirectingStreamHandler(final ChangeLogParser parser) {
|
---|
31 | super(new RedirectingOutputStream(parser),
|
---|
32 | new ByteArrayOutputStream());
|
---|
33 | }
|
---|
34 |
|
---|
35 |
|
---|
36 | String getErrors() {
|
---|
37 | try {
|
---|
38 | final ByteArrayOutputStream error
|
---|
39 | = (ByteArrayOutputStream) getErr();
|
---|
40 |
|
---|
41 | return error.toString("ASCII");
|
---|
42 | } catch (final Exception e) {
|
---|
43 | return null;
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 | public void stop() {
|
---|
49 | super.stop();
|
---|
50 | try {
|
---|
51 | getErr().close();
|
---|
52 | getOut().close();
|
---|
53 | } catch (final IOException e) {
|
---|
54 | // plain impossible
|
---|
55 | throw new BuildException(e);
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|