diff options
author | JJ | 2022-12-27 05:38:32 +0000 |
---|---|---|
committer | JJ | 2022-12-27 15:30:20 +0000 |
commit | c14e53775591cb4d75b486d21f4849552d5c7c8c (patch) | |
tree | fc9d67b66107f4965f3173183ec846e4d8e090c4 /src/main/model | |
parent | 0e693fd4814572712a4192cb4f176e71f7a344f7 (diff) |
Remove garbage serialization/logging code
Diffstat (limited to 'src/main/model')
-rw-r--r-- | src/main/model/BrowserState.java | 5 | ||||
-rw-r--r-- | src/main/model/html/ElementNode.java | 9 | ||||
-rw-r--r-- | src/main/model/html/HtmlParser.java | 8 | ||||
-rw-r--r-- | src/main/model/html/Node.java | 5 | ||||
-rw-r--r-- | src/main/model/html/TextNode.java | 10 | ||||
-rw-r--r-- | src/main/model/util/Event.java | 66 | ||||
-rw-r--r-- | src/main/model/util/EventLog.java | 60 |
7 files changed, 3 insertions, 160 deletions
diff --git a/src/main/model/BrowserState.java b/src/main/model/BrowserState.java index bb15abf..da21c41 100644 --- a/src/main/model/BrowserState.java +++ b/src/main/model/BrowserState.java @@ -1,8 +1,5 @@ package model; -import model.util.Event; -import model.util.EventLog; - import java.util.ArrayDeque; // This BrowserState function collects the stateful portions of the browser into one modelable class. @@ -37,13 +34,11 @@ public class BrowserState { if (!this.tabs.contains(added)) { this.tabs.add(added); } - EventLog.getInstance().logEvent(new Event("Added tab " + added + " to tablist")); } // MODIFIES: this // EFFECTS: removes a tab from the tablist public void removeTab(String removed) { this.tabs.remove(removed); - EventLog.getInstance().logEvent(new Event("Removed tab " + removed + " from tablist")); } } diff --git a/src/main/model/html/ElementNode.java b/src/main/model/html/ElementNode.java index ef241e4..6f0a556 100644 --- a/src/main/model/html/ElementNode.java +++ b/src/main/model/html/ElementNode.java @@ -1,15 +1,13 @@ package model.html; import org.javatuples.Pair; -import org.json.JSONObject; -import persistance.JsonAble; import java.util.ArrayList; /** * This ElementNode class represents an HTML tag and nested tags. */ -public class ElementNode implements Node, JsonAble { +public class ElementNode implements Node { private String tag; private ArrayList<Pair<String,String>> attributes; @@ -67,9 +65,4 @@ public class ElementNode implements Node, JsonAble { public String getData() { return getTag() + " " + getAttributes().toString(); } - - @Override - public JSONObject serialize() { - return new JSONObject(this); - } } diff --git a/src/main/model/html/HtmlParser.java b/src/main/model/html/HtmlParser.java index 5170205..e50f713 100644 --- a/src/main/model/html/HtmlParser.java +++ b/src/main/model/html/HtmlParser.java @@ -3,8 +3,6 @@ package model.html; import java.util.*; import org.javatuples.*; -import org.json.JSONObject; -import persistance.JsonAble; /** * This class represents the state of and implements an LL(1) HTML parser. @@ -19,7 +17,7 @@ import persistance.JsonAble; * SELF_CLOSING_TAG ::= 'img' | ... * (note that \forall T \in SELF_CLOSING_TAG, T \notin TAG) */ -public class HtmlParser implements JsonAble { +public class HtmlParser { /** * HTML is not nice to parse. We manage to get away with a relatively small number of parser states regardless. @@ -346,10 +344,6 @@ public class HtmlParser implements JsonAble { return false; } } - - public JSONObject serialize() { - return new JSONObject(this); - } } /* diff --git a/src/main/model/html/Node.java b/src/main/model/html/Node.java index 5c3ea41..9a846ee 100644 --- a/src/main/model/html/Node.java +++ b/src/main/model/html/Node.java @@ -1,7 +1,5 @@ package model.html; -import org.json.JSONObject; - /** * This Node represents an abstract relationship between ElementNode and TextNode. * It's extremely helpful / necessary for Lists of arbitrary ElementNodes/TextNodes. @@ -9,7 +7,4 @@ import org.json.JSONObject; public interface Node { // Return a representation of the Node. Useful for debugging. public String getData(); - - // EFFECTS: returns a serialized form of the data - public JSONObject serialize(); } diff --git a/src/main/model/html/TextNode.java b/src/main/model/html/TextNode.java index 82ae245..464180f 100644 --- a/src/main/model/html/TextNode.java +++ b/src/main/model/html/TextNode.java @@ -1,12 +1,9 @@ package model.html; -import org.json.JSONObject; -import persistance.JsonAble; - /** * This TextNode class represents raw text, with no nested tags. */ -public class TextNode implements Node, JsonAble { +public class TextNode implements Node { private String text = ""; /** @@ -25,9 +22,4 @@ public class TextNode implements Node, JsonAble { public String getData() { return getText(); } - - @Override - public JSONObject serialize() { - return new JSONObject(this); - } } diff --git a/src/main/model/util/Event.java b/src/main/model/util/Event.java deleted file mode 100644 index 8a42ef8..0000000 --- a/src/main/model/util/Event.java +++ /dev/null @@ -1,66 +0,0 @@ -package model.util; - -import java.util.Calendar; -import java.util.Date; - - -/** - * Represents an alarm system event. - */ -public class Event { - private static final int HASH_CONSTANT = 13; - private Date dateLogged; - private String description; - - /** - * Creates an event with the given description - * and the current date/time stamp. - * @param description a description of the event - */ - public Event(String description) { - dateLogged = Calendar.getInstance().getTime(); - this.description = description; - } - - /** - * Gets the date of this event (includes time). - * @return the date of the event - */ - public Date getDate() { - return dateLogged; - } - - /** - * Gets the description of this event. - * @return the description of the event - */ - public String getDescription() { - return description; - } - - @Override - public boolean equals(Object other) { - if (other == null) { - return false; - } - - if (other.getClass() != this.getClass()) { - return false; - } - - Event otherEvent = (Event) other; - - return (this.dateLogged.equals(otherEvent.dateLogged) - && this.description.equals(otherEvent.description)); - } - - @Override - public int hashCode() { - return (HASH_CONSTANT * dateLogged.hashCode() + description.hashCode()); - } - - @Override - public String toString() { - return dateLogged.toString() + "\n" + description; - } -} diff --git a/src/main/model/util/EventLog.java b/src/main/model/util/EventLog.java deleted file mode 100644 index 507c9b2..0000000 --- a/src/main/model/util/EventLog.java +++ /dev/null @@ -1,60 +0,0 @@ -package model.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -/** - * Represents a log of alarm system events. - * We use the Singleton Design Pattern to ensure that there is only - * one EventLog in the system and that the system has global access - * to the single instance of the EventLog. - */ -public class EventLog implements Iterable<Event> { - /** the only EventLog in the system (Singleton Design Pattern) */ - private static EventLog theLog; - private Collection<Event> events; - - /** - * Prevent external construction. - * (Singleton Design Pattern). - */ - private EventLog() { - events = new ArrayList<Event>(); - } - - /** - * Gets instance of EventLog - creates it - * if it doesn't already exist. - * (Singleton Design Pattern) - * @return instance of EventLog - */ - public static EventLog getInstance() { - if (theLog == null) { - theLog = new EventLog(); - } - - return theLog; - } - - /** - * Adds an event to the event log. - * @param e the event to be added - */ - public void logEvent(Event e) { - events.add(e); - } - - /** - * Clears the event log and logs the event. - */ - public void clear() { - events.clear(); - logEvent(new Event("Event log cleared.")); - } - - @Override - public Iterator<Event> iterator() { - return events.iterator(); - } -} |