List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java
@Override public void putAttributeDouble(String annotationName, Double value) { try {/*from www . j ava 2s.c o m*/ mJSONObject.put(annotationName, value.doubleValue()); } catch (JSONException e) { Log.e(TAG, e.toString()); } }
From source file:com.baidu.gcrm.customer.web.validator.CustomerAddValidator.java
@Override public void validate(Object target, Errors errors) { CustomerBean customerBean = (CustomerBean) target; ValidationUtils.invokeValidator(new CustomerValidator(), customerBean.getCustomer(), errors); // ???????// w w w . java2 s.c o m if (errors.hasErrors()) { return; } Customer customer = customerBean.getCustomer(); // ???? add by cch validatorNameAndLicense(customer, errors); //??? validatorAgentTypeAndAgentCountry(customer, errors); List<ContactPerson> contacts = customerBean.getContacts(); if (contacts != null && contacts.size() > CONTACT_LIMIT) { errors.rejectValue("", "contact.size.invalid"); } if (CollectionUtils.isNotEmpty(contacts)) { int i = 0; for (ContactPerson temContactPerson : contacts) { ContactPersonValidator.validateSingleContactPerson(errors, new StringBuilder("contacts[").append(i).append("].").toString(), temContactPerson, true); i++; } } Opportunity opportunity = customerBean.getOpportunity(); if (opportunity != null) { Double budget = opportunity.getBudget(); if (budget != null && budget.doubleValue() < 0) { errors.rejectValue("opportunity.budget", "opportunity.budget.number"); } } // weichengke add Qualification qualification = customerBean.getQualification(); if (qualification != null) { if (StringUtils.isNotBlank(qualification.getParterTop1()) && qualification.getParterTop1().length() > 128) { errors.rejectValue("qualification.parterTop1", "qualification.parterTop.length.toolong"); } if (StringUtils.isNotBlank(qualification.getParterTop2()) && qualification.getParterTop2().length() > 128) { errors.rejectValue("qualification.parterTop2", "qualification.parterTop.length.toolong"); } if (StringUtils.isNotBlank(qualification.getParterTop3()) && qualification.getParterTop3().length() > 128) { errors.rejectValue("qualification.parterTop3", "qualification.parterTop.length.toolong"); } if (StringUtils.isNotBlank(qualification.getPerformanceHighlights()) && qualification.getPerformanceHighlights().length() > 512) { errors.rejectValue("qualification.performanceHighlights", "qualification.performanceHighlights.length.toolong"); } List<CustomerResource> resources = qualification.getCustomerResources(); if (resources == null || resources.size() == 0) { return; } int index = 0; for (CustomerResource resource : qualification.getCustomerResources()) { if (StringUtils.isNotBlank(resource.getAdvertisersCompany1()) && resource.getAdvertisersCompany1().length() > 128) { errors.rejectValue("qualification.customerResources[" + index + "].advertisersCompany1", "costomerResource.advertisersCompany.length.toolong"); } if (StringUtils.isNotBlank(resource.getAdvertisersCompany2()) && resource.getAdvertisersCompany2().length() > 128) { errors.rejectValue("qualification.customerResources[" + index + "].advertisersCompany2", "costomerResource.advertisersCompany.length.toolong"); } if (StringUtils.isNotBlank(resource.getAdvertisersCompany3()) && resource.getAdvertisersCompany3().length() > 128) { errors.rejectValue("qualification.customerResources[" + index + "].advertisersCompany3", "costomerResource.advertisersCompany.length.toolong"); } if (StringUtils.isNotBlank(resource.getIndustry()) && resource.getIndustry().length() > 128) { errors.rejectValue("qualification.customerResources[" + index + "].industry", "costomerResource.industry.length.toolong"); } index++; } } }
From source file:org.apache.hadoop.hive.ql.udf.UDFOPEqual.java
public Boolean evaluate(Double a, Double b) { Boolean r = null;//from w w w.ja va2s .c o m if ((a == null) || (b == null)) { r = null; } else { r = Boolean.valueOf(a.doubleValue() == b.doubleValue()); } // LOG.info("evaluate(" + a + "," + b + ")=" + r); return r; }
From source file:de.hybris.platform.b2bacceleratorservices.jalo.promotions.ProductPriceDiscountPromotionByPaymentType.java
@Override public String getResultDescription(final SessionContext ctx, final PromotionResult promotionResult, final Locale locale) { final AbstractOrder order = promotionResult.getOrder(ctx); if (order != null) { final de.hybris.platform.jalo.c2l.Currency currency = order.getCurrency(ctx); final Double totalDiscount = Double.valueOf(promotionResult.getTotalDiscount(ctx)); if (totalDiscount.doubleValue() > 0D) { if (promotionResult.getFired(ctx)) { final Object[] args = { Helper.formatCurrencyAmount(ctx, locale, currency, totalDiscount.doubleValue()), B2BAcceleratorServicesManager.getInstance().getPaymentType(ctx, order) }; return formatMessage(this.getMessageFired(ctx), args, locale); }//ww w . ja va 2 s .co m } else if (promotionResult.getCouldFire(ctx)) { return this.getMessageCouldHaveFired(); } } return ""; }
From source file:org.tolven.gen.model.GenSource.java
/** * See if the specified patient should get data generated for this source and then do so. * @param patient/*from w w w. java2 s. co m*/ */ public void generate(GenMedical patient) { Matcher m = matchFirst(patient); if (m == null) return; // Ask the matcher to supply a reasonable event time Date eventTime = m.getEventTime(patient, rng, null); // At this point, we are 100% likely to create this event. apply(patient, eventTime); // Now check the repeats completely ignoring match criteria since we've already got // a match. // TODO: There's a possible flaw here: Since a recurrance is independent of the original match // criteria, a disease that can recur is not limited by age ranges. But there may be no such disease. // It would be a disease that can recur but only within a certain age range, once the patient // is older, the recurrance probability, like the initial disease, drops to zero. for (Double p : getRepeatProbability()) { if (rng.nextUniform(0.0, 1.0) > p.doubleValue()) break; long next; if (eventTime.getTime() + getMinimumSpacing() >= patient.getNow().getTime()) break; next = rng.nextLong(eventTime.getTime() + getMinimumSpacing(), patient.getNow().getTime()); eventTime = m.getEventTime(patient, rng, new Date(next)); apply(patient, eventTime); } }
From source file:com.aurel.track.fieldType.fieldChange.apply.DoubleFieldChangeApply.java
/** * Sets the workItemBean's attribute//from ww w . j av a 2 s .co m * @param workItemContext * @param workItemBean * @param fieldID * @param parameterCode * @param value * @return ErrorData if an error is found */ @Override public List<ErrorData> setWorkItemAttribute(WorkItemContext workItemContext, TWorkItemBean workItemBean, Integer parameterCode, Object value) { if (getSetter() == FieldChangeSetters.SET_NULL || getSetter() == FieldChangeSetters.SET_REQUIRED) { return super.setWorkItemAttribute(workItemContext, workItemBean, parameterCode, value); } Double doubleValue = null; try { doubleValue = (Double) value; } catch (Exception e) { LOGGER.warn("Getting the double value for " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } switch (getSetter()) { case FieldChangeSetters.SET_TO: workItemBean.setAttribute(activityType, parameterCode, doubleValue); break; case FieldChangeSetters.ADD_IF_SET: if (doubleValue != null) { Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { double newValue = originalValue.doubleValue() + doubleValue.doubleValue(); workItemBean.setAttribute(activityType, parameterCode, Double.valueOf(newValue)); } } break; case FieldChangeSetters.ADD_OR_SET: if (doubleValue != null) { Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { double newValue = originalValue.doubleValue() + doubleValue.doubleValue(); workItemBean.setAttribute(activityType, parameterCode, new Double(newValue)); } else { workItemBean.setAttribute(activityType, parameterCode, doubleValue); } } break; } return null; }
From source file:com.jaspersoft.jasperserver.war.action.EditMondrianPropertiesAction.java
private String validate(String option, String value) { Integer test;/*from w w w .j a v a2 s .co m*/ if (option.equals("mondrian.query.limit") || option.equals("mondrian.rolap.evaluate.MaxEvalDepth") || option.equals("mondrian.result.highCardChunkSize") || option.equals("mondrian.rolap.SparseSegmentValueThreshold") || option.equals("mondrian.rolap.maxConstraints")) { try { test = new Integer(value); if (test.intValue() < 1) { return "JAM_049_ONE_OR_GREATER"; } } catch (Exception e) { log.debug(option + " invalid input"); return "JAM_019_WHOLE_NUMBER_ERROR"; } } else if (option.equals("mondrian.xmla.drillthroughMaxRows") || option.equals("mondrian.result.limit") || option.equals("mondrian.rolap.iterationLimit") || option.equals("mondrian.olap.fun.crossjoin.optimizer.size") || option.equals("mondrian.rolap.queryTimeout")) { try { test = new Integer(value); if (test.intValue() < 0) { return "JAM_048_ZERO_OR_GREATER"; } } catch (Exception e) { log.debug(option + " invalid input"); return "JAM_019_WHOLE_NUMBER_ERROR"; } } else if (option.equals("mondrian.rolap.SparseSegmentDensityThreshold")) { try { Double d = new Double(value); if (d.doubleValue() > 1.0 || d.doubleValue() < 0.0) { log.debug(option + " invalid input"); return "JAM_020_RATIO_NUMBER_ERROR"; } } catch (Exception e) { log.debug(option + " invalid input"); return "JAM_020_RATIO_NUMBER_ERROR"; } } else if (option.equals("mondrian.util.memoryMonitor.percentage.threshold")) { try { test = new Integer(value); if (test.intValue() < 1 || test.intValue() > 99) { return "JAM_050_ONE_TO_99"; } } catch (Exception e) { log.debug(option + " invalid input"); return "JAM_019_WHOLE_NUMBER_ERROR"; } } else if ((option.equals("mondrian.rolap.aggregates.jdbcFactoryClass") || option.equals("mondrian.util.MemoryMonitor.class") || option.equals("mondrian.calc.ExpCompiler.class")) && !value.trim().equals("null")) { try { Class.forName(value); } catch (Exception e) { log.debug(option + " invalid input"); return "JAM_051_INVALID_CLASS"; } } return null; }
From source file:org.apache.lucene.spatial.strategy.util.CachingDoubleValueSource.java
@Override public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException { final int base = readerContext.docBase; final FunctionValues vals = source.getValues(context, readerContext); return new FunctionValues() { @Override/*from w ww. j ava 2s . c o m*/ public double doubleVal(int doc) { Integer key = Integer.valueOf(base + doc); Double v = cache.get(key); if (v == null) { v = Double.valueOf(vals.doubleVal(doc)); cache.put(key, v); } return v.doubleValue(); } @Override public float floatVal(int doc) { return (float) doubleVal(doc); } @Override public String toString(int doc) { return doubleVal(doc) + ""; } }; }
From source file:org.apache.hadoop.mapred.gridmix.InputStriper.java
/** * @param inputDir Pool used to resolve block locations. * @param bytes Target byte count//from ww w . j a va 2 s.co m * @param nLocs Number of block locations per split. * @return A set of files satisfying the byte count, with locations weighted * to the dominating proportion of input bytes. */ CombineFileSplit splitFor(FilePool inputDir, long bytes, int nLocs) throws IOException { final ArrayList<Path> paths = new ArrayList<Path>(); final ArrayList<Long> start = new ArrayList<Long>(); final ArrayList<Long> length = new ArrayList<Long>(); final HashMap<String, Double> sb = new HashMap<String, Double>(); do { paths.add(current.getPath()); start.add(currentStart); final long fromFile = Math.min(bytes, current.getLen() - currentStart); length.add(fromFile); for (BlockLocation loc : inputDir.locationsFor(current, currentStart, fromFile)) { final double tedium = loc.getLength() / (1.0 * bytes); for (String l : loc.getHosts()) { Double j = sb.get(l); if (null == j) { sb.put(l, tedium); } else { sb.put(l, j.doubleValue() + tedium); } } } currentStart += fromFile; bytes -= fromFile; if (current.getLen() - currentStart == 0) { current = files.get(++idx % files.size()); currentStart = 0; } } while (bytes > 0); final ArrayList<Entry<String, Double>> sort = new ArrayList<Entry<String, Double>>(sb.entrySet()); Collections.sort(sort, hostRank); final String[] hosts = new String[Math.min(nLocs, sort.size())]; for (int i = 0; i < nLocs && i < sort.size(); ++i) { hosts[i] = sort.get(i).getKey(); } return new CombineFileSplit(paths.toArray(new Path[0]), toLongArray(start), toLongArray(length), hosts); }
From source file:de.atomfrede.tools.evalutation.evaluator.evaluators.CopyEvaluator.java
@Override public boolean evaluate() throws Exception { log.info("Copy Evaluator started"); // setup all solenoid valves of interest solenoidValvesOfInterest = new double[Options.getSolenoidValvesOfInterest().size()]; int k = 0;/*from w w w . j av a 2 s. co m*/ for (Double d : Options.getSolenoidValvesOfInterest()) { solenoidValvesOfInterest[k] = d.doubleValue(); k++; } CSVWriter writer = null; try { // create one output file outputFile = new File(outputFolder, "allLaserData.csv"); outputFile.createNewFile(); if (!outputFile.exists()) return false; // create the corresponding csv writer to write lines into the // output file writer = getCsvWriter(outputFile); // read all files in the input folder File[] allInputFiles = inputRootFolder.listFiles(); log.debug("#Files " + allInputFiles.length); String[] header = null; List<String[]> allLines = new ArrayList<String[]>(); for (int i = 0; i < allInputFiles.length; i++) { File inputFile = allInputFiles[i]; progressBar.setValue((int) ((i * 1.0 / allInputFiles.length) * 100.0)); if (inputFile.isFile()) { // read all lines and write them to the new file List<String[]> currentLines = readAllLinesInFile(inputFile); if (currentLines.get(0).length == 1) { // if the length of the current line is equal to 1, the // input files are not separated by comma // instead by a fixed width. Preprocess the file so it // is a nice comma separated file PreProcessor.replaceWhiteSpacesWithComma(inputFile); currentLines = readAllLinesInFile(inputFile); } // if there is no header use the first line if (header == null) { header = currentLines.get(0); ColumnCheckUtil.checkInputFileHeader(header); } // then remove it, because we don't need the header of the // other files anymore currentLines.remove(0); for (int j = 1; j < currentLines.size(); j++) { String[] currentLine = currentLines.get(j); double solenoidValue = parseDoubleValue(currentLine, InputFileConstants.SOLENOID_VALVE_INPUT); // only add the interesting solenoid valves if (ArrayUtils.contains(solenoidValvesOfInterest, solenoidValue)) { allLines.add(currentLine); } } } } // sort all lines Collections.sort(allLines, new EntryComparator()); // add the header as first line allLines.add(0, header); // write all lines to output file writer.writeAll(allLines); progressBar.setValue(100); } catch (IOException ioe) { log.error(ioe); DialogUtil.getInstance().showError(ioe); return false; } catch (Exception e) { log.error(e); DialogUtil.getInstance().showError(e); return false; } finally { if (writer != null) writer.close(); } log.info("Copy Evaluator Done."); return true; }