public static ReadResponse success(int resourceId, Map<Integer, ?> value, Type type) { return new ReadResponse(ResponseCode.CONTENT, LwM2mMultipleResource.newResource(resourceId, value, type), null); }
/** * Request to write a <b>Multi-Instance Resource</b> using the TLV content format. * * @param objectId the id of the object to write. * @param objectInstanceId the id of the object instance to write. * @param resourceId the id of the resource to write. * @param values the list of resource instance (id->value) to write. * @param type the data type of the resource. * @exception InvalidRequestException if parameters are invalid. */ public WriteRequest(int objectId, int objectInstanceId, int resourceId, Map<Integer, ?> values, Type type) throws InvalidRequestException { this(Mode.REPLACE, ContentFormat.TLV, new LwM2mPath(objectId, objectInstanceId, resourceId), LwM2mMultipleResource.newResource(resourceId, values, type)); }
/** * Request to write a <b>Multi-Instance Resource</b>. * * @param contentFormat Format of the payload (TLV or JSON). * @param objectId the id of the object to write. * @param objectInstanceId the id of the object instance to write. * @param resourceId the id of the resource to write. * @param values the list of resource instance (id->value) to write. * @param type the data type of the resource. * @exception InvalidRequestException if bad @{link ContentFormat} format was used. * */ public WriteRequest(ContentFormat contentFormat, int objectId, int objectInstanceId, int resourceId, Map<Integer, ?> values, Type type) throws InvalidRequestException { this(Mode.REPLACE, contentFormat, new LwM2mPath(objectId, objectInstanceId, resourceId), LwM2mMultipleResource.newResource(resourceId, values, type)); }
node = LwM2mMultipleResource.newResource(id, values, expectedType); } else { throw new JsonParseException("Invalid node element");
return LwM2mMultipleResource.newResource(id, values, type);
return LwM2mMultipleResource.newResource(id, values, type);
parseJsonValue(e.getValue().getResourceValue(), expectedType, resourcePath)); LwM2mResource resource = LwM2mMultipleResource.newResource(resourcePath.getResourceId(), values, expectedType); LwM2mResource previousRes = lwM2mResourceMap.put(resourcePath.getResourceId(), resource); Type resourceType = getResourceType(baseName, model, null); lwM2mResourceMap.put(baseName.getResourceId(), LwM2mMultipleResource .newResource(baseName.getResourceId(), new HashMap<Integer, Object>(), resourceType));
return LwM2mMultipleResource.newResource(resourceModel.id, values, resourceModel.type);
private static LwM2mResource parseResourceTlv(Tlv tlv, LwM2mPath resourcePath, LwM2mModel model) throws CodecException { Type expectedType = getResourceType(resourcePath, model); Integer resourceId = tlv.getIdentifier(); switch (tlv.getType()) { case MULTIPLE_RESOURCE: return LwM2mMultipleResource.newResource(resourceId, parseTlvValues(tlv.getChildren(), expectedType, resourcePath), expectedType); case RESOURCE_VALUE: return LwM2mSingleResource.newResource(resourceId, parseTlvValue(tlv.getValue(), expectedType, resourcePath), expectedType); default: throw new CodecException("Invalid TLV type %s for resource %s", tlv.getType(), resourcePath); } }
} else { Type expectedRscType = getResourceType(path, model); return (T) LwM2mMultipleResource.newResource(path.getResourceId(), parseTlvValues(tlvs, expectedRscType, path), expectedRscType);