KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > jmx > remote > comm > HostAndPort


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.jmx.remote.comm;
25 //JDK imports
26
import java.util.StringTokenizer JavaDoc;
27 import java.io.Serializable JavaDoc;
28
29 /** Represents a host and a port in a convenient package that also
30  * accepts a convenient constructor.
31  * @author Lloyd Chambers
32  * @since S1AS7.0
33  * @version 1.1
34  */

35 public class HostAndPort implements Serializable JavaDoc
36 {
37     /* javac 1.3 generated serialVersionUID */
38     public static final long serialVersionUID = 6708656762332072746L;
39     protected String JavaDoc mHost = null;
40     protected int mPort;
41   private boolean secure = false;
42
43
44   public HostAndPort(String JavaDoc host, int port, boolean secure){
45     this.mHost = host;
46     this.mPort = port;
47     this.secure = secure;
48   }
49   
50   public HostAndPort(HostAndPort rhs){
51     this(rhs.mHost, rhs.mPort, rhs.secure);
52   }
53
54     public HostAndPort( String JavaDoc host, int port ) {
55       this(host, port, false);
56     }
57
58   public boolean isSecure(){
59     return this.secure;
60   }
61   
62     
63     
64         public String JavaDoc
65     getHost()
66     {
67         return( mHost );
68     }
69     
70         public int
71     getPort()
72     {
73         return( mPort );
74     }
75     
76     /**
77         Construct a new HostAndPort from a string of the form "host:port"
78         
79         @param str string of the form "host:port"
80     */

81     public HostAndPort( String JavaDoc str )
82     {
83         StringTokenizer JavaDoc tokenizer =
84             new StringTokenizer JavaDoc( str, ":", false);
85         
86         mHost = tokenizer.nextToken();
87         
88         final String JavaDoc portString = tokenizer.nextToken();
89         mPort = new Integer JavaDoc( portString ).intValue();
90     }
91     
92         public String JavaDoc
93     toString()
94     {
95         return( mHost + ":" + mPort );
96     }
97 }
98
Popular Tags