29 lines
593 B
Groovy
29 lines
593 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 Entry addEvent(Event e) {
|
||
|
def event = e.clone()
|
||
|
|
||
|
def m = event.description =~ descriptionPattern
|
||
|
|
||
|
event.description = m[0][1]
|
||
|
|
||
|
def entry = super.addEvent(event)
|
||
|
|
||
|
return entry
|
||
|
}
|
||
|
}
|