001 package org.protocol; 002 003 import java.io.*; 004 import org.util.xml.element.*; 005 import org.util.xml.parse.*; 006 import org.util.xml.parse.policy.*; 007 008 public class SoccerServerProtocol { 009 010 BufferedWriter writer_; 011 BufferedReader reader_; 012 013 ElementParser parser_; 014 ParserPolicy parser_policy_; 015 ParserPolicy connect_; 016 ParserPolicy order_; 017 018 public SoccerServerProtocol(InputStream in, OutputStream out) throws Exception { 019 parser_ = new ElementParser(in); 020 // parser_.setPolicy(createParserPolicy()); 021 init(in, out); 022 } 023 public void init(InputStream in, OutputStream out) throws Exception { 024 // br_ = new BufferedReader(new InputStreamReader(in)); 025 // bw_ = new BufferedWriter(new OutputStreamWriter(out)); 026 } 027 public void start() { 028 029 } 030 public class createParserPolicy implements ParserPolicy { 031 public ParserPolicy getInnerPolicy(Element element) { 032 ParserPolicy connect; 033 ParserPolicy order; 034 TagElement tag = (TagElement)element; 035 /* 036 if(tag.getKey().equals("connect")) 037 return connect_; 038 if(tag.getKey().equals("order")) 039 return order_; 040 else 041 return this; 042 */ 043 return this; 044 } 045 public Element allowElement(Element element) { 046 System.out.println(); 047 return element; 048 } 049 public String selectEncoding(java.lang.String last_tag_key) { return "utf-8"; } 050 public boolean checkEndTag() { return true; } 051 public boolean throwExceptionIfDocumentHasError() { return true; } 052 public boolean forceEmptyTag(java.lang.String key) { return false; } 053 } 054 055 056 }