Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.Serializable;
- import java.util.List;
- import static com.company.TuringConstants.*;
- public class Command implements Serializable {
- private String command;
- private String username;
- private String password;
- private String docName;
- private int section;
- private int numSections;
- private String collaborator;
- private FileAttachment fileAttachment;
- public Command(String command, String username) {
- this.command = command;
- this.username = username;
- }
- public String getUsername() {
- return username;
- }
- public String getPassword() {
- return password;
- }
- public String getCommand() {
- return command;
- }
- public String getDocName() {
- return docName;
- }
- public int getSection() {
- return section;
- }
- public String getCollaborator() {
- return collaborator;
- }
- public static Command buildLoginCommand(String username, String password) {
- Command command = new Command(COMMAND_LOGIN, username);
- command.password = password;
- return command;
- }
- public static Command buildLogoutCommand(String username) {
- return new Command(COMMAND_LOGOUT, username);
- }
- public static Command buildListCommand(String username) {
- return new Command(COMMAND_LIST, username);
- }
- public static Command buildCreateCommand(String username, String docName, int numSections) {
- Command command = new Command(COMMAND_CREATE, username);
- command.docName = docName;
- command.numSections = numSections;
- return command;
- }
- public static Command buildShareCommand(String username, String docName, String collaborator) {
- Command command = new Command(COMMAND_SHARE, username);
- command.docName = docName;
- command.collaborator = collaborator;
- return command;
- }
- public static Command buildShowSectionCommand(String username, String docName, int section) {
- Command command = new Command(COMMAND_SHOW_SECTION, username);
- command.docName = docName;
- command.section = section;
- return command;
- }
- public static Command buildEditSectionCommand(String username, String docName, int section) {
- Command command = new Command(COMMAND_EDIT_SECTION, username);
- command.docName = docName;
- command.section = section;
- return command;
- }
- public static Command buildEndEditSectionCommand(
- String username, String docName, int section, String srcFileAttachment, String dstFileAttachment) {
- Command command = new Command(COMMAND_END_EDIT_SECTION, username);
- command.docName = docName;
- command.section = section;
- command.fileAttachment = new FileAttachment(srcFileAttachment, dstFileAttachment);
- return command;
- }
- public static Command buildShowDocumentCommand(String username, String docName) {
- Command command = new Command(COMMAND_SHOW_DOCUMENT, username);
- command.docName = docName;
- return command;
- }
- public int getNumSections() {
- return numSections;
- }
- public FileAttachment getFileAttachment() {
- return fileAttachment;
- }
- public boolean hasFileAttachment() {
- return fileAttachment != null;
- }
- public boolean hasEmptyAttachment() {
- return fileAttachment.getSize() > 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement