source: release-kits/wirk3/ant-scripts/tasks/antelope/src/ise/antelope/tasks/typedefs/net/Hostname.java@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 1.4 KB
Line 
1package ise.antelope.tasks.typedefs.net;
2
3import java.net.*;
4
5/**
6 * Copyright 2003
7 *
8 * @version $Revision$
9 */
10public class Hostname implements NetOp {
11
12 private String host = null;
13 private boolean showIp = false;
14
15 /**
16 * Gets the defaultProperty attribute of the Hostname object
17 *
18 * @return The defaultProperty value
19 */
20 public String getDefaultProperty() {
21 return "hostname";
22 }
23
24 /**
25 * Sets the showip attribute of the Hostname object
26 *
27 * @param b The new showip value
28 */
29 public void setShowip(boolean b) {
30 showIp = b;
31 }
32
33 /**
34 * Sets the host attribute of the Hostname object
35 *
36 * @param h The new host value
37 */
38 public void setHost(String h) {
39 host = h;
40 }
41
42 /**
43 * Description of the Method
44 *
45 * @return Description of the Returned Value
46 */
47 public String execute() {
48 try {
49 InetAddress addr = null;
50 if (host == null) {
51 // localhost
52 addr = InetAddress.getLocalHost();
53 }
54 else {
55 // remote host
56 addr = InetAddress.getByName(host);
57 }
58 String hostname = showIp ? addr.getHostAddress() : addr.getHostName();
59 return hostname;
60 }
61 catch (Exception e) {
62 throw new RuntimeException(e.getMessage());
63 }
64 }
65}
66
Note: See TracBrowser for help on using the repository browser.