]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/java/org/opensrf/Method.java
LP1827055 Remove Python libs, install bits, and docs
[OpenSRF.git] / src / java / org / opensrf / Method.java
1 package org.opensrf;
2 import java.util.List;
3 import java.util.ArrayList;
4 import org.opensrf.util.*;
5
6
7 public class Method extends OSRFObject {
8
9     /** The method API name */
10     private String name;
11     /** The ordered list of method params */
12     private List<Object> params;
13
14     /** Create a registry for the osrfMethod object */
15     private static OSRFRegistry registry = 
16         OSRFRegistry.registerObject(
17             "osrfMethod", 
18             OSRFRegistry.WireProtocol.HASH, 
19             new String[] {"method", "params"});
20
21     /**
22      * @param name The method API name 
23      */
24     public Method(String name) {
25         this.name = name;
26         this.params = new ArrayList<Object>(8);
27     }
28
29     /**
30      * @param name The method API name
31      * @param params The ordered list of params
32      */
33     public Method(String name, List<Object> params) {
34         this.name = name;
35         this.params = params;
36     }
37
38     /**
39      * @return The method API name
40      */
41     public String getName() {
42         return name;
43     }
44     /**
45      * @return The ordered list of params
46      */
47     public List<Object> getParams() {
48        return params; 
49     }
50
51     /**
52      * Pushes a new param object onto the set of params 
53      * @param p The new param to add to the method.
54      */
55     public void addParam(Object p) {
56         this.params.add(p);
57     }
58
59     /**
60      * Implements the generic get() API required by OSRFSerializable
61      */
62     public Object get(String field) {
63         if("method".equals(field))
64             return getName();
65         if("params".equals(field))
66             return getParams();
67         return null;
68     }
69
70     /**
71      * @return The osrfMethod registry.
72      */
73     public OSRFRegistry getRegistry() {
74         return registry;
75     }
76
77 }
78