Mercurial > hg > Members > tatsuki > Alice
view src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java @ 375:e58f5f74748e multicast
create foundation
author | sugi |
---|---|
date | Wed, 04 Jun 2014 00:24:07 +0900 |
parents | |
children | ca093d55a886 |
line wrap: on
line source
package alice.test.topology.aquarium.fx; import java.util.regex.Matcher; import java.util.regex.Pattern; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class CheckMyName extends CodeSegment { private Receiver host = ids.create(CommandType.PEEK); private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$"); public CheckMyName(){ host.setKey("host"); } @Override public void run() { String name = host.asString(); Matcher matcher = pattern.matcher(name); matcher.find(); String type = matcher.group(1); int num = new Integer(matcher.group(2)); String[] args = {type+num}; Aquarium.main(args); } }