KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > solution > OutputDef


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jul 11, 2005
14  * @author James Dixon
15  *
16  */

17
18 package org.pentaho.core.solution;
19
20 import java.io.*;
21 import java.util.*;
22
23 public class OutputDef implements IOutputDef {
24
25     private String JavaDoc type;
26
27     private String JavaDoc name;
28
29     private boolean isList;
30
31     private Object JavaDoc value;
32
33     public OutputDef(String JavaDoc name, OutputStream outputStream) {
34         this.name = name;
35         isList = false;
36         type = "content"; //$NON-NLS-1$
37
value = outputStream;
38     }
39
40     public OutputDef(String JavaDoc name, List list) {
41         this.name = name;
42         isList = true;
43         type = "list"; //$NON-NLS-1$
44
value = list;
45     }
46
47     public OutputDef(String JavaDoc name, String JavaDoc type) {
48         this.name = name;
49         this.type = type;
50         isList = false;
51     }
52
53     /*
54      * (non-Javadoc)
55      *
56      * @see org.pentaho.core.solution.IOutputDef#getType()
57      */

58     public String JavaDoc getType() {
59         return type;
60     }
61
62     /*
63      * (non-Javadoc)
64      *
65      * @see org.pentaho.core.solution.IOutputDef#getName()
66      */

67     public String JavaDoc getName() {
68         return name;
69     }
70
71     /*
72      * (non-Javadoc)
73      *
74      * @see org.pentaho.core.solution.IOutputDef#isList()
75      */

76     public boolean isList() {
77         // TODO Auto-generated method stub
78
return isList;
79     }
80
81     /*
82      * (non-Javadoc)
83      *
84      * @see org.pentaho.core.solution.IOutputDef#setValue(java.lang.Object)
85      */

86     public void setValue(Object JavaDoc value) {
87         if (!"content".equals(type) && !"list".equals(type)) { //$NON-NLS-1$ //$NON-NLS-2$
88
this.value = value;
89         }
90     }
91
92     /*
93      * (non-Javadoc)
94      *
95      * @see org.pentaho.core.solution.IOutputDef#getOutputStream()
96      */

97     public OutputStream getOutputStream() {
98         // TODO Auto-generated method stub
99
if ("content".equals(type)) { //$NON-NLS-1$
100
return (OutputStream) value;
101         }
102         return null;
103     }
104
105     public void addToList(Object JavaDoc listItem) {
106         if ("list".equals(type)) { //$NON-NLS-1$
107
((List) value).add(listItem);
108         }
109     }
110
111 }
112
Popular Tags