KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > smi > TcpAddress


1 /*_############################################################################
2   _##
3   _## SNMP4J - TcpAddress.java
4   _##
5   _## Copyright 2003-2007 Frank Fock and Jochen Katz (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21
22
23 package org.snmp4j.smi;
24
25 import java.net.InetAddress JavaDoc;
26 import org.snmp4j.log.*;
27
28 /**
29  * The <code>TcpAddress</code> represents TCP/IP transport addresses.
30  * @author Frank Fock
31  * @version 1.0
32  */

33
34 public class TcpAddress extends TransportIpAddress {
35
36   static final long serialVersionUID = 1165319744164017388L;
37
38   private static final LogAdapter logger = LogFactory.getLogger(TcpAddress.class);
39
40   public TcpAddress() {
41     super();
42   }
43
44   public TcpAddress(InetAddress JavaDoc inetAddress, int port) {
45     setInetAddress(inetAddress);
46     setPort(port);
47   }
48
49   public TcpAddress(int port) {
50     super();
51     setPort(port);
52   }
53
54   public TcpAddress(String JavaDoc address) {
55     if (!parseAddress(address)) {
56       throw new IllegalArgumentException JavaDoc(address);
57     }
58   }
59
60   public static Address parse(String JavaDoc address) {
61     try {
62       TcpAddress a = new TcpAddress();
63       if (a.parseAddress(address)) {
64         return a;
65       }
66     }
67     catch (Exception JavaDoc ex) {
68       logger.error(ex);
69     }
70     return null;
71   }
72
73 }
74
Popular Tags