View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.plugin;
17  
18  /***
19   * Encapsulates required data to each plugin.
20   * 
21   * @author someda
22   */
23  public class PluginRequest {
24  
25  	private String[] args_ = null;
26  
27  	private Object child_ = null;
28  
29  	private String name_ = null;
30  
31  	private int mode_ = 0;
32  
33  	public PluginRequest() {
34  	}
35  
36  	public PluginRequest(String name, String[] args) {
37  		this.name_ = name;
38  		this.args_ = parseArgs(args);
39  		this.mode_ = AbstractPlugin.BLOCKPLUGIN_MODE | AbstractPlugin.INLINEPLUGIN_MODE;
40  	}
41  
42  	public PluginRequest(String[] args, Object child, String name, int mode) {
43  		this.args_ = args;
44  		this.child_ = child;
45  		this.name_ = name;
46  		this.mode_ = mode;
47  	}
48  
49  	public String[] getArgs() {
50  		return args_;
51  	}
52  
53  	public void setArgs(String[] args) {
54  		this.args_ = args;
55  	}
56  
57  	public Object getChild() {
58  		return child_;
59  	}
60  
61  	public void setChild(Object child) {
62  		this.child_ = child;
63  	}
64  
65  	public String getName() {
66  		return name_;
67  	}
68  
69  	public void setName(String name) {
70  		this.name_ = name;
71  	}
72  
73  	public int getMode() {
74  		return mode_;
75  	}
76  
77  	public void setMode(int mode) {
78  		this.mode_ = mode;
79  	}
80  
81  	public String toString() {
82  
83  		StringBuffer buf = new StringBuffer();
84  
85  		buf.append(this.name_);
86  		if (this.args_ != null) {
87  			buf.append("(");
88  			int length = this.args_.length;
89  			for (int i = 0; i < length; i++) {
90  				buf.append(this.args_[i]);
91  				if (i != length - 1)
92  					buf.append(",");
93  			}
94  			buf.append(")");
95  		}
96  
97  		if (this.child_ != null)
98  			buf.append("{" + this.child_.toString() + "}");
99  
100 		return buf.toString();
101 	}
102 
103 	private String[] parseArgs(String[] args) {
104 		if (args == null) {
105 			return null;
106 		}
107 		for (int i = 0; i < args.length; i++) {
108 			args[i] = (args[i] != null) ? args[i].trim() : "";
109 		}
110 		return args;
111 	}
112 }