Class HostnameTask

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
ise.antelope.tasks.HostnameTask
All Implemented Interfaces:
Cloneable

public class HostnameTask extends org.apache.tools.ant.Task
A task to put hostname or IP in a property. The default property is 'hostname'.

I updated this task in Apr 2005 to be able to show all hostnames and IP's for the local machine, which is sometimes handy for machines with dual cards, like maybe an ethernet card and a wireless card.

Dale Anson, May 2001

Version:
$Revision: 151 $
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     

    Fields inherited from class org.apache.tools.ant.Task

    target, taskName, taskType, wrapper

    Fields inherited from class org.apache.tools.ant.ProjectComponent

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Description of the Method
    void
    setFailonerror(boolean b)
    Should the build fail if this task fails? Default is no.
    void
    Set a specific network interface to get info for.
    void
     
    void
    setShowall(boolean b)
    Show all network interfaces, hostnames and IPs for the local host.
    void
    setShowcanonical(boolean b)
     
    void
    setShowip(boolean b)
    Should this task get the IP address of the local host instead of the hostname? Default is no, get the hostname, not the IP address.

    Methods inherited from class org.apache.tools.ant.Task

    bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

    Methods inherited from class org.apache.tools.ant.ProjectComponent

    clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • HostnameTask

      public HostnameTask()
  • Method Details

    • setProperty

      public void setProperty(String p)
      Parameters:
      p - The name of the property to hold the hostname or IP address.
    • setShowip

      public void setShowip(boolean b)
      Should this task get the IP address of the local host instead of the hostname? Default is no, get the hostname, not the IP address.
      Parameters:
      b - The new ip value
    • setFailonerror

      public void setFailonerror(boolean b)
      Should the build fail if this task fails? Default is no.
      Parameters:
      b - The new failonerror value
    • setNic

      public void setNic(String n)
      Set a specific network interface to get info for.
      Parameters:
      n - The new nic value
    • setShowall

      public void setShowall(boolean b)
      Show all network interfaces, hostnames and IPs for the local host. Default is false. If used, output will be something like:
      lo:127.0.0.1, eth0:mycomputer.somewhere.com, eth1:wireless.somwhere.com
      Parameters:
      b - if true, show all hostnames and IPs
    • setShowcanonical

      public void setShowcanonical(boolean b)
    • execute

      public void execute()
      Description of the Method
      Overrides:
      execute in class org.apache.tools.ant.Task