KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > jarbundler > Service


1 package net.sourceforge.jarbundler;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Arrays JavaDoc;
5 import java.util.List JavaDoc;
6
7
8
9 /**
10  * Represents an Info.plist Service specifying a service provided by the application.
11  *
12  * Port Name - The name of the port the application monitors for incoming service requests.
13  *
14  
15  * Message - The name of the instance method to invoke for the service.
16  * In Objective-C, the instance method must be of the form messageName:userData:error:.
17  * In Java, the instance method must be of the form messageName(NSPasteBoard,String).
18  *
19  *
20  * Menu Item - The text to add to the Services menu. The value must be unique.
21  * You can use a slash character "/" to specify a submenu. For example, Mail/Send
22  * would appear in the Services Menu as a menu named Mail with an item named Send.
23  *
24  *
25  * Send Types - A list of the data type names that can be read by the service.
26  * The NSPasteboard class description lists several common data types.
27  *
28  *
29  * Return Types - A list of the data type names that can be returned by the service.
30  * The NSPasteboard class description lists several common data types.
31  * You must specify either Return Types, Send Types or both.
32  *
33  * You must specify either Send Types, Return Types or both.
34  *
35  *
36  * Key Equivalent - This attribute is optional. The keyboard equivalent used to invoke
37  * the service menu command. The value has to be a single character. Users invoke this
38  * keyboard equivalent by pressing the Command and Shift key modifiers along with the character.
39  *
40  *
41  * User Data - This attribute is optional. The value is free choosable and is passed
42  * to the method as second parameter.
43  *
44  *
45  * Timeout - This attribute is optional. It indicates the number of milliseconds
46  * Services should wait for a response from the application providing
47  * a service when a respond is required.
48  *
49  *
50  * <service portname="jarBundler"
51  * message="processRequest"
52  * menuitem="JarBundler/Process Request"
53  * sendtypes="NSStringPboardType,NSFilenamesPboardType"
54  * returntypes="NSStringPboardType"
55  * keyequivalent="p"
56  * userdata="a string passed to the method"
57  * timeout="5000" />
58  */

59 public class Service {
60     private static final List JavaDoc EMPTYLIST = new ArrayList JavaDoc(0);
61
62     
63     /** The name of the port the application monitors for incoming service requests. */
64     private String JavaDoc portName = null;
65     
66
67     /**
68
69      * The name of the instance method to invoke for the service.
70      * In Objective-C, the instance method must be of the form messageName:userData:error:.
71
72      * In Java, the instance method must be of the form messageName(NSPasteBoard,String).
73      */

74     private String JavaDoc message = null;
75     
76
77     /**
78
79      * The text to add to the Services menu. The value must be unique.
80
81      * You can use a slash character "/" to specify a submenu. For example, Mail/Send
82
83      * would appear in the Services Menu as a menu named Mail with an item named Send.
84      */

85     private String JavaDoc menuItem = null;
86     
87     /**
88      * A list of the data type names that can be read by the service.
89
90      * The NSPasteboard class description lists several common data types.
91
92      * You must specify either Send Types, Return Types or both.
93      */

94     private String JavaDoc[] sendTypes = null;
95     
96
97     /**
98      * A list of the data type names that can be returned by the service.
99
100      * The NSPasteboard class description lists several common data types.
101
102      * You must specify either Return Types, Send Types or both.
103      */

104     private String JavaDoc[] returnTypes = null;
105     
106
107     /**
108      * This attribute is optional. The keyboard equivalent used to invoke
109
110      * the service menu command. The value has to be a single character. Users invoke this
111
112      * keyboard equivalent by pressing the Command and Shift key modifiers along with the character.
113
114      */

115     private String JavaDoc keyEquivalent = null;
116     
117
118     /**
119
120      * This attribute is optional. The value is free choosable and is passed
121
122      * to the method as second parameter.
123
124      */

125     private String JavaDoc userData = null;
126     
127
128     /**
129
130      * This attribute is optional. It indicates the number of milliseconds
131
132      * Services should wait for a response from the application providing
133
134      * a service when a respond is required.
135
136      */

137     private String JavaDoc timeout = null;
138     
139
140     public void setPortName(String JavaDoc portName) {
141         this.portName = portName;
142     }
143     
144     public String JavaDoc getPortName() {
145         return portName;
146     }
147     
148     public void setMessage(String JavaDoc message) {
149         this.message = message;
150     }
151     
152     public String JavaDoc getMessage() {
153         return message;
154     }
155     
156     public void setMenuItem(String JavaDoc menuItem) {
157         this.menuItem = menuItem;
158
159     }
160     
161     public String JavaDoc getMenuItem() {
162         return menuItem;
163     }
164     
165     public void setSendTypes(String JavaDoc sendTypes) {
166         this.sendTypes = sendTypes.split("[\\s,]");
167     }
168     
169     public List JavaDoc getSendTypes() {
170         return (sendTypes == null) ? EMPTYLIST : Arrays.asList(sendTypes);
171     }
172     
173     public void setReturnTypes(String JavaDoc returnTypes) {
174         this.returnTypes = returnTypes.split("[\\s,]");
175     }
176     
177     public List JavaDoc getReturnTypes() {
178         return (returnTypes == null) ? EMPTYLIST : Arrays.asList(returnTypes);
179     }
180     
181     public void setKeyEquivalent(String JavaDoc keyEquivalent) {
182         this.keyEquivalent = keyEquivalent;
183     }
184     
185     public String JavaDoc getKeyEquivalent() {
186         return keyEquivalent;
187     }
188     
189     public void setUserData(String JavaDoc userData) {
190         this.userData = userData;
191     }
192     
193     public String JavaDoc getUserData() {
194         return userData;
195     }
196     
197     public void setTimeout(String JavaDoc timeout) {
198         this.timeout = timeout;
199     }
200     
201     public String JavaDoc getTimeout() {
202         return timeout;
203     }
204 }
205
Popular Tags