KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > xscript > XScriptObjectResult


1 /*
2  * Copyright 1999-2004 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 package org.apache.cocoon.components.xscript;
17
18 import java.io.ByteArrayInputStream JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21
22 /**
23  * An <code>XScriptObject</code> created from a JAXP
24  * <code>Result</code> object.
25  *
26  * @author <a HREF="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
27  * @version CVS $Id: XScriptObjectResult.java 30932 2004-07-29 17:35:38Z vgritsenko $
28  * @since August 30, 2001
29  */

30 public class XScriptObjectResult extends XScriptObject {
31     /**
32      * The XML content of this object.
33      */

34     String JavaDoc content;
35
36     public XScriptObjectResult(XScriptManager manager, String JavaDoc content) {
37         super(manager);
38         this.content = content;
39     }
40
41     public InputStream JavaDoc getInputStream() throws IOException JavaDoc {
42         return new ByteArrayInputStream JavaDoc(content.getBytes());
43     }
44
45     public long getContentLength() {
46         return content.length();
47     }
48
49     public String JavaDoc getURI() {
50         // FIXME: Return a real URL that identifies this object
51
return "file:/";
52     }
53
54     public String JavaDoc toString() {
55         return "XScriptObjectResult: " + content;
56     }
57 }
58
Popular Tags