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 DrawingController
controller
private DrawingFrame
frame
private DlgLogParser
logParser
private DrawingModel
model
private java.io.BufferedReader
reader
private java.io.BufferedWriter
writer
-
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 void
open(java.io.File file)
Open forwarded log file and execute it command by command in interaction with user.private Circle
parseCircle(java.lang.String string)
Method that parseCircle
from log file.private HexagonAdapter
parseHexagon(java.lang.String string)
Method that parseHexagonAdapter
from log file.private Line
parseLine(java.lang.String string)
Method that parseLine
from log file.private Point
parsePoint(java.lang.String string)
Method that parsePoint
from log file.private Rectangle
parseRectangle(java.lang.String string)
Method that parseRectangle
from log file.private Shape
parseShape(java.lang.String shape, java.lang.String shapeParameters)
Determine which type of shape need to be parsed and call appropriate method.private Square
parseSquare(java.lang.String string)
Method that parseSquare
from log file.void
readLine(java.lang.String command)
Read one line from log file and parse it.void
save(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:
save
in 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:
open
in 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 parsePoint
from log file.
-
parseCircle
private Circle parseCircle(java.lang.String string)
Method that parseCircle
from log file.
-
parseSquare
private Square parseSquare(java.lang.String string)
Method that parseSquare
from log file.
-
parseRectangle
private Rectangle parseRectangle(java.lang.String string)
Method that parseRectangle
from log file.
-
parseHexagon
private HexagonAdapter parseHexagon(java.lang.String string)
Method that parseHexagonAdapter
from log file.- Parameters:
string
- RepresentHexagonAdapter
that need to be parsed.- Returns:
- Represent parsed
HexagonAdapter
.
-
-