import java.io.*; import java.text.Format; import java.util.*; import java.sql.*; import java.net.*; import java.util.zip.*; public class Tool { public static char choose(String msg, String choices, String def) throws IOException { while(true) { System.out.print(msg); String ans=new BufferedReader(new InputStreamReader(System.in)).readLine(); if(ans.length()==0) { if(def.length()==0) continue; return def.toUpperCase().charAt(0); } else if(choices.indexOf(ans.toUpperCase().charAt(0))>=0) return ans.toUpperCase().charAt(0); } } public static Vector parseQuotes(String s) { Vector V=new Vector(); if((s==null)||(s.length()==0)) return V; int x=s.indexOf("\""); while(x>=0) { if((x==0)||(s.charAt(x-1)=='\\')) x=s.indexOf("\"",x+1); else { String s2=null; if(s.startsWith("\"")) { s2=s.substring(0,x+1); s=s.substring(x+1); } else { s2=s.substring(0,x); s=s.substring(x); } if(s2.length()>0) V.addElement(s2); x=s.indexOf("\""); } } if(s.trim().length()>0) V.addElement(s.trim()); return V; } public static void dodir(String dir) throws IOException { File DIR=new File(dir); if(!DIR.isDirectory()) { System.out.println(dir+" is not a directory!"); return;} System.out.println("New Directory: "+DIR.getName()+"."); char c=choose("P)rocess, S)kip, or C)ancel (RETURN=P):","PSC","P"); if(c=='C') throw new IOException("Cancelled By User"); if(c=='S') return; String[] files=DIR.list(); for(int f=0;f=0)&&(end>start)&&(line.substring(start+6,end).indexOf("getScr(")<0)) { start+=len; Vector V=parseQuotes(line.substring(start,end)); StringBuffer newBuf=new StringBuffer(""); if((V.size()>0)&&(line.substring(start).startsWith(".tell("))); { String s=(String)V.firstElement(); if(s.endsWith(",")) { start+=s.length(); V.removeElementAt(0); } } boolean noQuotes=true; for(int i=0;i=0) noQuotes=false; if(noQuotes) continue; Vector TV=new Vector(); for(int v=0;v2)) newBuf.append(s.substring(1,s.length()-1)); else { if(s.startsWith("+")) s=s.substring(1); if(s.endsWith("+")) s=s.substring(0,s.length()-1); newBuf.append("@x"+(TV.size()+1)); TV.addElement(s); } } String newLine1=line.substring(0,start)+"getScr(\""+F.getName().substring(0,F.getName().length()-5)+"\",\""; String newLine2="\""; for(int i=0;i=0)) { tagName=new BufferedReader(new InputStreamReader(System.in)).readLine(); if(tagName.length()==0) { System.out.println("Cancelled."); break; } else if(!tagNamesUsed.contains(tagName.toUpperCase())&&(tagName.indexOf(" ")<0)) { FV.addElement(tagName+"="+newBuf.toString()); bufV.setElementAt(newLine1.toString()+tagName+newLine2.toString(),b); } } } else { start=line.indexOf("private String[] access={"); end=line.lastIndexOf("};"); if((start>=0)&&(end>start)&&(line.substring(start,end).indexOf("getScr(")<0)) { start+=25; Vector V=parseQuotes(line.substring(start,end)); Vector TV=new Vector(); for(int v=0;v0)?(""+i):"")+"\")"; if((i<(TV.size()-1))) newLine+=","; } newLine+=line.substring(end); System.out.println(""); System.out.println(line.trim()); System.out.println((newLine.toString()).trim()); String resp=null; while(resp==null) { System.out.print("Does this look OK? (Y/N)?"); resp=new BufferedReader(new InputStreamReader(System.in)).readLine(); if((!resp.toUpperCase().equals("Y"))&&(!resp.toUpperCase().equals("Y"))) resp=null; } if((resp!=null)&&(resp.toUpperCase().equalsIgnoreCase("Y"))) { for(int i=0;i0)?(""+i):"")+"="+(String)TV.elementAt(i)); bufV.setElementAt(newLine.toString(),b); } } } } System.out.println(""); if(FV.size()>0) { buf=new StringBuffer(""); for(int i=0;i0) V.addElement(str.toString()); return V; } public static int[] makeInt(int i) { int[] ii=new int[1]; ii[0]=i; return ii; } public static boolean saveFile(String filename, StringBuffer myRsc) { if(myRsc==null) { return false; } try { File F=new File(filename); FileWriter FW=new FileWriter(F); FW.write(myRsc.toString()); FW.close(); return true; } catch(IOException e) { System.out.println(filename+": "+e.getMessage()); } return false; } public static void main(String[] args) { try { Tool.dodir("."); } catch(Exception e){e.printStackTrace();} } }