Class Location

  • All Implemented Interfaces:
    ibis.ipl.Location, java.io.Serializable, java.lang.Comparable<ibis.ipl.Location>, java.lang.Iterable<java.lang.String>

    public final class Location
    extends java.lang.Object
    implements ibis.ipl.Location
    Represents a location on which an Ibis instance runs. This is the data type returned by MultiIbisIdentifier.location(). It represents a number of levels, for instance hostname, domain, in that order, t.i., from detailed to coarse.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SEPARATOR
      Separates level names in a string representation of the location.
      • Fields inherited from interface ibis.ipl.Location

        DEFAULT_LOCATION
    • Constructor Summary

      Constructors 
      Constructor Description
      Location​(byte[] codedForm)
      Constructs a Location from the specified coded form.
      Location​(byte[] codedForm, int offset, int size)
      Constructs a Location from the specified coded form, at a particular offset and size.
      Location​(java.io.DataInput dis)
      Reads a Location from the specified input stream.
      Location​(java.lang.String s)
      Constructs a location object from the specified string, in which level names are separated by the separator character.
      Location​(java.lang.String[] levels)
      Constructs a location object from the specified level names.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(ibis.ipl.Location o)  
      static Location defaultLocation​(java.util.Properties props)
      Method to retreive a default location, consisting of the domain and hostname of this machine.
      boolean equals​(java.lang.Object o)  
      java.lang.String getLevel​(int level)  
      java.lang.String[] getLevels()  
      ibis.ipl.Location getParent()  
      int hashCode()  
      java.util.Iterator<java.lang.String> iterator()  
      int numberOfLevels()  
      int numberOfMatchingLevels​(ibis.ipl.Location o)  
      byte[] toBytes()
      Returns the coded form of this Location.
      java.lang.String toString()  
      void writeTo​(java.io.DataOutput dos)
      Adds coded form of this Location to the specified output stream.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • SEPARATOR

        public static final java.lang.String SEPARATOR
        Separates level names in a string representation of the location.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Location

        public Location​(java.lang.String[] levels)
        Constructs a location object from the specified level names.
        Parameters:
        levels - the level names.
      • Location

        public Location​(java.lang.String s)
        Constructs a location object from the specified string, in which level names are separated by the separator character.
        Parameters:
        s - the specified string.
      • Location

        public Location​(byte[] codedForm)
                 throws java.io.IOException
        Constructs a Location from the specified coded form.
        Parameters:
        codedForm - the coded form.
        Throws:
        java.io.IOException - is thrown in case of trouble.
      • Location

        public Location​(byte[] codedForm,
                        int offset,
                        int size)
                 throws java.io.IOException
        Constructs a Location from the specified coded form, at a particular offset and size.
        Parameters:
        codedForm - the coded form.
        offset - offset in the coded form.
        size - size of the coded form.
        Throws:
        java.io.IOException - is thrown in case of trouble.
      • Location

        public Location​(java.io.DataInput dis)
                 throws java.io.IOException
        Reads a Location from the specified input stream.
        Parameters:
        dis - the input stream.
        Throws:
        java.io.IOException - is thrown in case of trouble.
    • Method Detail

      • toBytes

        public byte[] toBytes()
        Returns the coded form of this Location.
        Returns:
        the coded form.
      • writeTo

        public void writeTo​(java.io.DataOutput dos)
                     throws java.io.IOException
        Adds coded form of this Location to the specified output stream.
        Parameters:
        dos - the output stream.
        Throws:
        java.io.IOException - is thrown in case of trouble.
      • numberOfLevels

        public int numberOfLevels()
        Specified by:
        numberOfLevels in interface ibis.ipl.Location
      • getLevels

        public java.lang.String[] getLevels()
        Specified by:
        getLevels in interface ibis.ipl.Location
      • getLevel

        public java.lang.String getLevel​(int level)
        Specified by:
        getLevel in interface ibis.ipl.Location
      • numberOfMatchingLevels

        public int numberOfMatchingLevels​(ibis.ipl.Location o)
        Specified by:
        numberOfMatchingLevels in interface ibis.ipl.Location
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • defaultLocation

        public static Location defaultLocation​(java.util.Properties props)
        Method to retreive a default location, consisting of the domain and hostname of this machine.
        Parameters:
        props - properties.
        Returns:
        the default location of this machine.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareTo

        public int compareTo​(ibis.ipl.Location o)
        Specified by:
        compareTo in interface java.lang.Comparable<ibis.ipl.Location>
      • getParent

        public ibis.ipl.Location getParent()
        Specified by:
        getParent in interface ibis.ipl.Location
      • iterator

        public java.util.Iterator<java.lang.String> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>