This commit is contained in:
Tienan Chen 2013-10-29 20:09:43 +08:00
parent ff3ed52c7d
commit aa5585b812
1 changed files with 7 additions and 22 deletions

View File

@ -53,8 +53,7 @@ public class ScriptCapturer {
public void startRecord(int port, String fileDir, String fileName) {
try {
HttpCapture httpCapture = getCaptureDealWithNull(port, fileDir,
fileName);
HttpCapture httpCapture = buildACapture(port, fileDir, fileName);
httpCapture.startProxyServer();
httpCapture.startRecording();
} catch (IOException e1) {
@ -66,17 +65,12 @@ public class ScriptCapturer {
}
}
private HttpCapture getCaptureDealWithNull(int port, String filePath,
String fileName) {
HttpCapture httpCapture = this.getHttpCaptureMap().get(
new Integer(port));
if (httpCapture == null) {
this.getHttpCaptureMap().put(
new Integer(port),
new HttpCapture(filePath, fileName, port,
HTTPCATUREGENERATOR_STRING, new JTextArea()));
}
return this.getHttpCaptureMap().get(new Integer(port));
private HttpCapture buildACapture(int port, String filePath, String fileName) {
return this.getHttpCaptureMap().put(
new Integer(port),
new HttpCapture(filePath, fileName, port,
HTTPCATUREGENERATOR_STRING, new JTextArea()));
}
public void stopCurrentRecord(int port) {
@ -95,13 +89,4 @@ public class ScriptCapturer {
e1.printStackTrace();
}
}
public String getScriptContent(int port) {
HttpCapture httpCapture = this.getHttpCaptureMap().get(
new Integer(port));
if (httpCapture == null) {
return null;
}
return httpCapture.getScriptContent();
}
}