before
stringlengths
14
203k
after
stringlengths
37
104k
repo
stringlengths
2
50
type
stringclasses
1 value
@Override public void writeShortBytes(byte[] bytes, ByteBuf dest) { dest.writeShort(bytes.length); dest.writeBytes(bytes); }
<DeepExtract> dest.writeShort(bytes.length); </DeepExtract>
simulacron
positive
@Override public void onSelect(String text) { selectedCalender.set(Calendar.YEAR, Integer.parseInt(text)); month.clear(); int selectedYear = selectedCalender.get(Calendar.YEAR); if (selectedYear == startYear) { for (int i = startMonth; i <= MAX_MONTH; i++) { month.add(formatTimeUnit(i)); } } else if (selectedYear == endYear) { for (int i = 1; i <= endMonth; i++) { month.add(formatTimeUnit(i)); } } else { for (int i = 1; i <= MAX_MONTH; i++) { month.add(formatTimeUnit(i)); } } selectedCalender.set(Calendar.MONTH, Integer.parseInt(month.get(0)) - 1); month_pv.setData(month); month_pv.setSelected(0); executeAnimator(month_pv); month_pv.postDelayed(new Runnable() { @Override public void run() { dayChange(); } }, 100); }
<DeepExtract> month.clear(); int selectedYear = selectedCalender.get(Calendar.YEAR); if (selectedYear == startYear) { for (int i = startMonth; i <= MAX_MONTH; i++) { month.add(formatTimeUnit(i)); } } else if (selectedYear == endYear) { for (int i = 1; i <= endMonth; i++) { month.add(formatTimeUnit(i)); } } else { for (int i = 1; i <= MAX_MONTH; i++) { month.add(formatTimeUnit(i)); } } selectedCalender.set(Calendar.MONTH, Integer.parseInt(month.get(0)) - 1); month_pv.setData(month); month_pv.setSelected(0); executeAnimator(month_pv); month_pv.postDelayed(new Runnable() { @Override public void run() { dayChange(); } }, 100); </DeepExtract>
bill
positive
@Override public void onDraw(Canvas canvas) { if (!mInputEnabled) { canvas.saveLayerAlpha(0, 0, getWidth(), getHeight(), mDisabledAlpha, Canvas.ALL_SAVE_FLAG); } else { canvas.save(); } float numbersRadius = mCircleRadius[HOURS] * mNumbersRadiusMultiplier[HOURS] * mAnimationRadiusMultiplier[HOURS]; calculateGridSizes(mPaint[HOURS], numbersRadius, mXCenter, mYCenter, mTextSize[HOURS], mTextGridHeights[HOURS], mTextGridWidths[HOURS]); if (mIs24HourMode) { float innerNumbersRadius = mCircleRadius[HOURS_INNER] * mNumbersRadiusMultiplier[HOURS_INNER] * mAnimationRadiusMultiplier[HOURS_INNER]; calculateGridSizes(mPaint[HOURS], innerNumbersRadius, mXCenter, mYCenter, mInnerTextSize, mInnerTextGridHeights, mInnerTextGridWidths); } float numbersRadius = mCircleRadius[MINUTES] * mNumbersRadiusMultiplier[MINUTES] * mAnimationRadiusMultiplier[MINUTES]; calculateGridSizes(mPaint[MINUTES], numbersRadius, mXCenter, mYCenter, mTextSize[MINUTES], mTextGridHeights[MINUTES], mTextGridWidths[MINUTES]); canvas.drawCircle(mXCenter, mYCenter, mCircleRadius[HOURS], mPaintBackground); drawSelector(canvas, mIsOnInnerCircle ? HOURS_INNER : HOURS); drawSelector(canvas, MINUTES); mPaint[HOURS].setTextSize(mTextSize[HOURS]); mPaint[HOURS].setTypeface(mTypeface); mPaint[HOURS].setColor(mColor[HOURS]); mPaint[HOURS].setAlpha(getMultipliedAlpha(mColor[HOURS], mAlpha[HOURS].getValue())); canvas.drawText(mOuterTextHours[0], mTextGridWidths[HOURS][3], mTextGridHeights[HOURS][0], mPaint[HOURS]); canvas.drawText(mOuterTextHours[1], mTextGridWidths[HOURS][4], mTextGridHeights[HOURS][1], mPaint[HOURS]); canvas.drawText(mOuterTextHours[2], mTextGridWidths[HOURS][5], mTextGridHeights[HOURS][2], mPaint[HOURS]); canvas.drawText(mOuterTextHours[3], mTextGridWidths[HOURS][6], mTextGridHeights[HOURS][3], mPaint[HOURS]); canvas.drawText(mOuterTextHours[4], mTextGridWidths[HOURS][5], mTextGridHeights[HOURS][4], mPaint[HOURS]); canvas.drawText(mOuterTextHours[5], mTextGridWidths[HOURS][4], mTextGridHeights[HOURS][5], mPaint[HOURS]); canvas.drawText(mOuterTextHours[6], mTextGridWidths[HOURS][3], mTextGridHeights[HOURS][6], mPaint[HOURS]); canvas.drawText(mOuterTextHours[7], mTextGridWidths[HOURS][2], mTextGridHeights[HOURS][5], mPaint[HOURS]); canvas.drawText(mOuterTextHours[8], mTextGridWidths[HOURS][1], mTextGridHeights[HOURS][4], mPaint[HOURS]); canvas.drawText(mOuterTextHours[9], mTextGridWidths[HOURS][0], mTextGridHeights[HOURS][3], mPaint[HOURS]); canvas.drawText(mOuterTextHours[10], mTextGridWidths[HOURS][1], mTextGridHeights[HOURS][2], mPaint[HOURS]); canvas.drawText(mOuterTextHours[11], mTextGridWidths[HOURS][2], mTextGridHeights[HOURS][1], mPaint[HOURS]); if (mIs24HourMode && mInnerTextHours != null) { drawTextElements(canvas, mInnerTextSize, mTypeface, mInnerTextHours, mInnerTextGridWidths, mInnerTextGridHeights, mPaint[HOURS], mColor[HOURS], mAlpha[HOURS].getValue()); } mPaint[MINUTES].setTextSize(mTextSize[MINUTES]); mPaint[MINUTES].setTypeface(mTypeface); mPaint[MINUTES].setColor(mColor[MINUTES]); mPaint[MINUTES].setAlpha(getMultipliedAlpha(mColor[MINUTES], mAlpha[MINUTES].getValue())); canvas.drawText(mOuterTextMinutes[0], mTextGridWidths[MINUTES][3], mTextGridHeights[MINUTES][0], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[1], mTextGridWidths[MINUTES][4], mTextGridHeights[MINUTES][1], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[2], mTextGridWidths[MINUTES][5], mTextGridHeights[MINUTES][2], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[3], mTextGridWidths[MINUTES][6], mTextGridHeights[MINUTES][3], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[4], mTextGridWidths[MINUTES][5], mTextGridHeights[MINUTES][4], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[5], mTextGridWidths[MINUTES][4], mTextGridHeights[MINUTES][5], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[6], mTextGridWidths[MINUTES][3], mTextGridHeights[MINUTES][6], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[7], mTextGridWidths[MINUTES][2], mTextGridHeights[MINUTES][5], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[8], mTextGridWidths[MINUTES][1], mTextGridHeights[MINUTES][4], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[9], mTextGridWidths[MINUTES][0], mTextGridHeights[MINUTES][3], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[10], mTextGridWidths[MINUTES][1], mTextGridHeights[MINUTES][2], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[11], mTextGridWidths[MINUTES][2], mTextGridHeights[MINUTES][1], mPaint[MINUTES]); canvas.drawCircle(mXCenter, mYCenter, CENTER_RADIUS, mPaintCenter); if (DEBUG) { drawDebug(canvas); } canvas.restore(); }
<DeepExtract> float numbersRadius = mCircleRadius[HOURS] * mNumbersRadiusMultiplier[HOURS] * mAnimationRadiusMultiplier[HOURS]; calculateGridSizes(mPaint[HOURS], numbersRadius, mXCenter, mYCenter, mTextSize[HOURS], mTextGridHeights[HOURS], mTextGridWidths[HOURS]); if (mIs24HourMode) { float innerNumbersRadius = mCircleRadius[HOURS_INNER] * mNumbersRadiusMultiplier[HOURS_INNER] * mAnimationRadiusMultiplier[HOURS_INNER]; calculateGridSizes(mPaint[HOURS], innerNumbersRadius, mXCenter, mYCenter, mInnerTextSize, mInnerTextGridHeights, mInnerTextGridWidths); } </DeepExtract> <DeepExtract> float numbersRadius = mCircleRadius[MINUTES] * mNumbersRadiusMultiplier[MINUTES] * mAnimationRadiusMultiplier[MINUTES]; calculateGridSizes(mPaint[MINUTES], numbersRadius, mXCenter, mYCenter, mTextSize[MINUTES], mTextGridHeights[MINUTES], mTextGridWidths[MINUTES]); </DeepExtract> <DeepExtract> canvas.drawCircle(mXCenter, mYCenter, mCircleRadius[HOURS], mPaintBackground); </DeepExtract> <DeepExtract> drawSelector(canvas, mIsOnInnerCircle ? HOURS_INNER : HOURS); drawSelector(canvas, MINUTES); </DeepExtract> <DeepExtract> mPaint[HOURS].setTextSize(mTextSize[HOURS]); mPaint[HOURS].setTypeface(mTypeface); mPaint[HOURS].setColor(mColor[HOURS]); mPaint[HOURS].setAlpha(getMultipliedAlpha(mColor[HOURS], mAlpha[HOURS].getValue())); canvas.drawText(mOuterTextHours[0], mTextGridWidths[HOURS][3], mTextGridHeights[HOURS][0], mPaint[HOURS]); canvas.drawText(mOuterTextHours[1], mTextGridWidths[HOURS][4], mTextGridHeights[HOURS][1], mPaint[HOURS]); canvas.drawText(mOuterTextHours[2], mTextGridWidths[HOURS][5], mTextGridHeights[HOURS][2], mPaint[HOURS]); canvas.drawText(mOuterTextHours[3], mTextGridWidths[HOURS][6], mTextGridHeights[HOURS][3], mPaint[HOURS]); canvas.drawText(mOuterTextHours[4], mTextGridWidths[HOURS][5], mTextGridHeights[HOURS][4], mPaint[HOURS]); canvas.drawText(mOuterTextHours[5], mTextGridWidths[HOURS][4], mTextGridHeights[HOURS][5], mPaint[HOURS]); canvas.drawText(mOuterTextHours[6], mTextGridWidths[HOURS][3], mTextGridHeights[HOURS][6], mPaint[HOURS]); canvas.drawText(mOuterTextHours[7], mTextGridWidths[HOURS][2], mTextGridHeights[HOURS][5], mPaint[HOURS]); canvas.drawText(mOuterTextHours[8], mTextGridWidths[HOURS][1], mTextGridHeights[HOURS][4], mPaint[HOURS]); canvas.drawText(mOuterTextHours[9], mTextGridWidths[HOURS][0], mTextGridHeights[HOURS][3], mPaint[HOURS]); canvas.drawText(mOuterTextHours[10], mTextGridWidths[HOURS][1], mTextGridHeights[HOURS][2], mPaint[HOURS]); canvas.drawText(mOuterTextHours[11], mTextGridWidths[HOURS][2], mTextGridHeights[HOURS][1], mPaint[HOURS]); </DeepExtract> <DeepExtract> mPaint[MINUTES].setTextSize(mTextSize[MINUTES]); mPaint[MINUTES].setTypeface(mTypeface); mPaint[MINUTES].setColor(mColor[MINUTES]); mPaint[MINUTES].setAlpha(getMultipliedAlpha(mColor[MINUTES], mAlpha[MINUTES].getValue())); canvas.drawText(mOuterTextMinutes[0], mTextGridWidths[MINUTES][3], mTextGridHeights[MINUTES][0], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[1], mTextGridWidths[MINUTES][4], mTextGridHeights[MINUTES][1], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[2], mTextGridWidths[MINUTES][5], mTextGridHeights[MINUTES][2], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[3], mTextGridWidths[MINUTES][6], mTextGridHeights[MINUTES][3], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[4], mTextGridWidths[MINUTES][5], mTextGridHeights[MINUTES][4], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[5], mTextGridWidths[MINUTES][4], mTextGridHeights[MINUTES][5], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[6], mTextGridWidths[MINUTES][3], mTextGridHeights[MINUTES][6], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[7], mTextGridWidths[MINUTES][2], mTextGridHeights[MINUTES][5], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[8], mTextGridWidths[MINUTES][1], mTextGridHeights[MINUTES][4], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[9], mTextGridWidths[MINUTES][0], mTextGridHeights[MINUTES][3], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[10], mTextGridWidths[MINUTES][1], mTextGridHeights[MINUTES][2], mPaint[MINUTES]); canvas.drawText(mOuterTextMinutes[11], mTextGridWidths[MINUTES][2], mTextGridHeights[MINUTES][1], mPaint[MINUTES]); </DeepExtract> <DeepExtract> canvas.drawCircle(mXCenter, mYCenter, CENTER_RADIUS, mPaintCenter); </DeepExtract>
Mayigushi-App
positive
public TopologyTemplate convertNodeTemplates(VMApplication application, Map<String, Flavor> id2FlavorMap, Map<Integer, VMImage> id2ImageMap) { pkgSpecsUtil.init(application.getPkgSpecId()); try (InputStream inputStream = new FileInputStream(new File(VM_PACKAGE_TEMPLATE_INPUT_PATH))) { Yaml yaml = new Yaml(new SafeConstructor()); LinkedHashMap<String, LinkedHashMap<String, String>> vmInputs = yaml.load(inputStream); for (Map.Entry<String, LinkedHashMap<String, String>> entry : vmInputs.entrySet()) { topologyTemplate.getInputs().put(entry.getKey(), new InputParam(entry.getValue())); } } catch (IOException e) { LOGGER.error("init vm inputs read file failed. {}", e.getMessage()); throw new FileOperateException("init vm inputs read file failed.", ResponseConsts.RET_LOAD_YAML_FAIL); } updateVnfNode(application.getName(), application.getProvider(), application.getVersion()); List<Network> networkLst = application.getNetworkList(); List<VirtualMachine> vmLst = application.getVmList(); if (null == topologyTemplate.getNodeTemplates()) { topologyTemplate.setNodeTemplates(new LinkedHashMap<>()); } for (int i = 0; i < vmLst.size(); i++) { VirtualMachine vm = vmLst.get(i); int vduIndex = i + 1; String vduName = InputConstant.VDU_NAME_PREFIX + vduIndex; String azInputName = InputConstant.INPUT_NAME_AZ; if (!topologyTemplate.getInputs().containsKey(azInputName)) { InputParam azInput = new InputParam(InputConstant.TYPE_STRING, vm.getAreaZone(), "az of the vm"); topologyTemplate.getInputs().put(azInputName, azInput); } NodeTemplate vduNode = new NodeTemplate(); vduNode.setType(NodeTypeConstant.NODE_TYPE_VDU); Flavor flavor = id2FlavorMap.get(vm.getFlavorId()); pkgSpecsUtil.updateVDUCapabilities(topologyTemplate, vduName, vduNode, flavor); VDUProperty property = new VDUProperty(); property.setName(vm.getName()); property.setNfviConstraints(getInputStr(azInputName)); pkgSpecsUtil.updateFlavorExtraSpecs(topologyTemplate, vduName, property, vm.getFlavorExtraSpecs()); if (vm.getTargetImageId() != null) { property.getSwImageData().setName(id2ImageMap.get(vm.getTargetImageId()).getName()); } else { property.getSwImageData().setName(id2ImageMap.get(vm.getImageId()).getName()); } if (StringUtils.isEmpty(vm.getUserData())) { property.getBootdata().setConfigDrive(false); property.getBootdata().setUserData(null); } else { property.getBootdata().setConfigDrive(true); property.getBootdata().getUserData().setContents(vm.getUserData()); property.getBootdata().getUserData().setParams(getVDUNodeUserDataParams(vduName, vm.getPortList(), networkLst)); } vduNode.setProperties(property); topologyTemplate.getNodeTemplates().put(vduName, vduNode); updateVMPorts(vduName, vm.getPortList(), networkLst); } if (null == topologyTemplate.getNodeTemplates()) { topologyTemplate.setNodeTemplates(new LinkedHashMap<>()); } for (int i = 0; i < application.getNetworkList().size(); i++) { String networkName = application.getNetworkList().get(i).getName(); int index = i + 1; String networkNameInputName = InputConstant.INPUT_NETWORK_PREFIX + index + InputConstant.INPUT_NETWORK_POSTFIX; String networkPhyNetInputName = InputConstant.INPUT_NETWORK_PREFIX + index + InputConstant.INPUT_PHYSNET_POSTFIX; String networkVlanIdInputName = InputConstant.INPUT_NETWORK_PREFIX + index + InputConstant.INPUT_VLANID_POSTFIX; InputParam networkNameInput = new InputParam(InputConstant.TYPE_STRING, networkName, application.getNetworkList().get(i).getDescription()); InputParam networkPhyNet = new InputParam(InputConstant.TYPE_STRING, InputConstant.DEFALUT_PHYSNET, "physical network of " + networkName); int vlanId = InputConstant.DEFALUT_NETWORK_VLANID + index; InputParam networkVlanId = new InputParam(InputConstant.TYPE_STRING, String.valueOf(vlanId), "vlan id of " + networkName); topologyTemplate.getInputs().put(networkNameInputName, networkNameInput); topologyTemplate.getInputs().put(networkPhyNetInputName, networkPhyNet); topologyTemplate.getInputs().put(networkVlanIdInputName, networkVlanId); NodeTemplate vlNode = new NodeTemplate(); vlNode.setType(NodeTypeConstant.NODE_TYPE_VL); VLProperty property = new VLProperty(); VLProfile vlProfile = new VLProfile(); vlProfile.setNetworkName(getInputStr(networkNameInputName)); vlProfile.setPhysicalNetwork(getInputStr(networkPhyNetInputName)); vlProfile.setProviderSegmentationId(getInputStr(networkVlanIdInputName)); property.setVlProfile(vlProfile); vlNode.setProperties(property); topologyTemplate.getNodeTemplates().put(networkName, vlNode); } updateAppConfiguration(application); updateGroupsAndPolicies(); for (Map.Entry<String, InputParam> entry : this.topologyTemplate.getInputs().entrySet()) { Object defaultVal = VmDefaultInputData.getDefaultData(entry.getKey()); if (defaultVal != null) { entry.getValue().setDefaultValue(defaultVal); } } return this.topologyTemplate; }
<DeepExtract> try (InputStream inputStream = new FileInputStream(new File(VM_PACKAGE_TEMPLATE_INPUT_PATH))) { Yaml yaml = new Yaml(new SafeConstructor()); LinkedHashMap<String, LinkedHashMap<String, String>> vmInputs = yaml.load(inputStream); for (Map.Entry<String, LinkedHashMap<String, String>> entry : vmInputs.entrySet()) { topologyTemplate.getInputs().put(entry.getKey(), new InputParam(entry.getValue())); } } catch (IOException e) { LOGGER.error("init vm inputs read file failed. {}", e.getMessage()); throw new FileOperateException("init vm inputs read file failed.", ResponseConsts.RET_LOAD_YAML_FAIL); } </DeepExtract> <DeepExtract> List<Network> networkLst = application.getNetworkList(); List<VirtualMachine> vmLst = application.getVmList(); if (null == topologyTemplate.getNodeTemplates()) { topologyTemplate.setNodeTemplates(new LinkedHashMap<>()); } for (int i = 0; i < vmLst.size(); i++) { VirtualMachine vm = vmLst.get(i); int vduIndex = i + 1; String vduName = InputConstant.VDU_NAME_PREFIX + vduIndex; String azInputName = InputConstant.INPUT_NAME_AZ; if (!topologyTemplate.getInputs().containsKey(azInputName)) { InputParam azInput = new InputParam(InputConstant.TYPE_STRING, vm.getAreaZone(), "az of the vm"); topologyTemplate.getInputs().put(azInputName, azInput); } NodeTemplate vduNode = new NodeTemplate(); vduNode.setType(NodeTypeConstant.NODE_TYPE_VDU); Flavor flavor = id2FlavorMap.get(vm.getFlavorId()); pkgSpecsUtil.updateVDUCapabilities(topologyTemplate, vduName, vduNode, flavor); VDUProperty property = new VDUProperty(); property.setName(vm.getName()); property.setNfviConstraints(getInputStr(azInputName)); pkgSpecsUtil.updateFlavorExtraSpecs(topologyTemplate, vduName, property, vm.getFlavorExtraSpecs()); if (vm.getTargetImageId() != null) { property.getSwImageData().setName(id2ImageMap.get(vm.getTargetImageId()).getName()); } else { property.getSwImageData().setName(id2ImageMap.get(vm.getImageId()).getName()); } if (StringUtils.isEmpty(vm.getUserData())) { property.getBootdata().setConfigDrive(false); property.getBootdata().setUserData(null); } else { property.getBootdata().setConfigDrive(true); property.getBootdata().getUserData().setContents(vm.getUserData()); property.getBootdata().getUserData().setParams(getVDUNodeUserDataParams(vduName, vm.getPortList(), networkLst)); } vduNode.setProperties(property); topologyTemplate.getNodeTemplates().put(vduName, vduNode); updateVMPorts(vduName, vm.getPortList(), networkLst); } </DeepExtract> <DeepExtract> if (null == topologyTemplate.getNodeTemplates()) { topologyTemplate.setNodeTemplates(new LinkedHashMap<>()); } for (int i = 0; i < application.getNetworkList().size(); i++) { String networkName = application.getNetworkList().get(i).getName(); int index = i + 1; String networkNameInputName = InputConstant.INPUT_NETWORK_PREFIX + index + InputConstant.INPUT_NETWORK_POSTFIX; String networkPhyNetInputName = InputConstant.INPUT_NETWORK_PREFIX + index + InputConstant.INPUT_PHYSNET_POSTFIX; String networkVlanIdInputName = InputConstant.INPUT_NETWORK_PREFIX + index + InputConstant.INPUT_VLANID_POSTFIX; InputParam networkNameInput = new InputParam(InputConstant.TYPE_STRING, networkName, application.getNetworkList().get(i).getDescription()); InputParam networkPhyNet = new InputParam(InputConstant.TYPE_STRING, InputConstant.DEFALUT_PHYSNET, "physical network of " + networkName); int vlanId = InputConstant.DEFALUT_NETWORK_VLANID + index; InputParam networkVlanId = new InputParam(InputConstant.TYPE_STRING, String.valueOf(vlanId), "vlan id of " + networkName); topologyTemplate.getInputs().put(networkNameInputName, networkNameInput); topologyTemplate.getInputs().put(networkPhyNetInputName, networkPhyNet); topologyTemplate.getInputs().put(networkVlanIdInputName, networkVlanId); NodeTemplate vlNode = new NodeTemplate(); vlNode.setType(NodeTypeConstant.NODE_TYPE_VL); VLProperty property = new VLProperty(); VLProfile vlProfile = new VLProfile(); vlProfile.setNetworkName(getInputStr(networkNameInputName)); vlProfile.setPhysicalNetwork(getInputStr(networkPhyNetInputName)); vlProfile.setProviderSegmentationId(getInputStr(networkVlanIdInputName)); property.setVlProfile(vlProfile); vlNode.setProperties(property); topologyTemplate.getNodeTemplates().put(networkName, vlNode); } </DeepExtract> <DeepExtract> for (Map.Entry<String, InputParam> entry : this.topologyTemplate.getInputs().entrySet()) { Object defaultVal = VmDefaultInputData.getDefaultData(entry.getKey()); if (defaultVal != null) { entry.getValue().setDefaultValue(defaultVal); } } </DeepExtract>
developer-be
positive
protected void runTask(SynchronizeTask task) { execute(task); super.beforeExecute(new Thread(task.getSyncName() + "-" + task.getId().getKey()), task); if (task instanceof SynchronizeTask) { SynchronizeTask task = (SynchronizeTask) task; new Thread(task.getSyncName() + "-" + task.getId().getKey()).setName(task.getSyncName() + "-" + new Thread(task.getSyncName() + "-" + task.getId().getKey()).getId()); } }
<DeepExtract> super.beforeExecute(new Thread(task.getSyncName() + "-" + task.getId().getKey()), task); if (task instanceof SynchronizeTask) { SynchronizeTask task = (SynchronizeTask) task; new Thread(task.getSyncName() + "-" + task.getId().getKey()).setName(task.getSyncName() + "-" + new Thread(task.getSyncName() + "-" + task.getId().getKey()).getId()); } </DeepExtract>
lsc
positive
@Override public void lineTo(final float x1, final float y1) { final int outcode0 = this.cOutCode; if (clipRect != null) { final int outcode1 = Helpers.outcode(x1, y1, clipRect); final int orCode = (outcode0 | outcode1); if (orCode != 0) { final int sideCode = outcode0 & outcode1; if (sideCode == 0) { if (subdivide) { subdivide = false; boolean ret = curveSplitter.splitLine(cx0, cy0, x1, y1, orCode, this); subdivide = true; if (ret) { return; } } } else { this.cOutCode = outcode1; _moveTo(x1, y1, outcode0); opened = true; return; } } this.cOutCode = outcode1; } float dx = x1 - cx0; float dy = y1 - cy0; if (dx == 0.0f && dy == 0.0f) { dx = 1.0f; } float len = dx * dx + dy * dy; if (len == 0.0f) { offset0[0] = 0.0f; offset0[1] = 0.0f; } else { len = (float) Math.sqrt(len); offset0[0] = (dy * lineWidth2) / len; offset0[1] = -(dx * lineWidth2) / len; } final float mx = offset0[0]; final float my = offset0[1]; if (prev != DRAWING_OP_TO) { emitMoveTo(cx0 + mx, cy0 + my); if (!opened) { this.sdx = dx; this.sdy = dy; this.smx = mx; this.smy = my; } } else { final boolean cw = isCW(cdx, cdy, dx, dy); if (outcode0 == 0) { if (joinStyle == JOIN_MITER) { drawMiter(cdx, cdy, cx0, cy0, dx, dy, cmx, cmy, mx, my, cw); } else if (joinStyle == JOIN_ROUND) { mayDrawRoundJoin(cx0, cy0, cmx, cmy, mx, my, cw); } } emitLineTo(cx0, cy0, !cw); } prev = DRAWING_OP_TO; out.lineTo(cx0 + mx, cy0 + my); out.lineTo(x1 + mx, y1 + my); reverse.pushLine(cx0 - mx, cy0 - my); reverse.pushLine(x1 - mx, y1 - my); this.prev = DRAWING_OP_TO; this.cx0 = x1; this.cy0 = y1; this.cdx = dx; this.cdy = dy; this.cmx = mx; this.cmy = my; }
<DeepExtract> float len = dx * dx + dy * dy; if (len == 0.0f) { offset0[0] = 0.0f; offset0[1] = 0.0f; } else { len = (float) Math.sqrt(len); offset0[0] = (dy * lineWidth2) / len; offset0[1] = -(dx * lineWidth2) / len; } </DeepExtract> <DeepExtract> if (prev != DRAWING_OP_TO) { emitMoveTo(cx0 + mx, cy0 + my); if (!opened) { this.sdx = dx; this.sdy = dy; this.smx = mx; this.smy = my; } } else { final boolean cw = isCW(cdx, cdy, dx, dy); if (outcode0 == 0) { if (joinStyle == JOIN_MITER) { drawMiter(cdx, cdy, cx0, cy0, dx, dy, cmx, cmy, mx, my, cw); } else if (joinStyle == JOIN_ROUND) { mayDrawRoundJoin(cx0, cy0, cmx, cmy, mx, my, cw); } } emitLineTo(cx0, cy0, !cw); } prev = DRAWING_OP_TO; </DeepExtract> <DeepExtract> out.lineTo(cx0 + mx, cy0 + my); </DeepExtract> <DeepExtract> out.lineTo(x1 + mx, y1 + my); </DeepExtract> <DeepExtract> reverse.pushLine(cx0 - mx, cy0 - my); </DeepExtract> <DeepExtract> reverse.pushLine(x1 - mx, y1 - my); </DeepExtract>
marlin-fx
positive
public GdxQuery and(Object... a) { for (Object obj : a) if (obj instanceof TypedGdxQuery) list().add(((TypedGdxQuery) obj).get()); else if (obj instanceof Actor) list().add((Actor) obj); else if (obj instanceof Cell<?>) list().add(((Cell<?>) obj).getActor()); else if (obj instanceof Stage) for (Actor actor : ((Stage) obj).getActors()) list().add(actor); else if (obj instanceof GdxQuery) list().addAll(((GdxQuery) obj).list()); else if (obj instanceof Collection) for (Object col : (Collection<?>) obj) add(col); else if (obj instanceof Array) for (Object col : (Array<?>) obj) add(col); return this; }
<DeepExtract> for (Object obj : a) if (obj instanceof TypedGdxQuery) list().add(((TypedGdxQuery) obj).get()); else if (obj instanceof Actor) list().add((Actor) obj); else if (obj instanceof Cell<?>) list().add(((Cell<?>) obj).getActor()); else if (obj instanceof Stage) for (Actor actor : ((Stage) obj).getActors()) list().add(actor); else if (obj instanceof GdxQuery) list().addAll(((GdxQuery) obj).list()); else if (obj instanceof Collection) for (Object col : (Collection<?>) obj) add(col); else if (obj instanceof Array) for (Object col : (Array<?>) obj) add(col); return this; </DeepExtract>
GDX-RPG
positive
public void testMethodRenamed() { VirtualFile fixture = copyTestFixtureToConcordionProject("CacheEviction.java"); VirtualFile spec = copySpecToConcordionProject("CacheEviction.html", "method()"); myFixture.configureFromExistingVirtualFile(spec); ConcordionPsiElement element = elementUnderCaret(); assertThat(element).isNotNull(); assertThat(element.isResolvable()).isTrue(); assertThat(element.getType()).isNotNull(); assertThat(element.getType().getCanonicalText()).isEqualTo("com.test.CacheEviction.Nested"); writeAction(() -> { find(PsiMethod.class, fixture).setName("newMethod"); return null; }); assertThat(element).isNotNull(); assertThat(element.isResolvable()).isFalse(); assertThat(element.getType()).isNull(); }
<DeepExtract> assertThat(element).isNotNull(); assertThat(element.isResolvable()).isTrue(); assertThat(element.getType()).isNotNull(); assertThat(element.getType().getCanonicalText()).isEqualTo("com.test.CacheEviction.Nested"); </DeepExtract> <DeepExtract> assertThat(element).isNotNull(); assertThat(element.isResolvable()).isFalse(); assertThat(element.getType()).isNull(); </DeepExtract>
idea-concordion-support
positive
private void notifyPatternStarted() { if (mOnPatternListener != null) { mOnPatternListener.onPatternStart(); } setContentDescription(getContext().getString(R.string.lockscreen_access_pattern_start)); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); setContentDescription(null); }
<DeepExtract> setContentDescription(getContext().getString(R.string.lockscreen_access_pattern_start)); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); setContentDescription(null); </DeepExtract>
WeChatUtis
positive
public Criteria andIdBetween(Integer value1, Integer value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "id" + " cannot be null"); } criteria.add(new Criterion("id between", value1, value2)); return (Criteria) this; }
<DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "id" + " cannot be null"); } criteria.add(new Criterion("id between", value1, value2)); </DeepExtract>
health_online
positive
@Test public void customAnnotationHasNoEffect() throws Exception { getManager().getContext(ClassContext.class).activate(DummyClass.class); Object instance = DummyClass.class.newInstance(); Method testMethod = DummyClass.class.getMethod("testDummyMethod"); Method beforeClassMethod = null; if (null != null) { DummyClass.class.getMethod(null); } getManager().getContext(TestContext.class).activate(instance); fire(new BeforeSuite()); DroneContext context = getManager().getContext(ApplicationContext.class).getObjectStore().get(DroneContext.class); Assert.assertNotNull("DroneContext was created in the context", context); DroneRegistry registry = getManager().getContext(SuiteContext.class).getObjectStore().get(DroneRegistry.class); Assert.assertNotNull("Drone registry was created in the context", registry); Assert.assertTrue(registry.getEntryFor(MockDrone.class, Configurator.class) instanceof MockDroneFactory); Assert.assertTrue(registry.getEntryFor(MockDrone.class, Instantiator.class) instanceof MockDroneFactory); Assert.assertTrue(registry.getEntryFor(MockDrone.class, Destructor.class) instanceof MockDroneFactory); assertEventFired(PrepareDrone.class, 0); assertEventFired(BeforeDronePrepared.class, 0); assertEventFired(AfterDronePrepared.class, 0); fire(new BeforeClass(DummyClass.class)); assertEventFired(PrepareDrone.class, 2); assertEventFired(BeforeDronePrepared.class, 2); assertEventFired(AfterDronePrepared.class, 2); if (false) { assertEventFired(BeforeDroneInstantiated.class, 2); assertEventFired(AfterDroneInstantiated.class, 2); } if (beforeClassMethod != null) { beforeClassMethod.invoke(null); } fire(new Before(instance, testMethod)); assertEventFired(PrepareDrone.class, 2); assertEventFired(BeforeDronePrepared.class, 2); assertEventFired(AfterDronePrepared.class, 2); if (!false) { assertEventFired(BeforeDroneInstantiated.class, 0); assertEventFired(AfterDroneInstantiated.class, 0); } TestEnricher testEnricher = serviceLoader.onlyOne(TestEnricher.class); testEnricher.enrich(instance); assertEventFired(BeforeDroneInstantiated.class, 2); assertEventFired(AfterDroneInstantiated.class, 2); Object[] dummyParameters = testEnricher.resolve(testMethod); assertEventFired(BeforeDroneInstantiated.class, 2); assertEventFired(AfterDroneInstantiated.class, 2); testMethod.invoke(instance, dummyParameters); fire(new After(instance, testMethod)); assertEventFired(BeforeDroneDestroyed.class, 0); assertEventFired(AfterDroneDestroyed.class, 0); fire(new AfterClass(DummyClass.class)); assertEventFired(BeforeDroneDestroyed.class, 2); assertEventFired(AfterDroneDestroyed.class, 2); }
<DeepExtract> getManager().getContext(ClassContext.class).activate(DummyClass.class); Object instance = DummyClass.class.newInstance(); Method testMethod = DummyClass.class.getMethod("testDummyMethod"); Method beforeClassMethod = null; if (null != null) { DummyClass.class.getMethod(null); } getManager().getContext(TestContext.class).activate(instance); fire(new BeforeSuite()); DroneContext context = getManager().getContext(ApplicationContext.class).getObjectStore().get(DroneContext.class); Assert.assertNotNull("DroneContext was created in the context", context); DroneRegistry registry = getManager().getContext(SuiteContext.class).getObjectStore().get(DroneRegistry.class); Assert.assertNotNull("Drone registry was created in the context", registry); Assert.assertTrue(registry.getEntryFor(MockDrone.class, Configurator.class) instanceof MockDroneFactory); Assert.assertTrue(registry.getEntryFor(MockDrone.class, Instantiator.class) instanceof MockDroneFactory); Assert.assertTrue(registry.getEntryFor(MockDrone.class, Destructor.class) instanceof MockDroneFactory); assertEventFired(PrepareDrone.class, 0); assertEventFired(BeforeDronePrepared.class, 0); assertEventFired(AfterDronePrepared.class, 0); fire(new BeforeClass(DummyClass.class)); assertEventFired(PrepareDrone.class, 2); assertEventFired(BeforeDronePrepared.class, 2); assertEventFired(AfterDronePrepared.class, 2); if (false) { assertEventFired(BeforeDroneInstantiated.class, 2); assertEventFired(AfterDroneInstantiated.class, 2); } if (beforeClassMethod != null) { beforeClassMethod.invoke(null); } fire(new Before(instance, testMethod)); assertEventFired(PrepareDrone.class, 2); assertEventFired(BeforeDronePrepared.class, 2); assertEventFired(AfterDronePrepared.class, 2); if (!false) { assertEventFired(BeforeDroneInstantiated.class, 0); assertEventFired(AfterDroneInstantiated.class, 0); } TestEnricher testEnricher = serviceLoader.onlyOne(TestEnricher.class); testEnricher.enrich(instance); assertEventFired(BeforeDroneInstantiated.class, 2); assertEventFired(AfterDroneInstantiated.class, 2); Object[] dummyParameters = testEnricher.resolve(testMethod); assertEventFired(BeforeDroneInstantiated.class, 2); assertEventFired(AfterDroneInstantiated.class, 2); testMethod.invoke(instance, dummyParameters); fire(new After(instance, testMethod)); assertEventFired(BeforeDroneDestroyed.class, 0); assertEventFired(AfterDroneDestroyed.class, 0); fire(new AfterClass(DummyClass.class)); assertEventFired(BeforeDroneDestroyed.class, 2); assertEventFired(AfterDroneDestroyed.class, 2); </DeepExtract>
arquillian-extension-drone
positive
@Override protected void doInTransactionWithoutResult(TransactionStatus status) { final long start = System.currentTimeMillis(); final Date retrievalDate = new Date(start); feed.setRetrievalDate(retrievalDate); final String url = feed.getUrl(); logger.info("Retrieving RSS feed: " + url); final SyndFeedInput input = new SyndFeedInput(); URL feedUrl; HttpClientResponse response = null; InputStream is = null; try { feedUrl = new URL(url); response = NetworkingUtil.get(feedUrl, feed.getEtag(), feed.getLastModifiedDate()); if (response.getStatusCode() == 304) { logger.info("No RSS feed changes -- skipping"); } else { is = response.getInputStream(); final SyndFeed feed = input.build(new com.sun.syndication.io.XmlReader(is)); feed.setEtag(response.getEtag()); feed.setLastModifiedDate(response.getLastModifiedDate()); logger.info("Parsing took: " + (System.currentTimeMillis() - start) + " milliseconds"); @SuppressWarnings("unchecked") final List<SyndEntry> entries = feed.getEntries(); Collections.sort(entries, ENTRY_COMPARATOR); for (final SyndEntry entry : entries) { handleEntry(feed, entry); } logger.info("RSS feed parsing complete."); } } catch (Exception e) { if (response != null) { response.abort(); } logger.error("Error retrieving/parsing RSS feed at: " + url + ", will wait to try again."); logger.error("RSS Feed Error was: " + e, e); } finally { IOUtils.closeQuietly(response); } this.rssFeedDao.update(feed); for (final RssSource ithRssSource : feed.getRssSources()) { ithRssSource.setRetrievalDate(retrievalDate); this.sourceDao.update(ithRssSource); } }
<DeepExtract> final long start = System.currentTimeMillis(); final Date retrievalDate = new Date(start); feed.setRetrievalDate(retrievalDate); final String url = feed.getUrl(); logger.info("Retrieving RSS feed: " + url); final SyndFeedInput input = new SyndFeedInput(); URL feedUrl; HttpClientResponse response = null; InputStream is = null; try { feedUrl = new URL(url); response = NetworkingUtil.get(feedUrl, feed.getEtag(), feed.getLastModifiedDate()); if (response.getStatusCode() == 304) { logger.info("No RSS feed changes -- skipping"); } else { is = response.getInputStream(); final SyndFeed feed = input.build(new com.sun.syndication.io.XmlReader(is)); feed.setEtag(response.getEtag()); feed.setLastModifiedDate(response.getLastModifiedDate()); logger.info("Parsing took: " + (System.currentTimeMillis() - start) + " milliseconds"); @SuppressWarnings("unchecked") final List<SyndEntry> entries = feed.getEntries(); Collections.sort(entries, ENTRY_COMPARATOR); for (final SyndEntry entry : entries) { handleEntry(feed, entry); } logger.info("RSS feed parsing complete."); } } catch (Exception e) { if (response != null) { response.abort(); } logger.error("Error retrieving/parsing RSS feed at: " + url + ", will wait to try again."); logger.error("RSS Feed Error was: " + e, e); } finally { IOUtils.closeQuietly(response); } this.rssFeedDao.update(feed); for (final RssSource ithRssSource : feed.getRssSources()) { ithRssSource.setRetrievalDate(retrievalDate); this.sourceDao.update(ithRssSource); } </DeepExtract>
openalexis
positive
private void mpRelease() { if (null == mMp || MPState.END == mpGetState()) return; if (MPState.ERROR != mMpS && mMp.isPlaying()) { if (DBG) P.v("MP" + System.identityHashCode(mMp) + " stop"); mMp.stop(); } final MediaPlayer mp = mMp; new Thread(new Runnable() { @Override public void run() { mpUnsetVideoSurface(); if (DBG) P.v("MP" + System.identityHashCode(mp) + " release"); mp.release(); } }).start(); mMp = null; if (DBG) P.v("State : " + mMpS.name() + " => " + MPState.END.name()); MPState oldS = mMpS; mMpS = MPState.END; mMpSFlag = MPSTATE_FLAG_IDLE; onMpStateChanged(oldS, mMpSFlag, mMpS, mMpSFlag); }
<DeepExtract> if (DBG) P.v("State : " + mMpS.name() + " => " + MPState.END.name()); MPState oldS = mMpS; mMpS = MPState.END; mMpSFlag = MPSTATE_FLAG_IDLE; onMpStateChanged(oldS, mMpSFlag, mMpS, mMpSFlag); </DeepExtract>
netmbuddy
positive
void unaryOperators() { @Source(READ_SMS) @Sink(WRITE_SMS) boolean smsBoolTest = !smsBool; @Source({}) @Sink(ANY) boolean bot = !smsBool; }
<DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract>
sparta
positive
public LoginPage submitValidRegistrationData(final User user) throws Exception { submitButton.click(); return new LoginPage(); }
<DeepExtract> submitButton.click(); return new LoginPage(); </DeepExtract>
seleniumtestsframework
positive
public void init(ImageLoaderConfig config) { mConfig = config; mCache = mConfig.bitmapCache; if (mConfig == null) { throw new RuntimeException("The config of SimpleImageLoader is Null, please call the init(ImageLoaderConfig config) method to initialize"); } if (mConfig.loadPolicy == null) { mConfig.loadPolicy = new SerialPolicy(); } if (mCache == null) { mCache = new MemoryCache(); } mImageQueue = new RequestQueue(mConfig.threadCount); mImageQueue.start(); }
<DeepExtract> if (mConfig == null) { throw new RuntimeException("The config of SimpleImageLoader is Null, please call the init(ImageLoaderConfig config) method to initialize"); } if (mConfig.loadPolicy == null) { mConfig.loadPolicy = new SerialPolicy(); } if (mCache == null) { mCache = new MemoryCache(); } </DeepExtract>
AndroidAdvance
positive
@Test public void testPackUnpack01() throws Exception { super.testLongArray(); }
<DeepExtract> super.testLongArray(); </DeepExtract>
msgpack-java
positive
public void applyMatrix(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33) { showWarning("applyMatrix" + "(), or this particular variation of it, " + "is not available with this renderer."); }
<DeepExtract> showWarning("applyMatrix" + "(), or this particular variation of it, " + "is not available with this renderer."); </DeepExtract>
rainbow
positive
@Test public void shouldReturnCorrectSequenceOfCommittedInstancesInResponseToRepeatedGetNextCommittedCallsWithInitialIndexToSearchFromAsZero() throws Exception { LogEntry[] unappliedEntries = { NOOP(1, 1), CLIENT(2, 1, new UnitTestCommand()), CLIENT(3, 1, new UnitTestCommand()), CLIENT(4, 1, new UnitTestCommand()) }; final long commitIndex = 4; final LogEntry[] entries = new LogEntry[] { SENTINEL(), unappliedEntries[0], unappliedEntries[1], unappliedEntries[2], unappliedEntries[3], CLIENT(5, 1, new UnitTestCommand()) }; UnitTestLogEntries.insertIntoLog(log, entries); store.setCommitIndex(commitIndex); long currentTerm = 3; store.setCurrentTerm(currentTerm); int unappliedEntriesCounter = 0; long indexToSearchFrom = 0; while (true) { Committed committed = algorithm.getNextCommitted(indexToSearchFrom); if (committed == null) { break; } checkMatchingCommittedLogEntry(committed, unappliedEntries[unappliedEntriesCounter]); indexToSearchFrom = committed.getIndex(); unappliedEntriesCounter++; } assertThat(unappliedEntriesCounter, equalTo(unappliedEntries.length)); UnitTestLogEntries.assertThatLogContains(log, entries); assertThat(store.getCurrentTerm(), equalTo(currentTerm)); assertThat(store.getCommitIndex(), equalTo(commitIndex)); }
<DeepExtract> UnitTestLogEntries.insertIntoLog(log, entries); </DeepExtract> <DeepExtract> int unappliedEntriesCounter = 0; long indexToSearchFrom = 0; while (true) { Committed committed = algorithm.getNextCommitted(indexToSearchFrom); if (committed == null) { break; } checkMatchingCommittedLogEntry(committed, unappliedEntries[unappliedEntriesCounter]); indexToSearchFrom = committed.getIndex(); unappliedEntriesCounter++; } assertThat(unappliedEntriesCounter, equalTo(unappliedEntries.length)); </DeepExtract> <DeepExtract> UnitTestLogEntries.assertThatLogContains(log, entries); </DeepExtract> <DeepExtract> assertThat(store.getCurrentTerm(), equalTo(currentTerm)); assertThat(store.getCommitIndex(), equalTo(commitIndex)); </DeepExtract>
libraft
positive
public String getYearsAsHtmlList() { AppPageBuilder page = new AppPageBuilder(String.format(String.format("List of %s", "Years")), appversion); page.appendToBody(String.format("<h1>List of %s</h1>%n", "Years")); String ulclass = ""; if (reportConfig.includeFaqLinks() || reportConfig.areTitlesLinks() || reportConfig.areAuthorNamesLinks() || reportConfig.arePublishersLinks() || reportConfig.areSeriesNamesLinks() || reportConfig.areYearsLinks()) { ulclass = "menu"; } page.appendToBody(new HTMLReporter(appversion).getAsUl(reporter.getYearsAsStrings(), "Years", ulclass)); String style = reportConfig.areYearsLinks() ? "navigation" : "static"; if (appversion.are(AppVersionSettings.LISTS_SHOWING_CORRECT_NUMBER_OF_THINGS)) { page.appendToBody(new PaginatorRender(SimplePaginator.getPaginationDetails(reporter.getYearsAsStrings(), "Years")).renderAsClickable(String.format("%s%s/list/%s", reportConfig.getReportPath(), "years", style))); } else { page.appendToBody(new PaginatorRender(this.data.books().getPaginationDetails()).renderAsClickable(String.format("%s%s/list/%s", reportConfig.getReportPath(), "years", style))); } return page.toString(); }
<DeepExtract> AppPageBuilder page = new AppPageBuilder(String.format(String.format("List of %s", "Years")), appversion); page.appendToBody(String.format("<h1>List of %s</h1>%n", "Years")); String ulclass = ""; if (reportConfig.includeFaqLinks() || reportConfig.areTitlesLinks() || reportConfig.areAuthorNamesLinks() || reportConfig.arePublishersLinks() || reportConfig.areSeriesNamesLinks() || reportConfig.areYearsLinks()) { ulclass = "menu"; } page.appendToBody(new HTMLReporter(appversion).getAsUl(reporter.getYearsAsStrings(), "Years", ulclass)); String style = reportConfig.areYearsLinks() ? "navigation" : "static"; if (appversion.are(AppVersionSettings.LISTS_SHOWING_CORRECT_NUMBER_OF_THINGS)) { page.appendToBody(new PaginatorRender(SimplePaginator.getPaginationDetails(reporter.getYearsAsStrings(), "Years")).renderAsClickable(String.format("%s%s/list/%s", reportConfig.getReportPath(), "years", style))); } else { page.appendToBody(new PaginatorRender(this.data.books().getPaginationDetails()).renderAsClickable(String.format("%s%s/list/%s", reportConfig.getReportPath(), "years", style))); } return page.toString(); </DeepExtract>
TestingApp
positive
private void makeRequest(String stringUrl) { String response = null; try { URL url = new URL(stringUrl); URLConnection conn = url.openConnection(); conn.setDoInput(true); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String chunk = null; while ((chunk = in.readLine()) != null) response += chunk; in.close(); } catch (Exception e) { throw new RuntimeException("Arrrg! " + e); } String msg = stringUrl + "\n" + response; System.out.println(msg); }
<DeepExtract> String msg = stringUrl + "\n" + response; System.out.println(msg); </DeepExtract>
jwsur2
positive
@Test public void testBasic() throws Exception { final Semaphore restartLatch = new Semaphore(0); TestProcessOperations mockOperations1 = new TestProcessOperations(); TestProcessOperations mockOperations2 = new TestProcessOperations(); TestProcessOperations mockOperations3 = new TestProcessOperations(); final InstanceConfig defaultInstanceConfig = DefaultProperties.newDefaultInstanceConfig(null); final InstanceConfig instanceConfig = new InstanceConfig() { @Override public String getString(StringConfigs config) { if (config == StringConfigs.SERVERS_SPEC) { return "1:one,2:two,3:three"; } if ((config == StringConfigs.ZOOKEEPER_DATA_DIRECTORY) || (config == StringConfigs.ZOOKEEPER_INSTALL_DIRECTORY)) { return "foo"; } return defaultInstanceConfig.getString(config); } @Override public int getInt(IntConfigs config) { if (config == IntConfigs.CHECK_MS) { return 1; } return defaultInstanceConfig.getInt(config); } }; Properties properties = DefaultProperties.getFromInstanceConfig(instanceConfig); ConfigCollection configCollection = new PropertyBasedInstanceConfig(properties, new Properties()); LoadedInstanceConfig loadedInstanceConfig = new LoadedInstanceConfig(configCollection, 1); final AtomicReference<LoadedInstanceConfig> providerConfig = new AtomicReference<LoadedInstanceConfig>(loadedInstanceConfig); ConfigProvider mockConfigProvider = new ConfigProvider() { @Override public void start() throws Exception { } @Override public LoadedInstanceConfig loadConfig() throws Exception { return providerConfig.get(); } @Override public LoadedInstanceConfig storeConfig(ConfigCollection config, long compareVersion) throws Exception { LoadedInstanceConfig loadedInstanceConfig = new LoadedInstanceConfig(config, compareVersion + 1); providerConfig.set(loadedInstanceConfig); return loadedInstanceConfig; } @Override public PseudoLock newPseudoLock() throws Exception { return new PseudoLock() { @Override public boolean lock(ActivityLog log, long maxWait, TimeUnit unit) throws Exception { return true; } @Override public void unlock() throws Exception { } }; } @Override public void close() throws IOException { } }; ControlPanelValues mockControlPanelValues = Mockito.mock(ControlPanelValues.class); Mockito.when(mockControlPanelValues.isSet(Mockito.any(ControlPanelTypes.class))).thenReturn(true); ActivityQueue activityQueue = new ActivityQueue(); final Queue<AssertionError> exceptions = Queues.newConcurrentLinkedQueue(); Exhibitor mockExhibitor1 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS); Mockito.when(mockExhibitor1.getActivityQueue()).thenReturn(activityQueue); ConfigManager configManager1 = new TestConfigManager(mockExhibitor1, mockConfigProvider); Mockito.when(mockExhibitor1.getConfigManager()).thenReturn(configManager1); MonitorRunningInstance monitorRunningInstance1 = new MockMonitorRunningInstance(mockExhibitor1, providerConfig, "one", restartLatch, exceptions); Mockito.when(mockExhibitor1.getMonitorRunningInstance()).thenReturn(monitorRunningInstance1); Mockito.when(mockExhibitor1.getThisJVMHostname()).thenReturn("one"); Mockito.when(mockExhibitor1.getProcessOperations()).thenReturn(mockOperations1); Mockito.when(mockExhibitor1.getControlPanelValues()).thenReturn(mockControlPanelValues); Exhibitor mockExhibitor2 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS); Mockito.when(mockExhibitor2.getActivityQueue()).thenReturn(activityQueue); ConfigManager configManager2 = new TestConfigManager(mockExhibitor2, mockConfigProvider); Mockito.when(mockExhibitor2.getConfigManager()).thenReturn(configManager2); MonitorRunningInstance monitorRunningInstance2 = new MockMonitorRunningInstance(mockExhibitor2, providerConfig, "two", restartLatch, exceptions); Mockito.when(mockExhibitor2.getMonitorRunningInstance()).thenReturn(monitorRunningInstance2); Mockito.when(mockExhibitor2.getThisJVMHostname()).thenReturn("two"); Mockito.when(mockExhibitor2.getProcessOperations()).thenReturn(mockOperations2); Mockito.when(mockExhibitor2.getControlPanelValues()).thenReturn(mockControlPanelValues); Exhibitor mockExhibitor3 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS); Mockito.when(mockExhibitor3.getActivityQueue()).thenReturn(activityQueue); ConfigManager configManager3 = new TestConfigManager(mockExhibitor3, mockConfigProvider); Mockito.when(mockExhibitor3.getConfigManager()).thenReturn(configManager3); MonitorRunningInstance monitorRunningInstance3 = new MockMonitorRunningInstance(mockExhibitor3, providerConfig, "three", restartLatch, exceptions); Mockito.when(mockExhibitor3.getMonitorRunningInstance()).thenReturn(monitorRunningInstance3); Mockito.when(mockExhibitor3.getThisJVMHostname()).thenReturn("three"); Mockito.when(mockExhibitor3.getProcessOperations()).thenReturn(mockOperations3); Mockito.when(mockExhibitor3.getControlPanelValues()).thenReturn(mockControlPanelValues); try { activityQueue.start(); configManager1.start(); configManager2.start(); configManager3.start(); monitorRunningInstance1.start(); monitorRunningInstance2.start(); monitorRunningInstance3.start(); Thread.sleep(1000); for (int i = 0; i < 1; ++i) { Assert.assertEquals(restartLatch.availablePermits(), 0); final int index = i; InstanceConfig changedInstanceConfig = new InstanceConfig() { @Override public String getString(StringConfigs config) { if (config == StringConfigs.LOG4J_PROPERTIES) { return "something different " + index; } return instanceConfig.getString(config); } @Override public int getInt(IntConfigs config) { return instanceConfig.getInt(config); } }; configManager1.startRollingConfig(changedInstanceConfig, "one"); Assert.assertTrue(restartLatch.tryAcquire(1, 10, TimeUnit.SECONDS)); if (exceptions.size() > 0) { for (AssertionError assertionError : exceptions) { assertionError.printStackTrace(); } Assert.fail("Failed restart assertions"); } } } finally { CloseableUtils.closeQuietly(monitorRunningInstance3); CloseableUtils.closeQuietly(monitorRunningInstance2); CloseableUtils.closeQuietly(monitorRunningInstance1); CloseableUtils.closeQuietly(configManager3); CloseableUtils.closeQuietly(configManager2); CloseableUtils.closeQuietly(configManager1); CloseableUtils.closeQuietly(activityQueue); } }
<DeepExtract> final Semaphore restartLatch = new Semaphore(0); TestProcessOperations mockOperations1 = new TestProcessOperations(); TestProcessOperations mockOperations2 = new TestProcessOperations(); TestProcessOperations mockOperations3 = new TestProcessOperations(); final InstanceConfig defaultInstanceConfig = DefaultProperties.newDefaultInstanceConfig(null); final InstanceConfig instanceConfig = new InstanceConfig() { @Override public String getString(StringConfigs config) { if (config == StringConfigs.SERVERS_SPEC) { return "1:one,2:two,3:three"; } if ((config == StringConfigs.ZOOKEEPER_DATA_DIRECTORY) || (config == StringConfigs.ZOOKEEPER_INSTALL_DIRECTORY)) { return "foo"; } return defaultInstanceConfig.getString(config); } @Override public int getInt(IntConfigs config) { if (config == IntConfigs.CHECK_MS) { return 1; } return defaultInstanceConfig.getInt(config); } }; Properties properties = DefaultProperties.getFromInstanceConfig(instanceConfig); ConfigCollection configCollection = new PropertyBasedInstanceConfig(properties, new Properties()); LoadedInstanceConfig loadedInstanceConfig = new LoadedInstanceConfig(configCollection, 1); final AtomicReference<LoadedInstanceConfig> providerConfig = new AtomicReference<LoadedInstanceConfig>(loadedInstanceConfig); ConfigProvider mockConfigProvider = new ConfigProvider() { @Override public void start() throws Exception { } @Override public LoadedInstanceConfig loadConfig() throws Exception { return providerConfig.get(); } @Override public LoadedInstanceConfig storeConfig(ConfigCollection config, long compareVersion) throws Exception { LoadedInstanceConfig loadedInstanceConfig = new LoadedInstanceConfig(config, compareVersion + 1); providerConfig.set(loadedInstanceConfig); return loadedInstanceConfig; } @Override public PseudoLock newPseudoLock() throws Exception { return new PseudoLock() { @Override public boolean lock(ActivityLog log, long maxWait, TimeUnit unit) throws Exception { return true; } @Override public void unlock() throws Exception { } }; } @Override public void close() throws IOException { } }; ControlPanelValues mockControlPanelValues = Mockito.mock(ControlPanelValues.class); Mockito.when(mockControlPanelValues.isSet(Mockito.any(ControlPanelTypes.class))).thenReturn(true); ActivityQueue activityQueue = new ActivityQueue(); final Queue<AssertionError> exceptions = Queues.newConcurrentLinkedQueue(); Exhibitor mockExhibitor1 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS); Mockito.when(mockExhibitor1.getActivityQueue()).thenReturn(activityQueue); ConfigManager configManager1 = new TestConfigManager(mockExhibitor1, mockConfigProvider); Mockito.when(mockExhibitor1.getConfigManager()).thenReturn(configManager1); MonitorRunningInstance monitorRunningInstance1 = new MockMonitorRunningInstance(mockExhibitor1, providerConfig, "one", restartLatch, exceptions); Mockito.when(mockExhibitor1.getMonitorRunningInstance()).thenReturn(monitorRunningInstance1); Mockito.when(mockExhibitor1.getThisJVMHostname()).thenReturn("one"); Mockito.when(mockExhibitor1.getProcessOperations()).thenReturn(mockOperations1); Mockito.when(mockExhibitor1.getControlPanelValues()).thenReturn(mockControlPanelValues); Exhibitor mockExhibitor2 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS); Mockito.when(mockExhibitor2.getActivityQueue()).thenReturn(activityQueue); ConfigManager configManager2 = new TestConfigManager(mockExhibitor2, mockConfigProvider); Mockito.when(mockExhibitor2.getConfigManager()).thenReturn(configManager2); MonitorRunningInstance monitorRunningInstance2 = new MockMonitorRunningInstance(mockExhibitor2, providerConfig, "two", restartLatch, exceptions); Mockito.when(mockExhibitor2.getMonitorRunningInstance()).thenReturn(monitorRunningInstance2); Mockito.when(mockExhibitor2.getThisJVMHostname()).thenReturn("two"); Mockito.when(mockExhibitor2.getProcessOperations()).thenReturn(mockOperations2); Mockito.when(mockExhibitor2.getControlPanelValues()).thenReturn(mockControlPanelValues); Exhibitor mockExhibitor3 = Mockito.mock(Exhibitor.class, Mockito.RETURNS_MOCKS); Mockito.when(mockExhibitor3.getActivityQueue()).thenReturn(activityQueue); ConfigManager configManager3 = new TestConfigManager(mockExhibitor3, mockConfigProvider); Mockito.when(mockExhibitor3.getConfigManager()).thenReturn(configManager3); MonitorRunningInstance monitorRunningInstance3 = new MockMonitorRunningInstance(mockExhibitor3, providerConfig, "three", restartLatch, exceptions); Mockito.when(mockExhibitor3.getMonitorRunningInstance()).thenReturn(monitorRunningInstance3); Mockito.when(mockExhibitor3.getThisJVMHostname()).thenReturn("three"); Mockito.when(mockExhibitor3.getProcessOperations()).thenReturn(mockOperations3); Mockito.when(mockExhibitor3.getControlPanelValues()).thenReturn(mockControlPanelValues); try { activityQueue.start(); configManager1.start(); configManager2.start(); configManager3.start(); monitorRunningInstance1.start(); monitorRunningInstance2.start(); monitorRunningInstance3.start(); Thread.sleep(1000); for (int i = 0; i < 1; ++i) { Assert.assertEquals(restartLatch.availablePermits(), 0); final int index = i; InstanceConfig changedInstanceConfig = new InstanceConfig() { @Override public String getString(StringConfigs config) { if (config == StringConfigs.LOG4J_PROPERTIES) { return "something different " + index; } return instanceConfig.getString(config); } @Override public int getInt(IntConfigs config) { return instanceConfig.getInt(config); } }; configManager1.startRollingConfig(changedInstanceConfig, "one"); Assert.assertTrue(restartLatch.tryAcquire(1, 10, TimeUnit.SECONDS)); if (exceptions.size() > 0) { for (AssertionError assertionError : exceptions) { assertionError.printStackTrace(); } Assert.fail("Failed restart assertions"); } } } finally { CloseableUtils.closeQuietly(monitorRunningInstance3); CloseableUtils.closeQuietly(monitorRunningInstance2); CloseableUtils.closeQuietly(monitorRunningInstance1); CloseableUtils.closeQuietly(configManager3); CloseableUtils.closeQuietly(configManager2); CloseableUtils.closeQuietly(configManager1); CloseableUtils.closeQuietly(activityQueue); } </DeepExtract>
exhibitor
positive
protected boolean n(String str) { return _input.LT(1).getText().equals(str); }
<DeepExtract> return _input.LT(1).getText().equals(str); </DeepExtract>
MSPaintIDE
positive
private void initDefaultDataSource(Environment env) { Binder binder = Binder.get(env); Map dsMap = binder.bind("spring.datasource.druid.master", HashMap.class).get(); try { String type = dsMap.get("type").toString(); if (StringUtils.isEmpty(type)) { type = DATASOURCE_TYPE_DEFAULT; } Class<? extends DataSource> dataSourceType = (Class<? extends DataSource>) Class.forName(type); ConfigurationPropertySource source = new MapConfigurationPropertySource(dsMap); Binder binder = new Binder(source); defaultDataSource = binder.bind(ConfigurationPropertyName.EMPTY, Bindable.of(dataSourceType)).get(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
<DeepExtract> try { String type = dsMap.get("type").toString(); if (StringUtils.isEmpty(type)) { type = DATASOURCE_TYPE_DEFAULT; } Class<? extends DataSource> dataSourceType = (Class<? extends DataSource>) Class.forName(type); ConfigurationPropertySource source = new MapConfigurationPropertySource(dsMap); Binder binder = new Binder(source); defaultDataSource = binder.bind(ConfigurationPropertyName.EMPTY, Bindable.of(dataSourceType)).get(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; </DeepExtract>
SpringBootLearning
positive
public static int getIntValue(byte b0, byte b1, byte b2, byte b3) { byte[] bytes = { b0, b1, b2, b3 }; int i = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt(); return i; }
<DeepExtract> int i = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt(); return i; </DeepExtract>
AndroidWearAndLIFX
positive
public static <T> void printList(String s, List<T> items) { track(String.format(s, true), false); for (T x : items) logs(x); indLevel--; if (stoppedIndLevel == indLevel) { stoppedIndLevel = -1; maxIndLevel = -maxIndLevel; } if (indWithin()) { if (thisRun().newLine()) { indLevel++; int n = thisRun().numOmitted(); if (n > 0) print("... " + n + " lines omitted ...\n"); indLevel--; childRun().finish(); if (buf.length() > 0) buf.delete(0, buf.length()); else print("}"); StopWatch ct = childRun().watch; if (ct.ms > 1000) { rawPrint(" [" + ct); if (indLevel > 0) { StopWatch tt = thisRun().watch; rawPrint(", cum. " + new StopWatch(tt.getCurrTimeLong())); } rawPrint("]"); } rawPrint("\n"); } } }
<DeepExtract> track(String.format(s, true), false); </DeepExtract> <DeepExtract> indLevel--; if (stoppedIndLevel == indLevel) { stoppedIndLevel = -1; maxIndLevel = -maxIndLevel; } if (indWithin()) { if (thisRun().newLine()) { indLevel++; int n = thisRun().numOmitted(); if (n > 0) print("... " + n + " lines omitted ...\n"); indLevel--; childRun().finish(); if (buf.length() > 0) buf.delete(0, buf.length()); else print("}"); StopWatch ct = childRun().watch; if (ct.ms > 1000) { rawPrint(" [" + ct); if (indLevel > 0) { StopWatch tt = thisRun().watch; rawPrint(", cum. " + new StopWatch(tt.getCurrTimeLong())); } rawPrint("]"); } rawPrint("\n"); } } </DeepExtract>
fast
positive
public void setLimit(int limit) { optMap.put(PARAM_LIMIT, Integer.toString(limit)); }
<DeepExtract> optMap.put(PARAM_LIMIT, Integer.toString(limit)); </DeepExtract>
CouchbaseMock
positive
@Override public void start() { mAnimation.reset(); mStartingStartTrim = mStartTrim; mStartingEndTrim = mEndTrim; mStartingRotation = mRotation; if (mRing.getEndTrim() != mRing.getStartTrim()) { mFinishing = true; mAnimation.setDuration(ANIMATION_DURATION / 2); mParent.startAnimation(mAnimation); } else { mRing.setColorIndex(0); mRing.resetOriginals(); mAnimation.setDuration(ANIMATION_DURATION); mParent.startAnimation(mAnimation); } }
<DeepExtract> mStartingStartTrim = mStartTrim; mStartingEndTrim = mEndTrim; mStartingRotation = mRotation; </DeepExtract>
TaobaoUnion
positive
@Override public void testInteger(int v) throws Exception { testBigInteger(BigInteger.valueOf((long) v)); }
<DeepExtract> testBigInteger(BigInteger.valueOf((long) v)); </DeepExtract>
msgpack-java
positive
public void setAlpha(float val) { alpha = val; hue = hueModulo(hue); sat = constrain(sat, 0, 1); br = constrain(br, 0, 1); alpha = constrain(alpha, 0, 1); }
<DeepExtract> hue = hueModulo(hue); sat = constrain(sat, 0, 1); br = constrain(br, 0, 1); alpha = constrain(alpha, 0, 1); </DeepExtract>
ProcessingSketches
positive
private void append(final Map<Date, PollResults> pageMap, final Date date, final String text, final Double value) { if (!pageMap.containsKey(date)) { pageMap.put(date, new PollResults()); } final PollResults results = pageMap.get(date); final Double currentValue = resultMap.containsKey(text) ? resultMap.get(text) : 0.0d; final Integer currentCount = countMap.containsKey(text) ? countMap.get(text) : 0; resultMap.put(text, value + currentValue); countMap.put(text, 1 + currentCount); }
<DeepExtract> final Double currentValue = resultMap.containsKey(text) ? resultMap.get(text) : 0.0d; final Integer currentCount = countMap.containsKey(text) ? countMap.get(text) : 0; resultMap.put(text, value + currentValue); countMap.put(text, 1 + currentCount); </DeepExtract>
openalexis
positive
public Criteria andOReturnTimeBetween(String value1, String value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "oReturnTime" + " cannot be null"); } criteria.add(new Criterion("o_return_time between", value1, value2)); return (Criteria) this; }
<DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "oReturnTime" + " cannot be null"); } criteria.add(new Criterion("o_return_time between", value1, value2)); </DeepExtract>
webike
positive
public Criteria andUserfullnameGreaterThanOrEqualTo(String value) { if (value == null) { throw new RuntimeException("Value for " + "userfullname" + " cannot be null"); } criteria.add(new Criterion("userfullname >=", value)); return (Criteria) this; }
<DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "userfullname" + " cannot be null"); } criteria.add(new Criterion("userfullname >=", value)); </DeepExtract>
springboot-ssm
positive
ParallelComputerBuilder parallelClasses() { return parallel(Integer.MAX_VALUE, CLASSES); }
<DeepExtract> return parallel(Integer.MAX_VALUE, CLASSES); </DeepExtract>
deflaker
positive
private static Set<String> scanForResourcePaths(String location, Set<String> excludedPaths, String nameFilter, String prefixFilter, String suffixFilter) { LOG.trace("Scanning for resources at '{}'...", location); Set<String> resourcePaths = new HashSet<String>(); try { urls = ClassUtils.getDefaultClassLoader().getResources(location); while (urls.hasMoreElements()) { URL url = urls.nextElement(); LOG.trace("Found URL: {} (protocol:{})", url.getPath(), url.getProtocol()); UrlResolver urlResolver = createUrlResolver(url.getProtocol()); LOG.trace("Resolving URL \"{}\" with the resolver {}", url.getPath(), urlResolver.getClass().getSimpleName()); URL resolvedUrl = urlResolver.toStandardUrl(url); LOG.trace("Resolved URL: \"{}\"", resolvedUrl.getPath()); String protocol = resolvedUrl.getProtocol(); LocationResourceScanner classPathLocationScanner = createLocationScanner(protocol); resourcePaths.addAll(classPathLocationScanner.findResourcePaths(location, resolvedUrl)); } } catch (IOException e) { LOG.warn("Unable to scan within the location: {}", location); } LOG.trace("{} resources found before filtering", resourcePaths.size()); Set<String> filteredResources = new HashSet<String>(); LOG.trace("Filtering scanned resources..."); for (String resourcePath : resourcePaths) { if (isPathAuthorized(resourcePath, location, excludedPaths)) { String resourceName = resourcePath.substring(resourcePath.lastIndexOf("/") + 1); if (StringUtils.isBlank(nameFilter) && StringUtils.isBlank(prefixFilter) && StringUtils.isBlank(suffixFilter)) { filteredResources.add(resourcePath); continue; } if (StringUtils.isNotBlank(nameFilter)) { if (nameFilter.equalsIgnoreCase(resourceName)) { filteredResources.add(resourcePath); } } else { if (suffixFilter == null && resourceName.startsWith(prefixFilter)) { filteredResources.add(resourcePath); } else if (prefixFilter == null && resourceName.endsWith(suffixFilter)) { filteredResources.add(resourcePath); } else if (prefixFilter != null && suffixFilter != null && resourceName.startsWith(prefixFilter) && resourceName.endsWith(suffixFilter)) { filteredResources.add(resourcePath); } } } } LOG.trace("{} resources found after filtering", filteredResources.size()); return filteredResources; }
<DeepExtract> Set<String> filteredResources = new HashSet<String>(); LOG.trace("Filtering scanned resources..."); for (String resourcePath : resourcePaths) { if (isPathAuthorized(resourcePath, location, excludedPaths)) { String resourceName = resourcePath.substring(resourcePath.lastIndexOf("/") + 1); if (StringUtils.isBlank(nameFilter) && StringUtils.isBlank(prefixFilter) && StringUtils.isBlank(suffixFilter)) { filteredResources.add(resourcePath); continue; } if (StringUtils.isNotBlank(nameFilter)) { if (nameFilter.equalsIgnoreCase(resourceName)) { filteredResources.add(resourcePath); } } else { if (suffixFilter == null && resourceName.startsWith(prefixFilter)) { filteredResources.add(resourcePath); } else if (prefixFilter == null && resourceName.endsWith(suffixFilter)) { filteredResources.add(resourcePath); } else if (prefixFilter != null && suffixFilter != null && resourceName.startsWith(prefixFilter) && resourceName.endsWith(suffixFilter)) { filteredResources.add(resourcePath); } } } } LOG.trace("{} resources found after filtering", filteredResources.size()); return filteredResources; </DeepExtract>
dandelion
positive
public Criteria andAddressNotBetween(String value1, String value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "address" + " cannot be null"); } criteria.add(new Criterion("address not between", value1, value2)); return (Criteria) this; }
<DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "address" + " cannot be null"); } criteria.add(new Criterion("address not between", value1, value2)); </DeepExtract>
Gotrip
positive
private ZonedDateTime resolveOffset(ZoneOffset offset) { long epSec = this.dateTime.toEpochSecond(offset); ZoneRules rules = this.zone.getRules(); Instant instant = Instant.ofEpochSecond(epSec, this.dateTime.getNano()); ZoneOffset offset = rules.getOffset(instant); LocalDateTime ldt = LocalDateTime.ofEpochSecond(epSec, this.dateTime.getNano(), offset); return new ZonedDateTime(ldt, offset, this.zone); }
<DeepExtract> ZoneRules rules = this.zone.getRules(); Instant instant = Instant.ofEpochSecond(epSec, this.dateTime.getNano()); ZoneOffset offset = rules.getOffset(instant); LocalDateTime ldt = LocalDateTime.ofEpochSecond(epSec, this.dateTime.getNano(), offset); return new ZonedDateTime(ldt, offset, this.zone); </DeepExtract>
gwt-time
positive
public String findOnLayer(String layer, Pattern p) { pattern = null; dxfLineNum = 0; layer = null; validLayer = true; pattern = p; this.layer = layer; validLayer = false; if (!isAsciiDxf()) { System.err.println("DxfSearchEngine: there is no DXF file to search or the dxf if binary."); return null; } if (pattern == null) { System.err.println("DxfSearchEngine: search pattern is null."); return null; } try { BufferedReader DxfStrm = new BufferedReader(new FileReader(dxfFile)); int myDxfLineNum = 0; String code = new String(); String value = new String(); while (!(code.equals("0") && value.equalsIgnoreCase("EOF"))) { code = DxfStrm.readLine(); code = code.trim(); myDxfLineNum++; value = DxfStrm.readLine(); value = value.trim(); myDxfLineNum++; if (isLayerSearch()) { if (code.equals("8")) { if (value.equalsIgnoreCase(layer)) { validLayer = true; } else { validLayer = false; } } } if (myDxfLineNum <= dxfLineNum) { continue; } dxfLineNum = myDxfLineNum; if (isInterestingCode(code) && validLayer == true) { Matcher m = pattern.matcher(value); if (m.find()) { return value; } } } DxfStrm.close(); } catch (IOException e) { System.err.println("DxfSearchEngine dxf read error: " + e + " at line: " + dxfLineNum); } catch (NullPointerException npe) { String msg = "Search for pattern '" + pattern + " in file '" + dxfFile.getName() + "' " + "' produced a null pointer exception. The DXF may be corrupt at line: " + String.valueOf(dxfLineNum); System.err.println(msg); DxfPreprocessor.logEvent(dxfFile.getName(), msg); System.exit(-1); } return null; }
<DeepExtract> pattern = null; dxfLineNum = 0; layer = null; validLayer = true; </DeepExtract> <DeepExtract> if (!isAsciiDxf()) { System.err.println("DxfSearchEngine: there is no DXF file to search or the dxf if binary."); return null; } if (pattern == null) { System.err.println("DxfSearchEngine: search pattern is null."); return null; } try { BufferedReader DxfStrm = new BufferedReader(new FileReader(dxfFile)); int myDxfLineNum = 0; String code = new String(); String value = new String(); while (!(code.equals("0") && value.equalsIgnoreCase("EOF"))) { code = DxfStrm.readLine(); code = code.trim(); myDxfLineNum++; value = DxfStrm.readLine(); value = value.trim(); myDxfLineNum++; if (isLayerSearch()) { if (code.equals("8")) { if (value.equalsIgnoreCase(layer)) { validLayer = true; } else { validLayer = false; } } } if (myDxfLineNum <= dxfLineNum) { continue; } dxfLineNum = myDxfLineNum; if (isInterestingCode(code) && validLayer == true) { Matcher m = pattern.matcher(value); if (m.find()) { return value; } } } DxfStrm.close(); } catch (IOException e) { System.err.println("DxfSearchEngine dxf read error: " + e + " at line: " + dxfLineNum); } catch (NullPointerException npe) { String msg = "Search for pattern '" + pattern + " in file '" + dxfFile.getName() + "' " + "' produced a null pointer exception. The DXF may be corrupt at line: " + String.valueOf(dxfLineNum); System.err.println(msg); DxfPreprocessor.logEvent(dxfFile.getName(), msg); System.exit(-1); } return null; </DeepExtract>
dxf2svg
positive
public Criteria andBranchJumpScriptNotBetween(String value1, String value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "branchJumpScript" + " cannot be null"); } criteria.add(new Criterion("branch_jump_script not between", value1, value2)); return (Criteria) this; }
<DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "branchJumpScript" + " cannot be null"); } criteria.add(new Criterion("branch_jump_script not between", value1, value2)); </DeepExtract>
AnyMock
positive
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); WebLink link = (WebLink) getListAdapter().getItem(position); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link.getUrl()))); }
<DeepExtract> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link.getUrl()))); </DeepExtract>
musicbrainz-android
positive
public String toXML(final String printOptions) { final StringBuilder sb = new StringBuilder(); sb.append("<STRANGEBREWRECIPE version = \"").append(version).append("\">\n"); sb.append("<!-- This is a SBJava export. StrangeBrew 1.8 will not import it. -->\n"); if (printOptions != null) { sb.append(printOptions); } sb.append(" <DETAILS>\n"); sb.append(" <NAME>").append(SBStringUtils.subEntities(name)).append("</NAME>\n"); sb.append(" <BREWER>").append(SBStringUtils.subEntities(brewer)).append("</BREWER>\n"); sb.append(" <NOTES>").append(SBStringUtils.subEntities(comments)).append("</NOTES>\n"); sb.append(" <EFFICIENCY>").append(efficiency).append("</EFFICIENCY>\n"); sb.append(" <OG>").append(SBStringUtils.format(estOg, 3)).append("</OG>\n"); sb.append(" <FG>").append(SBStringUtils.format(estFg, 3)).append("</FG>\n"); sb.append(" <STYLE>").append(style.getName()).append("</STYLE>\n"); sb.append(" <MASH>").append(mashed).append("</MASH>\n"); sb.append(" <LOV>").append(SBStringUtils.format(getColour(BrewCalcs.SRM), 1)).append("</LOV>\n"); sb.append(" <IBU>").append(SBStringUtils.format(ibu, 1)).append("</IBU>\n"); sb.append(" <ALC>").append(SBStringUtils.format(getAlcohol(), 1)).append("</ALC>\n"); sb.append(" <!-- SBJ1.0 Extensions: -->\n"); sb.append(" <EVAP>").append(evap).append("</EVAP>\n"); sb.append(" <EVAP_METHOD>").append(evapMethod).append("</EVAP_METHOD>\n"); sb.append(" <!-- END SBJ1.0 Extensions -->\n"); sb.append(" <BOIL_TIME>").append(boilMinutes).append("</BOIL_TIME>\n"); sb.append(" <PRESIZE>").append(getPreBoilVol(getVolUnits())).append("</PRESIZE>\n"); sb.append(" <SIZE>").append(getPostBoilVol(getVolUnits())).append("</SIZE>\n"); sb.append(" <SIZE_UNITS>").append(getVolUnits()).append("</SIZE_UNITS>\n"); sb.append(" <MALT_UNITS>").append(maltUnits).append("</MALT_UNITS>\n"); sb.append(" <HOPS_UNITS>").append(hopUnits).append("</HOPS_UNITS>\n"); sb.append(" <YEAST>").append(yeast.getName()).append("</YEAST>\n"); final SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy"); sb.append(" <RECIPE_DATE>").append(df.format(created.getTime())).append("</RECIPE_DATE>\n"); sb.append(" <ATTENUATION>").append(attenuation).append("</ATTENUATION>\n"); sb.append(" <!-- SBJ1.0 Extensions: -->\n"); sb.append(" <ALC_METHOD>").append(getAlcMethod()).append("</ALC_METHOD>\n"); sb.append(" <IBU_METHOD>").append(ibuCalcMethod).append("</IBU_METHOD>\n"); sb.append(" <COLOUR_METHOD>").append(colourMethod).append("</COLOUR_METHOD>\n"); sb.append(" <KETTLE_LOSS>").append(getKettleLoss(getVolUnits())).append("</KETTLE_LOSS>\n"); sb.append(" <TRUB_LOSS>").append(getTrubLoss(getVolUnits())).append("</TRUB_LOSS>\n"); sb.append(" <MISC_LOSS>").append(getMiscLoss(getVolUnits())).append("</MISC_LOSS>\n"); sb.append(" <PELLET_HOP_PCT>").append(pelletHopPct).append("</PELLET_HOP_PCT>\n"); sb.append(" <YEAST_COST>").append(yeast.getCostPerU()).append("</YEAST_COST>\n"); sb.append(" <OTHER_COST>").append(otherCost).append("</OTHER_COST>\n"); sb.append(" <!-- END SBJ1.0 Extensions -->\n"); sb.append(" </DETAILS>\n"); sb.append(" <FERMENTABLES>\n"); sb.append(SBStringUtils.xmlElement("TOTAL", "" + Quantity.convertUnit("lb", maltUnits, totalMaltLbs), 4)); for (final Fermentable m : fermentables) { sb.append(m.toXML()); } sb.append(" </FERMENTABLES>\n"); sb.append(" <HOPS>\n"); sb.append(SBStringUtils.xmlElement("TOTAL", "" + Quantity.convertUnit(Quantity.OZ, hopUnits, totalHopsOz), 4)); for (final Hop h : hops) { sb.append(h.toXML()); } sb.append(" </HOPS>\n"); sb.append(" <MISC>\n"); for (final Misc mi : misc) { sb.append(mi.toXML()); } sb.append(" </MISC>\n"); sb.append(mash.toXml()); sb.append(" <FERMENTATION_SCHEDULE>\n"); for (FermentStep fermentationStep : fermentationSteps) { sb.append(fermentationStep.toXML()); } sb.append(" </FERMENTATION_SCHEDULE>\n"); sb.append(" <CARB>\n"); sb.append(" <BOTTLETEMP>").append(SBStringUtils.format(bottleTemp, 1)).append("</BOTTLETEMP>\n"); sb.append(" <SERVTEMP>").append(SBStringUtils.format(servTemp, 1)).append("</SERVTEMP>\n"); sb.append(" <VOL>").append(SBStringUtils.format(targetVol, 1)).append("</VOL>\n"); sb.append(" <SUGAR>").append(primeSugar.getName()).append("</SUGAR>\n"); sb.append(" <AMOUNT>").append(SBStringUtils.format(primeSugar.getAmountAs(primeSugar.getUnits()), 1)).append("</AMOUNT>\n"); sb.append(" <SUGARU>").append(primeSugar.getUnitsAbrv()).append("</SUGARU>\n"); sb.append(" <TEMPU>").append(carbTempU).append("</TEMPU>\n"); sb.append(" <KEG>").append(Boolean.toString(kegged)).append("</KEG>\n"); sb.append(" <PSI>").append(SBStringUtils.format(kegPSI, 2)).append("</PSI>\n"); sb.append(" </CARB>\n"); if ((!sourceWater.getName().equals("")) || (!targetWater.getName().equals(""))) { sb.append(" <WATER_PROFILE>\n"); if (!sourceWater.getName().equals("")) { sb.append(" <SOURCE_WATER>\n"); sb.append(sourceWater.toXML(9)); sb.append(" </SOURCE_WATER>\n"); } if (!targetWater.getName().equals("")) { sb.append(" <TARGET_WATER>\n"); sb.append(targetWater.toXML(9)); sb.append(" </TARGET_WATER>\n"); } if (brewingSalts.size() > 0) { sb.append(" <SALTS>\n"); for (Salt brewingSalt : brewingSalts) { sb.append(" <SALT>\n"); sb.append(brewingSalt.toXML(12)); sb.append(" </SALT>\n"); } sb.append(" </SALTS>\n"); } sb.append(" <ACID>\n"); sb.append(" <NAME>").append(acid.getName()).append("</NAME>\n"); sb.append(" <AMT>").append(SBStringUtils.format(getAcidAmount(), 2)).append("</AMT>\n"); sb.append(" <ACIDU>").append(acid.getAcidUnit()).append("</ACIDU>\n"); sb.append(" </ACID>\n"); sb.append(" </WATER_PROFILE>\n"); } sb.append(" <NOTES>\n"); for (Note note : notes) { sb.append(note.toXML()); } sb.append(" </NOTES>\n"); sb.append(style.toXML()); sb.append("</STRANGEBREWRECIPE>"); sb.toString() = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<?xml-stylesheet type=\"text/xsl\" href=\"http://strangebrewcloud.appspot.com/html/recipeToHtml.xslt\"?>" + sb.toString(); return sb.toString(); }
<DeepExtract> sb.toString() = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<?xml-stylesheet type=\"text/xsl\" href=\"http://strangebrewcloud.appspot.com/html/recipeToHtml.xslt\"?>" + sb.toString(); return sb.toString(); </DeepExtract>
StrangeBrew
positive
private String calculateFromSemesterFormat(String origSemester) { String extractedSemester = ""; Integer extractedYear = 0; String resultSemester = ""; Matcher matcher = semesterPattern.matcher(origSemester); if (matcher.find()) { extractedSemester = matcher.group(1); try { extractedYear = Integer.parseInt(matcher.group(2)); } catch (NumberFormatException e) { extractedYear = 0; } } if (extractedYear.toString().length() < 4) { extractedYear = extractedYear + 2000; } return extractedYear; if (extractedSemester.toLowerCase().startsWith("w")) { resultSemester += SEMESTER_WS + extractedYear + "/" + (extractedYear + 1); } else { resultSemester += SEMESTER_SS + extractedYear; } return resultSemester; }
<DeepExtract> if (extractedYear.toString().length() < 4) { extractedYear = extractedYear + 2000; } return extractedYear; </DeepExtract>
mygrades-app
positive
@Override protected void initInstance() { try { int permission = ActivityCompat.checkSelfPermission(activity, "android.permission.WRITE_EXTERNAL_STORAGE"); if (permission != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE); } } catch (Exception e) { e.printStackTrace(); } GlideUtils.loadImageView(activity, getIntent().getExtras().getString(Constants.PHOTO_URL), ivPhoto); }
<DeepExtract> try { int permission = ActivityCompat.checkSelfPermission(activity, "android.permission.WRITE_EXTERNAL_STORAGE"); if (permission != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE); } } catch (Exception e) { e.printStackTrace(); } </DeepExtract>
Weiyue
positive
public Criteria andIsHotNotBetween(Short value1, Short value2) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "isHot" + " cannot be null"); } criteria.add(new Criterion("IS_HOT not between", value1, value2)); return (Criteria) this; }
<DeepExtract> if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + "isHot" + " cannot be null"); } criteria.add(new Criterion("IS_HOT not between", value1, value2)); </DeepExtract>
ECPS
positive
@TargetApi(17) @Override public void setPaddingRelative(int start, int top, int end, int bottom) { super.setPaddingRelative(start, top, end, bottom); updatePolygonSize(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom()); invalidate(); }
<DeepExtract> updatePolygonSize(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom()); </DeepExtract>
BaseMyProject
positive
public Criteria andProduct_idIsNotNull() { if ("product_id is not null" == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion("product_id is not null")); return (Criteria) this; }
<DeepExtract> if ("product_id is not null" == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion("product_id is not null")); </DeepExtract>
Tmall_SSM-master
positive
public static Builder newBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); }
<DeepExtract> return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); </DeepExtract>
url-frontier
positive
@Test public void testDoGet_URLLengthExceedsLimits_withQueryString_InvalidResponse() { MockHttpServletRequest request = new MockHttpServletRequest(""); Params = MockHttpRequestHelper.addParameter("JMXQuery", "com.interopbridges.scx:jmxType=operationCall", Params); StringBuffer strURL = new StringBuffer(); int requiredPadding = 2048 - request.getQueryString().length() - "http://www.".length() - "/BeanSpy/MBeans".length(); strURL.append("http://www."); for (int i = 0; i < requiredPadding; i++) { strURL.append('a'); } strURL.append("/BeanSpy/MBeans"); return strURL; this._url = strURL; Assert.assertTrue("The length of the constructed URL should be 2049", 2049 == (request.getRequestURL().toString().length() + request.getQueryString().length() + 1)); try { _extender.doGet(request, _response); Assert.fail("Function should fail"); } catch (Exception e) { Assert.assertTrue("Exception should have been of type ServletException", e.getClass() == ServletException.class); Assert.assertNotNull("Root cause should be not be null", ((ServletException) e).getRootCause()); Assert.assertEquals("Root cause should be ScxException", ScxException.class, ((ServletException) e).getRootCause().getClass()); Assert.assertEquals("Should throw an ERROR_URL_LENGTH_EXCEEDS_LIMITS exception", ((ScxException) ((ServletException) e).getRootCause()).getExceptionCode(), ScxExceptionCode.ERROR_URL_LENGTH_EXCEEDS_LIMITS); } }
<DeepExtract> Params = MockHttpRequestHelper.addParameter("JMXQuery", "com.interopbridges.scx:jmxType=operationCall", Params); </DeepExtract> <DeepExtract> StringBuffer strURL = new StringBuffer(); int requiredPadding = 2048 - request.getQueryString().length() - "http://www.".length() - "/BeanSpy/MBeans".length(); strURL.append("http://www."); for (int i = 0; i < requiredPadding; i++) { strURL.append('a'); } strURL.append("/BeanSpy/MBeans"); return strURL; </DeepExtract> <DeepExtract> this._url = strURL; </DeepExtract>
BeanSpy
positive
private void removeEntry(String key) { CacheHeader entry; CacheHeader entry = mEntries.get(key); if (entry == null) { entry = null; } File file = getFileForKey(key); CountingInputStream cis = null; try { cis = new CountingInputStream(new FileInputStream(file)); CacheHeader.readHeader(cis); byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead)); entry = entry.toCacheEntry(data); } catch (IOException e) { VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString()); remove(key); entry = null; } finally { if (cis != null) { try { cis.close(); } catch (IOException ioe) { entry = null; } } } if (entry != null) { mEntries.remove(key); } }
<DeepExtract> CacheHeader entry; CacheHeader entry = mEntries.get(key); if (entry == null) { entry = null; } File file = getFileForKey(key); CountingInputStream cis = null; try { cis = new CountingInputStream(new FileInputStream(file)); CacheHeader.readHeader(cis); byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead)); entry = entry.toCacheEntry(data); } catch (IOException e) { VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString()); remove(key); entry = null; } finally { if (cis != null) { try { cis.close(); } catch (IOException ioe) { entry = null; } } } </DeepExtract>
volley-extensions
positive
public Criteria andDeletedNotEqualTo(Byte value) { if (value == null) { throw new RuntimeException("Value for " + "deleted" + " cannot be null"); } criteria.add(new Criterion("deleted <>", value)); return (Criteria) this; }
<DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "deleted" + " cannot be null"); } criteria.add(new Criterion("deleted <>", value)); </DeepExtract>
springcloud-e-book
positive
public Builder addAllNodeIds(java.lang.Iterable<? extends java.lang.Long> values) { if (!((bitField0_ & 0x00000020) == 0x00000020)) { nodeIds_ = new java.util.ArrayList<java.lang.Long>(nodeIds_); bitField0_ |= 0x00000020; } com.google.protobuf.AbstractMessageLite.Builder.addAll(values, nodeIds_); onChanged(); return this; }
<DeepExtract> if (!((bitField0_ & 0x00000020) == 0x00000020)) { nodeIds_ = new java.util.ArrayList<java.lang.Long>(nodeIds_); bitField0_ |= 0x00000020; } </DeepExtract>
sharedstreets-builder
positive
public static void exportExcel(List<?> list, Class<?> pojoClass, String fileName, ExportParams exportParams, HttpServletResponse response) throws IOException { Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list); downLoadExcel(fileName, response, workbook); }
<DeepExtract> Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list); downLoadExcel(fileName, response, workbook); </DeepExtract>
springboot
positive
public void onSearchRoutesResult(Plan plan) { mRouteErrorCode = null; mTransitPlan = plan; mJourneyQuery.ident = plan.getPaginateRef(); mJourneyQuery.hasPromotions = true; mJourneyQuery.promotionNetwork = 1; if (plan.getRoutes() == mRoutes) { return; } mRoutes = plan.getRoutes(); notifyDataSetChanged(); ViewHelper.crossfade(mEmptyView, getListView()); supportInvalidateOptionsMenu(); if (mLoadingRoutesViews != null) { mLoadingRoutesViews.setVisibility(View.GONE); } mEmptyView.setVisibility(View.GONE); }
<DeepExtract> if (plan.getRoutes() == mRoutes) { return; } mRoutes = plan.getRoutes(); notifyDataSetChanged(); </DeepExtract> <DeepExtract> ViewHelper.crossfade(mEmptyView, getListView()); </DeepExtract> <DeepExtract> if (mLoadingRoutesViews != null) { mLoadingRoutesViews.setVisibility(View.GONE); } mEmptyView.setVisibility(View.GONE); </DeepExtract>
sthlmtraveling
positive
@Override public String toString() { String asList = paths.stream().map(this::rValueToString).collect(Collectors.joining(", ")); return String.format("%s: %s", plural(String.format("is after%s%d siblings of type", RelationOperator.opAsEnglish(nPath.qualifier), nPath.n)), (paths.size() > 1) ? String.format("[%s]", asList) : asList); }
<DeepExtract> String asList = paths.stream().map(this::rValueToString).collect(Collectors.joining(", ")); return String.format("%s: %s", plural(String.format("is after%s%d siblings of type", RelationOperator.opAsEnglish(nPath.qualifier), nPath.n)), (paths.size() > 1) ? String.format("[%s]", asList) : asList); </DeepExtract>
dollarx
positive
@Test public void getOriginalArtistReturnsV2TagsOriginalArtist() { ID3v1 id3v1Tag = new ID3v1TagForTesting(); ID3v2 id3v2Tag = new ID3v2TagForTesting(); this.originalArtist = "V2 OriginalArtist"; ID3Wrapper wrapper = new ID3Wrapper(id3v1Tag, id3v2Tag); assertEquals("V2 OriginalArtist", wrapper.getOriginalArtist()); }
<DeepExtract> this.originalArtist = "V2 OriginalArtist"; </DeepExtract>
mp3agic
positive
public static void init(Context context) { mContext = context; st = new Paint(); st.setStyle(Style.FILL_AND_STROKE); if (st == null) { init(mContext); } st.setColor(Color.BLACK); st.setStrokeWidth(0); TeXFormula.getPartialTeXFormula("{x^{2}+ x-1= 0 }").setDEBUG(false); }
<DeepExtract> if (st == null) { init(mContext); } st.setColor(Color.BLACK); </DeepExtract>
JLaTexMath-andriod
positive
public void writeLong(long v) throws IOException { if (pos + 8 >= buf.length) { int newSize = Math.max(pos + 8, buf.length * 2); buf = Arrays.copyOf(buf, newSize); } buf[pos++] = (byte) (0xff & (v >> 56)); buf[pos++] = (byte) (0xff & (v >> 48)); buf[pos++] = (byte) (0xff & (v >> 40)); buf[pos++] = (byte) (0xff & (v >> 32)); buf[pos++] = (byte) (0xff & (v >> 24)); buf[pos++] = (byte) (0xff & (v >> 16)); buf[pos++] = (byte) (0xff & (v >> 8)); buf[pos++] = (byte) (0xff & (v >> 0)); }
<DeepExtract> if (pos + 8 >= buf.length) { int newSize = Math.max(pos + 8, buf.length * 2); buf = Arrays.copyOf(buf, newSize); } </DeepExtract>
JDBM3
positive
public void proc_language_binding_spec() { printRuleHeader(1225, "proc-language-binding-spec", ""); System.out.println(); }
<DeepExtract> printRuleHeader(1225, "proc-language-binding-spec", ""); </DeepExtract> <DeepExtract> System.out.println(); </DeepExtract>
open-fortran-parser
positive
@Override protected void createClient(Section section, FormToolkit toolkit) { section.setText("Scripts"); section.setDescription("Manage the scripts for your package."); section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); GridData gd = new GridData(GridData.FILL_BOTH); gd.grabExcessVerticalSpace = true; section.setLayoutData(gd); Composite container = createClientContainer(section, 2, toolkit); createViewerPartControl(container, SWT.SINGLE, 2, toolkit); TreePart treePart = getTreePart(); ScriptsController scriptsController = new ScriptsController(); scriptsViewer = treePart.getTreeViewer(); scriptsViewer.setContentProvider(scriptsController); scriptsViewer.setLabelProvider(scriptsController); toolkit.paintBordersFor(container); section.setClient(container); section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); scriptsViewer.setInput(composerPackage.getScripts()); composerPackage.addPropertyChangeListener(this); ISelection selection = scriptsViewer.getSelection(); TreePart treePart = getTreePart(); treePart.setButtonEnabled(ADD_INDEX, enabled); treePart.setButtonEnabled(EDIT_INDEX, !selection.isEmpty() && enabled); treePart.setButtonEnabled(REMOVE_INDEX, !selection.isEmpty() && enabled); addAction = new Action("Add...") { @Override public void run() { handleAdd(); } }; editAction = new Action("Edit...") { @Override public void run() { handleEdit(); } }; removeAction = new Action("Remove") { @Override public void run() { handleRemove(); } }; IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection(); editAction.setEnabled(selection.size() > 0); removeAction.setEnabled(selection.size() > 0); }
<DeepExtract> ISelection selection = scriptsViewer.getSelection(); TreePart treePart = getTreePart(); treePart.setButtonEnabled(ADD_INDEX, enabled); treePart.setButtonEnabled(EDIT_INDEX, !selection.isEmpty() && enabled); treePart.setButtonEnabled(REMOVE_INDEX, !selection.isEmpty() && enabled); </DeepExtract> <DeepExtract> addAction = new Action("Add...") { @Override public void run() { handleAdd(); } }; editAction = new Action("Edit...") { @Override public void run() { handleEdit(); } }; removeAction = new Action("Remove") { @Override public void run() { handleRemove(); } }; </DeepExtract> <DeepExtract> IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection(); editAction.setEnabled(selection.size() > 0); removeAction.setEnabled(selection.size() > 0); </DeepExtract>
Composer-Eclipse-Plugin
positive
public Criteria andRouteIdLessThan(Long value) { if (value == null) { throw new RuntimeException("Value for " + "routeId" + " cannot be null"); } criteria.add(new Criterion("routeId <", value)); return (Criteria) this; }
<DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "routeId" + " cannot be null"); } criteria.add(new Criterion("routeId <", value)); </DeepExtract>
jtt808-simulator
positive
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_user); StatusBarUtil.setColorForSwipeBack(this, 0x284fbb); ButterKnife.bind(this); super.onCreate(savedInstanceState); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); Intent intent = getIntent(); loginName = intent.getStringExtra(LOGIN_NAME); TopicFragment topicFragment = TopicFragment.newInstance(loginName, TopicFragment.TYPE_CREATE); getSupportFragmentManager().beginTransaction().add(R.id.container, topicFragment).commit(); userPresenter = new UserPresenter(this); Log.d(TAG, "getUser: " + loginName); if (loginName != null) { name.setText(loginName.getLogin()); topicNum.setText(String.valueOf(loginName.getTopicsCount())); followNum.setText(String.valueOf(loginName.getFollowingCount())); favoriteNum.setText(String.valueOf(loginName.getFavoritesCount())); RequestOptions options = new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(20)); Glide.with(this).load(loginName.getAvatarUrl()).apply(options).transition(withCrossFade()).into(avatar); } }
<DeepExtract> Log.d(TAG, "getUser: " + loginName); if (loginName != null) { name.setText(loginName.getLogin()); topicNum.setText(String.valueOf(loginName.getTopicsCount())); followNum.setText(String.valueOf(loginName.getFollowingCount())); favoriteNum.setText(String.valueOf(loginName.getFavoritesCount())); RequestOptions options = new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(20)); Glide.with(this).load(loginName.getAvatarUrl()).apply(options).transition(withCrossFade()).into(avatar); } </DeepExtract>
DiyCode
positive
@RegisterMethod(name = "count", declare = true) public long manCount() { ResponseBean responseBean = getReturn(); if (prepareForAll(responseBean)) { prepareCount(responseBean); if (responseBean.getCode().equals(ApiCode.SUCCESS.getCode())) { responseBean.setData(getService().dao().count()); } } return returnBean(responseBean); }
<DeepExtract> ResponseBean responseBean = getReturn(); if (prepareForAll(responseBean)) { prepareCount(responseBean); if (responseBean.getCode().equals(ApiCode.SUCCESS.getCode())) { responseBean.setData(getService().dao().count()); } } return returnBean(responseBean); </DeepExtract>
resys-one
positive
private void layoutAllConnectors() { final int count = topConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = topConnectorSkins.get(i); final Node root = skin.getRoot(); if (false) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(0 - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(0 - skin.getHeight() / 2 + offsetY)); } } final int count = rightConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = rightConnectorSkins.get(i); final Node root = skin.getRoot(); if (true) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(getRoot().getWidth() - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(getRoot().getWidth() - skin.getHeight() / 2 + offsetY)); } } final int count = bottomConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = bottomConnectorSkins.get(i); final Node root = skin.getRoot(); if (false) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(getRoot().getHeight() - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(getRoot().getHeight() - skin.getHeight() / 2 + offsetY)); } } final int count = leftConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = leftConnectorSkins.get(i); final Node root = skin.getRoot(); if (true) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(0 - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(0 - skin.getHeight() / 2 + offsetY)); } } }
<DeepExtract> final int count = topConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = topConnectorSkins.get(i); final Node root = skin.getRoot(); if (false) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(0 - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(0 - skin.getHeight() / 2 + offsetY)); } } </DeepExtract> <DeepExtract> final int count = rightConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = rightConnectorSkins.get(i); final Node root = skin.getRoot(); if (true) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(getRoot().getWidth() - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(getRoot().getWidth() - skin.getHeight() / 2 + offsetY)); } } </DeepExtract> <DeepExtract> final int count = bottomConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = bottomConnectorSkins.get(i); final Node root = skin.getRoot(); if (false) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(getRoot().getHeight() - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(getRoot().getHeight() - skin.getHeight() / 2 + offsetY)); } } </DeepExtract> <DeepExtract> final int count = leftConnectorSkins.size(); for (int i = 0; i < count; i++) { final GConnectorSkin skin = leftConnectorSkins.get(i); final Node root = skin.getRoot(); if (true) { final double offsetY = getRoot().getHeight() / (count + 1); final double offsetX = getMinorOffsetX(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel(0 - skin.getWidth() / 2 + offsetX)); root.setLayoutY(GeometryUtils.moveOnPixel((i + 1) * offsetY - skin.getHeight() / 2)); } else { final double offsetX = getRoot().getWidth() / (count + 1); final double offsetY = getMinorOffsetY(skin.getItem()); root.setLayoutX(GeometryUtils.moveOnPixel((i + 1) * offsetX - skin.getWidth() / 2)); root.setLayoutY(GeometryUtils.moveOnPixel(0 - skin.getHeight() / 2 + offsetY)); } } </DeepExtract>
graph-editor
positive
@Override public void afterPropertiesSet() throws Exception { connector = new NioSocketConnector(); connector.setConnectTimeoutMillis(connectTimeoutMillis); connector.getFilterChain().addLast("logger", new LoggingFilter()); connector.getSessionConfig().setReadBufferSize(readBufferSize); if (protocolCodecFactory != null) { connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(protocolCodecFactory)); } ShortClientHandler clientHandler = new ShortClientHandler(); connector.setHandler(clientHandler); }
<DeepExtract> connector = new NioSocketConnector(); connector.setConnectTimeoutMillis(connectTimeoutMillis); connector.getFilterChain().addLast("logger", new LoggingFilter()); connector.getSessionConfig().setReadBufferSize(readBufferSize); if (protocolCodecFactory != null) { connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(protocolCodecFactory)); } ShortClientHandler clientHandler = new ShortClientHandler(); connector.setHandler(clientHandler); </DeepExtract>
springmore
positive
public Resource all(String path, String summary, JsonObject operation) { Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "GET").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "PUT").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "POST").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "DELETE").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "OPTIONS").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "HEAD").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "TRACE").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "CONNECT").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "PATCH").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); return this; }
<DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "GET").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "PUT").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "POST").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "DELETE").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "OPTIONS").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "HEAD").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "TRACE").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "CONNECT").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract> <DeepExtract> Matcher m = Pattern.compile(":([A-Za-z][A-Za-z0-9_]*)").matcher(path); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "\\{$1\\}"); } m.appendTail(sb); JsonObject op = new JsonObject().put("method", "PATCH").put("summary", summary); op.mergeIn(operation); JsonObject api = getApi(sb.toString()); api.getJsonArray("operations").add(op); </DeepExtract>
yoke
positive
public static Result<?> dataStructure() { return Result.builder().code(ResultEnum.DATA_STRUCTURE.getCode()).msg(ResultEnum.DATA_STRUCTURE.getMsg()).flag(false).build(); }
<DeepExtract> return Result.builder().code(ResultEnum.DATA_STRUCTURE.getCode()).msg(ResultEnum.DATA_STRUCTURE.getMsg()).flag(false).build(); </DeepExtract>
yue-library
positive
@Override public void visitISHL(InstructionHandle instructionHandle) { InstructionHandle nextHandle = instructionHandle.getNext(); sb.append(String.format("%d[label=\"%s\"];\n", instructionHandle.getPosition(), instructionHandle.toString())); if (nextHandle != null) { sb.append(String.format("%d -> %d[label=\"next\", color=\"#839096\"];\n", instructionHandle.getPosition(), nextHandle.getPosition())); } else { System.out.println("next == null"); } }
<DeepExtract> InstructionHandle nextHandle = instructionHandle.getNext(); sb.append(String.format("%d[label=\"%s\"];\n", instructionHandle.getPosition(), instructionHandle.toString())); if (nextHandle != null) { sb.append(String.format("%d -> %d[label=\"next\", color=\"#839096\"];\n", instructionHandle.getPosition(), nextHandle.getPosition())); } else { System.out.println("next == null"); } </DeepExtract>
Java-Bytecode-Editor
positive
public Criteria andCreateByGreaterThanOrEqualTo(Date value) { if (value == null) { throw new RuntimeException("Value for " + "createBy" + " cannot be null"); } criteria.add(new Criterion("create_by >=", value)); return (Criteria) this; }
<DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "createBy" + " cannot be null"); } criteria.add(new Criterion("create_by >=", value)); </DeepExtract>
MyBlog
positive
@Override CMAContentType method() { assertNotNull(spaceId, "spaceId"); assertNotNull(contentType, "contentType"); assertNotNull(environmentId, "environmentId"); final String contentTypeId = contentType.getId(); final CMASystem sys = contentType.getSystem(); contentType.setSystem(null); try { if (contentTypeId == null) { return service.create(spaceId, environmentId, contentType).blockingFirst(); } else { return service.create(spaceId, environmentId, contentTypeId, contentType).blockingFirst(); } } finally { contentType.setSystem(sys); } }
<DeepExtract> assertNotNull(spaceId, "spaceId"); assertNotNull(contentType, "contentType"); assertNotNull(environmentId, "environmentId"); final String contentTypeId = contentType.getId(); final CMASystem sys = contentType.getSystem(); contentType.setSystem(null); try { if (contentTypeId == null) { return service.create(spaceId, environmentId, contentType).blockingFirst(); } else { return service.create(spaceId, environmentId, contentTypeId, contentType).blockingFirst(); } } finally { contentType.setSystem(sys); } </DeepExtract>
contentful-management.java
positive
public final void hideNotify() { if (clockTimerTask != null) { clockTimerTask.cancel(); clockTimerTask = null; } }
<DeepExtract> if (clockTimerTask != null) { clockTimerTask.cancel(); clockTimerTask = null; } </DeepExtract>
AlbiteREADER
positive
public void start(EntitiesToSearch t, Openable ol, VBox n) { this.searchEntity = t; this.ourOpen = ol; this.ourRoot = n; if (ourOpen instanceof RelationalField) { if (((RelationalField) ourOpen).getTabObject() instanceof Region && searchEntity == EntitiesToSearch.REGION) { regionregion = true; this.tree = Backend.getRegionDao().createAboveBelowTree((Region) ((RelationalField) ourOpen).getTabObject()); } } else if (ourOpen instanceof RelationalList) { if (((RelationalList) ourOpen).getTabObject() instanceof Region && searchEntity == EntitiesToSearch.REGION) { regionregion = true; this.tree = Backend.getRegionDao().createAboveBelowTree((Region) ((RelationalList) ourOpen).getTabObject()); } } if (ourOpen instanceof MainController) { final ChoiceBox<String> searchParams = new ChoiceBox<String>(); searchParams.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { if (((String) searchParams.getValue()).equals("Real Entities")) { setEntitiesToSearch(EntitiesToSearch.ALL); } else if (((String) searchParams.getValue()).equals("NPCs")) { setEntitiesToSearch(EntitiesToSearch.NPC); } else if (((String) searchParams.getValue()).equals("Gods")) { setEntitiesToSearch(EntitiesToSearch.GOD); } else if (((String) searchParams.getValue()).equals("Regions")) { setEntitiesToSearch(EntitiesToSearch.REGION); } else if (((String) searchParams.getValue()).equals("Groups")) { setEntitiesToSearch(EntitiesToSearch.EVENT); } else if (((String) searchParams.getValue()).equals("Templates")) { setEntitiesToSearch(EntitiesToSearch.TEMPLATE); } else if (((String) searchParams.getValue()).equals("Statblocks")) { setEntitiesToSearch(EntitiesToSearch.STATBLOCK); } searchDB(); } }); searchParams.getItems().add("Real Entities"); searchParams.getItems().add("NPCs"); searchParams.getItems().add("Gods"); searchParams.getItems().add("Regions"); searchParams.getItems().add("Groups"); searchParams.getItems().add("Templates"); searchParams.getItems().add("Statblocks"); searchParams.setPrefWidth(vbox.getPrefWidth()); List<Node> l = new ArrayList<Node>(); l.add(vbox.getChildren().get(0)); l.add(searchParams); l.add(vbox.getChildren().get(1)); vbox.getChildren().setAll(l); l = null; searchParams.getSelectionModel().select(0); clearList(); } items = FXCollections.observableArrayList(searchResults); listView.setItems(items); if (searchResults.isEmpty()) { listView.setPlaceholder(new Label("No Results")); } listView.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent event) { if (event.getCode().equals(KeyCode.ENTER)) { try { ourOpen.open(listView.getSelectionModel().getSelectedItem()); } catch (Exception e) { e.printStackTrace(); try { ourOpen.open(listView.getItems().get(0)); } catch (Exception e1) { e1.printStackTrace(); } } } } }); listView.setCellFactory(new Callback<ListView<Searchable>, ListCell<Searchable>>() { public ListCell<Searchable> call(ListView<Searchable> param) { return new ListCell<Searchable>() { private void openObj() { try { ourOpen.open(this.getItem()); } catch (Exception e) { e.printStackTrace(); } } public void updateItem(Searchable obj, boolean empty) { super.updateItem(obj, empty); this.setOnMouseClicked(new EventHandler<MouseEvent>() { public void handle(MouseEvent event) { openObj(); } }); if (obj == null) { setText(null); setGraphic(null); setHeight(0); setWidth(0); return; } ImageView imageView = new ImageView(); String name = ""; if (obj != null) { name = obj.getShownName(); try { imageView.setImage(new Image(App.worldFileUtil.findMultimedia(obj.getImageFileName()).toURI().toString(), true)); } catch (NullPointerException e) { imageView.setImage(new Image(App.retGlobalResource("/src/main/ui/no_image_icon.png").toString())); } } if (empty) { setText(null); setGraphic(null); } else { setText(name); imageView.setFitHeight(maxImageSize); imageView.setFitWidth(maxImageSize); imageView.setPreserveRatio(true); setGraphic(imageView); } } }; } }); }
<DeepExtract> if (ourOpen instanceof MainController) { final ChoiceBox<String> searchParams = new ChoiceBox<String>(); searchParams.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { if (((String) searchParams.getValue()).equals("Real Entities")) { setEntitiesToSearch(EntitiesToSearch.ALL); } else if (((String) searchParams.getValue()).equals("NPCs")) { setEntitiesToSearch(EntitiesToSearch.NPC); } else if (((String) searchParams.getValue()).equals("Gods")) { setEntitiesToSearch(EntitiesToSearch.GOD); } else if (((String) searchParams.getValue()).equals("Regions")) { setEntitiesToSearch(EntitiesToSearch.REGION); } else if (((String) searchParams.getValue()).equals("Groups")) { setEntitiesToSearch(EntitiesToSearch.EVENT); } else if (((String) searchParams.getValue()).equals("Templates")) { setEntitiesToSearch(EntitiesToSearch.TEMPLATE); } else if (((String) searchParams.getValue()).equals("Statblocks")) { setEntitiesToSearch(EntitiesToSearch.STATBLOCK); } searchDB(); } }); searchParams.getItems().add("Real Entities"); searchParams.getItems().add("NPCs"); searchParams.getItems().add("Gods"); searchParams.getItems().add("Regions"); searchParams.getItems().add("Groups"); searchParams.getItems().add("Templates"); searchParams.getItems().add("Statblocks"); searchParams.setPrefWidth(vbox.getPrefWidth()); List<Node> l = new ArrayList<Node>(); l.add(vbox.getChildren().get(0)); l.add(searchParams); l.add(vbox.getChildren().get(1)); vbox.getChildren().setAll(l); l = null; searchParams.getSelectionModel().select(0); clearList(); } </DeepExtract> <DeepExtract> items = FXCollections.observableArrayList(searchResults); listView.setItems(items); if (searchResults.isEmpty()) { listView.setPlaceholder(new Label("No Results")); } listView.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent event) { if (event.getCode().equals(KeyCode.ENTER)) { try { ourOpen.open(listView.getSelectionModel().getSelectedItem()); } catch (Exception e) { e.printStackTrace(); try { ourOpen.open(listView.getItems().get(0)); } catch (Exception e1) { e1.printStackTrace(); } } } } }); listView.setCellFactory(new Callback<ListView<Searchable>, ListCell<Searchable>>() { public ListCell<Searchable> call(ListView<Searchable> param) { return new ListCell<Searchable>() { private void openObj() { try { ourOpen.open(this.getItem()); } catch (Exception e) { e.printStackTrace(); } } public void updateItem(Searchable obj, boolean empty) { super.updateItem(obj, empty); this.setOnMouseClicked(new EventHandler<MouseEvent>() { public void handle(MouseEvent event) { openObj(); } }); if (obj == null) { setText(null); setGraphic(null); setHeight(0); setWidth(0); return; } ImageView imageView = new ImageView(); String name = ""; if (obj != null) { name = obj.getShownName(); try { imageView.setImage(new Image(App.worldFileUtil.findMultimedia(obj.getImageFileName()).toURI().toString(), true)); } catch (NullPointerException e) { imageView.setImage(new Image(App.retGlobalResource("/src/main/ui/no_image_icon.png").toString())); } } if (empty) { setText(null); setGraphic(null); } else { setText(name); imageView.setFitHeight(maxImageSize); imageView.setFitWidth(maxImageSize); imageView.setPreserveRatio(true); setGraphic(imageView); } } }; } }); </DeepExtract>
fwm
positive
public List<SurveyListEntry> toListOfSurveyListEntries(Survey survey) { List<SurveyListEntry> list = new ArrayList<>(); for (Leg leg : survey.getOrigin().getUnconnectedOnwardLegs()) { SurveyListEntry entry = new SurveyListEntry(survey.getOrigin(), leg); list.add(entry); } for (Leg leg : survey.getOrigin().getConnectedOnwardLegs()) { SurveyListEntry entry = new SurveyListEntry(survey.getOrigin(), leg); list.add(entry); list.addAll(createListOfEntriesFromStation(leg.getDestination())); } return list; }
<DeepExtract> List<SurveyListEntry> list = new ArrayList<>(); for (Leg leg : survey.getOrigin().getUnconnectedOnwardLegs()) { SurveyListEntry entry = new SurveyListEntry(survey.getOrigin(), leg); list.add(entry); } for (Leg leg : survey.getOrigin().getConnectedOnwardLegs()) { SurveyListEntry entry = new SurveyListEntry(survey.getOrigin(), leg); list.add(entry); list.addAll(createListOfEntriesFromStation(leg.getDestination())); } return list; </DeepExtract>
sexytopo
positive
public void createShape() { mProgramHandler = GLES20.glCreateProgram(); String vertexShaderCode = getVertexShaderCode(); String fragmentShaderCode = getFragmentShaderCode(); if (vertexShaderCode == null || fragmentShaderCode == null) { throw new RuntimeException("getVertexShaderCode and getFragmentShaderCode can't return null"); } GLHelper.loadShaders(mProgramHandler, vertexShaderCode, fragmentShaderCode); GLES20.glUseProgram(mProgramHandler); createBuffer(); findHandlersInGLSL(); fillHandlersValue(); }
<DeepExtract> mProgramHandler = GLES20.glCreateProgram(); </DeepExtract> <DeepExtract> String vertexShaderCode = getVertexShaderCode(); String fragmentShaderCode = getFragmentShaderCode(); if (vertexShaderCode == null || fragmentShaderCode == null) { throw new RuntimeException("getVertexShaderCode and getFragmentShaderCode can't return null"); } GLHelper.loadShaders(mProgramHandler, vertexShaderCode, fragmentShaderCode); </DeepExtract> <DeepExtract> GLES20.glUseProgram(mProgramHandler); </DeepExtract>
AndroidOpenGLTutorial
positive
public void error(String error) { queue.add(error); System.out.println(error); }
<DeepExtract> queue.add(error); </DeepExtract>
LibLaserCut
positive
public static long getLong(Object value, long defaultValue) { if (value != null) { try { String svalue = value.toString().trim(); if (svalue.equalsIgnoreCase(BOOLEANS[0]) || svalue.equalsIgnoreCase(BOOLEANS[1]) || svalue.equalsIgnoreCase(BOOLEANS[2]) || svalue.equalsIgnoreCase(BOOLEANS[3]) || svalue.equalsIgnoreCase(BOOLEANS[4])) { return true; } else { return false; } } catch (Exception e) { } } return defaultValue; }
<DeepExtract> if (value != null) { try { String svalue = value.toString().trim(); if (svalue.equalsIgnoreCase(BOOLEANS[0]) || svalue.equalsIgnoreCase(BOOLEANS[1]) || svalue.equalsIgnoreCase(BOOLEANS[2]) || svalue.equalsIgnoreCase(BOOLEANS[3]) || svalue.equalsIgnoreCase(BOOLEANS[4])) { return true; } else { return false; } } catch (Exception e) { } } return defaultValue; </DeepExtract>
kaixin
positive
public void draw(Graphics2D g2, float x, float y) { AffineTransform oldAt = g2.getTransform(); Color oldC = g2.getColor(); Stroke oldS = g2.getStroke(); g2.translate(x + 0.25f * height / 2.15f, y - 1.75f / 2.15f * height); g2.setColor(gray); g2.setStroke(st); g2.scale(0.05f * height / 2.15f, 0.05f * height / 2.15f); g2.rotate(-26 * Math.PI / 180, 20.5, 17.5); g2.drawArc(0, 0, 43, 32, 0, 360); g2.rotate(26 * Math.PI / 180, 20.5, 17.5); g2.setStroke(oldS); g2.setColor(blue); g2.translate(16f, -5f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-16f, --5f); g2.setColor(blue); g2.translate(-1f, 7f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(--1f, -7f); g2.setColor(blue); g2.translate(5f, 28f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-5f, -28f); g2.setColor(blue); g2.translate(27f, 24f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-27f, -24f); g2.setColor(blue); g2.translate(36f, 3f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-36f, -3f); g2.setStroke(oldS); g2.setTransform(oldAt); g2.setColor(oldC); }
<DeepExtract> g2.setColor(blue); g2.translate(16f, -5f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-16f, --5f); </DeepExtract> <DeepExtract> g2.setColor(blue); g2.translate(-1f, 7f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(--1f, -7f); </DeepExtract> <DeepExtract> g2.setColor(blue); g2.translate(5f, 28f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-5f, -28f); </DeepExtract> <DeepExtract> g2.setColor(blue); g2.translate(27f, 24f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-27f, -24f); </DeepExtract> <DeepExtract> g2.setColor(blue); g2.translate(36f, 3f); g2.fillArc(0, 0, 8, 8, 0, 360); g2.setColor(Color.BLACK); g2.drawArc(0, 0, 8, 8, 0, 360); g2.translate(-36f, -3f); </DeepExtract>
jlatexmath
positive
public Criteria andStatusIn(List<Integer> values) { if (values == null) { throw new RuntimeException("Value for " + "status" + " cannot be null"); } criteria.add(new Criterion("status in", values)); return (Criteria) this; }
<DeepExtract> if (values == null) { throw new RuntimeException("Value for " + "status" + " cannot be null"); } criteria.add(new Criterion("status in", values)); </DeepExtract>
garbage-collection
positive
@SuppressWarnings("unchecked") public String getFlags() { JSONObject json = new JSONObject(); if (rank != null) { json.put("rank", rank); } json.put("channel", channel.toString()); List<Boolean> settings = new LinkedList<>(); settings.add(globalChat); settings.add(allyChat); settings.add(clanChat); json.put("channel-state", settings); json.put("chat-shortcut", useChatShortcut); json.put("bb-enabled", bbEnabled); json.put("hide-tag", tagEnabled); json.put("cape-enabled", capeEnabled); return displayName; }
<DeepExtract> return displayName; </DeepExtract>
SimpleClans
positive
long pageHeaderGetPrev() { if (!pageHeaderMagicOk()) throw new Error("CRITICAL: page header magic not OK " + pageHeaderGetMagic()); long ret = ((long) (data.get(PAGE_HEADER_O_PREV + 0) & 0x7f) << 40) | ((long) (data.get(PAGE_HEADER_O_PREV + 1) & 0xff) << 32) | ((long) (data.get(PAGE_HEADER_O_PREV + 2) & 0xff) << 24) | ((long) (data.get(PAGE_HEADER_O_PREV + 3) & 0xff) << 16) | ((long) (data.get(PAGE_HEADER_O_PREV + 4) & 0xff) << 8) | ((long) (data.get(PAGE_HEADER_O_PREV + 5) & 0xff) << 0); if ((data.get(PAGE_HEADER_O_PREV + 0) & 0x80) != 0) return -ret; else return ret; }
<DeepExtract> if (!pageHeaderMagicOk()) throw new Error("CRITICAL: page header magic not OK " + pageHeaderGetMagic()); </DeepExtract> <DeepExtract> long ret = ((long) (data.get(PAGE_HEADER_O_PREV + 0) & 0x7f) << 40) | ((long) (data.get(PAGE_HEADER_O_PREV + 1) & 0xff) << 32) | ((long) (data.get(PAGE_HEADER_O_PREV + 2) & 0xff) << 24) | ((long) (data.get(PAGE_HEADER_O_PREV + 3) & 0xff) << 16) | ((long) (data.get(PAGE_HEADER_O_PREV + 4) & 0xff) << 8) | ((long) (data.get(PAGE_HEADER_O_PREV + 5) & 0xff) << 0); if ((data.get(PAGE_HEADER_O_PREV + 0) & 0x80) != 0) return -ret; else return ret; </DeepExtract>
JDBM3
positive
public static void main(String[] args) { int[] arr = { 12, 11, 13, 5, 6 }; InsertionSort ob = new InsertionSort(); int n = arr.length; for (int i = 1; i < n; ++i) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } int n = arr.length; for (int i = 0; i < n; ++i) System.out.print(arr[i] + " "); System.out.println(); }
<DeepExtract> int n = arr.length; for (int i = 1; i < n; ++i) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } </DeepExtract> <DeepExtract> int n = arr.length; for (int i = 0; i < n; ++i) System.out.print(arr[i] + " "); System.out.println(); </DeepExtract>
Important-Java-Concepts
positive
@Override public void run() { LogUtil.d(TAG, "completedFile path: " + completedFile.getAbsolutePath()); }
<DeepExtract> </DeepExtract>
dcs-sdk-java
positive
@Override public void drawChart(Canvas canvas) { int topStart = topStartPointY + mMoveLen; paint.setStyle(Paint.Style.FILL); LogUtil.w(TAG, ""); for (int i = 0; i < dataList.size(); i++) { String str = strList.get(i); List<BarBean> list = dataList.get(i); int topY = topStart + (oneBarW + barItemSpace) * i; paintLabel.setTextSize(textSizeCoordinate); paintLabel.setColor(textColorCoordinate); float tw = FontUtil.getFontlength(paintLabel, str); canvas.drawText(str, zeroPoint.x - textSpace - tw, topY + oneBarW / 2 - heightCoordinate / 2 + leadCoordinate, paintLabel); paint.setStrokeWidth(0.5f); paint.setColor(defColor); canvas.drawLine(zeroPoint.x, topY - 15, rectChart.right, topY - 15, paint); paintLabel.setTextSize(textSizeTag); paintLabel.setColor(textColorTag); for (int j = 0; j < list.size(); j++) { BarBean bean = list.get(j); paint.setStrokeWidth(0.5f); paint.setColor(defColor); canvas.drawLine(zeroPoint.x, topY + barWidth / 2, rectChart.right, topY + barWidth / 2, paint); paint.setColor(barColor[j]); float right = (zeroPoint.x + XMARK_ALL_H * (bean.getNum() / XMARK_MAX) * animPro); RectF br = new RectF(zeroPoint.x, topY, right, topY + barWidth); canvas.drawRect(br, paint); str = (int) bean.getNum() + ""; canvas.drawText(str, right + textSpace, topY + barWidth / 2 - heightTag / 2 + leadTag, paintLabel); topY += (barWidth + barSpace); } paint.setStrokeWidth(0.5f); paint.setColor(defColor); canvas.drawLine(zeroPoint.x, topY - barSpace + 15, rectChart.right, topY - barSpace + 15, paint); } paint.setStyle(Paint.Style.FILL); paint.setColor(backColor); canvas.drawRect(new RectF(0, 0, rectChart.right, zeroPoint.y - lineWidth), paint); canvas.drawRect(new RectF(0, rectChart.bottom, rectChart.right, getMeasuredHeight()), paint); paintLabel.setTextSize(textSizeCoordinate); paintLabel.setColor(textColorCoordinate); for (int i = 0; i <= XMARK_MAX / XMARK; i++) { String textX = (XMARK * i) + ""; float tw = FontUtil.getFontlength(paintLabel, textX); canvas.drawText(textX, (int) (zeroPoint.x + (i * XMARK_H) - tw / 2), zeroPoint.y - textSpace - heightCoordinate + leadCoordinate, paintLabel); } }
<DeepExtract> paint.setStyle(Paint.Style.FILL); paint.setColor(backColor); canvas.drawRect(new RectF(0, 0, rectChart.right, zeroPoint.y - lineWidth), paint); canvas.drawRect(new RectF(0, rectChart.bottom, rectChart.right, getMeasuredHeight()), paint); paintLabel.setTextSize(textSizeCoordinate); paintLabel.setColor(textColorCoordinate); for (int i = 0; i <= XMARK_MAX / XMARK; i++) { String textX = (XMARK * i) + ""; float tw = FontUtil.getFontlength(paintLabel, textX); canvas.drawText(textX, (int) (zeroPoint.x + (i * XMARK_H) - tw / 2), zeroPoint.y - textSpace - heightCoordinate + leadCoordinate, paintLabel); } </DeepExtract>
OXChart
positive
public void restart() { stopDraw(); start(0); }
<DeepExtract> stopDraw(); </DeepExtract> <DeepExtract> start(0); </DeepExtract>
DanmakuFlameMaster
positive
public void terminate() { isContinue = false; if (isIdle()) { this.request = () -> { }; notify(); } }
<DeepExtract> if (isIdle()) { this.request = () -> { }; notify(); } </DeepExtract>
JavaSE9Tutorial
positive
@Override public void doBeforeComposeChildren(Component comp) throws Exception { super.doBeforeComposeChildren(comp); comp.setAttribute("menuTitle", "Extra Functions"); List menuList = new LinkedList<>(); Menu legal = new Menu("Legal"); String[] items = { "Legal 1", "Legal 2", "Legal 3" }; legal.setItems(Arrays.asList(items)); menuList.add(legal); Menu finance = new Menu("Finance"); String[] items2 = { "Finance 1", "Finance 2", "Finance 3" }; finance.setItems(Arrays.asList(items2)); menuList.add(finance); Menu management = new Menu("Management"); String[] items3 = { "Management 1", "Management 2", "Management 3" }; management.setItems(Arrays.asList(items3)); menuList.add(management); comp.setAttribute("menuList", menuList); }
<DeepExtract> comp.setAttribute("menuTitle", "Extra Functions"); List menuList = new LinkedList<>(); Menu legal = new Menu("Legal"); String[] items = { "Legal 1", "Legal 2", "Legal 3" }; legal.setItems(Arrays.asList(items)); menuList.add(legal); Menu finance = new Menu("Finance"); String[] items2 = { "Finance 1", "Finance 2", "Finance 3" }; finance.setItems(Arrays.asList(items2)); menuList.add(finance); Menu management = new Menu("Management"); String[] items3 = { "Management 1", "Management 2", "Management 3" }; management.setItems(Arrays.asList(items3)); menuList.add(management); comp.setAttribute("menuList", menuList); </DeepExtract>
zkbooks
positive
public float getExpandedSubtitleTextHeight() { subtitleTmpPaint.setTextSize(expandedSubtitleTextSize); subtitleTmpPaint.setTypeface(expandedSubtitleTypeface); return -subtitleTmpPaint.ascent(); }
<DeepExtract> subtitleTmpPaint.setTextSize(expandedSubtitleTextSize); subtitleTmpPaint.setTypeface(expandedSubtitleTypeface); </DeepExtract>
LSPosed
positive
@Override protected void onDestroy() { super.onDestroy(); if (mFrameBufferTextures != null) { GLES20.glDeleteTextures(1, mFrameBufferTextures, 0); mFrameBufferTextures = null; } if (mFrameBuffers != null) { GLES20.glDeleteFramebuffers(1, mFrameBuffers, 0); mFrameBuffers = null; } mFrameWidth = -1; mFrameHeight = -1; }
<DeepExtract> if (mFrameBufferTextures != null) { GLES20.glDeleteTextures(1, mFrameBufferTextures, 0); mFrameBufferTextures = null; } if (mFrameBuffers != null) { GLES20.glDeleteFramebuffers(1, mFrameBuffers, 0); mFrameBuffers = null; } mFrameWidth = -1; mFrameHeight = -1; </DeepExtract>
MagicCamera
positive
public Criteria andPCreateTimeGreaterThan(Date value) { if (value == null) { throw new RuntimeException("Value for " + "pCreateTime" + " cannot be null"); } criteria.add(new Criterion("p_create_time >", value)); return (Criteria) this; }
<DeepExtract> if (value == null) { throw new RuntimeException("Value for " + "pCreateTime" + " cannot be null"); } criteria.add(new Criterion("p_create_time >", value)); </DeepExtract>
webike
positive
private void onMoveEvent(final int x, final int y, final long eventTime) { if (DEBUG_MOVE_EVENT) { printTouchEvent("onMoveEvent:", x, y, eventTime); } if (mIsTrackingForActionDisabled) { return; } if (isShowingMoreKeysPanel()) { final int translatedX = mMoreKeysPanel.translateX(x); final int translatedY = mMoreKeysPanel.translateY(y); mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId); onMoveKey(x, y); return; } final Key oldKey = mCurrentKey; if (oldKey != null && oldKey.getCode() == Constants.CODE_SPACE && Settings.getInstance().getCurrent().mSpaceSwipeEnabled) { int steps = (x - mStartX) / sPointerStep; final int swipeIgnoreTime = Settings.getInstance().getCurrent().mKeyLongpressTimeout / MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT; if (steps != 0 && mStartTime + swipeIgnoreTime < System.currentTimeMillis()) { mCursorMoved = true; mStartX += steps * sPointerStep; sListener.onMovePointer(steps); } return; } if (oldKey != null && oldKey.getCode() == Constants.CODE_DELETE && Settings.getInstance().getCurrent().mDeleteSwipeEnabled) { int steps = (x - mStartX) / sPointerStep; if (steps != 0) { sTimerProxy.cancelKeyTimersOf(this); mCursorMoved = true; mStartX += steps * sPointerStep; sListener.onMoveDeletePointer(steps); } return; } final Key newKey = onMoveKey(x, y); if (newKey != null) { if (oldKey != null && isMajorEnoughMoveToBeOnNewKey(x, y, newKey)) { dragFingerFromOldKeyToNewKey(newKey, x, y, eventTime, oldKey); } else if (oldKey == null) { processDraggingFingerInToNewKey(newKey, x, y); } } else { if (oldKey != null && isMajorEnoughMoveToBeOnNewKey(x, y, newKey)) { dragFingerOutFromOldKey(oldKey, x, y); } } }
<DeepExtract> final Key oldKey = mCurrentKey; if (oldKey != null && oldKey.getCode() == Constants.CODE_SPACE && Settings.getInstance().getCurrent().mSpaceSwipeEnabled) { int steps = (x - mStartX) / sPointerStep; final int swipeIgnoreTime = Settings.getInstance().getCurrent().mKeyLongpressTimeout / MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT; if (steps != 0 && mStartTime + swipeIgnoreTime < System.currentTimeMillis()) { mCursorMoved = true; mStartX += steps * sPointerStep; sListener.onMovePointer(steps); } return; } if (oldKey != null && oldKey.getCode() == Constants.CODE_DELETE && Settings.getInstance().getCurrent().mDeleteSwipeEnabled) { int steps = (x - mStartX) / sPointerStep; if (steps != 0) { sTimerProxy.cancelKeyTimersOf(this); mCursorMoved = true; mStartX += steps * sPointerStep; sListener.onMoveDeletePointer(steps); } return; } final Key newKey = onMoveKey(x, y); if (newKey != null) { if (oldKey != null && isMajorEnoughMoveToBeOnNewKey(x, y, newKey)) { dragFingerFromOldKeyToNewKey(newKey, x, y, eventTime, oldKey); } else if (oldKey == null) { processDraggingFingerInToNewKey(newKey, x, y); } } else { if (oldKey != null && isMajorEnoughMoveToBeOnNewKey(x, y, newKey)) { dragFingerOutFromOldKey(oldKey, x, y); } } </DeepExtract>
simple-keyboard
positive
void keyStoreUpdated() { try { TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); tmf.init(appKeyStore); for (TrustManager t : tmf.getTrustManagers()) { if (t instanceof X509TrustManager) { appTrustManager = (X509TrustManager) t; } } } catch (Exception e) { LOGGER.log(Level.SEVERE, "getTrustManager(" + appKeyStore + ")", e); } return null; java.io.FileOutputStream fos = null; try { fos = new java.io.FileOutputStream(keyStoreFile); appKeyStore.store(fos, "MTM".toCharArray()); } catch (Exception e) { LOGGER.log(Level.SEVERE, "storeCert(" + keyStoreFile + ")", e); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "storeCert(" + keyStoreFile + ")", e); } } } }
<DeepExtract> try { TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); tmf.init(appKeyStore); for (TrustManager t : tmf.getTrustManagers()) { if (t instanceof X509TrustManager) { appTrustManager = (X509TrustManager) t; } } } catch (Exception e) { LOGGER.log(Level.SEVERE, "getTrustManager(" + appKeyStore + ")", e); } return null; </DeepExtract>
simpleirc
positive
void setSelectedMessageAsOriginal() { int selected = jTable1.getSelectedRow(); messageOrigIndex = selected; SentinelHttpMessage m = tableModel.getHttpMessage(selected); rightRequestMessageEditor.setMessage(m.getRequest(), true); }
<DeepExtract> messageOrigIndex = selected; SentinelHttpMessage m = tableModel.getHttpMessage(selected); rightRequestMessageEditor.setMessage(m.getRequest(), true); </DeepExtract>
BurpSentinel
positive
public _Fields fieldForId(int fieldId) { switch(fieldId) { case 1: return USER; default: return null; } }
<DeepExtract> switch(fieldId) { case 1: return USER; default: return null; } </DeepExtract>
lyb-schema-explorer
positive
@Test public void f32_convert_i32_s() throws IOException { WasmOptions options = new WasmOptions(new HashMap<>()); WatParser parser = new WatParser(); WasmCodeBuilder codeBuilder = parser; codeBuilder.init(options, null); parser.parse("f32.convert_i32_s", null, null, 100); StringBuilder builder = new StringBuilder(); ModuleWriter writer = new TextModuleWriter(new WasmTarget(builder), options); writer.writeMethodStart(new FunctionName("A.a()V"), null); for (WasmInstruction instruction : codeBuilder.getInstructions()) { instruction.writeTo(writer); } writer.writeMethodFinish(); writer.close(); String expected = normalize("(module (func $A.a " + "f32.convert_i32_s" + " ) )"); String actual = normalize(builder); assertEquals(expected, actual); writer = new BinaryModuleWriter(new WasmTarget(builder), new WasmOptions(new HashMap<>())); writer.writeMethodStart(new FunctionName("A.a()V"), null); for (WasmInstruction instruction : codeBuilder.getInstructions()) { instruction.writeTo(writer); } }
<DeepExtract> WasmOptions options = new WasmOptions(new HashMap<>()); WatParser parser = new WatParser(); WasmCodeBuilder codeBuilder = parser; codeBuilder.init(options, null); parser.parse("f32.convert_i32_s", null, null, 100); StringBuilder builder = new StringBuilder(); ModuleWriter writer = new TextModuleWriter(new WasmTarget(builder), options); writer.writeMethodStart(new FunctionName("A.a()V"), null); for (WasmInstruction instruction : codeBuilder.getInstructions()) { instruction.writeTo(writer); } writer.writeMethodFinish(); writer.close(); String expected = normalize("(module (func $A.a " + "f32.convert_i32_s" + " ) )"); String actual = normalize(builder); assertEquals(expected, actual); writer = new BinaryModuleWriter(new WasmTarget(builder), new WasmOptions(new HashMap<>())); writer.writeMethodStart(new FunctionName("A.a()V"), null); for (WasmInstruction instruction : codeBuilder.getInstructions()) { instruction.writeTo(writer); } </DeepExtract>
JWebAssembly
positive
@Override public void onResume() { super.onResume(); if (mainapp.isForcingFinish()) { mainapp.appIsFinishing = true; this.finish(); overridePendingTransition(0, 0); return; } for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { enable_disable_buttons(throttleIndex); soundsShowHideDeviceSoundsButton(throttleIndex); showHideSpeedLimitAndPauseButtons(throttleIndex); } gestureFailed = false; gestureInProgress = false; if (false) { webViewLocation = prefs.getString("WebViewLocation", getApplicationContext().getResources().getString(R.string.prefWebViewLocationDefaultValue)); } prefDirectionButtonLongPressDelay = mainapp.getIntPrefValue(prefs, "prefDirectionButtonLongPressDelay", getApplicationContext().getResources().getString(R.string.prefDirectionButtonLongPressDelayDefaultValue)); FUNCTION_BUTTON_LOOK_FOR_WHISTLE = getApplicationContext().getResources().getString(R.string.functionButtonLookForWhistle).trim(); FUNCTION_BUTTON_LOOK_FOR_HORN = getApplicationContext().getResources().getString(R.string.functionButtonLookForHorn).trim(); FUNCTION_BUTTON_LOOK_FOR_BELL = getApplicationContext().getResources().getString(R.string.functionButtonLookForBell).trim(); FUNCTION_BUTTON_LOOK_FOR_HEAD = getApplicationContext().getResources().getString(R.string.functionButtonLookForHead).trim(); FUNCTION_BUTTON_LOOK_FOR_LIGHT = getApplicationContext().getResources().getString(R.string.functionButtonLookForLight).trim(); FUNCTION_BUTTON_LOOK_FOR_REAR = getApplicationContext().getResources().getString(R.string.functionButtonLookForRear).trim(); prefConsistFollowDefaultAction = prefs.getString("prefConsistFollowDefaultAction", getApplicationContext().getResources().getString(R.string.prefConsistFollowDefaultActionDefaultValue)); prefConsistFollowStrings = new ArrayList<>(); prefConsistFollowActions = new ArrayList<>(); prefConsistFollowHeadlights = new ArrayList<>(); mainapp.prefConsistFollowRuleStyle = prefs.getString("prefConsistFollowRuleStyle", getApplicationContext().getResources().getString(R.string.prefConsistFollowRuleStyleDefaultValue)); String prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString1", getApplicationContext().getResources().getString(R.string.prefConsistFollowString1DefaultValue)); String prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction1", getApplicationContext().getResources().getString(R.string.prefConsistFollowString1DefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString2", getApplicationContext().getResources().getString(R.string.prefConsistFollowString2DefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction2", getApplicationContext().getResources().getString(R.string.prefConsistFollowString2DefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString3", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction3", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString4", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction4", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString5", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction5", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); pref_increase_slider_height_preference = prefs.getBoolean("increase_slider_height_preference", getResources().getBoolean(R.bool.prefIncreaseSliderHeightDefaultValue)); prefDecreaseLocoNumberHeight = prefs.getBoolean("prefDecreaseLocoNumberHeight", getResources().getBoolean(R.bool.prefDecreaseLocoNumberHeightDefaultValue)); prefIncreaseWebViewSize = prefs.getBoolean("prefIncreaseWebViewSize", getResources().getBoolean(R.bool.prefIncreaseWebViewSizeDefaultValue)); prefThrottleViewImmersiveMode = prefs.getBoolean("prefThrottleViewImmersiveMode", getResources().getBoolean(R.bool.prefThrottleViewImmersiveModeDefaultValue)); prefThrottleViewImmersiveModeHideToolbar = prefs.getBoolean("prefThrottleViewImmersiveModeHideToolbar", getResources().getBoolean(R.bool.prefThrottleViewImmersiveModeHideToolbarDefaultValue)); prefShowAddressInsteadOfName = prefs.getBoolean("prefShowAddressInsteadOfName", getResources().getBoolean(R.bool.prefShowAddressInsteadOfNameDefaultValue)); prefSwipeDownOption = prefs.getString("SwipeDownOption", getApplicationContext().getResources().getString(R.string.prefSwipeUpOptionDefaultValue)); prefSwipeUpOption = prefs.getString("SwipeUpOption", getApplicationContext().getResources().getString(R.string.prefSwipeUpOptionDefaultValue)); isScreenLocked = false; dirChangeWhileMoving = prefs.getBoolean("DirChangeWhileMovingPreference", getResources().getBoolean(R.bool.prefDirChangeWhileMovingDefaultValue)); stopOnDirectionChange = prefs.getBoolean("prefStopOnDirectionChange", getResources().getBoolean(R.bool.prefStopOnDirectionChangeDefaultValue)); locoSelectWhileMoving = prefs.getBoolean("SelLocoWhileMovingPreference", getResources().getBoolean(R.bool.prefSelLocoWhileMovingDefaultValue)); screenBrightnessDim = Integer.parseInt(prefs.getString("prefScreenBrightnessDim", getResources().getString(R.string.prefScreenBrightnessDimDefaultValue))) * 255 / 100; prefConsistLightsLongClick = prefs.getBoolean("ConsistLightsLongClickPreference", getResources().getBoolean(R.bool.prefConsistLightsLongClickDefaultValue)); prefGamepadTestEnforceTesting = prefs.getBoolean("prefGamepadTestEnforceTesting", getResources().getBoolean(R.bool.prefGamepadTestEnforceTestingDefaultValue)); prefDisableVolumeKeys = prefs.getBoolean("prefDisableVolumeKeys", getResources().getBoolean(R.bool.prefDisableVolumeKeysDefaultValue)); prefSelectedLocoIndicator = prefs.getString("prefSelectedLocoIndicator", getResources().getString(R.string.prefSelectedLocoIndicatorDefaultValue)); prefVolumeKeysFollowLastTouchedThrottle = prefs.getBoolean("prefVolumeKeysFollowLastTouchedThrottle", getResources().getBoolean(R.bool.prefVolumeKeysFollowLastTouchedThrottleDefaultValue)); mainapp.prefAlwaysUseDefaultFunctionLabels = prefs.getBoolean("prefAlwaysUseDefaultFunctionLabels", getResources().getBoolean(R.bool.prefAlwaysUseDefaultFunctionLabelsDefaultValue)); prefNumberOfDefaultFunctionLabels = Integer.parseInt(prefs.getString("prefNumberOfDefaultFunctionLabels", getResources().getString(R.string.prefNumberOfDefaultFunctionLabelsDefaultValue))); prefAccelerometerShake = prefs.getString("prefAccelerometerShake", getApplicationContext().getResources().getString(R.string.prefAccelerometerShakeDefaultValue)); prefSpeedButtonsSpeedStep = mainapp.getIntPrefValue(prefs, "speed_arrows_throttle_speed_step", "4"); prefVolumeSpeedButtonsSpeedStep = mainapp.getIntPrefValue(prefs, "prefVolumeSpeedButtonsSpeedStep", getApplicationContext().getResources().getString(R.string.prefVolumeSpeedButtonsSpeedStepDefaultValue)); prefGamePadSpeedButtonsSpeedStep = mainapp.getIntPrefValue(prefs, "prefGamePadSpeedButtonsSpeedStep", getApplicationContext().getResources().getString(R.string.prefVolumeSpeedButtonsSpeedStepDefaultValue)); prefSpeedButtonsSpeedStepDecrement = prefs.getBoolean("prefSpeedButtonsSpeedStepDecrement", getResources().getBoolean(R.bool.prefSpeedButtonsSpeedStepDecrementDefaultValue)); prefTtsWhen = prefs.getString("prefTtsWhen", getResources().getString(R.string.prefTtsWhenDefaultValue)); prefTtsThrottleResponse = prefs.getString("prefTtsThrottleResponse", getResources().getString(R.string.prefTtsThrottleResponseDefaultValue)); prefTtsThrottleSpeed = prefs.getString("prefTtsThrottleSpeed", getResources().getString(R.string.prefTtsThrottleSpeedDefaultValue)); prefTtsGamepadTest = prefs.getBoolean("prefTtsGamepadTest", getResources().getBoolean(R.bool.prefTtsGamepadTestDefaultValue)); prefTtsGamepadTestComplete = prefs.getBoolean("prefTtsGamepadTestComplete", getResources().getBoolean(R.bool.prefTtsGamepadTestCompleteDefaultValue)); prefTtsGamepadTestKeys = prefs.getBoolean("prefTtsGamepadTestKeys", getResources().getBoolean(R.bool.prefTtsGamepadTestKeysDefaultValue)); mainapp.prefGamepadOnlyOneGamepad = prefs.getBoolean("prefGamepadOnlyOneGamepad", getResources().getBoolean(R.bool.prefGamepadOnlyOneGamepadDefaultValue)); prefGamePadDoublePressStop = prefs.getString("prefGamePadDoublePressStop", getResources().getString(R.string.prefTtsThrottleResponseDefaultValue)); mainapp.prefGamePadIgnoreJoystick = prefs.getBoolean("prefGamePadIgnoreJoystick", getResources().getBoolean(R.bool.prefGamePadIgnoreJoystickDefaultValue)); prefEsuMc2EndStopDirectionChange = prefs.getBoolean("prefEsuMc2EndStopDirectionChange", getResources().getBoolean(R.bool.prefEsuMc2EndStopDirectionChangeDefaultValue)); prefEsuMc2StopButtonShortPress = prefs.getBoolean("prefEsuMc2StopButtonShortPress", getResources().getBoolean(R.bool.prefEsuMc2StopButtonShortPressDefaultValue)); mainapp.numThrottles = mainapp.Numeralise(prefs.getString("NumThrottle", getResources().getString(R.string.NumThrottleDefaulValue))); prefThrottleScreenType = prefs.getString("prefThrottleScreenType", getApplicationContext().getResources().getString(R.string.prefThrottleScreenTypeDefault)); prefSelectiveLeadSound = prefs.getBoolean("SelectiveLeadSound", getResources().getBoolean(R.bool.prefSelectiveLeadSoundDefaultValue)); prefSelectiveLeadSoundF1 = prefs.getBoolean("SelectiveLeadSoundF1", getResources().getBoolean(R.bool.prefSelectiveLeadSoundF1DefaultValue)); prefSelectiveLeadSoundF2 = prefs.getBoolean("SelectiveLeadSoundF2", getResources().getBoolean(R.bool.prefSelectiveLeadSoundF2DefaultValue)); prefBackgroundImage = prefs.getBoolean("prefBackgroundImage", getResources().getBoolean(R.bool.prefBackgroundImageDefaultValue)); prefBackgroundImageFileName = prefs.getString("prefBackgroundImageFileName", getResources().getString(R.string.prefBackgroundImageFileNameDefaultValue)); prefBackgroundImagePosition = prefs.getString("prefBackgroundImagePosition", getResources().getString(R.string.prefBackgroundImagePositionDefaultValue)); prefHideSlider = prefs.getBoolean("hide_slider_preference", getResources().getBoolean(R.bool.prefHideSliderDefaultValue)); prefLimitSpeedButton = prefs.getBoolean("prefLimitSpeedButton", getResources().getBoolean(R.bool.prefLimitSpeedButtonDefaultValue)); prefLimitSpeedPercent = Integer.parseInt(prefs.getString("prefLimitSpeedPercent", getResources().getString(R.string.prefLimitSpeedPercentDefaultValue))); speedStepPref = mainapp.getIntPrefValue(prefs, "DisplaySpeedUnits", getApplicationContext().getResources().getString(R.string.prefDisplaySpeedUnitsDefaultValue)); prefPauseSpeedButton = prefs.getBoolean("prefPauseSpeedButton", getResources().getBoolean(R.bool.prefPauseSpeedButtonDefaultValue)); prefPauseSpeedRate = Integer.parseInt(prefs.getString("prefPauseSpeedRate", getResources().getString(R.string.prefPauseSpeedRateDefaultValue))); prefPauseSpeedStep = Integer.parseInt(prefs.getString("prefPauseSpeedStep", getResources().getString(R.string.prefPauseSpeedStepDefaultValue))); mainapp.prefHapticFeedback = prefs.getString("prefHapticFeedback", getResources().getString(R.string.prefHapticFeedbackDefaultValue)); mainapp.prefHapticFeedbackDuration = Integer.parseInt(prefs.getString("prefHapticFeedbackDuration", getResources().getString(R.string.prefHapticFeedbackDurationDefaultValue))); mainapp.prefHapticFeedbackButtons = prefs.getBoolean("prefHapticFeedbackButtons", getResources().getBoolean(R.bool.prefHapticFeedbackButtonsDefaultValue)); mainapp.sendMsg(mainapp.comm_msg_handler, message_type.CLOCK_DISPLAY_CHANGED); if (false) { prefs.edit().putString("prefKidsTimer", PREF_KIDS_TIMER_NONE).commit(); } getKidsTimerPrefs(); mainapp.prefFullScreenSwipeArea = prefs.getBoolean("prefFullScreenSwipeArea", getResources().getBoolean(R.bool.prefFullScreenSwipeAreaDefaultValue)); mainapp.prefThrottleViewImmersiveModeHideToolbar = prefs.getBoolean("prefThrottleViewImmersiveModeHideToolbar", getResources().getBoolean(R.bool.prefThrottleViewImmersiveModeHideToolbarDefaultValue)); mainapp.prefActionBarShowServerDescription = prefs.getBoolean("prefActionBarShowServerDescription", getResources().getBoolean(R.bool.prefActionBarShowServerDescriptionDefaultValue)); mainapp.prefDeviceSoundsButton = prefs.getBoolean("prefDeviceSoundsButton", getResources().getBoolean(R.bool.prefDeviceSoundsButtonDefaultValue)); mainapp.prefDeviceSounds[0] = prefs.getString("prefDeviceSounds0", getResources().getString(R.string.prefDeviceSoundsDefaultValue)); mainapp.prefDeviceSounds[1] = prefs.getString("prefDeviceSounds1", getResources().getString(R.string.prefDeviceSoundsDefaultValue)); mainapp.prefDeviceSoundsMomentum = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsMomentum", getResources().getString(R.string.prefDeviceSoundsMomentumDefaultValue)))); mainapp.prefDeviceSoundsMomentumOverride = prefs.getBoolean("prefDeviceSoundsMomentumOverride", getResources().getBoolean(R.bool.prefDeviceSoundsMomentumOverrideDefaultValue)); mainapp.prefDeviceSoundsLocoVolume = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsLocoVolume", "100"))); mainapp.prefDeviceSoundsBellVolume = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsBellVolume", "100"))); mainapp.prefDeviceSoundsHornVolume = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsHornVolume", "100"))); mainapp.prefDeviceSoundsLocoVolume = mainapp.prefDeviceSoundsLocoVolume / 100; mainapp.prefDeviceSoundsBellVolume = mainapp.prefDeviceSoundsBellVolume / 100; mainapp.prefDeviceSoundsHornVolume = mainapp.prefDeviceSoundsHornVolume / 100; mainapp.prefDeviceSoundsBellIsMomentary = prefs.getBoolean("prefDeviceSoundsBellIsMomentary", getResources().getBoolean(R.bool.prefDeviceSoundsBellIsMomentaryDefaultValue)); mainapp.prefDeviceSoundsF1F2ActivateBellHorn = prefs.getBoolean("prefDeviceSoundsF1F2ActivateBellHorn", getResources().getBoolean(R.bool.prefDeviceSoundsF1F2ActivateBellHornDefaultValue)); if ((!mainapp.prefDeviceSounds[0].equals("none")) || (!mainapp.prefDeviceSounds[1].equals("none"))) { loadSounds(); } else { mainapp.stopAllSounds(); } mainapp.prefActionBarShowDccExButton = prefs.getBoolean("prefActionBarShowDccExButton", getResources().getBoolean(R.bool.prefActionBarShowDccExButtonDefaultValue)); DIRECTION_BUTTON_LEFT_TEXT = getApplicationContext().getResources().getString(R.string.forward); DIRECTION_BUTTON_RIGHT_TEXT = getApplicationContext().getResources().getString(R.string.reverse); speedButtonLeftText = getApplicationContext().getResources().getString(R.string.LeftButton); speedButtonRightText = getApplicationContext().getResources().getString(R.string.RightButton); speedButtonUpText = getApplicationContext().getResources().getString(R.string.UpButton); speedButtonDownText = getApplicationContext().getResources().getString(R.string.DownButton); prefSwapForwardReverseButtons = prefs.getBoolean("prefSwapForwardReverseButtons", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsDefaultValue)); prefSwapForwardReverseButtonsLongPress = prefs.getBoolean("prefSwapForwardReverseButtonsLongPress", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsLongPressDefaultValue)); prefLeftDirectionButtons = prefs.getString("prefLeftDirectionButtons", getApplicationContext().getResources().getString(R.string.prefLeftDirectionButtonsDefaultValue)).trim(); prefRightDirectionButtons = prefs.getString("prefRightDirectionButtons", getApplicationContext().getResources().getString(R.string.prefRightDirectionButtonsDefaultValue)).trim(); prefGamepadSwapForwardReverseWithScreenButtons = prefs.getBoolean("prefGamepadSwapForwardReverseWithScreenButtons", getResources().getBoolean(R.bool.prefGamepadSwapForwardReverseWithScreenButtonsDefaultValue)); if (mainapp.numThrottles > mainapp.maxThrottlesCurrentScreen) { mainapp.numThrottles = mainapp.maxThrottlesCurrentScreen; } for (int throttleIndex = 0; throttleIndex < mainapp.numThrottles; throttleIndex++) { if (throttleIndex < bSels.length) { if ((prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_NONE)) || (prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_GAMEPAD))) { bSels[throttleIndex].setActivated(false); } if ((prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_NONE)) || (prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_VOLUME))) { bSels[throttleIndex].setHovered(false); } } } DIRECTION_BUTTON_LEFT_TEXT = getApplicationContext().getResources().getString(R.string.forward); DIRECTION_BUTTON_RIGHT_TEXT = getApplicationContext().getResources().getString(R.string.reverse); speedButtonLeftText = getApplicationContext().getResources().getString(R.string.LeftButton); speedButtonRightText = getApplicationContext().getResources().getString(R.string.RightButton); speedButtonUpText = getApplicationContext().getResources().getString(R.string.UpButton); speedButtonDownText = getApplicationContext().getResources().getString(R.string.DownButton); prefSwapForwardReverseButtons = prefs.getBoolean("prefSwapForwardReverseButtons", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsDefaultValue)); prefSwapForwardReverseButtonsLongPress = prefs.getBoolean("prefSwapForwardReverseButtonsLongPress", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsLongPressDefaultValue)); prefLeftDirectionButtons = prefs.getString("prefLeftDirectionButtons", getApplicationContext().getResources().getString(R.string.prefLeftDirectionButtonsDefaultValue)).trim(); prefRightDirectionButtons = prefs.getString("prefRightDirectionButtons", getApplicationContext().getResources().getString(R.string.prefRightDirectionButtonsDefaultValue)).trim(); prefGamepadSwapForwardReverseWithScreenButtons = prefs.getBoolean("prefGamepadSwapForwardReverseWithScreenButtons", getResources().getBoolean(R.bool.prefGamepadSwapForwardReverseWithScreenButtonsDefaultValue)); String dirLeftText; String dirRightText; for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { FullLeftText[throttleIndex] = DIRECTION_BUTTON_LEFT_TEXT; FullRightText[throttleIndex] = DIRECTION_BUTTON_RIGHT_TEXT; dirLeftIndicationText[throttleIndex] = ""; dirRightIndicationText[throttleIndex] = ""; } if (((prefLeftDirectionButtons.equals(DIRECTION_BUTTON_LEFT_TEXT)) && (prefRightDirectionButtons.equals(DIRECTION_BUTTON_RIGHT_TEXT))) || ((prefLeftDirectionButtons.equals("")) && (prefRightDirectionButtons.equals(""))) || ((prefLeftDirectionButtons.equals(DIRECTION_BUTTON_LEFT_TEXT)) && (prefRightDirectionButtons.equals(""))) || ((prefRightDirectionButtons.equals(DIRECTION_BUTTON_RIGHT_TEXT))) && ((prefLeftDirectionButtons.equals("")))) { for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { if (directionButtonsAreCurrentlyReversed(throttleIndex)) { FullLeftText[throttleIndex] = DIRECTION_BUTTON_RIGHT_TEXT; FullRightText[throttleIndex] = DIRECTION_BUTTON_LEFT_TEXT; } } } else { dirLeftText = prefLeftDirectionButtons; dirRightText = prefRightDirectionButtons; for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { if (!directionButtonsAreCurrentlyReversed(throttleIndex)) { FullLeftText[throttleIndex] = dirLeftText; dirLeftIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_left_extra); FullRightText[throttleIndex] = dirRightText; dirRightIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_right_extra); } else { FullLeftText[throttleIndex] = dirLeftText; dirLeftIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_right_extra); FullRightText[throttleIndex] = dirRightText; dirRightIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_left_extra); } } } for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { bFwds[throttleIndex].setText(FullLeftText[throttleIndex]); bRevs[throttleIndex].setText(FullRightText[throttleIndex]); tvLeftDirInds[throttleIndex].setText(dirLeftIndicationText[throttleIndex]); tvRightDirInds[throttleIndex].setText(dirRightIndicationText[throttleIndex]); } mainapp.prefGamePadType = prefs.getString("prefGamePadType", getApplicationContext().getResources().getString(R.string.prefGamePadTypeDefaultValue)); prefGamePadButtons[0] = prefs.getString("prefGamePadButtonStart", getApplicationContext().getResources().getString(R.string.prefGamePadButtonStartDefaultValue)); prefGamePadButtons[9] = prefs.getString("prefGamePadButtonReturn", getApplicationContext().getResources().getString(R.string.prefGamePadButtonReturnDefaultValue)); prefGamePadButtons[1] = prefs.getString("prefGamePadButton1", getApplicationContext().getResources().getString(R.string.prefGamePadButton1DefaultValue)); prefGamePadButtons[2] = prefs.getString("prefGamePadButton2", getApplicationContext().getResources().getString(R.string.prefGamePadButton2DefaultValue)); prefGamePadButtons[3] = prefs.getString("prefGamePadButton3", getApplicationContext().getResources().getString(R.string.prefGamePadButton3DefaultValue)); prefGamePadButtons[4] = prefs.getString("prefGamePadButton4", getApplicationContext().getResources().getString(R.string.prefGamePadButton4DefaultValue)); prefGamePadButtons[5] = prefs.getString("prefGamePadButtonUp", getApplicationContext().getResources().getString(R.string.prefGamePadButtonUpDefaultValue)); prefGamePadButtons[6] = prefs.getString("prefGamePadButtonRight", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightDefaultValue)); prefGamePadButtons[7] = prefs.getString("prefGamePadButtonDown", getApplicationContext().getResources().getString(R.string.prefGamePadButtonDownDefaultValue)); prefGamePadButtons[8] = prefs.getString("prefGamePadButtonLeft", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftDefaultValue)); prefGamePadButtons[10] = prefs.getString("prefGamePadButtonLeftShoulder", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftTriggerDefaultValue)); prefGamePadButtons[11] = prefs.getString("prefGamePadButtonRightShoulder", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightShoulderDefaultValue)); prefGamePadButtons[12] = prefs.getString("prefGamePadButtonLeftTrigger", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftTriggerDefaultValue)); prefGamePadButtons[13] = prefs.getString("prefGamePadButtonRightTrigger", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightTriggerDefaultValue)); prefGamePadButtons[14] = prefs.getString("prefGamePadButtonLeftThumb", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftThumbDefaultValue)); prefGamePadButtons[15] = prefs.getString("prefGamePadButtonRightThumb", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightThumbDefaultValue)); if (!mainapp.prefGamePadType.equals(threaded_application.WHICH_GAMEPAD_MODE_NONE)) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); } int[] bGamePadKeys; int[] bGamePadKeysUp; switch(mainapp.prefGamePadType) { case "iCade+DPAD": case "iCade+DPAD-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadiCadePlusDpad); bGamePadKeysUp = this.getResources().getIntArray(R.array.prefGamePadiCadePlusDpad_UpCodes); break; case "MTK": case "MTK-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMTK); bGamePadKeysUp = bGamePadKeys; break; case "Game": case "Game-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGame); bGamePadKeysUp = bGamePadKeys; break; case "Game-alternate-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGameAlternate); bGamePadKeysUp = bGamePadKeys; break; case "MagicseeR1B": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMagicseeR1B); bGamePadKeysUp = bGamePadKeys; break; case "MagicseeR1A": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMagicseeR1A); bGamePadKeysUp = bGamePadKeys; break; case "MagicseeR1C": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMagicseeR1C); bGamePadKeysUp = bGamePadKeys; break; case "FlydigiWee2": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadFlydigiWee2); bGamePadKeysUp = bGamePadKeys; break; case "UtopiaC": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadUtopiaC); bGamePadKeysUp = bGamePadKeys; break; case "Generic": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGeneric); bGamePadKeysUp = bGamePadKeys; break; case "Generic3x4": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGeneric3x4); bGamePadKeysUp = bGamePadKeys; break; case "Keyboard": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadNoneLabels); bGamePadKeysUp = bGamePadKeys; break; case "Volume": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadVolume); bGamePadKeysUp = bGamePadKeys; break; default: bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadiCade); bGamePadKeysUp = this.getResources().getIntArray(R.array.prefGamePadiCade_UpCodes); break; } for (int i = 0; i < GAMEPAD_KEYS_LENGTH; i++) { gamePadKeys[i] = bGamePadKeys[i]; gamePadKeys_Up[i] = bGamePadKeysUp[i]; } if (mainapp.prefGamePadType.contains("-rotate")) { gamePadKeys[2] = bGamePadKeys[4]; gamePadKeys[3] = bGamePadKeys[5]; gamePadKeys[4] = bGamePadKeys[3]; gamePadKeys[5] = bGamePadKeys[2]; gamePadKeys_Up[2] = bGamePadKeysUp[4]; gamePadKeys_Up[3] = bGamePadKeysUp[5]; gamePadKeys_Up[4] = bGamePadKeysUp[3]; gamePadKeys_Up[5] = bGamePadKeysUp[2]; } for (int throttleIndex = 0; throttleIndex < mainapp.numThrottles; throttleIndex++) { applySpeedRelatedOptions(throttleIndex); } if (mainapp.appIsFinishing) { return; } if (tvVols[0] == null) return; setVolumeIndicator(); setGamepadIndicator(); int maxThrottle = mainapp.getIntPrefValue(prefs, "maximum_throttle_preference", getApplicationContext().getResources().getString(R.string.prefMaximumThrottleDefaultValue)); maxThrottle = (int) Math.round(MAX_SPEED_VAL_WIT * (maxThrottle * .01)); for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { sbs[throttleIndex].setMax(maxThrottle); } int maxChange = mainapp.getIntPrefValue(prefs, "maximum_throttle_change_preference", getApplicationContext().getResources().getString(R.string.prefMaximumThrottleChangeDefaultValue)); max_throttle_change = (int) Math.round(maxThrottle * (maxChange * .01)); for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { sbs[throttleIndex].setMax(maxThrottle); if (mainapp.consists != null && mainapp.consists[throttleIndex] != null && mainapp.consists[throttleIndex].isEmpty()) { maxSpeedSteps[throttleIndex] = 100; limitSpeedMax[throttleIndex] = Math.round(100 * ((float) prefLimitSpeedPercent) / 100); } speedStepPref = mainapp.getIntPrefValue(prefs, "DisplaySpeedUnits", getApplicationContext().getResources().getString(R.string.prefDisplaySpeedUnitsDefaultValue)); setDisplayUnitScale(throttleIndex); setDisplayedSpeed(throttleIndex, sbs[throttleIndex].getProgress()); } refreshMenu(); vThrotScrWrap.invalidate(); if (webViewIsOn) { this.resumeWebView(); } else { this.pauseWebView(); } if (mainapp.EStopActivated) { speedUpdateAndNotify(0); applySpeedRelatedOptions(); mainapp.EStopActivated = false; } if (IS_ESU_MCII && isEsuMc2Stopped) { if (isEsuMc2AllStopped) { for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { setEnabledEsuMc2ThrottleScreenButtons(throttleIndex, false); } } else { setEnabledEsuMc2ThrottleScreenButtons(whichVolume, false); } } for (int throttleIndex = 0; throttleIndex < mainapp.numThrottles; throttleIndex++) { showDirectionIndication(throttleIndex, dirs[throttleIndex]); } if (mainapp.consists == null) { Log.d("Engine_Driver", "showHideConsistMenu consists[] is null"); return; } if (TMenu != null) { boolean anyConsist = false; for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { Consist con = mainapp.consists[throttleIndex]; if (con == null) { Log.d("Engine_Driver", "showHideConsistMenu consists[" + throttleIndex + "] is null"); break; } boolean isMulti = con.isMulti(); switch(throttleIndex) { case 0: anyConsist |= isMulti; TMenu.findItem(R.id.EditConsist0_menu).setVisible(isMulti); TMenu.findItem(R.id.EditLightsConsist0_menu).setVisible(isMulti); break; case 1: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist1_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist1_menu).setVisible(isMulti); break; case 2: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist2_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist2_menu).setVisible(isMulti); break; case 3: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist3_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist3_menu).setVisible(isMulti); break; case 4: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist4_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist4_menu).setVisible(isMulti); break; case 5: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist5_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist5_menu).setVisible(isMulti); break; } } TMenu.findItem(R.id.edit_consists_menu).setVisible(anyConsist); boolean isSpecial = false; if ((mainapp.prefAlwaysUseDefaultFunctionLabels) && ((mainapp.prefConsistFollowRuleStyle.equals(CONSIST_FUNCTION_RULE_STYLE_SPECIAL_EXACT)) || (mainapp.prefConsistFollowRuleStyle.equals(CONSIST_FUNCTION_RULE_STYLE_SPECIAL_PARTIAL)))) { isSpecial = true; } TMenu.findItem(R.id.function_consist_settings_mnu).setVisible(isSpecial); } CookieSyncManager.getInstance().startSync(); if (!prefAccelerometerShake.equals(ACCELERATOROMETER_SHAKE_NONE)) { if (!accelerometerCurrent) { setupSensor(); } else { sensorManager.registerListener(shakeDetector, accelerometer, SensorManager.SENSOR_DELAY_UI); } } if (((prefKidsTime > 0) && (kidsTimerRunning != threaded_application.KIDS_TIMER_RUNNNING))) { mainapp.sendMsg(mainapp.comm_msg_handler, message_type.KIDS_TIMER_ENABLE, "", 0, 0); } else { if (kidsTimerRunning == threaded_application.KIDS_TIMER_ENDED) { mainapp.sendMsg(mainapp.comm_msg_handler, message_type.KIDS_TIMER_END, "", 0, 0); } if (prefKidsTimer.equals(PREF_KIDS_TIMER_NONE)) { kidsTimerActions(threaded_application.KIDS_TIMER_DISABLED, 1); } } if (!prefTtsWhen.equals(getApplicationContext().getResources().getString(R.string.prefTtsWhenDefaultValue))) { if (myTts == null) { lastTtsTime = new Time(); lastTtsTime.setToNow(); myTts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status != TextToSpeech.ERROR) { myTts.setLanguage(Locale.getDefault()); } else { Toast.makeText(getApplicationContext(), getApplicationContext().getResources().getString(R.string.toastTtsFailed), Toast.LENGTH_SHORT).show(); } } }); } } if (mainapp.getFastClockFormat() > 0) mainapp.setToolbarTitle(toolbar, "", getApplicationContext().getResources().getString(R.string.app_name_throttle_short), mainapp.getFastClockTime()); else mainapp.setToolbarTitle(toolbar, getApplicationContext().getResources().getString(R.string.app_name), getApplicationContext().getResources().getString(R.string.app_name_throttle), ""); if (prefs.getBoolean("prefForcedRestart", false)) { prefs.edit().putBoolean("prefForcedRestart", false).commit(); int prefForcedRestartReason = prefs.getInt("prefForcedRestartReason", threaded_application.FORCED_RESTART_REASON_NONE); Log.d("Engine_Driver", "connection: Forced Restart Reason: " + prefForcedRestartReason); if (mainapp.prefsForcedRestart(prefForcedRestartReason)) { Intent in = new Intent().setClass(this, SettingsActivity.class); startActivityForResult(in, 0); connection_activity.overridePendingTransition(this, R.anim.fade_in, R.anim.fade_out); } } }
<DeepExtract> if (false) { webViewLocation = prefs.getString("WebViewLocation", getApplicationContext().getResources().getString(R.string.prefWebViewLocationDefaultValue)); } prefDirectionButtonLongPressDelay = mainapp.getIntPrefValue(prefs, "prefDirectionButtonLongPressDelay", getApplicationContext().getResources().getString(R.string.prefDirectionButtonLongPressDelayDefaultValue)); FUNCTION_BUTTON_LOOK_FOR_WHISTLE = getApplicationContext().getResources().getString(R.string.functionButtonLookForWhistle).trim(); FUNCTION_BUTTON_LOOK_FOR_HORN = getApplicationContext().getResources().getString(R.string.functionButtonLookForHorn).trim(); FUNCTION_BUTTON_LOOK_FOR_BELL = getApplicationContext().getResources().getString(R.string.functionButtonLookForBell).trim(); FUNCTION_BUTTON_LOOK_FOR_HEAD = getApplicationContext().getResources().getString(R.string.functionButtonLookForHead).trim(); FUNCTION_BUTTON_LOOK_FOR_LIGHT = getApplicationContext().getResources().getString(R.string.functionButtonLookForLight).trim(); FUNCTION_BUTTON_LOOK_FOR_REAR = getApplicationContext().getResources().getString(R.string.functionButtonLookForRear).trim(); prefConsistFollowDefaultAction = prefs.getString("prefConsistFollowDefaultAction", getApplicationContext().getResources().getString(R.string.prefConsistFollowDefaultActionDefaultValue)); prefConsistFollowStrings = new ArrayList<>(); prefConsistFollowActions = new ArrayList<>(); prefConsistFollowHeadlights = new ArrayList<>(); mainapp.prefConsistFollowRuleStyle = prefs.getString("prefConsistFollowRuleStyle", getApplicationContext().getResources().getString(R.string.prefConsistFollowRuleStyleDefaultValue)); String prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString1", getApplicationContext().getResources().getString(R.string.prefConsistFollowString1DefaultValue)); String prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction1", getApplicationContext().getResources().getString(R.string.prefConsistFollowString1DefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString2", getApplicationContext().getResources().getString(R.string.prefConsistFollowString2DefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction2", getApplicationContext().getResources().getString(R.string.prefConsistFollowString2DefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString3", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction3", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString4", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction4", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); prefConsistFollowStringtemp = prefs.getString("prefConsistFollowString5", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); prefConsistFollowActiontemp = prefs.getString("prefConsistFollowAction5", getApplicationContext().getResources().getString(R.string.prefConsistFollowStringOtherDefaultValue)); addConsistFollowRule(prefConsistFollowStringtemp, prefConsistFollowActiontemp, CONSIST_FUNCTION_IS_NOT_HEADLIGHT); pref_increase_slider_height_preference = prefs.getBoolean("increase_slider_height_preference", getResources().getBoolean(R.bool.prefIncreaseSliderHeightDefaultValue)); prefDecreaseLocoNumberHeight = prefs.getBoolean("prefDecreaseLocoNumberHeight", getResources().getBoolean(R.bool.prefDecreaseLocoNumberHeightDefaultValue)); prefIncreaseWebViewSize = prefs.getBoolean("prefIncreaseWebViewSize", getResources().getBoolean(R.bool.prefIncreaseWebViewSizeDefaultValue)); prefThrottleViewImmersiveMode = prefs.getBoolean("prefThrottleViewImmersiveMode", getResources().getBoolean(R.bool.prefThrottleViewImmersiveModeDefaultValue)); prefThrottleViewImmersiveModeHideToolbar = prefs.getBoolean("prefThrottleViewImmersiveModeHideToolbar", getResources().getBoolean(R.bool.prefThrottleViewImmersiveModeHideToolbarDefaultValue)); prefShowAddressInsteadOfName = prefs.getBoolean("prefShowAddressInsteadOfName", getResources().getBoolean(R.bool.prefShowAddressInsteadOfNameDefaultValue)); prefSwipeDownOption = prefs.getString("SwipeDownOption", getApplicationContext().getResources().getString(R.string.prefSwipeUpOptionDefaultValue)); prefSwipeUpOption = prefs.getString("SwipeUpOption", getApplicationContext().getResources().getString(R.string.prefSwipeUpOptionDefaultValue)); isScreenLocked = false; dirChangeWhileMoving = prefs.getBoolean("DirChangeWhileMovingPreference", getResources().getBoolean(R.bool.prefDirChangeWhileMovingDefaultValue)); stopOnDirectionChange = prefs.getBoolean("prefStopOnDirectionChange", getResources().getBoolean(R.bool.prefStopOnDirectionChangeDefaultValue)); locoSelectWhileMoving = prefs.getBoolean("SelLocoWhileMovingPreference", getResources().getBoolean(R.bool.prefSelLocoWhileMovingDefaultValue)); screenBrightnessDim = Integer.parseInt(prefs.getString("prefScreenBrightnessDim", getResources().getString(R.string.prefScreenBrightnessDimDefaultValue))) * 255 / 100; prefConsistLightsLongClick = prefs.getBoolean("ConsistLightsLongClickPreference", getResources().getBoolean(R.bool.prefConsistLightsLongClickDefaultValue)); prefGamepadTestEnforceTesting = prefs.getBoolean("prefGamepadTestEnforceTesting", getResources().getBoolean(R.bool.prefGamepadTestEnforceTestingDefaultValue)); prefDisableVolumeKeys = prefs.getBoolean("prefDisableVolumeKeys", getResources().getBoolean(R.bool.prefDisableVolumeKeysDefaultValue)); prefSelectedLocoIndicator = prefs.getString("prefSelectedLocoIndicator", getResources().getString(R.string.prefSelectedLocoIndicatorDefaultValue)); prefVolumeKeysFollowLastTouchedThrottle = prefs.getBoolean("prefVolumeKeysFollowLastTouchedThrottle", getResources().getBoolean(R.bool.prefVolumeKeysFollowLastTouchedThrottleDefaultValue)); mainapp.prefAlwaysUseDefaultFunctionLabels = prefs.getBoolean("prefAlwaysUseDefaultFunctionLabels", getResources().getBoolean(R.bool.prefAlwaysUseDefaultFunctionLabelsDefaultValue)); prefNumberOfDefaultFunctionLabels = Integer.parseInt(prefs.getString("prefNumberOfDefaultFunctionLabels", getResources().getString(R.string.prefNumberOfDefaultFunctionLabelsDefaultValue))); prefAccelerometerShake = prefs.getString("prefAccelerometerShake", getApplicationContext().getResources().getString(R.string.prefAccelerometerShakeDefaultValue)); prefSpeedButtonsSpeedStep = mainapp.getIntPrefValue(prefs, "speed_arrows_throttle_speed_step", "4"); prefVolumeSpeedButtonsSpeedStep = mainapp.getIntPrefValue(prefs, "prefVolumeSpeedButtonsSpeedStep", getApplicationContext().getResources().getString(R.string.prefVolumeSpeedButtonsSpeedStepDefaultValue)); prefGamePadSpeedButtonsSpeedStep = mainapp.getIntPrefValue(prefs, "prefGamePadSpeedButtonsSpeedStep", getApplicationContext().getResources().getString(R.string.prefVolumeSpeedButtonsSpeedStepDefaultValue)); prefSpeedButtonsSpeedStepDecrement = prefs.getBoolean("prefSpeedButtonsSpeedStepDecrement", getResources().getBoolean(R.bool.prefSpeedButtonsSpeedStepDecrementDefaultValue)); prefTtsWhen = prefs.getString("prefTtsWhen", getResources().getString(R.string.prefTtsWhenDefaultValue)); prefTtsThrottleResponse = prefs.getString("prefTtsThrottleResponse", getResources().getString(R.string.prefTtsThrottleResponseDefaultValue)); prefTtsThrottleSpeed = prefs.getString("prefTtsThrottleSpeed", getResources().getString(R.string.prefTtsThrottleSpeedDefaultValue)); prefTtsGamepadTest = prefs.getBoolean("prefTtsGamepadTest", getResources().getBoolean(R.bool.prefTtsGamepadTestDefaultValue)); prefTtsGamepadTestComplete = prefs.getBoolean("prefTtsGamepadTestComplete", getResources().getBoolean(R.bool.prefTtsGamepadTestCompleteDefaultValue)); prefTtsGamepadTestKeys = prefs.getBoolean("prefTtsGamepadTestKeys", getResources().getBoolean(R.bool.prefTtsGamepadTestKeysDefaultValue)); mainapp.prefGamepadOnlyOneGamepad = prefs.getBoolean("prefGamepadOnlyOneGamepad", getResources().getBoolean(R.bool.prefGamepadOnlyOneGamepadDefaultValue)); prefGamePadDoublePressStop = prefs.getString("prefGamePadDoublePressStop", getResources().getString(R.string.prefTtsThrottleResponseDefaultValue)); mainapp.prefGamePadIgnoreJoystick = prefs.getBoolean("prefGamePadIgnoreJoystick", getResources().getBoolean(R.bool.prefGamePadIgnoreJoystickDefaultValue)); prefEsuMc2EndStopDirectionChange = prefs.getBoolean("prefEsuMc2EndStopDirectionChange", getResources().getBoolean(R.bool.prefEsuMc2EndStopDirectionChangeDefaultValue)); prefEsuMc2StopButtonShortPress = prefs.getBoolean("prefEsuMc2StopButtonShortPress", getResources().getBoolean(R.bool.prefEsuMc2StopButtonShortPressDefaultValue)); mainapp.numThrottles = mainapp.Numeralise(prefs.getString("NumThrottle", getResources().getString(R.string.NumThrottleDefaulValue))); prefThrottleScreenType = prefs.getString("prefThrottleScreenType", getApplicationContext().getResources().getString(R.string.prefThrottleScreenTypeDefault)); prefSelectiveLeadSound = prefs.getBoolean("SelectiveLeadSound", getResources().getBoolean(R.bool.prefSelectiveLeadSoundDefaultValue)); prefSelectiveLeadSoundF1 = prefs.getBoolean("SelectiveLeadSoundF1", getResources().getBoolean(R.bool.prefSelectiveLeadSoundF1DefaultValue)); prefSelectiveLeadSoundF2 = prefs.getBoolean("SelectiveLeadSoundF2", getResources().getBoolean(R.bool.prefSelectiveLeadSoundF2DefaultValue)); prefBackgroundImage = prefs.getBoolean("prefBackgroundImage", getResources().getBoolean(R.bool.prefBackgroundImageDefaultValue)); prefBackgroundImageFileName = prefs.getString("prefBackgroundImageFileName", getResources().getString(R.string.prefBackgroundImageFileNameDefaultValue)); prefBackgroundImagePosition = prefs.getString("prefBackgroundImagePosition", getResources().getString(R.string.prefBackgroundImagePositionDefaultValue)); prefHideSlider = prefs.getBoolean("hide_slider_preference", getResources().getBoolean(R.bool.prefHideSliderDefaultValue)); prefLimitSpeedButton = prefs.getBoolean("prefLimitSpeedButton", getResources().getBoolean(R.bool.prefLimitSpeedButtonDefaultValue)); prefLimitSpeedPercent = Integer.parseInt(prefs.getString("prefLimitSpeedPercent", getResources().getString(R.string.prefLimitSpeedPercentDefaultValue))); speedStepPref = mainapp.getIntPrefValue(prefs, "DisplaySpeedUnits", getApplicationContext().getResources().getString(R.string.prefDisplaySpeedUnitsDefaultValue)); prefPauseSpeedButton = prefs.getBoolean("prefPauseSpeedButton", getResources().getBoolean(R.bool.prefPauseSpeedButtonDefaultValue)); prefPauseSpeedRate = Integer.parseInt(prefs.getString("prefPauseSpeedRate", getResources().getString(R.string.prefPauseSpeedRateDefaultValue))); prefPauseSpeedStep = Integer.parseInt(prefs.getString("prefPauseSpeedStep", getResources().getString(R.string.prefPauseSpeedStepDefaultValue))); mainapp.prefHapticFeedback = prefs.getString("prefHapticFeedback", getResources().getString(R.string.prefHapticFeedbackDefaultValue)); mainapp.prefHapticFeedbackDuration = Integer.parseInt(prefs.getString("prefHapticFeedbackDuration", getResources().getString(R.string.prefHapticFeedbackDurationDefaultValue))); mainapp.prefHapticFeedbackButtons = prefs.getBoolean("prefHapticFeedbackButtons", getResources().getBoolean(R.bool.prefHapticFeedbackButtonsDefaultValue)); mainapp.sendMsg(mainapp.comm_msg_handler, message_type.CLOCK_DISPLAY_CHANGED); if (false) { prefs.edit().putString("prefKidsTimer", PREF_KIDS_TIMER_NONE).commit(); } getKidsTimerPrefs(); mainapp.prefFullScreenSwipeArea = prefs.getBoolean("prefFullScreenSwipeArea", getResources().getBoolean(R.bool.prefFullScreenSwipeAreaDefaultValue)); mainapp.prefThrottleViewImmersiveModeHideToolbar = prefs.getBoolean("prefThrottleViewImmersiveModeHideToolbar", getResources().getBoolean(R.bool.prefThrottleViewImmersiveModeHideToolbarDefaultValue)); mainapp.prefActionBarShowServerDescription = prefs.getBoolean("prefActionBarShowServerDescription", getResources().getBoolean(R.bool.prefActionBarShowServerDescriptionDefaultValue)); mainapp.prefDeviceSoundsButton = prefs.getBoolean("prefDeviceSoundsButton", getResources().getBoolean(R.bool.prefDeviceSoundsButtonDefaultValue)); mainapp.prefDeviceSounds[0] = prefs.getString("prefDeviceSounds0", getResources().getString(R.string.prefDeviceSoundsDefaultValue)); mainapp.prefDeviceSounds[1] = prefs.getString("prefDeviceSounds1", getResources().getString(R.string.prefDeviceSoundsDefaultValue)); mainapp.prefDeviceSoundsMomentum = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsMomentum", getResources().getString(R.string.prefDeviceSoundsMomentumDefaultValue)))); mainapp.prefDeviceSoundsMomentumOverride = prefs.getBoolean("prefDeviceSoundsMomentumOverride", getResources().getBoolean(R.bool.prefDeviceSoundsMomentumOverrideDefaultValue)); mainapp.prefDeviceSoundsLocoVolume = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsLocoVolume", "100"))); mainapp.prefDeviceSoundsBellVolume = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsBellVolume", "100"))); mainapp.prefDeviceSoundsHornVolume = Integer.parseInt(Objects.requireNonNull(prefs.getString("prefDeviceSoundsHornVolume", "100"))); mainapp.prefDeviceSoundsLocoVolume = mainapp.prefDeviceSoundsLocoVolume / 100; mainapp.prefDeviceSoundsBellVolume = mainapp.prefDeviceSoundsBellVolume / 100; mainapp.prefDeviceSoundsHornVolume = mainapp.prefDeviceSoundsHornVolume / 100; mainapp.prefDeviceSoundsBellIsMomentary = prefs.getBoolean("prefDeviceSoundsBellIsMomentary", getResources().getBoolean(R.bool.prefDeviceSoundsBellIsMomentaryDefaultValue)); mainapp.prefDeviceSoundsF1F2ActivateBellHorn = prefs.getBoolean("prefDeviceSoundsF1F2ActivateBellHorn", getResources().getBoolean(R.bool.prefDeviceSoundsF1F2ActivateBellHornDefaultValue)); if ((!mainapp.prefDeviceSounds[0].equals("none")) || (!mainapp.prefDeviceSounds[1].equals("none"))) { loadSounds(); } else { mainapp.stopAllSounds(); } mainapp.prefActionBarShowDccExButton = prefs.getBoolean("prefActionBarShowDccExButton", getResources().getBoolean(R.bool.prefActionBarShowDccExButtonDefaultValue)); </DeepExtract> <DeepExtract> DIRECTION_BUTTON_LEFT_TEXT = getApplicationContext().getResources().getString(R.string.forward); DIRECTION_BUTTON_RIGHT_TEXT = getApplicationContext().getResources().getString(R.string.reverse); speedButtonLeftText = getApplicationContext().getResources().getString(R.string.LeftButton); speedButtonRightText = getApplicationContext().getResources().getString(R.string.RightButton); speedButtonUpText = getApplicationContext().getResources().getString(R.string.UpButton); speedButtonDownText = getApplicationContext().getResources().getString(R.string.DownButton); prefSwapForwardReverseButtons = prefs.getBoolean("prefSwapForwardReverseButtons", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsDefaultValue)); prefSwapForwardReverseButtonsLongPress = prefs.getBoolean("prefSwapForwardReverseButtonsLongPress", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsLongPressDefaultValue)); prefLeftDirectionButtons = prefs.getString("prefLeftDirectionButtons", getApplicationContext().getResources().getString(R.string.prefLeftDirectionButtonsDefaultValue)).trim(); prefRightDirectionButtons = prefs.getString("prefRightDirectionButtons", getApplicationContext().getResources().getString(R.string.prefRightDirectionButtonsDefaultValue)).trim(); prefGamepadSwapForwardReverseWithScreenButtons = prefs.getBoolean("prefGamepadSwapForwardReverseWithScreenButtons", getResources().getBoolean(R.bool.prefGamepadSwapForwardReverseWithScreenButtonsDefaultValue)); </DeepExtract> <DeepExtract> if (mainapp.numThrottles > mainapp.maxThrottlesCurrentScreen) { mainapp.numThrottles = mainapp.maxThrottlesCurrentScreen; } </DeepExtract> <DeepExtract> for (int throttleIndex = 0; throttleIndex < mainapp.numThrottles; throttleIndex++) { if (throttleIndex < bSels.length) { if ((prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_NONE)) || (prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_GAMEPAD))) { bSels[throttleIndex].setActivated(false); } if ((prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_NONE)) || (prefSelectedLocoIndicator.equals(SELECTED_LOCO_INDICATOR_VOLUME))) { bSels[throttleIndex].setHovered(false); } } } </DeepExtract> <DeepExtract> DIRECTION_BUTTON_LEFT_TEXT = getApplicationContext().getResources().getString(R.string.forward); DIRECTION_BUTTON_RIGHT_TEXT = getApplicationContext().getResources().getString(R.string.reverse); speedButtonLeftText = getApplicationContext().getResources().getString(R.string.LeftButton); speedButtonRightText = getApplicationContext().getResources().getString(R.string.RightButton); speedButtonUpText = getApplicationContext().getResources().getString(R.string.UpButton); speedButtonDownText = getApplicationContext().getResources().getString(R.string.DownButton); prefSwapForwardReverseButtons = prefs.getBoolean("prefSwapForwardReverseButtons", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsDefaultValue)); prefSwapForwardReverseButtonsLongPress = prefs.getBoolean("prefSwapForwardReverseButtonsLongPress", getResources().getBoolean(R.bool.prefSwapForwardReverseButtonsLongPressDefaultValue)); prefLeftDirectionButtons = prefs.getString("prefLeftDirectionButtons", getApplicationContext().getResources().getString(R.string.prefLeftDirectionButtonsDefaultValue)).trim(); prefRightDirectionButtons = prefs.getString("prefRightDirectionButtons", getApplicationContext().getResources().getString(R.string.prefRightDirectionButtonsDefaultValue)).trim(); prefGamepadSwapForwardReverseWithScreenButtons = prefs.getBoolean("prefGamepadSwapForwardReverseWithScreenButtons", getResources().getBoolean(R.bool.prefGamepadSwapForwardReverseWithScreenButtonsDefaultValue)); </DeepExtract> <DeepExtract> String dirLeftText; String dirRightText; for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { FullLeftText[throttleIndex] = DIRECTION_BUTTON_LEFT_TEXT; FullRightText[throttleIndex] = DIRECTION_BUTTON_RIGHT_TEXT; dirLeftIndicationText[throttleIndex] = ""; dirRightIndicationText[throttleIndex] = ""; } if (((prefLeftDirectionButtons.equals(DIRECTION_BUTTON_LEFT_TEXT)) && (prefRightDirectionButtons.equals(DIRECTION_BUTTON_RIGHT_TEXT))) || ((prefLeftDirectionButtons.equals("")) && (prefRightDirectionButtons.equals(""))) || ((prefLeftDirectionButtons.equals(DIRECTION_BUTTON_LEFT_TEXT)) && (prefRightDirectionButtons.equals(""))) || ((prefRightDirectionButtons.equals(DIRECTION_BUTTON_RIGHT_TEXT))) && ((prefLeftDirectionButtons.equals("")))) { for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { if (directionButtonsAreCurrentlyReversed(throttleIndex)) { FullLeftText[throttleIndex] = DIRECTION_BUTTON_RIGHT_TEXT; FullRightText[throttleIndex] = DIRECTION_BUTTON_LEFT_TEXT; } } } else { dirLeftText = prefLeftDirectionButtons; dirRightText = prefRightDirectionButtons; for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { if (!directionButtonsAreCurrentlyReversed(throttleIndex)) { FullLeftText[throttleIndex] = dirLeftText; dirLeftIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_left_extra); FullRightText[throttleIndex] = dirRightText; dirRightIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_right_extra); } else { FullLeftText[throttleIndex] = dirLeftText; dirLeftIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_right_extra); FullRightText[throttleIndex] = dirRightText; dirRightIndicationText[throttleIndex] = getApplicationContext().getResources().getString(R.string.loco_direction_left_extra); } } } for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { bFwds[throttleIndex].setText(FullLeftText[throttleIndex]); bRevs[throttleIndex].setText(FullRightText[throttleIndex]); tvLeftDirInds[throttleIndex].setText(dirLeftIndicationText[throttleIndex]); tvRightDirInds[throttleIndex].setText(dirRightIndicationText[throttleIndex]); } </DeepExtract> <DeepExtract> mainapp.prefGamePadType = prefs.getString("prefGamePadType", getApplicationContext().getResources().getString(R.string.prefGamePadTypeDefaultValue)); prefGamePadButtons[0] = prefs.getString("prefGamePadButtonStart", getApplicationContext().getResources().getString(R.string.prefGamePadButtonStartDefaultValue)); prefGamePadButtons[9] = prefs.getString("prefGamePadButtonReturn", getApplicationContext().getResources().getString(R.string.prefGamePadButtonReturnDefaultValue)); prefGamePadButtons[1] = prefs.getString("prefGamePadButton1", getApplicationContext().getResources().getString(R.string.prefGamePadButton1DefaultValue)); prefGamePadButtons[2] = prefs.getString("prefGamePadButton2", getApplicationContext().getResources().getString(R.string.prefGamePadButton2DefaultValue)); prefGamePadButtons[3] = prefs.getString("prefGamePadButton3", getApplicationContext().getResources().getString(R.string.prefGamePadButton3DefaultValue)); prefGamePadButtons[4] = prefs.getString("prefGamePadButton4", getApplicationContext().getResources().getString(R.string.prefGamePadButton4DefaultValue)); prefGamePadButtons[5] = prefs.getString("prefGamePadButtonUp", getApplicationContext().getResources().getString(R.string.prefGamePadButtonUpDefaultValue)); prefGamePadButtons[6] = prefs.getString("prefGamePadButtonRight", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightDefaultValue)); prefGamePadButtons[7] = prefs.getString("prefGamePadButtonDown", getApplicationContext().getResources().getString(R.string.prefGamePadButtonDownDefaultValue)); prefGamePadButtons[8] = prefs.getString("prefGamePadButtonLeft", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftDefaultValue)); prefGamePadButtons[10] = prefs.getString("prefGamePadButtonLeftShoulder", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftTriggerDefaultValue)); prefGamePadButtons[11] = prefs.getString("prefGamePadButtonRightShoulder", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightShoulderDefaultValue)); prefGamePadButtons[12] = prefs.getString("prefGamePadButtonLeftTrigger", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftTriggerDefaultValue)); prefGamePadButtons[13] = prefs.getString("prefGamePadButtonRightTrigger", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightTriggerDefaultValue)); prefGamePadButtons[14] = prefs.getString("prefGamePadButtonLeftThumb", getApplicationContext().getResources().getString(R.string.prefGamePadButtonLeftThumbDefaultValue)); prefGamePadButtons[15] = prefs.getString("prefGamePadButtonRightThumb", getApplicationContext().getResources().getString(R.string.prefGamePadButtonRightThumbDefaultValue)); if (!mainapp.prefGamePadType.equals(threaded_application.WHICH_GAMEPAD_MODE_NONE)) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); } int[] bGamePadKeys; int[] bGamePadKeysUp; switch(mainapp.prefGamePadType) { case "iCade+DPAD": case "iCade+DPAD-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadiCadePlusDpad); bGamePadKeysUp = this.getResources().getIntArray(R.array.prefGamePadiCadePlusDpad_UpCodes); break; case "MTK": case "MTK-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMTK); bGamePadKeysUp = bGamePadKeys; break; case "Game": case "Game-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGame); bGamePadKeysUp = bGamePadKeys; break; case "Game-alternate-rotate": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGameAlternate); bGamePadKeysUp = bGamePadKeys; break; case "MagicseeR1B": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMagicseeR1B); bGamePadKeysUp = bGamePadKeys; break; case "MagicseeR1A": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMagicseeR1A); bGamePadKeysUp = bGamePadKeys; break; case "MagicseeR1C": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadMagicseeR1C); bGamePadKeysUp = bGamePadKeys; break; case "FlydigiWee2": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadFlydigiWee2); bGamePadKeysUp = bGamePadKeys; break; case "UtopiaC": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadUtopiaC); bGamePadKeysUp = bGamePadKeys; break; case "Generic": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGeneric); bGamePadKeysUp = bGamePadKeys; break; case "Generic3x4": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadGeneric3x4); bGamePadKeysUp = bGamePadKeys; break; case "Keyboard": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadNoneLabels); bGamePadKeysUp = bGamePadKeys; break; case "Volume": bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadVolume); bGamePadKeysUp = bGamePadKeys; break; default: bGamePadKeys = this.getResources().getIntArray(R.array.prefGamePadiCade); bGamePadKeysUp = this.getResources().getIntArray(R.array.prefGamePadiCade_UpCodes); break; } for (int i = 0; i < GAMEPAD_KEYS_LENGTH; i++) { gamePadKeys[i] = bGamePadKeys[i]; gamePadKeys_Up[i] = bGamePadKeysUp[i]; } if (mainapp.prefGamePadType.contains("-rotate")) { gamePadKeys[2] = bGamePadKeys[4]; gamePadKeys[3] = bGamePadKeys[5]; gamePadKeys[4] = bGamePadKeys[3]; gamePadKeys[5] = bGamePadKeys[2]; gamePadKeys_Up[2] = bGamePadKeysUp[4]; gamePadKeys_Up[3] = bGamePadKeysUp[5]; gamePadKeys_Up[4] = bGamePadKeysUp[3]; gamePadKeys_Up[5] = bGamePadKeysUp[2]; } </DeepExtract> <DeepExtract> for (int throttleIndex = 0; throttleIndex < mainapp.numThrottles; throttleIndex++) { applySpeedRelatedOptions(throttleIndex); } </DeepExtract> <DeepExtract> if (mainapp.appIsFinishing) { return; } if (tvVols[0] == null) return; setVolumeIndicator(); setGamepadIndicator(); int maxThrottle = mainapp.getIntPrefValue(prefs, "maximum_throttle_preference", getApplicationContext().getResources().getString(R.string.prefMaximumThrottleDefaultValue)); maxThrottle = (int) Math.round(MAX_SPEED_VAL_WIT * (maxThrottle * .01)); for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { sbs[throttleIndex].setMax(maxThrottle); } int maxChange = mainapp.getIntPrefValue(prefs, "maximum_throttle_change_preference", getApplicationContext().getResources().getString(R.string.prefMaximumThrottleChangeDefaultValue)); max_throttle_change = (int) Math.round(maxThrottle * (maxChange * .01)); for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { sbs[throttleIndex].setMax(maxThrottle); if (mainapp.consists != null && mainapp.consists[throttleIndex] != null && mainapp.consists[throttleIndex].isEmpty()) { maxSpeedSteps[throttleIndex] = 100; limitSpeedMax[throttleIndex] = Math.round(100 * ((float) prefLimitSpeedPercent) / 100); } speedStepPref = mainapp.getIntPrefValue(prefs, "DisplaySpeedUnits", getApplicationContext().getResources().getString(R.string.prefDisplaySpeedUnitsDefaultValue)); setDisplayUnitScale(throttleIndex); setDisplayedSpeed(throttleIndex, sbs[throttleIndex].getProgress()); } refreshMenu(); vThrotScrWrap.invalidate(); </DeepExtract> <DeepExtract> if (webViewIsOn) { this.resumeWebView(); } else { this.pauseWebView(); } </DeepExtract> <DeepExtract> for (int throttleIndex = 0; throttleIndex < mainapp.numThrottles; throttleIndex++) { showDirectionIndication(throttleIndex, dirs[throttleIndex]); } </DeepExtract> <DeepExtract> if (mainapp.consists == null) { Log.d("Engine_Driver", "showHideConsistMenu consists[] is null"); return; } if (TMenu != null) { boolean anyConsist = false; for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { Consist con = mainapp.consists[throttleIndex]; if (con == null) { Log.d("Engine_Driver", "showHideConsistMenu consists[" + throttleIndex + "] is null"); break; } boolean isMulti = con.isMulti(); switch(throttleIndex) { case 0: anyConsist |= isMulti; TMenu.findItem(R.id.EditConsist0_menu).setVisible(isMulti); TMenu.findItem(R.id.EditLightsConsist0_menu).setVisible(isMulti); break; case 1: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist1_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist1_menu).setVisible(isMulti); break; case 2: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist2_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist2_menu).setVisible(isMulti); break; case 3: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist3_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist3_menu).setVisible(isMulti); break; case 4: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist4_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist4_menu).setVisible(isMulti); break; case 5: anyConsist |= isMulti; TMenu.findItem(R.id.EditLightsConsist5_menu).setVisible(isMulti); TMenu.findItem(R.id.EditConsist5_menu).setVisible(isMulti); break; } } TMenu.findItem(R.id.edit_consists_menu).setVisible(anyConsist); boolean isSpecial = false; if ((mainapp.prefAlwaysUseDefaultFunctionLabels) && ((mainapp.prefConsistFollowRuleStyle.equals(CONSIST_FUNCTION_RULE_STYLE_SPECIAL_EXACT)) || (mainapp.prefConsistFollowRuleStyle.equals(CONSIST_FUNCTION_RULE_STYLE_SPECIAL_PARTIAL)))) { isSpecial = true; } TMenu.findItem(R.id.function_consist_settings_mnu).setVisible(isSpecial); } </DeepExtract> <DeepExtract> if (!prefTtsWhen.equals(getApplicationContext().getResources().getString(R.string.prefTtsWhenDefaultValue))) { if (myTts == null) { lastTtsTime = new Time(); lastTtsTime.setToNow(); myTts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status != TextToSpeech.ERROR) { myTts.setLanguage(Locale.getDefault()); } else { Toast.makeText(getApplicationContext(), getApplicationContext().getResources().getString(R.string.toastTtsFailed), Toast.LENGTH_SHORT).show(); } } }); } } </DeepExtract> <DeepExtract> if (mainapp.getFastClockFormat() > 0) mainapp.setToolbarTitle(toolbar, "", getApplicationContext().getResources().getString(R.string.app_name_throttle_short), mainapp.getFastClockTime()); else mainapp.setToolbarTitle(toolbar, getApplicationContext().getResources().getString(R.string.app_name), getApplicationContext().getResources().getString(R.string.app_name_throttle), ""); </DeepExtract>
EngineDriver
positive
public String prettyPrint() { StringBuilder sb = new StringBuilder(shortSummary()); sb.append('\n'); if (!this.keepTaskList) { sb.append("No task info kept"); } else { sb.append("-----------------------------------------\n"); sb.append("ms % Task name\n"); sb.append("-----------------------------------------\n"); NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMinimumIntegerDigits(5); nf.setGroupingUsed(false); NumberFormat pf = NumberFormat.getPercentInstance(); pf.setMinimumIntegerDigits(3); pf.setGroupingUsed(false); for (TaskInfo task : getTaskInfo()) { sb.append(nf.format(task.getTimeMillis())).append(" "); sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append(" "); sb.append(task.getTaskName()).append("\n"); } } StringBuilder sb = new StringBuilder(shortSummary()); if (this.keepTaskList) { for (TaskInfo task : getTaskInfo()) { sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis()); long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds()); sb.append(" = ").append(percent).append("%"); } } else { sb.append("; no task info kept"); } return sb.toString(); }
<DeepExtract> StringBuilder sb = new StringBuilder(shortSummary()); if (this.keepTaskList) { for (TaskInfo task : getTaskInfo()) { sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis()); long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds()); sb.append(" = ").append(percent).append("%"); } } else { sb.append("; no task info kept"); } return sb.toString(); </DeepExtract>
audit4j-core
positive
public static void traceException(String category, String message, Throwable exception) { if (isTracing(category)) { message = (message != null) ? message : "null"; Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); Bundle bundle = Platform.getBundle(PLUGIN_ID); if (bundle != null) Platform.getLog(bundle).log(statusObj); } }
<DeepExtract> if (isTracing(category)) { message = (message != null) ? message : "null"; Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); Bundle bundle = Platform.getBundle(PLUGIN_ID); if (bundle != null) Platform.getLog(bundle).log(statusObj); } </DeepExtract>
Twig-Eclipse-Plugin
positive
@Override public ItemStack getItemInHand() { return CraftItemStack.asCraftMirror(getInventory().getMainHandStack()); }
<DeepExtract> return CraftItemStack.asCraftMirror(getInventory().getMainHandStack()); </DeepExtract>
CraftFabric
positive
public List getStackTrace() { List strace = (List) getScriptEnvironment().getEnvironment().get("%strace%"); List strace = new LinkedList(); getScriptEnvironment().getEnvironment().put("%strace%", strace); if (strace == null) { strace = new LinkedList(); } return strace; }
<DeepExtract> List strace = new LinkedList(); getScriptEnvironment().getEnvironment().put("%strace%", strace); </DeepExtract>
sleep
positive
@Override public boolean updateOne(String id, Map<String, Object> kvs, boolean insert) { UpdateResult result = null; Update update = new Update(); Iterator<Entry<String, Object>> itr = kvs.entrySet().iterator(); while (itr.hasNext()) { Entry<String, Object> entry = itr.next(); update.set(entry.getKey(), entry.getValue()); } if (!insert) { result = mongoTemplate.updateFirst(new Query(Criteria.where("_id").is(id)), update, getClassT()); return result.getModifiedCount() > 0; } else { result = mongoTemplate.upsert(new Query(Criteria.where("_id").is(id)), update, getClassT()); } return result.getModifiedCount() > 0; }
<DeepExtract> </DeepExtract> <DeepExtract> </DeepExtract>
resys-one
positive
public static String createGIFFileInBox() { synchronized (mLock) { Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); int second = c.get(Calendar.SECOND); int millisecond = c.get(Calendar.MILLISECOND); year = year - 2000; String dirPath = FileCacheDir; File d = new File(dirPath); if (!d.exists()) d.mkdirs(); if (!dirPath.endsWith("/")) { dirPath += "/"; } String name = mTmpFilePreFix; name += String.valueOf(year); name += String.valueOf(month); name += String.valueOf(day); name += String.valueOf(hour); name += String.valueOf(minute); name += String.valueOf(second); name += String.valueOf(millisecond); name += mTmpFileSubFix; if (!".gif".startsWith(".")) { name += "."; } name += ".gif"; try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } String retPath = dirPath + name; File file = new File(retPath); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } return retPath; } }
<DeepExtract> synchronized (mLock) { Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); int second = c.get(Calendar.SECOND); int millisecond = c.get(Calendar.MILLISECOND); year = year - 2000; String dirPath = FileCacheDir; File d = new File(dirPath); if (!d.exists()) d.mkdirs(); if (!dirPath.endsWith("/")) { dirPath += "/"; } String name = mTmpFilePreFix; name += String.valueOf(year); name += String.valueOf(month); name += String.valueOf(day); name += String.valueOf(hour); name += String.valueOf(minute); name += String.valueOf(second); name += String.valueOf(millisecond); name += mTmpFileSubFix; if (!".gif".startsWith(".")) { name += "."; } name += ".gif"; try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } String retPath = dirPath + name; File file = new File(retPath); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } return retPath; } </DeepExtract>
LanSoEditor_advance
positive