refactor
This commit is contained in:
parent
ff3ed52c7d
commit
aa5585b812
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue