@Test public void testParse() { String name = "/media/aap/[1..100]"; NameParser parser = new NameParser(); Collection<NameToken> tokens = parser.parse(name); assertEquals(3, tokens.size()); Iterator<NameToken> it = tokens.iterator(); NameToken t = it.next(); assertEquals(true, t instanceof FixedToken); t = it.next(); assertEquals(true, t instanceof FixedToken); t = it.next(); assertEquals(true, t instanceof NumericRange); }
public Collection<NameToken> parse(String name) { ArrayList<NameToken> list = new ArrayList(); String[] parts = name.split("/"); for (String part: parts) { part = part.trim(); if (part.length() == 0) { continue; } if (part.startsWith("[")) { list.add(new NumericRange(part)); } else { list.add(new FixedToken(part)); } } return list; }
NameParser { public Collection<NameToken> parse(String name) { ArrayList<NameToken> list = new ArrayList(); String[] parts = name.split("/"); for (String part: parts) { part = part.trim(); if (part.length() == 0) { continue; } if (part.startsWith("[")) { list.add(new NumericRange(part)); } else { list.add(new FixedToken(part)); } } return list; } }
NameParser { public Collection<NameToken> parse(String name) { ArrayList<NameToken> list = new ArrayList(); String[] parts = name.split("/"); for (String part: parts) { part = part.trim(); if (part.length() == 0) { continue; } if (part.startsWith("[")) { list.add(new NumericRange(part)); } else { list.add(new FixedToken(part)); } } return list; }  }
NameParser { public Collection<NameToken> parse(String name) { ArrayList<NameToken> list = new ArrayList(); String[] parts = name.split("/"); for (String part: parts) { part = part.trim(); if (part.length() == 0) { continue; } if (part.startsWith("[")) { list.add(new NumericRange(part)); } else { list.add(new FixedToken(part)); } } return list; }  Collection<NameToken> parse(String name); }
NameParser { public Collection<NameToken> parse(String name) { ArrayList<NameToken> list = new ArrayList(); String[] parts = name.split("/"); for (String part: parts) { part = part.trim(); if (part.length() == 0) { continue; } if (part.startsWith("[")) { list.add(new NumericRange(part)); } else { list.add(new FixedToken(part)); } } return list; }  Collection<NameToken> parse(String name);  }