Subversion Repositories programming

Rev

Rev 221 | Rev 224 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 221 Rev 222
Line 3... Line 3...
3
{
3
{
4
    private int[] fields = new int[4];
4
    private int[] fields = new int[4];
5
 
5
 
6
    public IPAddr (String ip)
6
    public IPAddr (String ip)
7
    {
7
    {
-
 
8
        int i;
8
        String[] sp = ip.split("\\.");
9
        String[] sp = ip.split("\\.");
9
        
10
 
10
        for (int i=0; i<sp.length; i++)
11
        for (i=0; i<sp.length; i++)
11
            fields[i] = Integer.parseInt(sp[i]);
12
            fields[i] = Integer.parseInt(sp[i]);
12
    }
13
    }
13
 
14
 
14
    public int getField (int fieldNum)
15
    public int getField (int fieldNum)
15
    {
16
    {
Line 36... Line 37...
36
        return this.compareTo(that);
37
        return this.compareTo(that);
37
    }
38
    }
38
 
39
 
39
    public String toString ()
40
    public String toString ()
40
    {
41
    {
41
        String s = new String();
42
        String s = new String("" + fields[0] + '.' + fields[1] + '.'
42
        s.format ("%d.%d.%d.%d", fields[0], fields[1], fields[2], fields[3]);
43
                            + fields[2] + '.' + fields[3]);
43
 
-
 
44
        return s;
44
        return s;
45
    }
45
    }
46
}
46
}
47
 
47