From 2f848cd91f899fe3de2701085ee720b96ba317c0 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 12 Oct 2003 03:24:56 +0000 Subject: Allow passing a path to the Path class constructor. --- src/org/noreply/fancydress/type3/HalfPath.java | 53 +++++++++++++++++++++- src/org/noreply/fancydress/type3/Path.java | 23 +++------- .../fancydress/type3/routing/RoutingHOST.java | 4 +- .../fancydress/type3/routing/RoutingIP4.java | 4 +- 4 files changed, 63 insertions(+), 21 deletions(-) (limited to 'src/org/noreply/fancydress/type3') diff --git a/src/org/noreply/fancydress/type3/HalfPath.java b/src/org/noreply/fancydress/type3/HalfPath.java index 3c72b91..14d4af6 100644 --- a/src/org/noreply/fancydress/type3/HalfPath.java +++ b/src/org/noreply/fancydress/type3/HalfPath.java @@ -1,11 +1,62 @@ /* $Id$ */ package org.noreply.fancydress.type3; +import org.noreply.fancydress.directory.*; +import org.noreply.fancydress.status.*; +import org.noreply.fancydress.type3.routing.*; +import java.util.*; + public class HalfPath { private Hop[] hops; - public HalfPath(Hop[] hops) { /* FIXME */ + public HalfPath(Hop[] hops) { this.hops = hops; } + + private String[] tokenize(String path) throws Mix3Exception { + ArrayList nicks = new ArrayList(); + int indexFrom = 0; + int indexOf; + + while ((indexOf = path.indexOf(',', indexFrom)) != -1) { + String v = path.substring(indexFrom, indexOf).trim(); + if (v.equals("")) + throw new Mix3Exception("Invalid path."); + nicks.add( v ); + indexFrom = indexOf + 1; + } + String v = path.substring(indexFrom).trim(); + if (v.equals("")) + throw new Mix3Exception("Invalid path."); + nicks.add( v ); + + String[] result = new String[nicks.size()]; + for (int i=0; i