List of usage examples for java.lang Float compare
public static int compare(float f1, float f2)
From source file:org.apache.solr.SolrTestCaseJ4.java
public boolean compareSolrInputDocument(Object expected, Object actual) { if (!(expected instanceof SolrInputDocument) || !(actual instanceof SolrInputDocument)) { return false; }//from w ww . j ava 2 s . c om if (expected == actual) { return true; } SolrInputDocument sdoc1 = (SolrInputDocument) expected; SolrInputDocument sdoc2 = (SolrInputDocument) actual; if (Float.compare(sdoc1.getDocumentBoost(), sdoc2.getDocumentBoost()) != 0) { return false; } if (sdoc1.getFieldNames().size() != sdoc2.getFieldNames().size()) { return false; } Iterator<String> iter1 = sdoc1.getFieldNames().iterator(); Iterator<String> iter2 = sdoc2.getFieldNames().iterator(); if (iter1.hasNext()) { String key1 = iter1.next(); String key2 = iter2.next(); Object val1 = sdoc1.getFieldValues(key1); Object val2 = sdoc2.getFieldValues(key2); if (!key1.equals(key2) || !val1.equals(val2)) { return false; } } if (sdoc1.getChildDocuments() == null && sdoc2.getChildDocuments() == null) { return true; } if (sdoc1.getChildDocuments() == null || sdoc2.getChildDocuments() == null) { return false; } else if (sdoc1.getChildDocuments().size() != sdoc2.getChildDocuments().size()) { return false; } else { Iterator<SolrInputDocument> childDocsIter1 = sdoc1.getChildDocuments().iterator(); Iterator<SolrInputDocument> childDocsIter2 = sdoc2.getChildDocuments().iterator(); while (childDocsIter1.hasNext()) { if (!compareSolrInputDocument(childDocsIter1.next(), childDocsIter2.next())) { return false; } } return true; } }
From source file:org.cesecore.certificates.ca.X509CA.java
/** * Implementation of UpgradableDataHashMap function upgrade. *//*from w ww.j a v a 2 s.c om*/ public void upgrade() { if (Float.compare(LATEST_VERSION, getVersion()) != 0) { // New version of the class, upgrade log.info("Upgrading X509CA with version " + getVersion()); if (data.get(DEFAULTOCSPSERVICELOCATOR) == null) { setDefaultCRLDistPoint(""); setDefaultOCSPServiceLocator(""); } if (data.get(CRLISSUEINTERVAL) == null) { setCRLIssueInterval(0); } if (data.get(CRLOVERLAPTIME) == null) { // Default value 10 minutes setCRLOverlapTime(10); } boolean useprintablestring = true; if (data.get("alwaysuseutf8subjectdn") == null) { // Default value false if (data.get(USEUTF8POLICYTEXT) == null) { setUseUTF8PolicyText(false); } } else { // Use the same value as we had before when we had alwaysuseutf8subjectdn boolean useutf8 = ((Boolean) data.get("alwaysuseutf8subjectdn")).booleanValue(); if (data.get(USEUTF8POLICYTEXT) == null) { setUseUTF8PolicyText(useutf8); } // If we had checked to use utf8 on an old CA, we do not want to use PrintableString after upgrading useprintablestring = !useutf8; } if (data.get(USEPRINTABLESTRINGSUBJECTDN) == null) { // Default value true (as before) setUsePrintableStringSubjectDN(useprintablestring); } if (data.get(DEFAULTCRLISSUER) == null) { setDefaultCRLIssuer(null); } if (data.get(USELDAPDNORDER) == null) { setUseLdapDNOrder(true); // Default value } if (data.get(DELTACRLPERIOD) == null) { setDeltaCRLPeriod(0); // v14 } if (data.get(USECRLDISTRIBUTIONPOINTONCRL) == null) { setUseCrlDistributionPointOnCrl(false); // v15 } if (data.get(CRLDISTRIBUTIONPOINTONCRLCRITICAL) == null) { setCrlDistributionPointOnCrlCritical(false); // v15 } if (data.get(INCLUDEINHEALTHCHECK) == null) { setIncludeInHealthCheck(true); // v16 } // v17->v18 is only an upgrade in order to upgrade CA token // v18->v19 Object o = data.get(CRLPERIOD); if (o instanceof Integer) { setCRLPeriod(((Integer) o).longValue() * SimpleTime.MILLISECONDS_PER_HOUR); // h to ms } o = data.get(CRLISSUEINTERVAL); if (o instanceof Integer) { setCRLIssueInterval(((Integer) o).longValue() * SimpleTime.MILLISECONDS_PER_HOUR); // h to ms } o = data.get(CRLOVERLAPTIME); if (o instanceof Integer) { setCRLOverlapTime(((Integer) o).longValue() * SimpleTime.MILLISECONDS_PER_MINUTE); // min to ms } o = data.get(DELTACRLPERIOD); if (o instanceof Integer) { setDeltaCRLPeriod(((Integer) o).longValue() * SimpleTime.MILLISECONDS_PER_HOUR); // h to ms } data.put(VERSION, new Float(LATEST_VERSION)); } }
From source file:org.apache.solr.SolrTestCaseJ4.java
public boolean assertSolrInputFieldEquals(Object expected, Object actual) { if (!(expected instanceof SolrInputField) || !(actual instanceof SolrInputField)) { return false; }// w w w .ja va 2 s .c o m if (expected == actual) { return true; } SolrInputField sif1 = (SolrInputField) expected; SolrInputField sif2 = (SolrInputField) actual; if (!sif1.getName().equals(sif2.getName())) { return false; } if (!sif1.getValue().equals(sif2.getValue())) { return false; } if (Float.compare(sif1.getBoost(), sif2.getBoost()) != 0) { return false; } return true; }
From source file:org.ejbca.core.model.ca.publisher.LdapPublisher.java
/** * Implemtation of UpgradableDataHashMap function upgrade. *///from www. ja v a2 s.co m public void upgrade() { log.trace(">upgrade"); if (Float.compare(LATEST_VERSION, getVersion()) != 0) { // New version of the class, upgrade String msg = intres.getLocalizedMessage("publisher.upgrade", new Float(getVersion())); log.info(msg); if (data.get(ADDMULTIPLECERTIFICATES) == null) { setAddMultipleCertificates(false); } if (data.get(REMOVEREVOKED) == null) { setRemoveRevokedCertificates(true); } if (data.get(REMOVEUSERONCERTREVOKE) == null) { setRemoveUsersWhenCertRevoked(false); } if (data.get(CREATEINTERMEDIATENODES) == null) { setCreateIntermediateNodes(false); // v6 } if (data.get(DELTACRLATTRIBUTE) == null) { setDeltaCRLAttribute(DEFAULT_DELTACRLATTRIBUTE); // v7 } if (data.get(ADDNONEXISTINGATTR) == null) { setModifyExistingAttributes(false); // v8 setAddNonExistingAttributes(true); } if (getVersion() < 9) { setConnectionTimeOut(getConnectionTimeOut()); // v9 } if (data.get(SETUSERPASSWORD) == null) { setUserPassword(false); // v10 } if (data.get(READTIMEOUT) == null) { setStoreTimeOut(getStoreTimeOut()); // v11 setReadTimeOut(getReadTimeOut()); } if (data.get(CONNECTIONSECURITY) == null) { // v12 if (((Boolean) data.get(USESSL)).booleanValue() == true) { setConnectionSecurity(ConnectionSecurity.SSL); } else { setConnectionSecurity(ConnectionSecurity.PLAIN); } } data.put(VERSION, new Float(LATEST_VERSION)); } log.trace("<upgrade"); }
From source file:org.cesecore.certificates.ca.X509CA.java
/** * Method to upgrade new (or existing external caservices) This method needs to be called outside the regular upgrade since the CA isn't * instantiated in the regular upgrade.//from ww w. j a v a 2 s . com */ @SuppressWarnings({ "rawtypes", "deprecation" }) public boolean upgradeExtendedCAServices() { boolean retval = false; // call upgrade, if needed, on installed CA services Collection<Integer> externalServiceTypes = getExternalCAServiceTypes(); if (!CesecoreConfiguration.getCaKeepOcspExtendedService() && externalServiceTypes.contains(ExtendedCAServiceTypes.TYPE_OCSPEXTENDEDSERVICE)) { //This type has been removed, so remove it from any CAs it's been added to as well. externalServiceTypes.remove(ExtendedCAServiceTypes.TYPE_OCSPEXTENDEDSERVICE); data.put(EXTENDEDCASERVICES, externalServiceTypes); retval = true; } for (Integer type : externalServiceTypes) { ExtendedCAService service = getExtendedCAService(type); if (service != null) { if (Float.compare(service.getLatestVersion(), service.getVersion()) != 0) { retval = true; service.upgrade(); setExtendedCAServiceData(service.getExtendedCAServiceInfo().getType(), (HashMap) service.saveData()); } else if (service.isUpgraded()) { // Also return true if the service was automatically upgraded by a UpgradeableDataHashMap.load, which calls upgrade automagically. retval = true; setExtendedCAServiceData(service.getExtendedCAServiceInfo().getType(), (HashMap) service.saveData()); } } else { log.error("Extended service is null, can not upgrade service of type: " + type); } } return retval; }
From source file:org.cesecore.certificates.certificateprofile.CertificateProfile.java
/** * Implementation of UpgradableDataHashMap function upgrade. *//*from w w w . j av 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<Object>()); } 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.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<String>()); 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.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 if (data.get(USEAUTHORITYINFORMATIONACCESS) == null) { 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); } if (data.get(USEISSUERALTERNATIVENAME) == null) { // v 36 setUseIssuerAlternativeName(false); } if (data.get(ISSUERALTERNATIVENAMECRITICAL) == null) { // v 36 setIssuerAlternativeNameCritical(false); } if (data.get(USEDOCUMENTTYPELIST) == null) { // v 37 setUseDocumentTypeList(false); } if (data.get(DOCUMENTTYPELISTCRITICAL) == null) { // v 37 setDocumentTypeListCritical(false); } if (data.get(DOCUMENTTYPELIST) == null) { // v 37 setDocumentTypeList(new ArrayList<String>()); } data.put(VERSION, new Float(LATEST_VERSION)); } log.trace("<upgrade"); }