From 3281ba53bae484d4f8b2016d6c534e82bb9a29bd Mon Sep 17 00:00:00 2001 From: ribeaudc <ribeaudc> Date: Wed, 5 Dec 2007 07:40:24 +0000 Subject: [PATCH] [LMS-117] add: - Method 'createChannelListFromString(String)'. SVN: 2928 --- .../ch/systemsx/cisd/bds/hcs/ChannelList.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bds/source/java/ch/systemsx/cisd/bds/hcs/ChannelList.java b/bds/source/java/ch/systemsx/cisd/bds/hcs/ChannelList.java index 38ab5bee692..c07b137bf7a 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/hcs/ChannelList.java +++ b/bds/source/java/ch/systemsx/cisd/bds/hcs/ChannelList.java @@ -51,6 +51,30 @@ public final class ChannelList implements IStorable, Iterable<Channel> } this.channels = channels; } + + /** + * Creates a <code>ChannelList</code> instance from given <var>value</var>. + * <p> + * The current implementation expects an <code>int</code> as value. + * </p> + */ + public final static ChannelList createChannelListFromString(final String value) + { + assert value != null : "Given value can not be null."; + try + { + final int size = Integer.parseInt(value); + final List<Channel> channels = new ArrayList<Channel>(size); + for (int i = 0; i < size; i++) + { + channels.add(new Channel(i, 0)); + } + return new ChannelList(channels); + } catch (NumberFormatException ex) + { + return null; + } + } /** * Loads all <code>Channels</code> from the specified directory. -- GitLab