11package net .sf .j2s .ui .launching ;
22
3+ import java .io .BufferedReader ;
34import java .io .ByteArrayInputStream ;
45import java .io .ByteArrayOutputStream ;
56import java .io .File ;
910import java .io .FileOutputStream ;
1011import java .io .IOException ;
1112import java .io .InputStream ;
13+ import java .io .InputStreamReader ;
14+ import java .io .StringWriter ;
1215import java .net .MalformedURLException ;
1316import java .net .URL ;
17+ import java .util .HashMap ;
1418import java .util .HashSet ;
19+ import java .util .Map ;
1520import java .util .Properties ;
1621import java .util .Set ;
1722
18- import net .sf .j2s .core .astvisitors .ASTTigerVisitor ;
1923import net .sf .j2s .core .astvisitors .ASTTypeVisitor ;
2024import net .sf .j2s .core .astvisitors .DependencyASTVisitor ;
2125import net .sf .j2s .core .hotspot .InnerHotspotServer ;
@@ -614,7 +618,7 @@ public static void writeMainHTML(File file, String html) {
614618 /*
615619 * Append the *.js in classpath
616620 */
617- static String generateClasspathHTML (
621+ public static String generateClasspathHTML (
618622 ILaunchConfiguration configuration , String mainType , File workingDir )
619623 throws CoreException {
620624 StringBuffer buf = new StringBuffer ();
@@ -695,7 +699,7 @@ static String generateClasspathHTML(
695699 /*
696700 * Append the *.js in classpath
697701 */
698- static String generateClasspathJ2X (
702+ public static String generateClasspathJ2X (
699703 ILaunchConfiguration configuration , String varName , File workingDir )
700704 throws CoreException {
701705 boolean isUseGlobalURL = configuration .getAttribute (IJ2SLauchingConfiguration .USE_GLOBAL_ALAA_URL , false );
@@ -846,7 +850,7 @@ public boolean accept(File pathname) {
846850 /*
847851 * Append the *.js in classpath
848852 */
849- static String generateClasspathExistedClasses (
853+ public static String generateClasspathExistedClasses (
850854 ILaunchConfiguration configuration , String mainType , File workingDir , String indent )
851855 throws CoreException {
852856 boolean isUseGlobalURL = configuration .getAttribute (IJ2SLauchingConfiguration .USE_GLOBAL_ALAA_URL , false );
@@ -1020,7 +1024,7 @@ static String generateClasspathExistedClasses (
10201024 /*
10211025 * To generate ClazzLoader.ignore (...)
10221026 */
1023- static String generateClasspathIgnoredClasses (
1027+ public static String generateClasspathIgnoredClasses (
10241028 ILaunchConfiguration configuration , String mainType , File workingDir , String indent )
10251029 throws CoreException {
10261030 StringBuffer buf = new StringBuffer ();
@@ -1183,7 +1187,7 @@ public static String readAFile(InputStream res) {
11831187 return null ;
11841188 }
11851189
1186- static File getWorkingDirectory (ILaunchConfiguration configuration )
1190+ public static File getWorkingDirectory (ILaunchConfiguration configuration )
11871191 throws CoreException {
11881192 File workingDir = null ;
11891193 String path = configuration .getAttribute (
@@ -1234,7 +1238,7 @@ static File getWorkingDirectory(ILaunchConfiguration configuration)
12341238 return workingDir ;
12351239 }
12361240
1237- static String getMainType (ILaunchConfiguration configuration )
1241+ public static String getMainType (ILaunchConfiguration configuration )
12381242 throws CoreException {
12391243 String mainType ;
12401244 mainType = configuration .getAttribute (
@@ -1247,4 +1251,41 @@ static String getMainType(ILaunchConfiguration configuration)
12471251 .performStringSubstitution (mainType );
12481252 return mainType ;
12491253 }
1254+
1255+
1256+ //added by sgurin for template support:
1257+ public static void readString (InputStream in , StringWriter w ) throws IOException {
1258+ BufferedReader br = new BufferedReader (new InputStreamReader (in ));
1259+ String line = null ;
1260+ while ((line = br .readLine ()) != null ) {
1261+ w .append (line + "\n " );
1262+ }
1263+ br .close ();
1264+ }
1265+
1266+ public static Map toMap (Object []a ) {
1267+ Map m = new HashMap ();
1268+ for (int i = 0 ; i < a .length -1 ; i =i +2 )
1269+ m .put (a [i ], a [i +1 ]);
1270+ return m ;
1271+ }
1272+
1273+ public static String inputStreamAsString (InputStream in )
1274+ throws IOException {
1275+ BufferedReader br = new BufferedReader (new InputStreamReader (in ));
1276+ StringBuilder sb = new StringBuilder ();
1277+ String line = null ;
1278+ while ((line = br .readLine ()) != null ) {
1279+ sb .append (line + "\n " );
1280+ }
1281+ br .close ();
1282+ return sb .toString ();
1283+ }
1284+
1285+ public static boolean arrayContains (Object [] a , Object o ) {
1286+ for (int i = 0 ; i < a .length ; i ++)
1287+ if (a [i ].equals (o ))
1288+ return true ;
1289+ return false ;
1290+ }
12501291}
0 commit comments