/** * Subscribe to all channels whose name matches the regular expression. Note that to subscribe to * all channels, you must specify ".*", not "*". */ public void subscribe(String regex, ZCMSubscriber sub) { if (this.closed) throw new IllegalStateException(); SubscriptionRecord srec = new SubscriptionRecord(); srec.regex = regex; srec.pat = Pattern.compile(regex); srec.lcsub = sub; synchronized (this) { zcmjni.subscribe(regex, this); } synchronized (subscriptions) { subscriptions.add(srec); for (String channel : subscriptionsMap.keySet()) { if (srec.pat.matcher(channel).matches()) { ArrayList<SubscriptionRecord> subs = subscriptionsMap.get(channel); subs.add(srec); } } } }