public final class NsdServiceInfo extends Object implements Parcelable
NsdManager
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<NsdServiceInfo> |
CREATOR
Implement the Parcelable interface
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
NsdServiceInfo() |
NsdServiceInfo(String sn,
String rt) |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Implement the Parcelable interface
|
Map<String,byte[]> |
getAttributes()
Retrive attributes as a map of String keys to byte[] values.
|
InetAddress |
getHost()
Get the host address.
|
int |
getPort()
Get port number.
|
String |
getServiceName()
Get the service name
|
String |
getServiceType()
Get the service type
|
byte[] |
getTxtRecord() |
void |
removeAttribute(String key)
Remove an attribute by key
|
void |
setAttribute(String key,
byte[] value) |
void |
setAttribute(String key,
String value)
Add a service attribute as a key/value pair.
|
void |
setHost(InetAddress s)
Set the host address
|
void |
setPort(int p)
Set port number
|
void |
setServiceName(String s)
Set the service name
|
void |
setServiceType(String s)
Set the service type
|
void |
setTxtRecords(String rawRecords)
Unpack txt information from a base-64 encoded byte array.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Implement the Parcelable interface
|
public static final Parcelable.Creator<NsdServiceInfo> CREATOR
public String getServiceName()
public void setServiceName(String s)
public String getServiceType()
public void setServiceType(String s)
public InetAddress getHost()
public void setHost(InetAddress s)
public int getPort()
public void setPort(int p)
public void setTxtRecords(String rawRecords)
rawRecords
- The raw base64 encoded records string read from netd.public void setAttribute(String key, byte[] value)
public void setAttribute(String key, String value)
Service attributes are included as DNS-SD TXT record pairs.
The key must be US-ASCII printable characters, excluding the '=' character. Values may be UTF-8 strings or null. The total length of key + value must be less than 255 bytes.
Keys should be short, ideally no more than 9 characters, and unique per instance of
NsdServiceInfo
. Calling setAttribute(java.lang.String, byte[])
twice with the same key will overwrite
first value.
public void removeAttribute(String key)
public Map<String,byte[]> getAttributes()
The returned map is unmodifiable; changes must be made through setAttribute(java.lang.String, byte[])
and
removeAttribute(java.lang.String)
.
public byte[] getTxtRecord()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public int describeContents()
describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.