本文整理汇总了Java中javax.jmdns.ServiceInfo.getTextBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceInfo.getTextBytes方法的具体用法?Java ServiceInfo.getTextBytes怎么用?Java ServiceInfo.getTextBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jmdns.ServiceInfo
的用法示例。
在下文中一共展示了ServiceInfo.getTextBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ServiceInfoImpl
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
/**
* During recovery we need to duplicate service info to reregister them
*
* @param info
*/
public ServiceInfoImpl(ServiceInfo info)
{
if (info != null)
{
this._domain = info.getDomain();
this._protocol = info.getProtocol();
this._application = info.getApplication();
this._name = info.getName();
this._subtype = info.getSubtype();
this._port = info.getPort();
this._weight = info.getWeight();
this._priority = info.getPriority();
this._text = info.getTextBytes();
this._persistent = info.isPersistent();
this._ipv4Addr = info.getInet4Address();
this._ipv6Addr = info.getInet6Address();
}
this._state = new ServiceInfoState(this);
}
示例2: _sameInfo
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
private static final boolean _sameInfo(ServiceInfo info, ServiceInfo lastInfo)
{
if (info == null)
return false;
if (lastInfo == null)
return false;
if (!info.equals(lastInfo))
return false;
byte[] text = info.getTextBytes();
byte[] lastText = lastInfo.getTextBytes();
if (text.length != lastText.length)
return false;
for (int i = 0; i < text.length; i++)
{
if (text[i] != lastText[i])
return false;
}
return true;
}
示例3: _sameInfo
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
private static final boolean _sameInfo(ServiceInfo info, ServiceInfo lastInfo) {
if (info == null) return false;
if (lastInfo == null) return false;
if (!info.equals(lastInfo)) return false;
byte[] text = info.getTextBytes();
byte[] lastText = lastInfo.getTextBytes();
if (text.length != lastText.length) return false;
for (int i = 0; i < text.length; i++) {
if (text[i] != lastText[i]) return false;
}
return true;
}
示例4: __parseSeviceInfo2IOTAddress
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
private static IOTAddress __parseSeviceInfo2IOTAddress(ServiceInfo serviceInfo)
{
byte[] textBytes = serviceInfo.getTextBytes();
log.debug("__parseSeviceInfo2IOTAddress(): textBytes toString: " + new String(textBytes));
// check whether the serviceInfo is valid
int index = 0;
while (index < textBytes.length)
{
index += (1 + textBytes[index]);
}
if (index != textBytes.length)
{
log.warn("__parseSeviceInfo2IOTAddress(): bad serviceInfo format, return null");
return null;
}
// get InetAddress
InetAddress inetAddress = null;
inetAddress = serviceInfo.getInet4Addresses()[0];
// get bssid, device type, device version
Map<String, String> keyValue = new HashMap<String, String>();
index = 0;
String part = null;
String[] subParts = null;
while (index < textBytes.length)
{
part = new String(textBytes, index + 1, textBytes[index]);
subParts = part.split("=");
// if the content is invalid, just ignore it
if (subParts.length == 2)
{
keyValue.put(subParts[0], subParts[1]);
}
index += (1 + textBytes[index]);
}
String bssid = keyValue.get(KEY_BSSID);
String type = keyValue.get(KEY_TYPE);
if (bssid == null || type == null)
{
log.warn("__parseSeviceInfo2IOTAddress(): bssid = null or type = null, return null");
return null;
}
EspDeviceType deviceType = EspDeviceType.getEspTypeEnumByString(type);
if (deviceType == null)
{
log.warn("__parseSeviceInfo2IOTAddress(): deviceType = null, return null");
return null;
}
IOTAddress iotAddress = new IOTAddress(bssid, inetAddress);
iotAddress.setEspDeviceTypeEnum(deviceType);
return iotAddress;
}