Package ibis.ipl.impl.multi
Class Location
- java.lang.Object
-
- ibis.ipl.impl.multi.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.LocationRepresents a location on which an Ibis instance runs. This is the data type returned byMultiIbisIdentifier.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.StringSEPARATORSeparates level names in a string representation of the location.
-
Constructor Summary
Constructors Constructor Description Location(byte[] codedForm)Constructs aLocationfrom the specified coded form.Location(byte[] codedForm, int offset, int size)Constructs aLocationfrom the specified coded form, at a particular offset and size.Location(java.io.DataInput dis)Reads aLocationfrom 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 intcompareTo(ibis.ipl.Location o)static LocationdefaultLocation(java.util.Properties props)Method to retreive a default location, consisting of the domain and hostname of this machine.booleanequals(java.lang.Object o)java.lang.StringgetLevel(int level)java.lang.String[]getLevels()ibis.ipl.LocationgetParent()inthashCode()java.util.Iterator<java.lang.String>iterator()intnumberOfLevels()intnumberOfMatchingLevels(ibis.ipl.Location o)byte[]toBytes()Returns the coded form of thisLocation.java.lang.StringtoString()voidwriteTo(java.io.DataOutput dos)Adds coded form of thisLocationto the specified output stream.
-
-
-
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.IOExceptionConstructs aLocationfrom 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.IOExceptionConstructs aLocationfrom 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.IOExceptionReads aLocationfrom 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 thisLocation.- Returns:
- the coded form.
-
writeTo
public void writeTo(java.io.DataOutput dos) throws java.io.IOExceptionAdds coded form of thisLocationto 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:
numberOfLevelsin interfaceibis.ipl.Location
-
getLevels
public java.lang.String[] getLevels()
- Specified by:
getLevelsin interfaceibis.ipl.Location
-
getLevel
public java.lang.String getLevel(int level)
- Specified by:
getLevelin interfaceibis.ipl.Location
-
numberOfMatchingLevels
public int numberOfMatchingLevels(ibis.ipl.Location o)
- Specified by:
numberOfMatchingLevelsin interfaceibis.ipl.Location
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.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:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(ibis.ipl.Location o)
- Specified by:
compareToin interfacejava.lang.Comparable<ibis.ipl.Location>
-
getParent
public ibis.ipl.Location getParent()
- Specified by:
getParentin interfaceibis.ipl.Location
-
iterator
public java.util.Iterator<java.lang.String> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.String>
-
-