25 lines
531 B
Groovy
25 lines
531 B
Groovy
package com.jdbernard.timeanalyzer
|
|
|
|
public class TwoLevelCategory extends Category {
|
|
|
|
private final def descriptionPattern
|
|
|
|
public TwoLevelCategory(String heading) {
|
|
super(heading)
|
|
|
|
descriptionPattern = ~/^${heading}:\s*(.*)/
|
|
}
|
|
|
|
public boolean matchesEvent(Event e) {
|
|
return e.description ==~ descriptionPattern
|
|
}
|
|
|
|
public Event addEvent(Event e) {
|
|
def m = e.description =~ descriptionPattern
|
|
|
|
e = new Event(e, description: m[0][1])
|
|
|
|
super.addEvent(e)
|
|
}
|
|
}
|