Created
February 8, 2010 09:07
-
-
Save tyama/298003 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FilterCore { | |
private String pattern | |
private String map | |
private DocObj mydoc | |
boolean proc = false | |
def FilterCore(String pattern,DocObj mydoc){ | |
this.pattern = pattern | |
this.mydoc=mydoc | |
} | |
def tag(map){ | |
this.map = map | |
return this | |
} | |
def save(){ | |
println pattern + ":"+map | |
} | |
def process(boolean autosave = false){ | |
if(!this.proc){ | |
println "実行" | |
this.proc=true | |
this.mydoc.proc(this) | |
if(autosave)this.save() | |
this.proc=false | |
} | |
} | |
} | |
interface DocObj { | |
def filter(pattern) | |
def proc(obj) | |
} | |
class Viewer implements DocObj { | |
def filter(pattern){ | |
return new FilterCore(pattern,this) | |
} | |
def proc(obj){ | |
println "proc called:"+obj | |
} | |
} | |
def view = new Viewer() | |
view.filter("/パターン/").tag("{'name':'tyama'}").process(true) | |
view.filter("/パターン2/") | |
.tag("{'name':'tyama2'}") | |
.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment