本文整理汇总了Java中org.ws4d.coap.messages.CoapMediaType类的典型用法代码示例。如果您正苦于以下问题:Java CoapMediaType类的具体用法?Java CoapMediaType怎么用?Java CoapMediaType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CoapMediaType类属于org.ws4d.coap.messages包,在下文中一共展示了CoapMediaType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BasicCoapResource
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public BasicCoapResource(String path, byte[] value, CoapMediaType mediaType) {
this.path = path;
this.value = value;
this.mediaType = mediaType;
}
示例2: setCoapMediaType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public void setCoapMediaType(CoapMediaType mediaType) {
this.mediaType = mediaType;
}
示例3: getCoapMediaType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
@Override
public CoapMediaType getCoapMediaType() {
return mediaType;
}
示例4: getCoapMediaType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
@Override
public CoapMediaType getCoapMediaType() {
return CoapMediaType.link_format;
}
示例5: createResponse
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public CoapResponse createResponse(CoapMessage request,
CoapResponseCode responseCode, CoapMediaType contentType);
示例6: doGet
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
@Override
public void doGet(ServerChannel channel, CoapRequest request) {
String responseValue = null;
EnOceanRequest enoceanRequest = new EnOceanRequest(request);
CoapMessage response = channel.createResponse(request,
CoapResponseCode.Content_205);
switch (enoceanRequest.getRequest()) {
case Location:
responseValue = Utils.displayListOfChildren(enoceanStorage,
enoceanRequest.getLocation()).toString();
response.setContentFormat(CoapMediaType.json);
break;
case EEP:
responseValue = Utils.displayListOfMeasures(enoceanStorage,
enoceanRequest.getFunctionality(),
enoceanRequest.getLocation()).toString();
response.setContentFormat(CoapMediaType.json);
break;
case Value:
responseValue = Utils.displayActionValue(enoceanStorage,
enoceanRequest.getFunctionality(),
enoceanRequest.getLocation(), enoceanRequest.getAction());
response.setContentFormat(CoapMediaType.text_plain);
break;
case Storage:
logger.debug("DoGet() Storage ");
Vector<String> uriQuery = request.getUriQuery();
Hashtable<String, String> options = new Hashtable<String, String>();
for (int i = 0; i < uriQuery.size(); i++) {
if (uriQuery.get(i).contains("=")) {
String[] opts = uriQuery.get(i).split("=");
options.put(opts[0], opts[1]);
} else {
options.put(uriQuery.get(i), null);
}
}
if (options.containsKey("from") && options.containsKey("to")) {
responseValue = Utils.getStorageByDates(enoceanStorage,
enoceanRequest.getFunctionality(),
enoceanRequest.getLocation(),
enoceanRequest.getAction(), options.get("from"),
options.get("to")).toString();
} else if (options.containsKey("days")) {
responseValue = Utils.getStorageByDays(enoceanStorage,
enoceanRequest.getFunctionality(),
enoceanRequest.getLocation(),
enoceanRequest.getAction(), options.get("days"))
.toString();
} else {
response = channel.createResponse(request,
CoapResponseCode.Bad_Request_400);
}
response.setContentFormat(CoapMediaType.json);
break;
default:
logger.error("Error with type of request");
break;
}
// Have a better display for the urls
if (responseValue == null) {
response = channel.createResponse(request,
CoapResponseCode.Not_Found_404);
} else {
responseValue = responseValue.replace("\\/", "/");
logger.debug(responseValue);
response.setPayload(responseValue);
}
channel.sendMessage(response);
}
示例7: getCoapMediaType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public CoapMediaType getCoapMediaType() {
return mediaType;
}
示例8: getCoapMediaType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public CoapMediaType getCoapMediaType() {
return CoapMediaType.link_format;
}
示例9: getCoapMediaType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public CoapMediaType getCoapMediaType();
示例10: addAccept
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public void addAccept(CoapMediaType mediaType);
示例11: getAccept
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public Vector<CoapMediaType> getAccept(CoapMediaType mediaType);
示例12: setContentFormat
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public void setContentFormat(CoapMediaType mediaType);
示例13: getContentFormat
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public CoapMediaType getContentFormat();
示例14: setContentType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public void setContentType(CoapMediaType mediaType);
示例15: getContentType
import org.ws4d.coap.messages.CoapMediaType; //导入依赖的package包/类
public CoapMediaType getContentType();