Class InetAddressQuestion


  • public abstract class InetAddressQuestion
    extends Question
    A question to which the response is an IP address. Both IPv4 and IPv6 addresses are supported.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int IPv4
      A constant to indicate that only IPv4 addresses should be used.
      static int IPv6
      A constant to indicate that IPv6 addresses should be used.
      protected java.net.InetAddress value
      The current (default or latest) response to this question.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected InetAddressQuestion​(Interview interview, java.lang.String tag)
      Create a question with a nominated tag.
      protected InetAddressQuestion​(Interview interview, java.lang.String tag, int type)
      Create a question with a nominated tag.
    • Field Detail

      • IPv4

        public static final int IPv4
        A constant to indicate that only IPv4 addresses should be used.
        See Also:
        Constant Field Values
      • IPv6

        public static final int IPv6
        A constant to indicate that IPv6 addresses should be used. Note that IPv6 includes IPv4 addresses.
        See Also:
        Constant Field Values
      • value

        protected java.net.InetAddress value
        The current (default or latest) response to this question.
    • Constructor Detail

      • InetAddressQuestion

        protected InetAddressQuestion​(Interview interview,
                                      java.lang.String tag)
        Create a question with a nominated tag.
        Parameters:
        interview - The interview containing this question.
        tag - A unique tag to identify this specific question.
      • InetAddressQuestion

        protected InetAddressQuestion​(Interview interview,
                                      java.lang.String tag,
                                      int type)
        Create a question with a nominated tag.
        Parameters:
        interview - The interview containing this question.
        tag - A unique tag to identify this specific question.
        type - A value to (IPv4 or IPv6) to indicate the type of address used by the question.
    • Method Detail

      • equal

        protected static boolean equal​(java.net.InetAddress i1,
                                       java.net.InetAddress i2)
        Compare two network address objects for equality.
        Parameters:
        i1 - The first address to be compared, or null.
        i2 - The other address to be compared, or null.
        Returns:
        true if both arguments are null, or if both represent the same network address.
      • getType

        public int getType()
        Get the type of addresses (IPv4 or IPv6) that will be accepted by this question.
        Returns:
        the type of address that will be accepted by this question
        See Also:
        setType(int)
      • setType

        protected void setType​(int type)
        Set the type of addresses (IPv4 or IPv6) that should be accepted by this question.
        Parameters:
        type - the type of address that should be accepted by this question
        See Also:
        getType()
      • getStyle

        public int getStyle()
        Get the presentation style (IPv4 or IPv6) for this question. This is only a hint. Setting the type to IPv6 or setting suggestions may cause the actual presentation style to be IPv6. In IPv4 style, the data entry is four dotted decimal fields. In IPv6 style, the data entry is a single type in field, with an associated lookup button.
        Returns:
        the presentation style for this question
        See Also:
        setStyle(int)
      • setStyle

        protected void setStyle​(int style)
        Set the presentation style (IPv4 or IPv6) for this question. In IPv4 style, the data entry is four dotted decimal fields. In IPv6 style, the data entry is a single type in field, with an associated lookup button.
        Parameters:
        style - the presentation style for this question
        See Also:
        getStyle()
      • getSuggestions

        public java.net.InetAddress[] getSuggestions()
        Get the suggested responses to this question, or null if none.
        Returns:
        The suggestions.
        See Also:
        setSuggestions(java.net.InetAddress...)
      • setSuggestions

        public void setSuggestions​(java.net.InetAddress... newSuggestions)
        Set the set of suggested responses.
        Parameters:
        newSuggestions - The values to be set, or null if none
        Throws:
        java.lang.IllegalArgumentException - if any except the first of the values in the array are null
        See Also:
        getSuggestions()
      • getDefaultValue

        public java.net.InetAddress getDefaultValue()
        Get the default response for this question.
        Returns:
        the default response for this question.
        See Also:
        setDefaultValue(java.net.InetAddress)
      • setDefaultValue

        public void setDefaultValue​(java.net.InetAddress v)
        Set the default response for this question, used by the clear method.
        Parameters:
        v - the default response for this question.
        See Also:
        getDefaultValue()
      • getValue

        public java.net.InetAddress getValue()
        Get the current (default or latest) response to this question. If the question type is set to IPv4, a valid response will be an Inet4Address; otherwise, if the question type is set to IPv6, a valid response will be an Inet4Address or an Inet6Address
        Returns:
        The current value.
        See Also:
        setValue(java.net.InetAddress)
      • setValue

        public void setValue​(java.net.InetAddress newValue)
        Set the current value. Although any value can be set, if the value is to be considered valid it must be an Inet4Address if the question type is set to IPv4, or either an Inet4Address or an Inet6Address if the question type is set to IPv6.
        Parameters:
        newValue - The value to be set.
        See Also:
        getValue()
      • setValue

        public void setValue​(java.lang.String newValue)
                      throws Interview.Fault
        Set the current value.
        Specified by:
        setValue in class Question
        Parameters:
        newValue - The value to be set.
        Throws:
        Interview.Fault - retained for compatibility; should not be thrown
        See Also:
        getValue()
      • getValueOnPath

        public java.net.InetAddress getValueOnPath()
                                            throws Interview.NotOnPathFault
        Verify this question is on the current path, and if it is, return the current value.
        Returns:
        the current value of this question
        Throws:
        Interview.NotOnPathFault - if this question is not on the current path
        See Also:
        getValue()
      • getStringValue

        public java.lang.String getStringValue()
        Description copied from class: Question
        Get the response to this question as a string.
        Specified by:
        getStringValue in class Question
        Returns:
        a string representing the current response to this question, or null.
        See Also:
        Question.setValue(String)
      • isValueValid

        public boolean isValueValid()
        Description copied from class: Question
        Check if the question currently has a valid response.
        Specified by:
        isValueValid in class Question
        Returns:
        true if the question currently has a valid response, and false otherwise.
      • isValueAlwaysValid

        public boolean isValueAlwaysValid()
        Description copied from class: Question
        Check if the question always has a valid response. This may be true, for example, for a choice question with a default response.
        Specified by:
        isValueAlwaysValid in class Question
        Returns:
        true if the question always has a valid response, and false otherwise.
      • clear

        public void clear()
        Clear any response to this question, resetting the value back to its initial state.
        Specified by:
        clear in class Question
      • save

        protected void save​(java.util.Map<java.lang.String,​java.lang.String> data)
        Save the value for this question in a dictionary, using the tag as the key.
        Specified by:
        save in class Question
        Parameters:
        data - The map in which to save the value for this question.