001: package net.sourceforge.jarbundler;
002:
003: import java.util.ArrayList;
004: import java.util.Arrays;
005: import java.util.List;
006:
007: /**
008: * Represents an Info.plist Service specifying a service provided by the application.
009: *
010: * Port Name - The name of the port the application monitors for incoming service requests.
011: *
012:
013: * Message - The name of the instance method to invoke for the service.
014: * In Objective-C, the instance method must be of the form messageName:userData:error:.
015: * In Java, the instance method must be of the form messageName(NSPasteBoard,String).
016: *
017: *
018: * Menu Item - The text to add to the Services menu. The value must be unique.
019: * You can use a slash character "/" to specify a submenu. For example, Mail/Send
020: * would appear in the Services Menu as a menu named Mail with an item named Send.
021: *
022: *
023: * Send Types - A list of the data type names that can be read by the service.
024: * The NSPasteboard class description lists several common data types.
025: *
026: *
027: * Return Types - A list of the data type names that can be returned by the service.
028: * The NSPasteboard class description lists several common data types.
029: * You must specify either Return Types, Send Types or both.
030: *
031: * You must specify either Send Types, Return Types or both.
032: *
033: *
034: * Key Equivalent - This attribute is optional. The keyboard equivalent used to invoke
035: * the service menu command. The value has to be a single character. Users invoke this
036: * keyboard equivalent by pressing the Command and Shift key modifiers along with the character.
037: *
038: *
039: * User Data - This attribute is optional. The value is free choosable and is passed
040: * to the method as second parameter.
041: *
042: *
043: * Timeout - This attribute is optional. It indicates the number of milliseconds
044: * Services should wait for a response from the application providing
045: * a service when a respond is required.
046: *
047: *
048: * <service portname="jarBundler"
049: * message="processRequest"
050: * menuitem="JarBundler/Process Request"
051: * sendtypes="NSStringPboardType,NSFilenamesPboardType"
052: * returntypes="NSStringPboardType"
053: * keyequivalent="p"
054: * userdata="a string passed to the method"
055: * timeout="5000" />
056: */
057: public class Service {
058: private static final List EMPTYLIST = new ArrayList(0);
059:
060: /** The name of the port the application monitors for incoming service requests. */
061: private String portName = null;
062:
063: /**
064:
065: * The name of the instance method to invoke for the service.
066: * In Objective-C, the instance method must be of the form messageName:userData:error:.
067:
068: * In Java, the instance method must be of the form messageName(NSPasteBoard,String).
069: */
070: private String message = null;
071:
072: /**
073:
074: * The text to add to the Services menu. The value must be unique.
075:
076: * You can use a slash character "/" to specify a submenu. For example, Mail/Send
077:
078: * would appear in the Services Menu as a menu named Mail with an item named Send.
079: */
080: private String menuItem = null;
081:
082: /**
083: * A list of the data type names that can be read by the service.
084:
085: * The NSPasteboard class description lists several common data types.
086:
087: * You must specify either Send Types, Return Types or both.
088: */
089: private String[] sendTypes = null;
090:
091: /**
092: * A list of the data type names that can be returned by the service.
093:
094: * The NSPasteboard class description lists several common data types.
095:
096: * You must specify either Return Types, Send Types or both.
097: */
098: private String[] returnTypes = null;
099:
100: /**
101: * This attribute is optional. The keyboard equivalent used to invoke
102:
103: * the service menu command. The value has to be a single character. Users invoke this
104:
105: * keyboard equivalent by pressing the Command and Shift key modifiers along with the character.
106:
107: */
108: private String keyEquivalent = null;
109:
110: /**
111:
112: * This attribute is optional. The value is free choosable and is passed
113:
114: * to the method as second parameter.
115:
116: */
117: private String userData = null;
118:
119: /**
120:
121: * This attribute is optional. It indicates the number of milliseconds
122:
123: * Services should wait for a response from the application providing
124:
125: * a service when a respond is required.
126:
127: */
128: private String timeout = null;
129:
130: public void setPortName(String portName) {
131: this .portName = portName;
132: }
133:
134: public String getPortName() {
135: return portName;
136: }
137:
138: public void setMessage(String message) {
139: this .message = message;
140: }
141:
142: public String getMessage() {
143: return message;
144: }
145:
146: public void setMenuItem(String menuItem) {
147: this .menuItem = menuItem;
148:
149: }
150:
151: public String getMenuItem() {
152: return menuItem;
153: }
154:
155: public void setSendTypes(String sendTypes) {
156: this .sendTypes = sendTypes.split("[\\s,]");
157: }
158:
159: public List getSendTypes() {
160: return (sendTypes == null) ? EMPTYLIST : Arrays
161: .asList(sendTypes);
162: }
163:
164: public void setReturnTypes(String returnTypes) {
165: this .returnTypes = returnTypes.split("[\\s,]");
166: }
167:
168: public List getReturnTypes() {
169: return (returnTypes == null) ? EMPTYLIST : Arrays
170: .asList(returnTypes);
171: }
172:
173: public void setKeyEquivalent(String keyEquivalent) {
174: this .keyEquivalent = keyEquivalent;
175: }
176:
177: public String getKeyEquivalent() {
178: return keyEquivalent;
179: }
180:
181: public void setUserData(String userData) {
182: this .userData = userData;
183: }
184:
185: public String getUserData() {
186: return userData;
187: }
188:
189: public void setTimeout(String timeout) {
190: this .timeout = timeout;
191: }
192:
193: public String getTimeout() {
194: return timeout;
195: }
196: }
|