Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package test.unit.gov.nist.javax.sip.stack.tls;
 import java.util.*;
 
 
 public class HopImpl implements Hop {
     
Creates new Hop

Parameters:
hop is a hop string in the form of host:port/Transport
Throws:
IllegalArgument exception if string is not properly formatted or null.
    private String host;
    private int port;
    private String transport;
    public String getHost() { return this.; }
    public int getPort() { return this.; }
    public String getTransport() { return this.; }
    public HopImpl(String hopthrows IllegalArgumentException {
        if (hop == nullthrow new IllegalArgumentException("Null arg!");
        ..println("hop = " + hop);
        StringTokenizer stringTokenizer = new StringTokenizer(hop + "/");
        String hostPort = stringTokenizer.nextToken("/");
         = stringTokenizer.nextToken().trim();
        // System.out.println("Hop: transport = " + transport);
        if ( == null = "UDP";
        else if ( == "" = "UDP";
        if (.compareToIgnoreCase("UDP") != 0 &&
        .compareToIgnoreCase("TLS") != 0 &&
        .compareToIgnoreCase("TCP") != 0)  {
            ..println("Bad transport string " + );
            throw new IllegalArgumentException(hop);
        }
        stringTokenizer = new StringTokenizer(hostPort+":");
         = stringTokenizer.nextToken(":");
        if ( == null || .equals"") )
            throw new IllegalArgumentException("no host!");
        String portString = null;
        try {
            portString = stringTokenizer.nextToken(":");
        } catch (NoSuchElementException ex) {
            // Ignore.
        }
        if (portString == null || portString.equals("")) {
             = 5060;
        } else {
            try {
                 = Integer.parseInt(portString);
            } catch (NumberFormatException ex) {
                throw new IllegalArgumentException("Bad port spec");
            }
        }
    }
New to GrepCode? Check out our FAQ X