private State initNewObject() { if (currentJsonNode != null) { this.nodesStack.push(currentJsonNode); } currentJsonNode = new BMap<String, BRefType<?>>(BTypes.typeJSON); return FIRST_FIELD_READY_STATE; }
@Override public void invalidate() { sessionManager.invalidateSession(this); attributeMap = new BMap<>(); isValid = false; }
private static BMap<String, BValue> createInvocationContext(Context context, BMap<String, BValue> userPrincipal, BMap<String, BValue> authContext) { StructureTypeInfo invocationContextInfo = getStructInfo(context, BALLERINA_RUNTIME_PKG, STRUCT_TYPE_INVOCATION_CONTEXT); UUID invocationId = UUID.randomUUID(); return BLangVMStructs.createBStruct(invocationContextInfo, invocationId.toString(), userPrincipal, authContext, new BMap()); }
public static BMap<String, BValue> getMatrixParamsMap(String path, HttpCarbonMessage carbonMessage) { BMap<String, BValue> matrixParamsBMap = new BMap<>(); Map<String, Map<String, String>> pathToMatrixParamMap = (Map<String, Map<String, String>>) carbonMessage.getProperty(HttpConstants.MATRIX_PARAMS); Map<String, String> matrixParamsMap = pathToMatrixParamMap.get(path); if (matrixParamsMap != null) { for (Map.Entry<String, String> matrixParamEntry : matrixParamsMap.entrySet()) { matrixParamsBMap.put(matrixParamEntry.getKey(), new BString(matrixParamEntry.getValue())); } } return matrixParamsBMap; }
private static BError generateError(Strand strand, boolean attachCallStack, BErrorType type, String reason, BMap<String, BValue> details) { BMap<String, BValue> detailMap = Optional.ofNullable(details).orElse(new BMap<>(BTypes.typeMap)); BError error = new BError(type, Optional.ofNullable(reason).orElse(""), detailMap); StructureTypeInfo typeInfo = getStructureTypeInfo(strand.programFile); if (attachCallStack) { attachStack(error, typeInfo, strand); } return error; }
private static void createNewStruct(int[] operands, StackFrame sf) { int cpIndex = operands[0]; int i = operands[1]; StructureRefCPEntry structureRefCPEntry = (StructureRefCPEntry) sf.constPool[cpIndex]; StructureTypeInfo structInfo = (StructureTypeInfo) ((TypeDefInfo) structureRefCPEntry .getStructureTypeInfo()).typeInfo; sf.refRegs[i] = new BMap<>(structInfo.getType()); }
public void setClaims(Map<String, String> claims) { BMap<String, BString> bMap = new BMap<>(); if (claims != null) { claims.forEach((key, value) -> bMap.put(key, new BString(value))); } authContextStruct.put(CLAIMS_REF_FIELD_KEY, bMap); }
private static void convertStructToMap(Strand strand, int[] operands, StackFrame sf) { int i = operands[0]; int j = operands[1]; // TODO: do validation for type? BMap newMap = new BMap(BTypes.typeMap); ((BMap) sf.refRegs[i]).getMap().forEach((key, value) -> newMap.put(key, value == null ? null : ((BValue) value).copy(new HashMap<>()))); sf.refRegs[j] = newMap; }
static BMap<String, BValue> wrapWithTypeMetadata(String type, BValue payload) { BMap<String, BValue> map = new BMap<>(); map.put(JsonSerializerConst.TYPE_TAG, createBString(type)); map.put(JsonSerializerConst.VALUE_TAG, payload); return map; }
private static BMap<String, BValue> createUserPrincipal(Context context) { StructureTypeInfo authContextInfo = getStructInfo(context, BALLERINA_RUNTIME_PKG, STRUCT_TYPE_USER_PRINCIPAL); String userId = ""; String username = ""; BMap<String, BString> claims = new BMap<>(); BValueArray scopes = new BValueArray(BTypes.typeString); return BLangVMStructs.createBStruct(authContextInfo, userId, username, claims, scopes); } }
public static BError createError(Strand strand, String reason, String detail) { BMap<String, BValue> detailMap = new BMap<>(BTypes.typeMap); if (detail != null) { detailMap.put(ERROR_MESSAGE_FIELD, new BString(detail)); } return generateError(strand, true, BTypes.typeError, reason, detailMap); }
@SuppressWarnings("rawtypes") protected WorkerExecutionContext onHaltFinalized() { BMap<String, BRefType> mbMap = new BMap<>(); channelNames.forEach((k, v) -> { BRefType workerRes = getWorkerResult(v); mbMap.put(k, workerRes); }); this.targetCtx.workerLocal.refRegs[joinVarReg] = (BRefType) mbMap; this.modifyDebugCommands(this.targetCtx, this.currentSignal.getSourceContext()); return BLangScheduler.resume(this.targetCtx, joinTargetIp, true); }
@Override @SuppressWarnings("unchecked") public BMap toObject(BPacket packet, BValueDeserializer bValueDeserializer) { BMap payload = (BMap<String, BValue>) packet.getValue(); HashMap deserializedMap = (HashMap) bValueDeserializer.deserialize(payload, HashMap.class); BType type = (BType) bValueDeserializer.deserialize(packet.get(MAP_STORAGE_TYPE), BType.class); BMap bMap = new BMap(type); bMap.getMap().putAll(deserializedMap); return bMap; } }
private BMap<String, BValue> createExistingReferenceNode(Object obj) { BMap<String, BValue> map = new BMap<>(); long objId = objectUID.findUID(obj); map.put(JsonSerializerConst.EXISTING_TAG, new BInteger(objId)); objectUID.addRepeatedRef(objId); return map; }
private static BMap<String, BValue> getSQLParameter(Context context) { PackageInfo sqlPackageInfo = context.getProgramFile().getPackageInfo(Constants.SQL_PACKAGE_PATH); StructureTypeInfo paramStructInfo = sqlPackageInfo.getStructInfo(Constants.SQL_PARAMETER); return new BMap<>(paramStructInfo.getType()); }
BMap<String, BValue> createStruct(Context context, String structName) { PackageInfo httpPackageInfo = context.getProgramFile() .getPackageInfo(PROTOCOL_STRUCT_PACKAGE_GRPC); StructureTypeInfo structInfo = httpPackageInfo.getStructInfo(structName); BStructureType structType = structInfo.getType(); return new BMap<>(structType); }
/** * {@inheritDoc} */ @Override public BMap<?, ?> getAttributesMap() { if (sequence.size() == 1) { return ((BXMLItem) sequence.getRefValue(0)).getAttributesMap(); } return new BMap<>(new BMapType(BTypes.typeString)); }
void notifyErrorReply(Context context, String errorMessage) { BErrorType errType = BTypes.typeError; String reason = "{ballerina/grpc}" + INTERNAL.name(); BMap<String, BValue> refData = new BMap<>(errType.detailsType); refData.put("message", new BString(errorMessage)); context.setReturnValues(new BError(BTypes.typeError, reason, refData)); } }
private BValue[] getSignatureParameters(LocalFileSystemEvent fileEvent) { BMap<String, BValue> eventStruct = new BMap<>(this.structInfo.getType()); eventStruct.put(FILE_EVENT_NAME, new BString(fileEvent.getFileName())); eventStruct.put(FILE_EVENT_OPERATION, new BString(fileEvent.getEvent())); return new BValue[] { eventStruct }; }
private BMap<String, BString> getTags(MetricId metricId) { BMap<String, BString> bTags = new BMap<>(new BMapType(BTypes.typeString)); Set<Tag> tags = metricId.getTags(); for (Tag tag : tags) { bTags.put(tag.getKey(), new BString(tag.getValue())); } return bTags; } }