本文整理匯總了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;
}