import java.applet.*; import java.net.*; import java.io.*; import java.util.*; import java.text.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.html.*; import javax.swing.text.*; import javax.swing.text.html.parser.*; import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLEditorKit.Parser; import javax.swing.text.html.HTMLEditorKit.ParserCallback; public class AgetTeamArr11 extends JApplet { static String OffStg = "Offense"; static String VwStg = "Views:"; static String PosStg = "POS"; static String TTxt, TTxt2, TTxtAll; static String[] outArr, outArrAll; static int[] PosInt = {0, 0, 0, 0}; static boolean tstbool = false; static Reader reader; //static String TL_propsfile = "FFL_TeamList4.properties"; static Properties TL_props = new Properties (); //static String TP_propsfile = "TeamPlayer.properties"; static Properties TP_props = new Properties (); static String TL_prop_val, newInFile, newOutFile, Def_nRFile, Off_nRFile; static URL baseAddress; static String LivePage_PropFile; static String TeamPlayer_PropFile; static String[] OffArr = {"","","","","","","","","","","","","","","","","","","",""}; static String[] KkrArr = {"","","","","","","","","","","","","","","","","","","",""}; static String[] DefArr = {"","","","","","","","","","","","","","","","","","","",""}; public String[] getTeamStgArr() { LivePage_PropFile = getParameter("LivePagePropFile"); //System.out.println("TP_propsfile: " + TP_propsfile); try { TP_props.load(new BufferedInputStream(new FileInputStream("LivePage_PropFile"))); outArrAll = new String[TP_props.size()]; System.out.println("TP_props.size(): " + TP_props.size()); for (int n = 0; n < TP_props.size(); n++) { outArrAll[n] = TP_props.getProperty("TeamPlayer." + n); } return outArrAll; } catch ( IOException e) {System.out.println("No Props File");} try { FileInputStream fileStream = new FileInputStream ("TeamPlayer_PropFile"); TL_props.load(fileStream); fileStream.close(); } catch (IOException x) { System.out.println("Exception: " + x); } String[] TL_prop_val = new String[TL_props.size()]; for (int n = 0; n < TL_props.size(); n++) { TL_prop_val[n] = TL_props.getProperty("TeamList." + n); TLrun( TL_prop_val[n] ); TTxtAll = TTxtAll + TTxt2; } stgToArray staT = new stgToArray(); outArrAll = staT.stringToArray(TTxtAll); return outArrAll; } public void TLrun( String IOFile ) { String IOFileOrig = IOFile; if (IOFile.indexOf('/')>-1) IOFile = IOFile.substring( IOFile.lastIndexOf( '/' ) + 1, IOFile.length() ); if (IOFile.indexOf('\\')>-1) IOFile = IOFile.substring( IOFile.lastIndexOf( '\\' ) + 1, IOFile.length() ); String IOFileHTM = IOFile; if (IOFile.indexOf(".htm")>-1) IOFile = IOFile.substring( 0, IOFile.indexOf(".htm") ); String newInFile = IOFile; String newOutFile = IOFile+".txt"; TTxt = "";TTxt2 = ""; HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback () { public void handleText(char[] text, int pos) { String outText = new String(text); if ( outText.indexOf(OffStg) >= 0 ) { tstbool = true; } else if ( outText.indexOf(VwStg) >= 0) { tstbool = false; } if (tstbool) { TTxt = TTxt + outText + "\n"; } } }; try { if (IOFileOrig.indexOf("://")>-1) { baseAddress = new URL(IOFileOrig); URLConnection uc = baseAddress.openConnection(); InputStream content = (InputStream)uc.getInputStream(); reader = new BufferedReader (new InputStreamReader (content)); } else { reader = new FileReader(IOFileOrig); } // Trick to use Swing's HTML parser Parser parser = (new HTMLEditorKit() { public Parser getParser() { return super.getParser(); } }).getParser(); parser.parse(reader, callback, true); stgToArray sta = new stgToArray(); outArr = sta.stringToArray(TTxt); int PosCnt = 0; for (int j = 0; j < outArr.length; j++) { if ( outArr[j].indexOf(PosStg) >= 0) { PosInt[PosCnt] = j; PosCnt++; } } int ComCnt = 0; for (int k = PosInt[0]; k < PosInt[1]; k++) { if ( outArr[k].indexOf(",") >= 0 && outArr[k].indexOf("(") == -1 ) { if ( outArr[k+1].indexOf("(") >= 0 && outArr[k+1].indexOf(")") >= 0 ) { OffArr[ComCnt]=IOFile+"|Off:"+outArr[k]+"|"+outArr[k+1]; } else if ( outArr[k+2].indexOf("(") >= 0 && outArr[k+2].indexOf(")") >= 0 ) { OffArr[ComCnt]=IOFile+"|Off:"+outArr[k]+"|"+outArr[k+2]; } else if ( outArr[k+3].indexOf("(") >= 0 && outArr[k+3].indexOf(")") >= 0 ) { OffArr[ComCnt]=IOFile+"|Off:"+outArr[k]+"|"+outArr[k+3]; } else if ( outArr[k+4].indexOf("(") >= 0 && outArr[k+4].indexOf(")") >= 0 ) { OffArr[ComCnt]=IOFile+"|Off:"+outArr[k]+"|"+outArr[k+4]; } else { OffArr[ComCnt]=IOFile+"|Off:"+outArr[k]+"|NoTeam"; } TTxt2=TTxt2+OffArr[ComCnt]+"\n"; ComCnt++; } } ComCnt = 0; for (int l = PosInt[1]; l < PosInt[2]; l++) { if ( outArr[l].indexOf(",") >= 0 && outArr[l].indexOf("(") == -1 ) { if ( outArr[l+1].indexOf("(") >= 0 && outArr[l+1].indexOf(")") >= 0 ) { KkrArr[ComCnt]=IOFile+"|Kkr:"+outArr[l]+"|"+outArr[l+1]; } else if ( outArr[l+2].indexOf("(") >= 0 && outArr[l+2].indexOf(")") >= 0 ) { KkrArr[ComCnt]=IOFile+"|Kkr:"+outArr[l]+"|"+outArr[l+2]; } else if ( outArr[l+3].indexOf("(") >= 0 && outArr[l+3].indexOf(")") >= 0 ) { KkrArr[ComCnt]=IOFile+"|Kkr:"+outArr[l]+"|"+outArr[l+3]; } else if ( outArr[l+4].indexOf("(") >= 0 && outArr[l+4].indexOf(")") >= 0 ) { KkrArr[ComCnt]=IOFile+"|Kkr:"+outArr[l]+"|"+outArr[l+4]; } else { KkrArr[ComCnt]=IOFile+"|Kkr:"+outArr[l]+"|NoTeam"; } TTxt2=TTxt2+KkrArr[ComCnt]+"\n"; ComCnt++; } } ComCnt = 0; for (int m = PosInt[2]; m < outArr.length; m++) { if ( outArr[m].indexOf(",") >= 0 && outArr[m].indexOf("(") == -1 ) { if ( outArr[m+1].indexOf("(") >= 0 && outArr[m+1].indexOf(")") >= 0 ) { DefArr[ComCnt]=IOFile+"|Def:"+outArr[m]+"|"+outArr[m+1]; } else if ( outArr[m+2].indexOf("(") >= 0 && outArr[m+2].indexOf(")") >= 0 ) { DefArr[ComCnt]=IOFile+"|Def:"+outArr[m]+"|"+outArr[m+2]; } else if ( outArr[m+3].indexOf("(") >= 0 && outArr[m+3].indexOf(")") >= 0 ) { DefArr[ComCnt]=IOFile+"|Def:"+outArr[m]+"|"+outArr[m+3]; } else if ( outArr[m+4].indexOf("(") >= 0 && outArr[m+4].indexOf(")") >= 0 ) { DefArr[ComCnt]=IOFile+"|Def:"+outArr[m]+"|"+outArr[m+4]; } else { DefArr[ComCnt]=IOFile+"|Def:"+outArr[m]+"|NoTeam"; } TTxt2=TTxt2+DefArr[ComCnt]+"\n"; ComCnt++; } } } catch (MalformedURLException e) { System.out.println("Bad url: "+e+"\n"); } catch (IOException ie) { System.out.println("Bad io: "+ie+"\n"); } } }