Package strategy
Class FileLog
- java.lang.Object
-
- strategy.FileLog
-
- All Implemented Interfaces:
FileHandler
public class FileLog extends java.lang.Object implements FileHandler
Class that is responsible to save and parse log of executed commands.
-
-
Field Summary
Fields Modifier and Type Field Description private DrawingControllercontrollerprivate DrawingFrameframeprivate DlgLogParserlogParserprivate DrawingModelmodelprivate java.io.BufferedReaderreaderprivate java.io.BufferedWriterwriter
-
Constructor Summary
Constructors Constructor Description FileLog(DrawingFrame frame, DrawingModel model, DrawingController controller)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidopen(java.io.File file)Open forwarded log file and execute it command by command in interaction with user.private CircleparseCircle(java.lang.String string)Method that parseCirclefrom log file.private HexagonAdapterparseHexagon(java.lang.String string)Method that parseHexagonAdapterfrom log file.private LineparseLine(java.lang.String string)Method that parseLinefrom log file.private PointparsePoint(java.lang.String string)Method that parsePointfrom log file.private RectangleparseRectangle(java.lang.String string)Method that parseRectanglefrom log file.private ShapeparseShape(java.lang.String shape, java.lang.String shapeParameters)Determine which type of shape need to be parsed and call appropriate method.private SquareparseSquare(java.lang.String string)Method that parseSquarefrom log file.voidreadLine(java.lang.String command)Read one line from log file and parse it.voidsave(java.io.File file)Save forwarded file as log of commands.
-
-
-
Field Detail
-
writer
private java.io.BufferedWriter writer
-
reader
private java.io.BufferedReader reader
-
frame
private DrawingFrame frame
-
model
private DrawingModel model
-
controller
private DrawingController controller
-
logParser
private DlgLogParser logParser
-
-
Constructor Detail
-
FileLog
public FileLog(DrawingFrame frame, DrawingModel model, DrawingController controller)
-
-
Method Detail
-
save
public void save(java.io.File file)
Save forwarded file as log of commands.- Specified by:
savein interfaceFileHandler
-
open
public void open(java.io.File file)
Open forwarded log file and execute it command by command in interaction with user.- Specified by:
openin interfaceFileHandler
-
readLine
public void readLine(java.lang.String command)
Read one line from log file and parse it.- Parameters:
command- Represent command that need to be parsed.
-
parseShape
private Shape parseShape(java.lang.String shape, java.lang.String shapeParameters)
Determine which type of shape need to be parsed and call appropriate method.- Parameters:
shape- Represent type of shape which need to be parsed.shapeParameters- Represent values of that shape.- Returns:
- Represent parsed shape.
-
parsePoint
private Point parsePoint(java.lang.String string)
Method that parsePointfrom log file.
-
parseCircle
private Circle parseCircle(java.lang.String string)
Method that parseCirclefrom log file.
-
parseSquare
private Square parseSquare(java.lang.String string)
Method that parseSquarefrom log file.
-
parseRectangle
private Rectangle parseRectangle(java.lang.String string)
Method that parseRectanglefrom log file.
-
parseHexagon
private HexagonAdapter parseHexagon(java.lang.String string)
Method that parseHexagonAdapterfrom log file.- Parameters:
string- RepresentHexagonAdapterthat need to be parsed.- Returns:
- Represent parsed
HexagonAdapter.
-
-