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
| public static List<String> findAll(String findStr, Pattern regex) { | |
| List<String> result = new ArrayList<String>(); | |
| Matcher matcher = regex.matcher(findStr); | |
| while (matcher.find()) { | |
| result.add(matcher.group()); | |
| } | |
| return result; | |
| } |
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
| import java.util.Enumeration; | |
| import java.util.Map; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.servlet.http.HttpServletRequestWrapper; | |
| public class HttpHeaderWrappedRequest extends HttpServletRequestWrapper { | |
| /** 追加HTTPヘッダ情報を保持するマップ */ | |
| private Map<String, String> addingHeader; |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace Utility { | |
| /// <summary> | |
| /// シンタクスシュガー用ユーティリティクラス | |
| /// </summary> | |
| public static class SS { |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Reflection; | |
| using System.IO; | |
| namespace Test { | |
| static class TestHelperUtility { | |
| /// <summary> |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace Fumokmm.Utility | |
| { | |
| /// <summary> | |
| /// シンタクスシュガー用ユーティリティクラス | |
| /// </summary> |
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
| @Grab('nekohtml:nekohtml:1.9.6.2') | |
| import org.cyberneko.html.parsers.SAXParser | |
| def gdkdoc = new XmlSlurper(new SAXParser()).parseText( | |
| new URL('http://groovy.codehaus.org/groovy-jdk/index-all.html').text | |
| // new File('C:/tool/Groovy/groovy-1.9.0-beta-4/html/groovy-jdk/index-all.html').text | |
| ) | |
| // search all DT tags and DD tags. | |
| def dt = gdkdoc.'**'.findAll{ it.name() == 'DT' }.collect{ it.text() } |
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
| // http://d.hatena.ne.jp/fumokmm/20110917/1316223642 | |
| import org.xml.sax.helpers.DefaultHandler | |
| import org.xml.sax.Attributes | |
| class GroovyMarkupDSLHandler extends DefaultHandler { | |
| IndentPrinter p | |
| boolean needNewLine | |
| GroovyMarkupDSLHandler(Writer writer = new PrintWriter(System.out), String indent = ' ') { | |
| p = new IndentPrinter(writer, indent) | |
| needNewLine = false |
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
| def reg = /[a-zA-Z]*/.with{ [/^${it}/, '|', /${it}$/].join() } | |
| assert 'あああ' == 'aaaABCあああzzz'.replaceAll(reg, '') | |
| assert 'いいい' == 'bbbABCいいいzzz'.replaceAll(reg, '') |
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
| // cf. http://groovy.codehaus.org/groovy-jdk/java/io/File.html#traverse%28java.util.Map,%20groovy.lang.Closure%29 | |
| // require Groovy v1.7.1 or upper | |
| // blog. http://d.hatena.ne.jp/fumokmm/20110911/1315709484 | |
| def findFirstFile(File rootDir, java.util.regex.Pattern filter) { | |
| File result | |
| rootDir.traverse( | |
| type : groovy.io.FileType.FILES, | |
| nameFilter : filter | |
| ) { it -> result = it | |
| groovy.io.FileVisitResult.TERMINATE |
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
| def realCurry(Closure clos) { | |
| if (clos.maximumNumberOfParameters >= 1) { | |
| return { x -> | |
| def cc = clos.curry(x) | |
| if (cc.maximumNumberOfParameters) realCurry(cc) | |
| else cc() | |
| } | |
| } else { | |
| return clos | |
| } |