List of usage examples for java.lang Float compare
public static int compare(float f1, float f2)
From source file:com.android.leanlauncher.CellLayout.java
/** * Find a vacant area that will fit the given bounds nearest the requested * cell location, and will also weigh in a suggested direction vector of the * desired location. This method computers distance based on unit grid distances, * not pixel distances.//from w w w .j a va2 s.c o m * * @param cellX The X cell nearest to which you want to search for a vacant area. * @param cellY The Y cell nearest which you want to search for a vacant area. * @param spanX Horizontal span of the object. * @param spanY Vertical span of the object. * @param direction The favored direction in which the views should move from x, y * matches exactly. Otherwise we find the best matching direction. * @param occupied The array which represents which cells in the CellLayout are occupied * @param blockOccupied The array which represents which cells in the specified block (cellX, * cellY, spanX, spanY) are occupied. This is used when try to move a group of views. * @param result Array in which to place the result, or null (in which case a new array will * be allocated) * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ private int[] findNearestArea(int cellX, int cellY, int spanX, int spanY, int[] direction, boolean[][] occupied, boolean blockOccupied[][], int[] result) { // Keep track of best-scoring drop area final int[] bestXY = result != null ? result : new int[2]; float bestDistance = Float.MAX_VALUE; int bestDirectionScore = Integer.MIN_VALUE; final int countX = mCountX; final int countY = mCountY; for (int y = 0; y < countY - (spanY - 1); y++) { inner: for (int x = 0; x < countX - (spanX - 1); x++) { // First, let's see if this thing fits anywhere for (int i = 0; i < spanX; i++) { for (int j = 0; j < spanY; j++) { if (occupied[x + i][y + j] && (blockOccupied == null || blockOccupied[i][j])) { continue inner; } } } float distance = (float) Math.sqrt((x - cellX) * (x - cellX) + (y - cellY) * (y - cellY)); int[] curDirection = mTmpPoint; computeDirectionVector(x - cellX, y - cellY, curDirection); // The direction score is just the dot product of the two candidate direction // and that passed in. int curDirectionScore = direction[0] * curDirection[0] + direction[1] * curDirection[1]; boolean exactDirectionOnly = false; boolean directionMatches = direction[0] == curDirection[0] && direction[0] == curDirection[0]; if ((directionMatches || !exactDirectionOnly) && Float.compare(distance, bestDistance) < 0 || (Float.compare(distance, bestDistance) == 0 && curDirectionScore > bestDirectionScore)) { bestDistance = distance; bestDirectionScore = curDirectionScore; bestXY[0] = x; bestXY[1] = y; } } } // Return -1, -1 if no suitable location found if (bestDistance == Float.MAX_VALUE) { bestXY[0] = -1; bestXY[1] = -1; } return bestXY; }
From source file:ml.shifu.shifu.core.dtrain.dt.DTWorker.java
@Override public void load(GuaguaWritableAdapter<LongWritable> currentKey, GuaguaWritableAdapter<Text> currentValue, WorkerContext<DTMasterParams, DTWorkerParams> context) { this.count += 1; if ((this.count) % 5000 == 0) { LOG.info("Read {} records.", this.count); }/*from w w w . j ava 2s . com*/ // hashcode for fixed input split in train and validation long hashcode = 0; short[] inputs = new short[this.inputCount]; float ideal = 0f; float significance = 1f; // use guava Splitter to iterate only once // use NNConstants.NN_DEFAULT_COLUMN_SEPARATOR to replace getModelConfig().getDataSetDelimiter(), super follows // the function in akka mode. int index = 0, inputIndex = 0; for (String input : this.splitter.split(currentValue.getWritable().toString())) { if (index == this.columnConfigList.size()) { // do we need to check if not weighted directly set to 1f; if such logic non-weight at first, then // weight, how to process??? if (StringUtils.isBlank(modelConfig.getWeightColumnName())) { significance = 1f; break; } // check here to avoid bad performance in failed NumberFormatUtils.getFloat(input, 1f) significance = input.length() == 0 ? 1f : NumberFormatUtils.getFloat(input, 1f); // if invalid weight, set it to 1f and warning in log if (Float.compare(significance, 0f) < 0) { LOG.warn( "The {} record in current worker weight {} is less than 0f, it is invalid, set it to 1.", count, significance); significance = 1f; } // the last field is significance, break here break; } else { ColumnConfig columnConfig = this.columnConfigList.get(index); if (columnConfig != null && columnConfig.isTarget()) { ideal = getFloatValue(input); } else { if (!isAfterVarSelect) { // no variable selected, good candidate but not meta and not target chose if (!columnConfig.isMeta() && !columnConfig.isTarget() && CommonUtils.isGoodCandidate(columnConfig, this.hasCandidates)) { if (columnConfig.isNumerical()) { float floatValue = getFloatValue(input); // cast is safe as we limit max bin to Short.MAX_VALUE short binIndex = (short) getBinIndex(floatValue, columnConfig.getBinBoundary()); inputs[inputIndex] = binIndex; if (!this.inputIndexMap.containsKey(columnConfig.getColumnNum())) { this.inputIndexMap.put(columnConfig.getColumnNum(), inputIndex); } } else if (columnConfig.isCategorical()) { short shortValue = (short) (columnConfig.getBinCategory().size()); if (input.length() == 0) { // empty shortValue = (short) (columnConfig.getBinCategory().size()); } else { Integer categoricalIndex = this.columnCategoryIndexMapping .get(columnConfig.getColumnNum()).get(input); if (categoricalIndex == null) { shortValue = -1; // invalid category, set to -1 for last index } else { // cast is safe as we limit max bin to Short.MAX_VALUE shortValue = (short) (categoricalIndex.intValue()); } if (shortValue == -1) { // not found shortValue = (short) (columnConfig.getBinCategory().size()); } } inputs[inputIndex] = shortValue; if (!this.inputIndexMap.containsKey(columnConfig.getColumnNum())) { this.inputIndexMap.put(columnConfig.getColumnNum(), inputIndex); } } hashcode = hashcode * 31 + input.hashCode(); inputIndex += 1; } } else { // final select some variables but meta and target are not included if (columnConfig != null && !columnConfig.isMeta() && !columnConfig.isTarget() && columnConfig.isFinalSelect()) { if (columnConfig.isNumerical()) { float floatValue = getFloatValue(input); // cast is safe as we limit max bin to Short.MAX_VALUE short binIndex = (short) getBinIndex(floatValue, columnConfig.getBinBoundary()); inputs[inputIndex] = binIndex; if (!this.inputIndexMap.containsKey(columnConfig.getColumnNum())) { this.inputIndexMap.put(columnConfig.getColumnNum(), inputIndex); } } else if (columnConfig.isCategorical()) { // cast is safe as we limit max bin to Short.MAX_VALUE short shortValue = (short) (columnConfig.getBinCategory().size()); if (input.length() == 0) { // empty shortValue = (short) (columnConfig.getBinCategory().size()); } else { Integer categoricalIndex = this.columnCategoryIndexMapping .get(columnConfig.getColumnNum()).get(input); if (categoricalIndex == null) { shortValue = -1; // invalid category, set to -1 for last index } else { // cast is safe as we limit max bin to Short.MAX_VALUE shortValue = (short) (categoricalIndex.intValue()); } if (shortValue == -1) { // not found shortValue = (short) (columnConfig.getBinCategory().size()); } } inputs[inputIndex] = shortValue; if (!this.inputIndexMap.containsKey(columnConfig.getColumnNum())) { this.inputIndexMap.put(columnConfig.getColumnNum(), inputIndex); } } hashcode = hashcode * 31 + input.hashCode(); inputIndex += 1; } } } } index += 1; } // output delimiter in norm can be set by user now and if user set a special one later changed, this exception // is helped to quick find such issue. if (inputIndex != inputs.length) { String delimiter = context.getProps().getProperty(Constants.SHIFU_OUTPUT_DATA_DELIMITER, Constants.DEFAULT_DELIMITER); throw new RuntimeException("Input length is inconsistent with parsing size. Input original size: " + inputs.length + ", parsing size:" + inputIndex + ", delimiter:" + delimiter + "."); } if (this.isOneVsAll) { // if one vs all, update target value according to index of target ideal = updateOneVsAllTargetValue(ideal); } // sample negative only logic here if (modelConfig.getTrain().getSampleNegOnly()) { if (this.modelConfig.isFixInitialInput()) { // if fixInitialInput, sample hashcode in 1-sampleRate range out if negative records int startHashCode = (100 / this.modelConfig.getBaggingNum()) * this.trainerId; // here BaggingSampleRate means how many data will be used in training and validation, if it is 0.8, we // should take 1-0.8 to check endHashCode int endHashCode = startHashCode + Double.valueOf((1d - this.modelConfig.getBaggingSampleRate()) * 100).intValue(); if ((modelConfig.isRegression() || this.isOneVsAll) // regression or onevsall && (int) (ideal + 0.01d) == 0 // negative record && isInRange(hashcode, startHashCode, endHashCode)) { return; } } else { // if not fixed initial input, and for regression or onevsall multiple classification (regression also). // and if negative record do sampling out if ((modelConfig.isRegression() || this.isOneVsAll) // regression or onevsall && (int) (ideal + 0.01d) == 0 // negative record && Double.compare(this.sampelNegOnlyRandom.nextDouble(), this.modelConfig.getBaggingSampleRate()) >= 0) { return; } } } float output = ideal; float predict = ideal; // up sampling logic, just add more weights while bagging sampling rate is still not changed if (modelConfig.isRegression() && isUpSampleEnabled() && Double.compare(ideal, 1d) == 0) { // Double.compare(ideal, 1d) == 0 means positive tags; sample + 1 to avoid sample count to 0 significance = significance * (this.upSampleRng.sample() + 1); } Data data = new Data(inputs, predict, output, output, significance); boolean isValidation = false; if (context.getAttachment() != null && context.getAttachment() instanceof Boolean) { isValidation = (Boolean) context.getAttachment(); } // split into validation and training data set according to validation rate boolean isInTraining = this.addDataPairToDataSet(hashcode, data, isValidation); // do bagging sampling only for training data if (isInTraining) { data.subsampleWeights = sampleWeights(data.label); // for training data, compute real selected training data according to baggingSampleRate // if gbdt, only the 1st sampling value is used, if rf, use the 1st to denote some information, no need all if (isPositive(data.label)) { this.positiveSelectedTrainCount += data.subsampleWeights[0] * 1L; } else { this.negativeSelectedTrainCount += data.subsampleWeights[0] * 1L; } } else { // for validation data, according bagging sampling logic, we may need to sampling validation data set, while // validation data set are only used to compute validation error, not to do real sampling is ok. } }
From source file:com.marlonjones.voidlauncher.CellLayout.java
/** * Find a vacant area that will fit the given bounds nearest the requested * cell location, and will also weigh in a suggested direction vector of the * desired location. This method computers distance based on unit grid distances, * not pixel distances.//from w w w . ja va 2 s . co m * * @param cellX The X cell nearest to which you want to search for a vacant area. * @param cellY The Y cell nearest which you want to search for a vacant area. * @param spanX Horizontal span of the object. * @param spanY Vertical span of the object. * @param direction The favored direction in which the views should move from x, y * @param occupied The array which represents which cells in the CellLayout are occupied * @param blockOccupied The array which represents which cells in the specified block (cellX, * cellY, spanX, spanY) are occupied. This is used when try to move a group of views. * @param result Array in which to place the result, or null (in which case a new array will * be allocated) * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ private int[] findNearestArea(int cellX, int cellY, int spanX, int spanY, int[] direction, boolean[][] occupied, boolean blockOccupied[][], int[] result) { // Keep track of best-scoring drop area final int[] bestXY = result != null ? result : new int[2]; float bestDistance = Float.MAX_VALUE; int bestDirectionScore = Integer.MIN_VALUE; final int countX = mCountX; final int countY = mCountY; for (int y = 0; y < countY - (spanY - 1); y++) { inner: for (int x = 0; x < countX - (spanX - 1); x++) { // First, let's see if this thing fits anywhere for (int i = 0; i < spanX; i++) { for (int j = 0; j < spanY; j++) { if (occupied[x + i][y + j] && (blockOccupied == null || blockOccupied[i][j])) { continue inner; } } } float distance = (float) Math.hypot(x - cellX, y - cellY); int[] curDirection = mTmpPoint; computeDirectionVector(x - cellX, y - cellY, curDirection); // The direction score is just the dot product of the two candidate direction // and that passed in. int curDirectionScore = direction[0] * curDirection[0] + direction[1] * curDirection[1]; if (Float.compare(distance, bestDistance) < 0 || (Float.compare(distance, bestDistance) == 0 && curDirectionScore > bestDirectionScore)) { bestDistance = distance; bestDirectionScore = curDirectionScore; bestXY[0] = x; bestXY[1] = y; } } } // Return -1, -1 if no suitable location found if (bestDistance == Float.MAX_VALUE) { bestXY[0] = -1; bestXY[1] = -1; } return bestXY; }
From source file:xyz.klinker.blur.launcher3.Workspace.java
@Override protected Matrix getPageShiftMatrix() { if (Float.compare(mOverlayTranslation, 0) != 0) { // The pages are translated by mOverlayTranslation. incorporate that in the // visible page calculation by shifting everything back by that same amount. mTempMatrix.set(getMatrix());/*from w w w. j av a 2 s . c o m*/ mTempMatrix.postTranslate(-mOverlayTranslation, 0); return mTempMatrix; } return super.getPageShiftMatrix(); }
From source file:com.android.launcher3.CellLayout.java
/** * Find a vacant area that will fit the given bounds nearest the requested * cell location, and will also weigh in a suggested direction vector of the * desired location. This method computers distance based on unit grid distances, * not pixel distances.// ww w. jav a 2s .c o m * * @param cellX The X cell nearest to which you want to search for a vacant area. * @param cellY The Y cell nearest which you want to search for a vacant area. * @param spanX Horizontal span of the object. * @param spanY Vertical span of the object. * @param direction The favored direction in which the views should move from x, y * @param exactDirectionOnly If this parameter is true, then only solutions where the direction * matches exactly. Otherwise we find the best matching direction. * @param occoupied The array which represents which cells in the CellLayout are occupied * @param blockOccupied The array which represents which cells in the specified block (cellX, * cellY, spanX, spanY) are occupied. This is used when try to move a group of views. * @param result Array in which to place the result, or null (in which case a new array will * be allocated) * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ private int[] findNearestArea(int cellX, int cellY, int spanX, int spanY, int[] direction, boolean[][] occupied, boolean blockOccupied[][], int[] result) { // Keep track of best-scoring drop area final int[] bestXY = result != null ? result : new int[2]; float bestDistance = Float.MAX_VALUE; int bestDirectionScore = Integer.MIN_VALUE; final int countX = mCountX; final int countY = mCountY; for (int y = 0; y < countY - (spanY - 1); y++) { inner: for (int x = 0; x < countX - (spanX - 1); x++) { // First, let's see if this thing fits anywhere for (int i = 0; i < spanX; i++) { for (int j = 0; j < spanY; j++) { if (occupied[x + i][y + j] && (blockOccupied == null || blockOccupied[i][j])) { continue inner; } } } float distance = (float) Math.hypot(x - cellX, y - cellY); int[] curDirection = mTmpPoint; computeDirectionVector(x - cellX, y - cellY, curDirection); // The direction score is just the dot product of the two candidate direction // and that passed in. int curDirectionScore = direction[0] * curDirection[0] + direction[1] * curDirection[1]; boolean exactDirectionOnly = false; boolean directionMatches = direction[0] == curDirection[0] && direction[0] == curDirection[0]; if ((directionMatches || !exactDirectionOnly) && Float.compare(distance, bestDistance) < 0 || (Float.compare(distance, bestDistance) == 0 && curDirectionScore > bestDirectionScore)) { bestDistance = distance; bestDirectionScore = curDirectionScore; bestXY[0] = x; bestXY[1] = y; } } } // Return -1, -1 if no suitable location found if (bestDistance == Float.MAX_VALUE) { bestXY[0] = -1; bestXY[1] = -1; } return bestXY; }
From source file:cc.flydev.launcher.Workspace.java
private void updateStateForCustomContent(int screenCenter) { float translationX = 0; float progress = 0; if (hasCustomContent()) { int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID); int scrollDelta = getScrollX() - getScrollForPage(index) - getLayoutTransitionOffsetForPage(index); float scrollRange = getScrollForPage(index + 1) - getScrollForPage(index); translationX = scrollRange - scrollDelta; progress = (scrollRange - scrollDelta) / scrollRange; if (isLayoutRtl()) { translationX = Math.min(0, translationX); } else {//from ww w .j ava 2 s . c o m translationX = Math.max(0, translationX); } progress = Math.max(0, progress); } if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return; CellLayout cc = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID); if (progress > 0 && cc.getVisibility() != VISIBLE && !isSmall()) { cc.setVisibility(VISIBLE); } mLastCustomContentScrollProgress = progress; setBackgroundAlpha(progress * 0.8f); if (mLauncher.getHotseat() != null) { mLauncher.getHotseat().setTranslationX(translationX); } if (getPageIndicator() != null) { getPageIndicator().setTranslationX(translationX); } if (mCustomContentCallbacks != null) { mCustomContentCallbacks.onScrollProgressChanged(progress); } }
From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java
@Override protected void screenScrolled(int screenCenter) { final boolean isRtl = isLayoutRtl(); mUseTransitionEffect = !isInOverviewMode() && !mIsSwitchingState; updatePageAlphaValues(screenCenter); super.screenScrolled(screenCenter); enableHwLayersOnVisiblePages();// w w w. j av a2 s . co m boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX; if (isInOverscroll) { int index = 0; float pivotX = 0f; final float leftBiasedPivot = 0.35f; final float rightBiasedPivot = 0.65f; final int lowerIndex = 0; final int upperIndex = getChildCount() - 1; final boolean isLeftPage = mOverScrollX < 0; index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex; pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot; View v = getPageAt(index); if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) { mOverscrollTransformsSet = true; mLastOverscrollPivotX = pivotX; v.setCameraDistance(mDensity * mCameraDistance); v.setPivotX(v.getMeasuredWidth() * pivotX); } float scrollProgress = getScrollProgress(screenCenter, v, index); float rotation = -TRANSITION_MAX_ROTATION * scrollProgress; v.setRotationY(rotation); } else { if (mOverscrollTransformsSet) { mOverscrollTransformsSet = false; View v0 = getPageAt(mCurrentPage); v0.setRotationY(0); v0.setCameraDistance(mDensity * mCameraDistance); v0.setPivotX(v0.getMeasuredWidth() / 2); v0.setPivotY(v0.getMeasuredHeight() / 2); } } }
From source file:cc.flydev.launcher.Workspace.java
@Override protected void screenScrolled(int screenCenter) { final boolean isRtl = isLayoutRtl(); super.screenScrolled(screenCenter); updatePageAlphaValues(screenCenter); updateStateForCustomContent(screenCenter); enableHwLayersOnVisiblePages();/*from ww w. j ava 2 s .c o m*/ boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl())) || (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl())); if (shouldOverScroll) { int index = 0; float pivotX = 0f; final float leftBiasedPivot = 0.25f; final float rightBiasedPivot = 0.75f; final int lowerIndex = 0; final int upperIndex = getChildCount() - 1; final boolean isLeftPage = mOverScrollX < 0; index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex; pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot; CellLayout cl = (CellLayout) getChildAt(index); float scrollProgress = getScrollProgress(screenCenter, cl, index); cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage); float rotation = -WORKSPACE_OVERSCROLL_ROTATION * scrollProgress; cl.setRotationY(rotation); if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) { mOverscrollTransformsSet = true; mLastOverscrollPivotX = pivotX; cl.setCameraDistance(mDensity * mCameraDistance); cl.setPivotX(cl.getMeasuredWidth() * pivotX); cl.setPivotY(cl.getMeasuredHeight() * 0.5f); cl.setOverscrollTransformsDirty(true); } } else { if (mOverscrollTransformsSet) { mOverscrollTransformsSet = false; ((CellLayout) getChildAt(0)).resetOverscrollTransforms(); ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms(); } } }
From source file:org.ejbca.core.model.ca.certificateprofiles.CertificateProfile.java
/** * Implementation of UpgradableDataHashMap function upgrade. *//*from w ww.j a v a 2 s .c o m*/ public void upgrade() { if (log.isTraceEnabled()) { log.trace(">upgrade: " + getLatestVersion() + ", " + getVersion()); } if (Float.compare(getLatestVersion(), getVersion()) != 0) { // New version of the class, upgrade String msg = intres.getLocalizedMessage("certprofile.upgrade", new Float(getVersion())); log.info(msg); if (data.get(ALLOWKEYUSAGEOVERRIDE) == null) { data.put(ALLOWKEYUSAGEOVERRIDE, Boolean.TRUE); } if (data.get(USEEXTENDEDKEYUSAGE) == null) { data.put(USEEXTENDEDKEYUSAGE, Boolean.FALSE); } if (data.get(EXTENDEDKEYUSAGE) == null) { data.put(EXTENDEDKEYUSAGE, new ArrayList()); } if (data.get(EXTENDEDKEYUSAGECRITICAL) == null) { data.put(EXTENDEDKEYUSAGECRITICAL, Boolean.FALSE); } if (data.get(AVAILABLECAS) == null) { ArrayList<Integer> availablecas = new ArrayList<Integer>(); availablecas.add(Integer.valueOf(ANYCA)); data.put(AVAILABLECAS, availablecas); } if (data.get(USEDPUBLISHERS) == null) { data.put(USEDPUBLISHERS, new ArrayList<Integer>()); } if ((data.get(USEOCSPSERVICELOCATOR) == null) && (data.get(USEAUTHORITYINFORMATIONACCESS) == null)) { // Only set this flag if we have not already set the new flag USEAUTHORITYINFORMATIONACCESS // setUseOCSPServiceLocator(false); data.put(USEOCSPSERVICELOCATOR, Boolean.valueOf(false)); setOCSPServiceLocatorURI(""); } if (data.get(USEMICROSOFTTEMPLATE) == null) { setUseMicrosoftTemplate(false); setMicrosoftTemplate(""); } if (data.get(USECNPOSTFIX) == null) { setUseCNPostfix(false); setCNPostfix(""); } if (data.get(USESUBJECTDNSUBSET) == null) { setUseSubjectDNSubSet(false); setSubjectDNSubSet(new ArrayList<Integer>()); setUseSubjectAltNameSubSet(false); setSubjectAltNameSubSet(new ArrayList<Integer>()); } if (data.get(USEPATHLENGTHCONSTRAINT) == null) { setUsePathLengthConstraint(false); setPathLengthConstraint(0); } if (data.get(USEQCSTATEMENT) == null) { setUseQCStatement(false); setUsePkixQCSyntaxV2(false); setQCStatementCritical(false); setQCStatementRAName(null); setQCSemanticsId(null); setUseQCEtsiQCCompliance(false); setUseQCEtsiSignatureDevice(false); setUseQCEtsiValueLimit(false); setUseQCEtsiRetentionPeriod(false); setQCEtsiRetentionPeriod(0); setQCEtsiValueLimit(0); setQCEtsiValueLimitExp(0); setQCEtsiValueLimitCurrency(null); } if (data.get(USEDEFAULTCRLDISTRIBUTIONPOINT) == null) { setUseDefaultCRLDistributionPoint(false); setUseDefaultOCSPServiceLocator(false); } if (data.get(USEQCCUSTOMSTRING) == null) { setUseQCCustomString(false); setQCCustomStringOid(null); setQCCustomStringText(null); } if (data.get(USESUBJECTDIRATTRIBUTES) == null) { setUseSubjectDirAttributes(false); } if (data.get(ALLOWVALIDITYOVERRIDE) == null) { setAllowValidityOverride(false); } if (data.get(CRLISSUER) == null) { setCRLIssuer(null); // v20 } if (data.get(USEOCSPNOCHECK) == null) { setUseOcspNoCheck(false); // v21 } if (data.get(USEFRESHESTCRL) == null) { setUseFreshestCRL(false); // v22 setUseCADefinedFreshestCRL(false); setFreshestCRLURI(null); } if (data.get(CERTIFICATE_POLICIES) == null) { // v23 if (data.get(CERTIFICATEPOLICYID) != null) { String ids = (String) data.get(CERTIFICATEPOLICYID); String unotice = null; String cpsuri = null; if (data.get(POLICY_NOTICE_UNOTICE_TEXT) != null) { unotice = (String) data.get(POLICY_NOTICE_UNOTICE_TEXT); } if (data.get(POLICY_NOTICE_CPS_URL) != null) { cpsuri = (String) data.get(POLICY_NOTICE_CPS_URL); } // Only the first policy could have user notice and cpsuri in the old scheme StringTokenizer tokenizer = new StringTokenizer(ids, ";", false); if (tokenizer.hasMoreTokens()) { String id = tokenizer.nextToken(); CertificatePolicy newpolicy = null; if (StringUtils.isNotEmpty(unotice)) { newpolicy = new CertificatePolicy(id, CertificatePolicy.id_qt_unotice, unotice); addCertificatePolicy(newpolicy); } if (StringUtils.isNotEmpty(cpsuri)) { newpolicy = new CertificatePolicy(id, CertificatePolicy.id_qt_cps, cpsuri); addCertificatePolicy(newpolicy); } // If it was a lonely policy id if (newpolicy == null) { newpolicy = new CertificatePolicy(id, null, null); addCertificatePolicy(newpolicy); } } while (tokenizer.hasMoreTokens()) { String id = tokenizer.nextToken(); CertificatePolicy newpolicy = new CertificatePolicy(id, null, null); addCertificatePolicy(newpolicy); } } } if (data.get(USECRLDISTRIBUTIONPOINTONCRL) == null) { setUseCRLDistributionPointOnCRL(false); // v24 } if ((data.get(USECAISSUERS) == null) && (data.get(USEAUTHORITYINFORMATIONACCESS) == null)) { // Only set this flag if we have not already set the new flag USEAUTHORITYINFORMATIONACCESS //setUseCaIssuers(false); // v24 data.put(USECAISSUERS, Boolean.valueOf(false)); // v24 setCaIssuers(new ArrayList<String>()); } if (((data.get(USEOCSPSERVICELOCATOR) != null) || (data.get(USECAISSUERS) != null)) && (data.get(USEAUTHORITYINFORMATIONACCESS) == null)) { // Only do this if we have not already set the new flag USEAUTHORITYINFORMATIONACCESS boolean ocsp = false; if ((data.get(USEOCSPSERVICELOCATOR) != null)) { ocsp = ((Boolean) data.get(USEOCSPSERVICELOCATOR)).booleanValue(); } boolean caissuers = false; if ((data.get(USECAISSUERS) != null)) { caissuers = ((Boolean) data.get(USECAISSUERS)).booleanValue(); } if (ocsp || caissuers) { setUseAuthorityInformationAccess(true); // v25 } else { setUseAuthorityInformationAccess(false); // v25 } } else { setUseAuthorityInformationAccess(false); } if (data.get(ALLOWEXTENSIONOVERRIDE) == null) { setAllowExtensionOverride(false); // v26 } if (data.get(USEQCETSIRETENTIONPERIOD) == null) { setUseQCEtsiRetentionPeriod(false); // v27 setQCEtsiRetentionPeriod(0); } if (data.get(CVCACCESSRIGHTS) == null) { setCVCAccessRights(CertificateProfile.CVC_ACCESS_NONE); // v28 } if (data.get(USELDAPDNORDER) == null) { setUseLdapDnOrder(true); // v29, default value is true } if (data.get(USECARDNUMBER) == null) { //v30, default value is false setUseCardNumber(false); } if (data.get(ALLOWDNOVERRIDE) == null) { setAllowDNOverride(false); // v31 } if (Float.compare((float) 32.0, getVersion()) > 0) { // v32 // Extended key usage storage changed from ArrayList of Integers to an ArrayList of Strings. setExtendedKeyUsage(getExtendedKeyUsageAsOIDStrings(true)); } if (data.get(NUMOFREQAPPROVALS) == null) { // v 33 setNumOfReqApprovals(1); } if (data.get(APPROVALSETTINGS) == null) { // v 33 setApprovalSettings(new ArrayList<Integer>()); } if (data.get(SIGNATUREALGORITHM) == null) { // v 34 setSignatureAlgorithm(null); } if (data.get(USEPRIVKEYUSAGEPERIODNOTBEFORE) == null) { // v 35 setUsePrivateKeyUsagePeriodNotBefore(false); } if (data.get(USEPRIVKEYUSAGEPERIODNOTAFTER) == null) { // v 35 setUsePrivateKeyUsagePeriodNotAfter(false); } if (data.get(PRIVKEYUSAGEPERIODSTARTOFFSET) == null) { // v 35 setPrivateKeyUsagePeriodStartOffset(0); } if (data.get(PRIVKEYUSAGEPERIODLENGTH) == null) { // v 35 setPrivateKeyUsagePeriodLength(getValidity() * 24 * 3600); } data.put(VERSION, new Float(LATEST_VERSION)); } log.trace("<upgrade"); }
From source file:ml.shifu.shifu.core.dtrain.dt.DTWorker.java
private boolean isPositive(float value) { return Float.compare(1f, value) == 0 ? true : false; }