Initial commit

This commit is contained in:
Jonathan Bernard
2011-01-09 15:11:36 -06:00
commit 9f4008a775
17 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package com.jdbernard.timeanalyzer
public abstract class Category implements Comparable<T extends Category> {
List<Entry> entries
public abstract boolean matchesEvent(Event e)
public abstract Entry addEvent(Event e)
public Category() { entries = [] }
public int compareTo(C other) {
}
}

View File

@ -0,0 +1,6 @@
package com.jdbernard.timanalyzer;
public class Entry extends Event {
public Category category;
}

View File

@ -0,0 +1,13 @@
package com.jdbernard.timeanalyzer;
import org.joda.time.DateTime;
import org.joda.time.Duration;
public class Event {
public String description;
public String notes;
public DateTime start;
public Duration duration;
}

View File

@ -0,0 +1,25 @@
package com.jdbernard.timeanalyzer;
public abstract class EventTransformation {
private Category category;
public EventTransformation(Category cat) {
this.category = cat;
}
/**
* Determine if this transformation is applicable for a given event.
* @param e An event to match.
* @return *true* if this transformation is applicable to the given event,
* *false* otherwise.
*/
public abstract boolean matches(Event e);
/**
* Transform an entry.
* @param e The Event to transform.
* @return A new Entry.
*/
public abstract Entry transform(Event e);
}

View File

@ -0,0 +1,21 @@
package com.jdbernard.timeanalyzer
public class EventTransformer {
List transformations
public EventTransformer(List transformations) {
this.transformations = transformations
}
/**
* Transform an event. The first matching transformation is used.
* @param e The event to transform.
* @return The resulting Entry.
*/
public Entry transform(Event e) {
for (t : transformations)
if (t.matches(e))
return t.transform(t)
}
}