本文整理汇总了Java中org.eclipse.leshan.core.model.ResourceModel.Type.BOOLEAN属性的典型用法代码示例。如果您正苦于以下问题:Java Type.BOOLEAN属性的具体用法?Java Type.BOOLEAN怎么用?Java Type.BOOLEAN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.leshan.core.model.ResourceModel.Type
的用法示例。
在下文中一共展示了Type.BOOLEAN属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
public ResourceModel.Type getType() {
if (booleanValue != null) {
return Type.BOOLEAN;
}
if (floatValue != null) {
return Type.FLOAT;
}
if (objectLinkValue != null) {
// TODO handle object link or not ..
return null;
}
if (stringValue != null) {
return Type.STRING;
}
return null;
}
示例2: createObjectModels
protected List<ObjectModel> createObjectModels() {
// load default object from the spec
List<ObjectModel> objectModels = ObjectLoader.loadDefault();
// define custom model for testing purpose
ResourceModel stringfield = new ResourceModel(STRING_RESOURCE_ID, "stringres", Operations.RW, false, false,
Type.STRING, null, null, null);
ResourceModel booleanfield = new ResourceModel(BOOLEAN_RESOURCE_ID, "booleanres", Operations.RW, false, false,
Type.BOOLEAN, null, null, null);
ResourceModel integerfield = new ResourceModel(INTEGER_RESOURCE_ID, "integerres", Operations.RW, false, false,
Type.INTEGER, null, null, null);
ResourceModel floatfield = new ResourceModel(FLOAT_RESOURCE_ID, "floatres", Operations.RW, false, false,
Type.FLOAT, null, null, null);
ResourceModel timefield = new ResourceModel(TIME_RESOURCE_ID, "timeres", Operations.RW, false, false, Type.TIME,
null, null, null);
ResourceModel opaquefield = new ResourceModel(OPAQUE_RESOURCE_ID, "opaque", Operations.RW, false, false,
Type.OPAQUE, null, null, null);
ResourceModel objlnkfield = new ResourceModel(OBJLNK_MULTI_INSTANCE_RESOURCE_ID, "objlnk", Operations.RW, true,
false, Type.OBJLNK, null, null, null);
ResourceModel objlnkSinglefield = new ResourceModel(OBJLNK_SINGLE_INSTANCE_RESOURCE_ID, "objlnk", Operations.RW,
false, false, Type.OBJLNK, null, null, null);
objectModels.add(new ObjectModel(TEST_OBJECT_ID, "testobject", null, ObjectModel.DEFAULT_VERSION, false, false,
stringfield, booleanfield, integerfield, floatfield, timefield, opaquefield, objlnkfield,
objlnkSinglefield));
return objectModels;
}
示例3: getType
public ResourceModel.Type getType() {
if (booleanValue != null) {
return Type.BOOLEAN;
}
if (floatValue != null) {
return Type.FLOAT;
}
if (objectLinkValue != null) {
return Type.OBJLNK;
}
if (stringValue != null) {
return Type.STRING;
}
return null;
}
示例4: parseResource
private ResourceModel parseResource(Node item) {
Integer id = Integer.valueOf(item.getAttributes().getNamedItem("ID").getTextContent());
String name = null;
Operations operations = Operations.NONE;
boolean multiple = false;
boolean mandatory = false;
Type type = Type.STRING;
String rangeEnumeration = null;
String units = null;
String description = null;
for (int i = 0; i < item.getChildNodes().getLength(); i++) {
Node field = item.getChildNodes().item(i);
switch (field.getNodeName()) {
case "Name":
name = field.getTextContent();
break;
case "Operations":
String strOp = field.getTextContent();
if (strOp != null && !strOp.isEmpty()) {
operations = Operations.valueOf(strOp);
}
break;
case "MultipleInstances":
multiple = "Multiple".equals(field.getTextContent());
break;
case "Mandatory":
mandatory = "Mandatory".equals(field.getTextContent());
break;
case "Type":
switch (field.getTextContent()) {
case "String":
type = Type.STRING;
break;
case "Integer":
type = Type.INTEGER;
break;
case "Float":
type = Type.FLOAT;
break;
case "Boolean":
type = Type.BOOLEAN;
break;
case "Opaque":
type = Type.OPAQUE;
break;
case "Time":
type = Type.TIME;
break;
}
break;
case "RangeEnumeration":
rangeEnumeration = field.getTextContent();
break;
case "Units":
units = field.getTextContent();
break;
case "Description":
description = field.getTextContent();
break;
}
}
return new ResourceModel(id, name, operations, multiple, mandatory, type, rangeEnumeration, units, description);
}
示例5: newBooleanResource
public static LwM2mMultipleResource newBooleanResource(int id, Map<Integer, Boolean> values) {
Validate.noNullElements(values.values());
return new LwM2mMultipleResource(id, values, Type.BOOLEAN);
}
示例6: newBooleanResource
public static LwM2mSingleResource newBooleanResource(int id, boolean value) {
return new LwM2mSingleResource(id, value, Type.BOOLEAN);
}
示例7: write
@Override
public WriteResponse write(int resourceId, LwM2mResource value) {
LOG.debug("Write on resource {}: {}", resourceId, value);
// restricted to BS server?
switch (resourceId) {
case SEC_SERVER_URI: // server uri
if (value.getType() != Type.STRING) {
return WriteResponse.badRequest("invalid type");
}
serverUri = (String) value.getValue();
return WriteResponse.success();
case SEC_BOOTSTRAP: // is bootstrap server
if (value.getType() != Type.BOOLEAN) {
return WriteResponse.badRequest("invalid type");
}
bootstrapServer = (Boolean) value.getValue();
return WriteResponse.success();
case SEC_SECURITY_MODE: // security mode
if (value.getType() != Type.INTEGER) {
return WriteResponse.badRequest("invalid type");
}
securityMode = ((Long) value.getValue()).intValue();
return WriteResponse.success();
case SEC_PUBKEY_IDENTITY: // Public Key or Identity
if (value.getType() != Type.OPAQUE) {
return WriteResponse.badRequest("invalid type");
}
publicKeyOrIdentity = (byte[]) value.getValue();
return WriteResponse.success();
case SEC_SERVER_PUBKEY: // server public key
if (value.getType() != Type.OPAQUE) {
return WriteResponse.badRequest("invalid type");
}
secretKey = (byte[]) value.getValue();
return WriteResponse.success();
case SEC_SECRET_KEY: // Secret Key
if (value.getType() != Type.OPAQUE) {
return WriteResponse.badRequest("invalid type");
}
secretKey = (byte[]) value.getValue();
return WriteResponse.success();
case SEC_SERVER_ID: // short server id
if (value.getType() != Type.INTEGER) {
return WriteResponse.badRequest("invalid type");
}
shortServerId = ((Long) value.getValue()).intValue();
return WriteResponse.success();
default:
return super.write(resourceId, value);
}
}
示例8: write
@Override
public WriteResponse write(int resourceid, LwM2mResource value) {
switch (resourceid) {
case 0:
if (value.getType() != Type.INTEGER) {
return WriteResponse.badRequest("invalid type");
}
shortServerId = ((Long) value.getValue()).intValue();
return WriteResponse.success();
case 1:
if (value.getType() != Type.INTEGER) {
return WriteResponse.badRequest("invalid type");
}
lifetime = (Long) value.getValue();
return WriteResponse.success();
case 2:
if (value.getType() != Type.INTEGER) {
return WriteResponse.badRequest("invalid type");
}
defaultMinPeriod = (Long) value.getValue();
return WriteResponse.success();
case 3:
if (value.getType() != Type.INTEGER) {
return WriteResponse.badRequest("invalid type");
}
defaultMaxPeriod = (Long) value.getValue();
return WriteResponse.success();
case 6: // notification storing when disable or offline
if (value.getType() != Type.BOOLEAN) {
return WriteResponse.badRequest("invalid type");
}
notifyWhenDisable = (boolean) value.getValue();
return WriteResponse.success();
case 7: // binding
if (value.getType() != Type.STRING) {
return WriteResponse.badRequest("invalid type");
}
try {
binding = BindingMode.valueOf((String) value.getValue());
return WriteResponse.success();
} catch (IllegalArgumentException e) {
return WriteResponse.badRequest("invalid value");
}
default:
return super.write(resourceid, value);
}
}
示例9: parseResource
private ResourceModel parseResource(Node item) {
Integer id = Integer.valueOf(item.getAttributes().getNamedItem("ID").getTextContent());
String name = null;
Operations operations = Operations.NONE;
boolean multiple = false;
boolean mandatory = false;
Type type = Type.STRING;
String rangeEnumeration = null;
String units = null;
String description = null;
for (int i = 0; i < item.getChildNodes().getLength(); i++) {
Node field = item.getChildNodes().item(i);
switch (field.getNodeName()) {
case "Name":
name = field.getTextContent();
break;
case "Operations":
String strOp = field.getTextContent();
if (strOp != null && !strOp.isEmpty()) {
operations = Operations.valueOf(strOp);
}
break;
case "MultipleInstances":
multiple = "Multiple".equals(field.getTextContent());
break;
case "Mandatory":
mandatory = "Mandatory".equals(field.getTextContent());
break;
case "Type":
switch (field.getTextContent()) {
case "String":
type = Type.STRING;
break;
case "Integer":
type = Type.INTEGER;
break;
case "Float":
type = Type.FLOAT;
break;
case "Boolean":
type = Type.BOOLEAN;
break;
case "Opaque":
type = Type.OPAQUE;
break;
case "Time":
type = Type.TIME;
break;
case "Objlnk":
type = Type.OBJLNK;
break;
}
break;
case "RangeEnumeration":
rangeEnumeration = field.getTextContent();
break;
case "Units":
units = field.getTextContent();
break;
case "Description":
description = field.getTextContent();
break;
}
}
return new ResourceModel(id, name, operations, multiple, mandatory, type, rangeEnumeration, units, description);
}