本文整理汇总了Java中com.digitalpetri.opcua.stack.core.util.ArrayUtil类的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil类的具体用法?Java ArrayUtil怎么用?Java ArrayUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayUtil类属于com.digitalpetri.opcua.stack.core.util包,在下文中一共展示了ArrayUtil类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataType
import com.digitalpetri.opcua.stack.core.util.ArrayUtil; //导入依赖的package包/类
public Optional<NodeId> getDataType() {
if (value == null) return Optional.empty();
if (value instanceof UaStructure) {
return Optional.of(((UaStructure) value).getTypeId());
} else if (value instanceof UaEnumeration) {
return Optional.of(Identifiers.Int32);
} else {
Class<?> clazz = value.getClass().isArray() ?
ArrayUtil.getType(value) : value.getClass();
int typeId = TypeUtil.getBuiltinTypeId(clazz);
return typeId == -1 ?
Optional.empty() : Optional.of(new NodeId(0, typeId));
}
}
示例2: decodeVariant
import com.digitalpetri.opcua.stack.core.util.ArrayUtil; //导入依赖的package包/类
@Override
public Variant decodeVariant(String field) throws UaSerializationException {
int encodingMask = buffer.readByte();
if (encodingMask == 0) {
return new Variant(null);
} else {
int typeId = encodingMask & 0x3F;
boolean dimensionsEncoded = (encodingMask & 0x40) == 0x40;
boolean arrayEncoded = (encodingMask & 0x80) == 0x80;
if (arrayEncoded) {
int length = decodeInt32(null);
Class<?> backingClass = TypeUtil.getBackingClass(typeId);
Object flatArray = Array.newInstance(backingClass, length);
for (int i = 0; i < length; i++) {
Object element = decodeBuiltinType(typeId);
Array.set(flatArray, i, element);
}
int[] dimensions = dimensionsEncoded ? decodeDimensions() : new int[]{length};
Object array = dimensions.length > 1 ? ArrayUtil.unflatten(flatArray, dimensions) : flatArray;
return new Variant(array);
} else {
Object value = decodeBuiltinType(typeId);
return new Variant(value);
}
}
}
示例3: getClass
import com.digitalpetri.opcua.stack.core.util.ArrayUtil; //导入依赖的package包/类
private Class<?> getClass(@Nonnull Object o) {
if (o.getClass().isArray()) {
return ArrayUtil.getType(o);
} else {
return o.getClass();
}
}
示例4: Variant
import com.digitalpetri.opcua.stack.core.util.ArrayUtil; //导入依赖的package包/类
/**
* Create a new Variant with a given value.
*
* @param value the value this Variant holds.
*/
public Variant(@Nullable Object value) {
if (value != null) {
boolean clazzIsArray = value.getClass().isArray();
Class<?> componentClazz = clazzIsArray ?
ArrayUtil.getType(value) : value.getClass();
checkArgument(clazzIsArray || !Variant.class.equals(componentClazz), "Variant cannot contain Variant");
checkArgument(!DataValue.class.equals(componentClazz), "Variant cannot contain DataValue");
checkArgument(!DiagnosticInfo.class.equals(componentClazz), "Variant cannot contain DiagnosticInfo");
}
this.value = value;
}