Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/remote/script/ScriptableFrameBeanInfo.java


1   /*
2    * ScriptableFrameBeanInfo.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:36 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.remote.script;
12  
13  import java.beans.IntrospectionException;
14  import java.beans.MethodDescriptor;
15  import java.beans.ParameterDescriptor;
16  import java.beans.SimpleBeanInfo;
17  import java.lang.reflect.Method;
18  
19  public class ScriptableFrameBeanInfo extends SimpleBeanInfo
20  {
21    /**
22     * A method descriptor used by AppleScript for Java's introspector to generate the aete
23     * This descriptor describes the parameters and method to be published in the aete and
24     * overrides the default generated values
25     */
26    public MethodDescriptor[] getMethodDescriptors()  
27    {
28      MethodDescriptor md[] = new MethodDescriptor[25];  // the method descriptor provides 
29                                // extra information to the introspector
30      try
31      {
32        /** Creating a parameter descriptor allows you to specify a formal name in the terminology
33          * for the paramter(s) of a method. In this instance, you will be able to write:
34          *
35          * Get Next File of <object> from "<atype>"
36          * 
37          * instead of:
38          * 
39          *  Get Next File of <object> parameters { "<atype>" }
40          * 
41          */
42  
43  // GetNextFile
44        md[0] = new MethodDescriptor( getMethod( ScriptableFrame.class, "GetNextFile" )) ;
45        md[0].setShortDescription( "Sets the next Asset in the list to the current Asset, and returns it's filename."
46              + "This can be used as a shortcut for SelectNextAsset(); GetFileName();" );
47  // GetFileName
48        md[1] = new MethodDescriptor( getMethod( ScriptableFrame.class, "GetFileName" )) ;
49        md[1].setShortDescription( "Returns the filename for the current Asset" );      
50  // SelectNextAsset
51           md[2] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SelectNextAsset" )) ;
52        md[2].setShortDescription( "Updates ImportData with the current Child Assets Data,"
53              + "\r then sets the next Asset in the list to the current Asset"
54              + "\rReturns true if succesful false if it fails");      
55  // addChildAsset
56           md[3] = new MethodDescriptor( getMethod( ScriptableFrame.class, "addChildAsset" )) ;
57        md[3].setShortDescription( "Creates a new DisguiseAssetRecordData object, and adds it to the currentAsset as a child."
58              + "\rReturns true if succesful false if it fails");  
59  // addData
60           ParameterDescriptor[] pd0 = new ParameterDescriptor[1];
61        pd0[0] = new ParameterDescriptor();
62        pd0[0].setShortDescription( "A key value pair. IE: filename=aFile.TIF" );
63        pd0[0].setName( "with" );
64           md[4] = new MethodDescriptor( getMethod( ScriptableFrame.class, "addData" ), pd0) ;
65        md[4].setShortDescription( "Sets the value specified for the Asset field (key) specified."
66              + "\rReturns true if succesful false if it fails" );  
67  // getValueAsString
68           ParameterDescriptor[] pd1 = new ParameterDescriptor[1];
69        pd1[0] = new ParameterDescriptor();
70        pd1[0].setShortDescription( "The key for which the value is needed. IE: roleid, filename" );
71        pd1[0].setName( "using" );
72           md[5] = new MethodDescriptor( getMethod( ScriptableFrame.class, "getValueAsString" ), pd1) ;
73        md[5].setShortDescription( "Returns the value stored in the currentData for the given key" );  
74  // getValueAsInteger
75           ParameterDescriptor[] pd2 = new ParameterDescriptor[1];
76        pd2[0] = new ParameterDescriptor();
77        pd2[0].setShortDescription( "The key for which the value is needed. IE: width, height" );
78        pd2[0].setName( "using" );
79           md[6] = new MethodDescriptor( getMethod( ScriptableFrame.class, "getValueAsInteger" ), pd2) ;
80        md[6].setShortDescription( "Returns the value requested as an integer, if it cannot be converted -1 is returned." );  
81  // writeToErrorlog
82           ParameterDescriptor[] pd3 = new ParameterDescriptor[1];
83        pd3[0] = new ParameterDescriptor();
84        pd3[0].setShortDescription( "a string - The text to be written to the logs" );
85        pd3[0].setName( "with" );
86        md[7] = new MethodDescriptor( getMethod( ScriptableFrame.class, "writeToErrorlog" ), pd3) ;
87        md[7].setShortDescription( "Writes text to output console, debug log,"
88                 + " and to the FlexDBServer error log.");      
89  // SelectAssetByPath
90           ParameterDescriptor[] pd4 = new ParameterDescriptor[1];
91        pd4[0] = new ParameterDescriptor();
92        pd4[0].setShortDescription( "The name of the file you wish to access the Asset for." );
93        pd4[0].setName( "using" );
94           md[8] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SelectAssetByPath" ), pd4) ;
95        md[8].setShortDescription( "Updates ImportData with the current Child Assets Data,"
96              + "\rthen sets the currentAsset to the one specified by the value passed in.  The value passed in should be in the following format <servername>:<absolutepath><filename>"
97              + "\rReturns true if succesful false if it fails" );  
98  // completeUpdate
99           md[9] = new MethodDescriptor( getMethod( ScriptableFrame.class, "completeUpdate" )) ;
100       md[9].setShortDescription( "Completes the update process by sending the data for the current Child Asset,"
101             + "\r and setting things up to send it all back from whence it came."
102             + "\rThis should be used when your service is finished updating the ImportData Object."
103             + "\rReturns true if succesful false if it fails");  
104             
105 // getCTLOptions
106          md[10] = new MethodDescriptor( getMethod( ScriptableFrame.class, "getCTLOptions" )) ;
107       md[10].setShortDescription( "Gets the [options] section of the .ctl file, and returns it as an array of strings." );  
108 
109 // getNumberOfAssets
110          md[11] = new MethodDescriptor( getMethod( ScriptableFrame.class, "GetNumberOfAssets" )) ;
111       md[11].setShortDescription( "Returns the number of Assets to be processed." );
112 // makeChildCurrent
113          md[12] = new MethodDescriptor( getMethod( ScriptableFrame.class, "makeChildCurrent" )) ;
114       md[12].setShortDescription( "After updating ImportData with the currentData,"
115             + "\rThe currentChild Asset (created by calling addChildAsset) is set to be the currentAsset."
116             + "This is done to create children of children, so addChildAsset is usually called after this." );
117 // logDebugMessage
118          ParameterDescriptor[] pd5 = new ParameterDescriptor[1];
119       pd5[0] = new ParameterDescriptor();
120       pd5[0].setShortDescription( "a string - The text to be written to the log - <your script name>.log" );
121       pd5[0].setName( "with" );
122       md[13] = new MethodDescriptor( getMethod( ScriptableFrame.class, "logDebugMessage" ), pd5) ;
123       md[13].setShortDescription( "When debug is enabled in services.config [Archive] section"
124             + "\rYour applescript may call this method to make entries in the debug log - <your script name>.log" 
125             + "\rThis text does NOT show up in the console window.");      
126 
127 
128 
129 
130 // GetServerName
131          md[14] = new MethodDescriptor( getMethod( ScriptableFrame.class, "GetServerName" )) ;
132       md[14].setShortDescription( "Returns the name of the server for the current Asset."
133             + "\rDEPRECATED - Use getValueAsString.  IE: get Value As String of Frame theFrame using \"server\"");
134 // SetFileName
135          ParameterDescriptor[] pd6 = new ParameterDescriptor[1];
136       pd6[0] = new ParameterDescriptor();
137       pd6[0].setShortDescription( "The filename of the file you want this child asset to represent (filename only)" );
138       pd6[0].setName( "to" );
139       md[15] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SetFileName" ), pd6) ;
140       md[15].setShortDescription( "Set the filename for the current Child Asset."
141             + "Returns true if succesful false if it fails"
142             + "\rThis method has been DEPRECATED, use addData instead IE: add Data of Frame theFrame using \"filename=aFile.TIF\"");
143 
144 // SetImageType
145          ParameterDescriptor[] pd7 = new ParameterDescriptor[1];
146       pd7[0] = new ParameterDescriptor();
147       pd7[0].setShortDescription( "DEPRECATED" );
148       pd7[0].setName( "to" );
149       md[16] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SetImageType" ), pd7) ;
150       md[16].setShortDescription( "Returns true if succesful false if it fails"
151             + "DEPRECATED: Use addData and pass in the role ID of the Role you want the new Child asset to have. IE: add Data of Frame theFrame using \"roleid=3\" (3 is for thumbnail)" );      
152 // SetXRes
153          ParameterDescriptor[] pd8 = new ParameterDescriptor[1];
154       pd8[0] = new ParameterDescriptor();
155       pd8[0].setShortDescription( "The XResolution of the file." );
156       pd8[0].setName( "to" );
157       md[17] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SetXRes" ), pd8) ;
158       md[17].setShortDescription( "Sets the XRes value for the current Child Asset"
159             + "\rDEPRECATED: Use addData instead. IE: add Data of Frame theFrame using \"xres=100\"" );
160 //SetYRes
161          ParameterDescriptor[] pd9 = new ParameterDescriptor[1];
162       pd9[0] = new ParameterDescriptor();
163       pd9[0].setShortDescription( "The YResolution of the file." );
164       pd9[0].setName( "to" );
165       md[18] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SetYRes" ), pd9) ;
166       md[18].setShortDescription( "Sets the YRes value for the current Child Asset."
167             + "\rReturns true if succesful false if it fails"
168             + "\rDEPRECATED: Use addData instead. IE: add Data of Frame theFrame using \"yres=100\"" );    
169 // SetWidth
170          ParameterDescriptor[] pd10 = new ParameterDescriptor[1];
171       pd10[0] = new ParameterDescriptor();
172       pd10[0].setShortDescription( "The Width of the file." );
173       pd10[0].setName( "to" );
174       md[19] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SetWidth" ), pd10) ;
175       md[19].setShortDescription( "Sets the Width value for the current Child Asset."
176             + "\rReturns true if succesful false if it fails"
177             + "\rDEPRECATED: Use addData instead. IE: add Data of Frame theFrame using \"width=100\"" );      
178 // SetHeight
179          ParameterDescriptor[] pd11 = new ParameterDescriptor[1];
180       pd11[0] = new ParameterDescriptor();
181       pd11[0].setShortDescription( "The Height of the file." );
182       pd11[0].setName( "to" );
183       md[20] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SetHeight" ), pd11) ;
184       md[20].setShortDescription( "Sets the Height value for the current Child Asset."
185             + "\rReturns true if succesful false if it fails"
186             + "\rDEPRECATED: Use addData instead. IE: add Data of Frame theFrame using \"height=100\"" );      
187 // SetFileSize
188          ParameterDescriptor[] pd12 = new ParameterDescriptor[1];
189       pd12[0] = new ParameterDescriptor();
190       pd12[0].setShortDescription( "The size of the file." );
191       pd12[0].setName( "to" );
192       md[21] = new MethodDescriptor( getMethod( ScriptableFrame.class, "SetFileSize" ), pd12) ;
193       md[21].setShortDescription( "Sets the FileSize value for the current Child Asset."
194             + "\rReturns true if succesful false if it fails"
195             + "\rDEPRECATED: Use addData instead. IE: add Data of Frame theFrame using \"filesize=100\"" );      
196 
197 // deleteCurrentAsset
198          md[22] = new MethodDescriptor( getMethod( ScriptableFrame.class, "deleteCurrentAsset" )) ;
199       md[22].setShortDescription( "Deletes the current 'in' asset, and sets both the current asset"
200             + "\rand the current 'out' asset to null");
201       
202 // deleteCurrentOutAsset
203          md[23] = new MethodDescriptor( getMethod( ScriptableFrame.class, "deleteCurrentOutAsset" )) ;
204       md[23].setShortDescription( "Deletes the current 'out' asset, and sets current 'out' to the current asset");
205 
206 // writeToConsole
207          ParameterDescriptor[] pd13 = new ParameterDescriptor[1];
208       pd13[0] = new ParameterDescriptor();
209       pd13[0].setShortDescription( "a string - The text to be written to the log - <your script name>.log" );
210       pd13[0].setName( "with" );
211       md[24] = new MethodDescriptor( getMethod( ScriptableFrame.class, "writeToConsole" ), pd13) ;
212       md[24].setShortDescription( "Allows applescripts to write text to the output console of the Remote Asset Server."
213                + "This text also gets written to the debug log");      
214 
215 // closeWindow
216          //md[23] = new MethodDescriptor( getMethod( ScriptableFrame.class, "closeWindow" )) ;
217       //md[23].setShortDescription( "Closes the Frame created for you script" );      
218          //md[23].setName("Object");
219       return md;
220     }
221     catch ( IntrospectionException e )
222     {
223       e.printStackTrace();
224     }
225     return null;
226   }
227 
228   /**
229    * getMethod is called by the introspector to return a list of methods in the class
230    */
231   Method getMethod( Class c, String methodName )  throws IntrospectionException
232   {
233     Method methods[] = c.getMethods();
234     
235     for ( int i = 0; i < methods.length; i++ )
236     {
237       if ( methods[i].getName().equals( methodName )) 
238       {
239         return methods[i];
240       }
241     }
242     throw new IntrospectionException( "No such method \"" + methodName + "\"" );
243   }
244 }