多治見IT勉強会 Groovy Grails

  • View
    112

  • Download
    0

Embed Size (px)

DESCRIPTION

Groovy/grails

Transcript

  • 1. 2010.10.14 at Tajimidef speaker = new Cast(name:T.Yamamoto,version:TI-2010-10-14)

2. def name='World' def list = ["Hello", " ", "World"] println "Hello $name!" list.each{print it} class Greet { def name Greet(who) { name = who[0].toUpperCase() +who[1..-1] } def salute() { println "Hello $name!" } } def g = new Greet('world') // create object g.salute() 3. import java.util.Date; } return this.black;public Integer getColorId() { } public class Color { return this.colorId;public void setBlack(String black) {private Integer colorId;} this.black = black;private String colorName; public void setColorId(Integer colorId) { }private String cyan;this.colorId = colorId; public String getRgb() {private String magenta; } return this.rgb;private String yellow;public String getColorName() {}private String black; return this.colorName;public void setRgb(String rgb) {private String rgb; } this.rgb = rgb;private String sysIpaddress;public void setColorName(String }private Date sysLastmodied; colorName) { public String getSysIpaddress() {private Integer sysUid; this.colorName = colorName; return this.sysIpaddress;public Color(Integer colorId, String} } colorName, String cyan,public String getCyan() { public void setSysIpaddress(String String magenta, String yellow, Stringreturn this.cyan; sysIpaddress) { black, String rgb, } this.sysIpaddress = sysIpaddress; String sysIpaddress, Datepublic void setCyan(String cyan) {} sysLastmodied, Integer sysUid) {this.cyan = cyan; public Date getSysLastmodied() {this.colorId = colorId; } return this.sysLastmodied;this.colorName = colorName; public String getMagenta() {}this.cyan = cyan; return this.magenta;public void setSysLastmodied(Datethis.magenta = magenta; } sysLastmodied) {this.yellow = yellow; public void setMagenta(String magenta) {this.sysLastmodied = sysLastmodied;this.black = black; this.magenta = magenta; }this.rgb = rgb; } public Integer getSysUid() {this.sysIpaddress = sysIpaddress; public String getYellow() { return this.sysUid;this.sysLastmodied = sysLastmodied; return this.yellow; }this.sysUid = sysUid; } public void setSysUid(Integer sysUid) {} public void setYellow(String yellow) {this.sysUid = sysUid;public Color() {} this.yellow = yellow; }public Color(Integer colorId) { } }this.colorId = colorId; public String getBlack() { 4. class Color {Integer colorIdString colorNameString cyan,magenta,yellow,black,rgbString sysIpaddressDate sysLastmodiedInteger sysUid}class Color { Integer colorId, sysUid String colorName,cyan,magenta,yellow,black,rgb,sysIpaddress Date sysLastmodied } 5. public class HelloWorld { String name;public void setName(String name){ this.name = name; } public String getName(){ return name; }public String greet(){ return "Hello "+name; }public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld(); helloWorld.setName("Groovy"); System.out.println(helloWorld.greet()); } } 6. public class HelloWorld { String name;public void setName(String name){ this.name = name; } public String getName(){ return name; }public String greet(){ return "Hello "+name; }public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld(); helloWorld.setName("Groovy"); System.out.println(helloWorld.greet()); } } 7. public class HelloWorld { String namepublic void setName(String name){ this.name = name } public String getName(){ return name }public String greet(){ return "Hello "+name }public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld() helloWorld.setName("Groovy") System.out.println(helloWorld.greet()) } } 8. public class HelloWorld { String namepublic String greet(){ return "Hello "+name }public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld() helloWorld.setName("Groovy") System.out.println(helloWorld.greet()) } } 9. public class HelloWorld { String namepublic String greet(){ return "Hello "+name } }HelloWorld helloWorld = new HelloWorld() helloWorld.setName("Groovy") System.out.println(helloWorld.greet()) 10. class HelloWorld { String namedef greet(){ return "Hello "+name } }def helloWorld = new HelloWorld() helloWorld.setName("Groovy") println(helloWorld.greet()) 11. class HelloWorld { String namedef greet(){ return "Hello "+name } }def helloWorld = new HelloWorld() helloWorld.name = "Groovy" println helloWorld.greet() 12. class HelloWorld { String namedef greet(){ "Hello $name"} }def helloWorld = new HelloWorld() helloWorld.name = "Groovy" println helloWorld.greet() 13. class HelloWorld { String name def greet(){ "Hello $name"} }def helloWorld = new HelloWorld(name: "Groovy") println helloWorld.greet() 14. @Grab('com.google.code.jcouchdb:jcouchdb:1.0.1-1') import org.jcouchdb.db.Database Database db = new Database( "localhost", "example_xmldo" ) db.createDocument( [name:' ',comment:'']) 15. Groovy G*() 16. mailService.send to: 'foobar@gmail.com', subject: 'Hello World', htmlBody: 'Hello' 17. import com.google.appengine.api.datastore.Entitydef person = new Entity("person") person['name'] = "" person.age = 18println person.name person.save()def q = new Query('person') def list = datastoreService.prepare(q).asList( Builder.withLimit(20).offset(0) ) person.delete() 18. 29 19. 30 20. 31 21. % grails run-app38 22. class Chat { String messageDate dateCreated Date lastUpdatedclass ChatController { static constraints = {static scaffold = true message nullable:false } dateCreated() lastUpdated() } } 23. Q&A 24. 43