View Javadoc

1   package org.dbe.studio.tools.sdlCompiler2Java;
2   
3   import org.eclipse.core.runtime.Platform;
4   import org.eclipse.core.runtime.preferences.IPreferencesService;
5   
6   
7   public class Sdl2JavaProps {
8   	
9   //	public static String Declar = "#\n" + 
10  //	                              "# deployment.props - Application deployment descriptor\n" + 
11  //	                              "#\n";
12  	public static String Entries = "#\n" + 
13                                     "# Emtries\n" + 
14                                     "#\n";
15  	public static String Param = "#\n" + 
16                                   "# Application parameters\n" + 
17                                   "#\n";
18  	
19  	/***
20  	 * 
21  	 * @param String javaFile
22  	 * @return String deployment props
23  	 */
24  	public static String getPropFile(String javaFile){
25  		String applicationName = null;
26  		int plus = 0;
27          int i = javaFile.toLowerCase().indexOf("interface ");
28  		plus = "interface ".length();
29  		if (i != -1)
30          {
31              int q = i + plus;
32              for (q = i + plus; q < javaFile.length(); q++)
33              {
34                  char c = javaFile.charAt(q);
35  
36                  if (!Character.isWhitespace(c))
37                      break;
38              }
39  
40              int w;
41              for (w = q + 1; w < javaFile.length(); w++)
42              {
43                  char c = javaFile.charAt(w);
44  
45                  if (Character.isWhitespace(c))
46                      break;
47              }
48  		applicationName = javaFile.substring(q,w).trim() ;
49          }
50  		
51  		//take the package name from preferences page
52  		Pack p = new Pack();
53          IPreferencesService service = Platform.getPreferencesService();
54  		try {
55  			p.setPack(service.getString("org.dbe.studio.tools.sdl2java", Sdl2JavaMessages.PREF_DEFAULT_NAMESPACE_KEY, Sdl2JavaMessages.PREF_DEFAULT_NAMESPACE_VALUE, null));
56  		}
57  		catch ( Exception ignored ) {
58  		}
59  		
60  		//check the valability of the namespace from preferences page
61  		String packName = Sdl2Java.validateNamespace(p);
62  		
63  		String adapterName = applicationName.replaceAll("Service","")+"Adapter";
64  		adapterName = packName + "." + applicationName.replaceAll("Service","").toLowerCase() + "." + adapterName;
65  		
66  		// the main String that contain all the props for the Generated Service
67  		String depProps = //Declar + "\n" +  
68  		                  "applicationName=" + applicationName + "\n" + 
69  		                  "adapter=" + adapterName + "\n" + 
70  		                  "proxy=" + "\n" + 
71  		                  "codebase=/lib/codebase.jar" + "\n" + "\n" +
72  		                  Entries +  
73  		                  "entries=one" + "\n" +
74  		                  "one=" +  applicationName.replaceAll("Service","").toLowerCase() + "\n" + "\n" +
75  		                  Param + "\n"
76  		                  ;
77  		return depProps;
78  	}
79  }