PageRenderTime 87ms CodeModel.GetById 79ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/net/sourceforge/jarbundler/Service.java

#
Java | 204 lines | 63 code | 37 blank | 104 comment | 2 complexity | aa1cf86da8865d71ee039ff9f4edab9a MD5 | raw file
  1package net.sourceforge.jarbundler;
  2
  3import java.util.ArrayList;
  4import java.util.Arrays;
  5import java.util.List;
  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 */
 59public class Service {
 60	private static final List EMPTYLIST = new ArrayList(0);
 61
 62	
 63	/** The name of the port the application monitors for incoming service requests. */
 64	private String 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 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 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[] 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[] 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 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 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 timeout = null;
138	
139
140	public void setPortName(String portName) {
141		this.portName = portName;
142	}
143	
144	public String getPortName() {
145		return portName;
146	}
147	
148	public void setMessage(String message) {
149		this.message = message;
150	}
151	
152	public String getMessage() {
153		return message;
154	}
155	
156	public void setMenuItem(String menuItem) {
157		this.menuItem = menuItem;
158
159	}
160	
161	public String getMenuItem() {
162		return menuItem;
163	}
164	
165	public void setSendTypes(String sendTypes) {
166		this.sendTypes = sendTypes.split("[\\s,]");
167	}
168	
169	public List getSendTypes() {
170		return (sendTypes == null) ? EMPTYLIST : Arrays.asList(sendTypes);
171	}
172	
173	public void setReturnTypes(String returnTypes) {
174		this.returnTypes = returnTypes.split("[\\s,]");
175	}
176	
177	public List getReturnTypes() {
178		return (returnTypes == null) ? EMPTYLIST : Arrays.asList(returnTypes);
179	}
180	
181	public void setKeyEquivalent(String keyEquivalent) {
182		this.keyEquivalent = keyEquivalent;
183	}
184	
185	public String getKeyEquivalent() {
186		return keyEquivalent;
187	}
188	
189	public void setUserData(String userData) {
190		this.userData = userData;
191	}
192	
193	public String getUserData() {
194		return userData;
195	}
196	
197	public void setTimeout(String timeout) {
198		this.timeout = timeout;
199	}
200	
201	public String getTimeout() {
202		return timeout;
203	}
204}