List of usage examples for java.lang Boolean Boolean
@Deprecated(since = "9") public Boolean(String s)
From source file:org.apache.synapse.rest.API.java
boolean canProcess(MessageContext synCtx) { if (synCtx.isResponse()) { String apiName = (String) synCtx.getProperty(RESTConstants.SYNAPSE_REST_API); String version = synCtx.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION) == null ? "" : (String) synCtx.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION); //if api name is not matching OR versions are different if (!getName().equals(apiName) || !versionStrategy.getVersion().equals(version)) { return false; }/*from w w w. j a v a 2 s. c o m*/ } else { String path = RESTUtils.getFullRequestPath(synCtx); if (!path.startsWith(context + "/") && !path.startsWith(context + "?") && !context.equals(path) && !"/".equals(context)) { auditDebug("API context: " + context + " does not match request URI: " + path); return false; } if (!versionStrategy.isMatchingVersion(synCtx)) { return false; } org.apache.axis2.context.MessageContext msgCtx = ((Axis2MessageContext) synCtx) .getAxis2MessageContext(); if (host != null || port != -1) { String hostHeader = getHostHeader(msgCtx); if (hostHeader != null) { if (host != null && !host.equals(extractHostName(hostHeader))) { auditDebug("API host: " + host + " does not match host information " + "in the request: " + hostHeader); return false; } if (port != -1 && port != extractPortNumber(hostHeader, msgCtx.getIncomingTransportName())) { auditDebug("API port: " + port + " does not match port information " + "in the request: " + hostHeader); return false; } } else { auditDebug("Host information not available on the message"); return false; } } if (protocol == RESTConstants.PROTOCOL_HTTP_ONLY && !Constants.TRANSPORT_HTTP.equals(msgCtx.getIncomingTransportName())) { if (log.isDebugEnabled()) { log.debug("Protocol information does not match - Expected HTTP"); } synCtx.setProperty(SynapseConstants.TRANSPORT_DENIED, new Boolean(true)); synCtx.setProperty(SynapseConstants.IN_TRANSPORT, msgCtx.getTransportIn().getName()); log.warn("Trying to access API : " + name + " on restricted transport chanel [" + msgCtx.getTransportIn().getName() + "]"); return false; } if (protocol == RESTConstants.PROTOCOL_HTTPS_ONLY && !Constants.TRANSPORT_HTTPS.equals(msgCtx.getIncomingTransportName())) { if (log.isDebugEnabled()) { log.debug("Protocol information does not match - Expected HTTPS"); } synCtx.setProperty(SynapseConstants.TRANSPORT_DENIED, new Boolean(true)); synCtx.setProperty(SynapseConstants.IN_TRANSPORT, msgCtx.getTransportIn().getName()); log.warn("Trying to access API : " + name + " on restricted transport chanel [" + msgCtx.getTransportIn().getName() + "]"); return false; } } return true; }
From source file:com.redhat.rhn.common.conf.test.ConfigTest.java
public void testSetBoolean() throws Exception { boolean oldValue = c.getBoolean("prefix.boolean_true"); c.setBoolean("prefix.boolean_true", Boolean.FALSE.toString()); assertFalse(c.getBoolean("prefix.boolean_true")); assertEquals("0", c.getString("prefix.boolean_true")); c.setBoolean("prefix.boolean_true", new Boolean(oldValue).toString()); }
From source file:fi.aalto.seqpig.filter.MappabilityFilter.java
public MappabilityFilter(String mappability_threshold_s) throws Exception { double mappability_threshold = Double.parseDouble(mappability_threshold_s); Configuration conf = UDFContext.getUDFContext().getJobConf(); // see https://issues.apache.org/jira/browse/PIG-2576 if (conf == null || conf.get("mapred.task.id") == null) { // we are running on the frontend //decodeSAMFileHeader(); return;/*from w w w . j a v a 2 s. c o m*/ } if (samfileheader == null) { this.samfileheader = ""; try { FileSystem fs = FileSystem.getLocal(conf); BufferedReader headerin = new BufferedReader( new InputStreamReader(fs.open(new Path("input_asciiheader")))); while (true) { String str = headerin.readLine(); if (str == null) break; else this.samfileheader += str + "\n"; } headerin.close(); if (this.samfileheader.equals("")) { int errCode = 0; String errMsg = "MappabilityFilter: unable to read samfileheader from distributed cache!"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT); } else { String msg = "successfully read samfileheader"; warn(msg, PigWarning.UDF_WARNING_1); this.samfileheader_decoded = getSAMFileHeader(); } } catch (Exception e) { String errMsg = "MappabilityFilter: ERROR: could not read BAM header: " + e.toString(); int errCode = 0; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT); } } if (regions == null) { regions = new TreeMap<RegionEntry, Boolean>(); try { FileSystem fs = FileSystem.getLocal(conf); // this was required before creating symlinks to files in the distributed cache /*Path[] cacheFiles = DistributedCache.getLocalCacheFiles(conf); for (Path cachePath : cacheFiles) { String msg = "found cache file: "+cachePath.getName(); warn(msg, PigWarning.UDF_WARNING_1); if (cachePath.getName().equals("input_regionfile")) { BufferedReader regionin = new BufferedReader(new InputStreamReader(fs.open( cachePath ))); BufferedReader regionin = new BufferedReader(new InputStreamReader(fs.open(new Path(fs.getHomeDirectory(), new Path(regionfilename)))));'*/ BufferedReader regionin = new BufferedReader( new InputStreamReader(fs.open(new Path("./input_regionfile")))); regionin.readLine(); // throw away first line that describes colums while (true) { String str = regionin.readLine(); if (str == null) break; else { String[] region_data = str.split("\t"); if (region_data[0] == null || region_data[1] == null || region_data[2] == null || region_data[3] == null) { int errCode = 0; String errMsg = "MappabilityFilter: Error while reading region file input"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT); } if (Double.parseDouble(region_data[3]) >= mappability_threshold) { int start = parseCoordinate(region_data[1]); int end = parseCoordinate(region_data[2]); if (end < start) { int errCode = 0; String errMsg = "MappabilityFilter: Error while reading region file input"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT); } if (region_size < 0) { region_size = end - start + 1; warn("setting region size to " + Integer.toString(region_size), PigWarning.UDF_WARNING_1); } SAMSequenceRecord ref = samfileheader_decoded.getSequence(region_data[0]); if (ref == null) try { ref = samfileheader_decoded.getSequence(Integer.parseInt(region_data[0])); } catch (NumberFormatException e) { warn(new String("unable to parse region entry!"), PigWarning.UDF_WARNING_1); } if (ref == null) { int errCode = 0; String errMsg = "MappabilityFilter: Unable find sequence record for region: " + str; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT); } RegionEntry e = new RegionEntry(ref.getSequenceIndex(), start, end); regions.put(e, new Boolean(true)); } } } regionin.close(); String msg = "successfully read region file with " + regions.size() + " regions"; warn(msg, PigWarning.UDF_WARNING_1); } catch (Exception e) { String errMsg = "MappabilityFilter: ERROR: could not region file: " + e.toString(); int errCode = 0; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT); } } }
From source file:com.alkacon.opencms.excelimport.CmsResourceExcelImport.java
/** * Returns if security dialog should appear.<p> * /*from w w w .j a v a 2 s .co m*/ * @return true, if security dialog should appear, otherwise false */ public boolean useConfirmationDialog() { boolean security = true; // get the module CmsModule module = OpenCms.getModuleManager().getModule(CmsExcelImport.MODULE_NAME); if (module != null) { String securityString = module.getParameter("securitydialog"); security = new Boolean(securityString).booleanValue(); } return security; }
From source file:org.openmrs.module.birt.report.renderer.BirtPdfTemplateRenderer.java
/** * Generate a report based on the attributes of the given report object. * /*from www.j a v a2s .co m*/ * @param report the report to generate */ public void executeReport(BirtReport report) { //log.debug("Generating output for report " + designResource + ", hashcode " + designResource.hashCode()); IRunAndRenderTask task = null; try { // Get the report engine that will be used to render the report IReportEngine engine = BirtConfiguration.getReportEngine(); // Open the report design IReportRunnable reportRunnable = engine.openReportDesign(report.getReportDesignPath()); // Create a report rendering task task = engine.createRunAndRenderTask(reportRunnable); //task.setParameterValues(null); // Validate runtime parameters task.validateParameters(); //task.setRenderOption(BirtConfiguration.getRenderOption(report)); PDFRenderOption options = new PDFRenderOption(); options.setOutputFileName(report.getOutputFilename()); options.setOutputFormat(report.getOutputFormat()); options.setOption(IPDFRenderOption.FIT_TO_PAGE, new Boolean(true)); options.setOption(IPDFRenderOption.PAGEBREAK_PAGINATION_ONLY, new Boolean(true)); task.setRenderOption(options); //task.setRenderOption(BirtConfiguration.getRenderOption(report)); // Render report design task.run(); //engine.destroy(); //log.debug("Output file: " + report.getOutputFile().getAbsolutePath()); } catch (EngineException e) { log.error("Unable to generate report due to a BIRT Exception: " + e.getMessage(), e); throw new BirtReportException("Unable to generate report due to a BIRT Exception: " + e.getMessage(), e); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (task != null) task.close(); } }
From source file:edu.hawaii.soest.hioos.isus.ISUSSource.java
/** * A method that processes the data object passed and flushes the * data to the DataTurbine given the sensor properties in the XMLConfiguration * passed in.// w w w . j a v a 2 s . c o m * * @param xmlConfig - the XMLConfiguration object containing the list of * sensor properties * @param frameMap - the parsed data as a HierarchicalMap object */ public boolean process(XMLConfiguration xmlConfig, HierarchicalMap frameMap) { logger.debug("ISUSSource.process() called."); // do not execute the stream if there is no connection if (!isConnected()) return false; boolean success = false; try { // add channels of data that will be pushed to the server. // Each sample will be sent to the Data Turbine as an rbnb frame. Information // on each channel is found in the XMLConfiguration file (email.account.properties.xml) // and the StorXParser object (to get the data string) ChannelMap rbnbChannelMap = new ChannelMap(); // used to flush channels ChannelMap registerChannelMap = new ChannelMap(); // used to register channels int channelIndex = 0; String sensorName = null; String sensorSerialNumber = null; String sensorDescription = null; boolean isImmersed = false; String[] calibrationURLs = null; String calibrationURL = null; String type = null; List sensorList = xmlConfig.configurationsAt("account.logger.sensor"); for (Iterator sIterator = sensorList.iterator(); sIterator.hasNext();) { // HierarchicalConfiguration sensorConfig = (HierarchicalConfiguration) sIterator.next(); sensorSerialNumber = sensorConfig.getString("serialNumber"); // find the correct sensor configuration properties if (sensorSerialNumber.equals(frameMap.get("serialNumber"))) { sensorName = sensorConfig.getString("name"); sensorDescription = sensorConfig.getString("description"); isImmersed = new Boolean(sensorConfig.getString("isImmersed")).booleanValue(); calibrationURLs = sensorConfig.getStringArray("calibrationURL"); type = (String) frameMap.get("type"); // find the correct calibrationURL from the list given the type for (String url : calibrationURLs) { if (url.indexOf(type) > 0) { calibrationURL = url; break; } else { logger.debug("There was no match for " + type); } } // get a Calibration instance to interpret raw sensor values Calibration calibration = new Calibration(); if (calibration.parse(calibrationURL)) { // Build the RBNB channel map // get the sample date and convert it to seconds since the epoch Date frameDate = (Date) frameMap.get("date"); Calendar frameDateTime = Calendar.getInstance(); frameDateTime.setTime(frameDate); double sampleTimeAsSecondsSinceEpoch = (double) (frameDateTime.getTimeInMillis() / 1000); // and create a string formatted date for the given time zone DATE_FORMAT.setTimeZone(TZ); String frameDateAsString = DATE_FORMAT.format(frameDate).toString(); // get the sample data from the frame map ByteBuffer rawFrame = (ByteBuffer) frameMap.get("rawFrame"); ISUSFrame isusFrame = (ISUSFrame) frameMap.get("parsedFrameObject"); String serialNumber = isusFrame.getSerialNumber(); String sampleDate = isusFrame.getSampleDate(); String sampleTime = isusFrame.getSampleTime(); SimpleDateFormat dtFormat = new SimpleDateFormat(); Date sampleDateTime = isusFrame.getSampleDateTime(); dtFormat.setTimeZone(TimeZone.getTimeZone("UTC")); dtFormat.applyPattern("MM/dd/yy"); String sampleDateUTC = dtFormat.format(sampleDateTime); dtFormat.applyPattern("HH:mm:ss"); String sampleTimeUTC = dtFormat.format(sampleDateTime); dtFormat.setTimeZone(TimeZone.getTimeZone("HST")); dtFormat.applyPattern("MM/dd/yy"); String sampleDateHST = dtFormat.format(sampleDateTime); dtFormat.applyPattern("HH:mm:ss"); String sampleTimeHST = dtFormat.format(sampleDateTime); dtFormat.applyPattern("dd-MMM-yy HH:mm"); String sampleDateTimeHST = dtFormat.format(sampleDateTime); double rawNitrogenConcentration = isusFrame.getNitrogenConcentration(); double rawAuxConcentration1 = isusFrame.getAuxConcentration1(); double rawAuxConcentration2 = isusFrame.getAuxConcentration2(); double rawAuxConcentration3 = isusFrame.getAuxConcentration3(); double rawRmsError = isusFrame.getRmsError(); double rawInsideTemperature = isusFrame.getInsideTemperature(); double rawSpectrometerTemperature = isusFrame.getSpectrometerTemperature(); double rawLampTemperature = isusFrame.getLampTemperature(); int rawLampTime = isusFrame.getLampTime(); double rawHumidity = isusFrame.getHumidity(); double rawLampVoltage12 = isusFrame.getLampVoltage12(); double rawInternalPowerVoltage5 = isusFrame.getInternalPowerVoltage5(); double rawMainPowerVoltage = isusFrame.getMainPowerVoltage(); double rawReferenceAverage = isusFrame.getReferenceAverage(); double rawReferenceVariance = isusFrame.getReferenceVariance(); double rawSeaWaterDarkCounts = isusFrame.getSeaWaterDarkCounts(); double rawSpectrometerAverage = isusFrame.getSpectrometerAverage(); int checksum = isusFrame.getChecksum(); //// apply calibrations to the observed data double nitrogenConcentration = calibration.apply(rawNitrogenConcentration, isImmersed, "NITRATE"); double auxConcentration1 = calibration.apply(rawAuxConcentration1, isImmersed, "AUX1"); double auxConcentration2 = calibration.apply(rawAuxConcentration2, isImmersed, "AUX2"); double auxConcentration3 = calibration.apply(rawAuxConcentration3, isImmersed, "AUX3"); double rmsError = calibration.apply(rawRmsError, isImmersed, "RMSe"); double insideTemperature = calibration.apply(rawInsideTemperature, isImmersed, "T_INT"); double spectrometerTemperature = calibration.apply(rawSpectrometerTemperature, isImmersed, "T_SPEC"); double lampTemperature = calibration.apply(rawLampTemperature, isImmersed, "T_LAMP"); int lampTime = rawLampTime; double humidity = calibration.apply(rawHumidity, isImmersed, "HUMIDITY"); double lampVoltage12 = calibration.apply(rawLampVoltage12, isImmersed, "VOLT_12"); double internalPowerVoltage5 = calibration.apply(rawInternalPowerVoltage5, isImmersed, "VOLT_5"); double mainPowerVoltage = calibration.apply(rawMainPowerVoltage, isImmersed, "VOLT_MAIN"); double referenceAverage = calibration.apply(rawReferenceAverage, isImmersed, "REF_AVG"); double referenceVariance = calibration.apply(rawReferenceVariance, isImmersed, "REF_STD"); double seaWaterDarkCounts = calibration.apply(rawSeaWaterDarkCounts, isImmersed, "SW_DARK"); double spectrometerAverage = calibration.apply(rawSpectrometerAverage, isImmersed, "SPEC_AVG"); // iterate through the individual wavelengths List<String> variableNames = calibration.getVariableNames(); TreeMap<String, Double> wavelengthsMap = new TreeMap<String, Double>(); Collections.sort(variableNames); int rawWavelengthCounts = 0; int count = 1; for (String name : variableNames) { // just handle the wavelength channels if (name.startsWith("UV_")) { rawWavelengthCounts = isusFrame.getChannelWavelengthCounts(count); double value = calibration.apply(rawWavelengthCounts, isImmersed, name); count++; wavelengthsMap.put(name, new Double(value)); } } String sampleString = ""; sampleString += sampleDate + "\t"; sampleString += sampleDateUTC + "\t"; sampleString += sampleTime + "\t"; sampleString += sampleTimeUTC + "\t"; sampleString += sampleDateHST + "\t"; sampleString += sampleTimeHST + "\t"; sampleString += sampleDateTimeHST + "\t"; sampleString += String.format("%-15.11f", nitrogenConcentration) + "\t"; //sampleString += String.format("%15.11f", auxConcentration1) + "\t"; //sampleString += String.format("%15.11f", auxConcentration2) + "\t"; //sampleString += String.format("%15.11f", auxConcentration3) + "\t"; sampleString += String.format("%15.11f", rmsError) + "\t"; sampleString += String.format("%15.11f", insideTemperature) + "\t"; sampleString += String.format("%15.11f", spectrometerTemperature) + "\t"; sampleString += String.format("%15.11f", lampTemperature) + "\t"; sampleString += String.format("%6d", lampTime) + "\t"; sampleString += String.format("%15.11f", humidity) + "\t"; sampleString += String.format("%15.11f", lampVoltage12) + "\t"; sampleString += String.format("%15.11f", internalPowerVoltage5) + "\t"; sampleString += String.format("%15.11f", mainPowerVoltage) + "\t"; sampleString += String.format("%15.11f", referenceAverage) + "\t"; sampleString += String.format("%15.11f", referenceVariance) + "\t"; sampleString += String.format("%15.11f", seaWaterDarkCounts) + "\t"; sampleString += String.format("%15.11f", spectrometerAverage) + "\t"; Set<String> wavelengths = wavelengthsMap.keySet(); Iterator wIterator = wavelengths.iterator(); while (wIterator.hasNext()) { String name = (String) wIterator.next(); Double wavelengthValue = (Double) wavelengthsMap.get(name); sampleString += String.format("%6d", wavelengthValue.intValue()) + "\t"; channelIndex = registerChannelMap.Add(name); registerChannelMap.PutUserInfo(channelIndex, "units=counts"); channelIndex = rbnbChannelMap.Add(name); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { wavelengthValue.doubleValue() }); } sampleString += String.format("%03d", checksum); sampleString += "\n"; // add the sample timestamp to the rbnb channel map //registerChannelMap.PutTime(sampleTimeAsSecondsSinceEpoch, 0d); rbnbChannelMap.PutTime(sampleTimeAsSecondsSinceEpoch, 0d); // add the BinaryRawSatlanticFrameData channel to the channelMap channelIndex = registerChannelMap.Add("BinaryRawSatlanticFrameData"); registerChannelMap.PutUserInfo(channelIndex, "units=none"); channelIndex = rbnbChannelMap.Add("BinaryRawSatlanticFrameData"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsByteArray(channelIndex, rawFrame.array()); // add the DecimalASCIISampleData channel to the channelMap channelIndex = registerChannelMap.Add(getRBNBChannelName()); registerChannelMap.PutUserInfo(channelIndex, "units=none"); channelIndex = rbnbChannelMap.Add(getRBNBChannelName()); rbnbChannelMap.PutMime(channelIndex, "text/plain"); rbnbChannelMap.PutDataAsString(channelIndex, sampleString); // add the serialNumber channel to the channelMap channelIndex = registerChannelMap.Add("serialNumber"); registerChannelMap.PutUserInfo(channelIndex, "units=none"); channelIndex = rbnbChannelMap.Add("serialNumber"); rbnbChannelMap.PutMime(channelIndex, "text/plain"); rbnbChannelMap.PutDataAsString(channelIndex, serialNumber); // add the sampleDateUTC channel to the channelMap channelIndex = registerChannelMap.Add("sampleDateUTC"); registerChannelMap.PutUserInfo(channelIndex, "units=YYYYDDD"); channelIndex = rbnbChannelMap.Add("sampleDateUTC"); rbnbChannelMap.PutMime(channelIndex, "text/plain"); rbnbChannelMap.PutDataAsString(channelIndex, sampleDate); // add the sampleTimeUTC channel to the channelMap channelIndex = registerChannelMap.Add("sampleTimeUTC"); registerChannelMap.PutUserInfo(channelIndex, "units=hh.hhhhhh"); channelIndex = rbnbChannelMap.Add("sampleTimeUTC"); rbnbChannelMap.PutMime(channelIndex, "text/plain"); rbnbChannelMap.PutDataAsString(channelIndex, sampleTimeUTC); // add the nitrogenConcentration channel to the channelMap channelIndex = registerChannelMap.Add("nitrogenConcentration"); registerChannelMap.PutUserInfo(channelIndex, "units=uM"); channelIndex = rbnbChannelMap.Add("nitrogenConcentration"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { nitrogenConcentration }); // add the auxConcentration1 channel to the channelMap channelIndex = registerChannelMap.Add("auxConcentration1"); registerChannelMap.PutUserInfo(channelIndex, "units=none"); channelIndex = rbnbChannelMap.Add("auxConcentration1"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { auxConcentration1 }); // add the auxConcentration3 channel to the channelMap channelIndex = registerChannelMap.Add("auxConcentration2"); registerChannelMap.PutUserInfo(channelIndex, "units=none"); channelIndex = rbnbChannelMap.Add("auxConcentration2"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { auxConcentration2 }); // add the serialNumber channel to the channelMap channelIndex = registerChannelMap.Add("auxConcentration3"); registerChannelMap.PutUserInfo(channelIndex, "units=none"); channelIndex = rbnbChannelMap.Add("auxConcentration3"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { auxConcentration3 }); // add the rmsError channel to the channelMap channelIndex = registerChannelMap.Add("rmsError"); registerChannelMap.PutUserInfo(channelIndex, "units=none"); channelIndex = rbnbChannelMap.Add("rmsError"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { rmsError }); // add the insideTemperature channel to the channelMap channelIndex = registerChannelMap.Add("insideTemperature"); registerChannelMap.PutUserInfo(channelIndex, "units=Celsius"); channelIndex = rbnbChannelMap.Add("insideTemperature"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { insideTemperature }); // add the spectrometerTemperature channel to the channelMap channelIndex = registerChannelMap.Add("spectrometerTemperature"); registerChannelMap.PutUserInfo(channelIndex, "units=Celsius"); channelIndex = rbnbChannelMap.Add("spectrometerTemperature"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { spectrometerTemperature }); // add the lampTemperature channel to the channelMap channelIndex = registerChannelMap.Add("lampTemperature"); registerChannelMap.PutUserInfo(channelIndex, "units=Celsius"); channelIndex = rbnbChannelMap.Add("lampTemperature"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { lampTemperature }); // add the lampTime channel to the channelMap channelIndex = registerChannelMap.Add("lampTime"); registerChannelMap.PutUserInfo(channelIndex, "units=seconds"); channelIndex = rbnbChannelMap.Add("lampTime"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsInt32(channelIndex, new int[] { lampTime }); // add the humidity channel to the channelMap channelIndex = registerChannelMap.Add("humidity"); registerChannelMap.PutUserInfo(channelIndex, "units=%"); channelIndex = rbnbChannelMap.Add("humidity"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { humidity }); // add the lampVoltage12 channel to the channelMap channelIndex = registerChannelMap.Add("lampVoltage12"); registerChannelMap.PutUserInfo(channelIndex, "units=V"); channelIndex = rbnbChannelMap.Add("lampVoltage12"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { lampVoltage12 }); // add the internalPowerVoltage5 channel to the channelMap channelIndex = registerChannelMap.Add("internalPowerVoltage5"); registerChannelMap.PutUserInfo(channelIndex, "units=V"); channelIndex = rbnbChannelMap.Add("internalPowerVoltage5"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { internalPowerVoltage5 }); // add the mainPowerVoltage channel to the channelMap channelIndex = registerChannelMap.Add("mainPowerVoltage"); registerChannelMap.PutUserInfo(channelIndex, "units=V"); channelIndex = rbnbChannelMap.Add("mainPowerVoltage"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { mainPowerVoltage }); // add the referenceAverage channel to the channelMap channelIndex = registerChannelMap.Add("referenceAverage"); registerChannelMap.PutUserInfo(channelIndex, "units=count"); channelIndex = rbnbChannelMap.Add("referenceAverage"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { referenceAverage }); // add the referenceVariance channel to the channelMap channelIndex = registerChannelMap.Add("referenceVariance"); registerChannelMap.PutUserInfo(channelIndex, "units=count"); channelIndex = rbnbChannelMap.Add("referenceVariance"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { referenceVariance }); // add the seaWaterDarkCounts channel to the channelMap channelIndex = registerChannelMap.Add("seaWaterDarkCounts"); registerChannelMap.PutUserInfo(channelIndex, "units=count"); channelIndex = rbnbChannelMap.Add("seaWaterDarkCounts"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { seaWaterDarkCounts }); // add the spectrometerAverage channel to the channelMap channelIndex = registerChannelMap.Add("spectrometerAverage"); registerChannelMap.PutUserInfo(channelIndex, "units=count"); channelIndex = rbnbChannelMap.Add("averageWavelength"); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { spectrometerAverage }); // Now register the RBNB channels, and flush the rbnbChannelMap to the // DataTurbine getSource().Register(registerChannelMap); getSource().Flush(rbnbChannelMap); logger.info(frameDateAsString + " " + "Sample sent to the DataTurbine: (" + serialNumber + ") " + sampleString); registerChannelMap.Clear(); rbnbChannelMap.Clear(); } else { logger.info("Couldn't apply the calibration coefficients. " + "Skipping this sample."); } // end if() } // end if() } // end for() //getSource.Detach(); success = true; } catch (ParseException pe) { // parsing of the calibration file failed. Log the exception, return false success = false; logger.debug("There was a problem parsing the calibration file. The " + "error message was: " + pe.getMessage()); return success; } catch (SAPIException sapie) { // In the event of an RBNB communication exception, log the exception, // and allow execute() to return false, which will prompt a retry. success = false; sapie.printStackTrace(); return success; } return success; }
From source file:com.prowidesoftware.swift.model.SwiftBlock.java
/** * Only valid for block2, only when using hibernate for persistence * @return <code>true</code> if message block type is <code>2O</code> * @deprecated use {@link #getBlockType()} *//* w w w. ja va2 s. c o m*/ public Boolean getOutput() { return new Boolean(StringUtils.equals(getBlockType(), "2O")); }
From source file:com.duroty.application.admin.utils.AdminDefaultAction.java
/** * DOCUMENT ME!/*from www . java2 s .c o m*/ * * @param request DOCUMENT ME! * @param response DOCUMENT ME! * * @return DOCUMENT ME! * * @throws LanguageControlException DOCUMENT ME! */ protected Locale languageControl(HttpServletRequest request, HttpServletResponse response) throws LanguageControlException { Preferences preferences = null; String language = null; String name = Configuration.properties.getProperty(Configuration.COOKIE_LANGUAGE); int maxAge = Integer.parseInt(Configuration.properties.getProperty(Configuration.COOKIE_MAX_AGE)); Cookie cookie = CookieManager.getCookie(name, request); if (cookie != null) { language = cookie.getValue(); cookie.setMaxAge(maxAge); CookieManager.setCookie("/", cookie, response); } else { } try { preferences = getPreferencesInstance(request); language = preferences.getPreferences().getLanguage(); } catch (RemoteException e) { } catch (NamingException e) { } catch (CreateException e) { } catch (MailException e) { } Boolean b = new Boolean(Configuration.properties.getProperty(Configuration.AUTO_LOCALE)); boolean autoLocale = b.booleanValue(); if (language == null) { if (!autoLocale) { throw new LanguageControlException("Choose Language. The language is empty", null); } else { language = Configuration.properties.getProperty(Configuration.DEFAULT_LANGUAGE); } } cookie = new Cookie(name, language); cookie.setMaxAge(maxAge); CookieManager.setCookie("/", cookie, response); return new Locale(language); }
From source file:de.ipk_gatersleben.ag_pbi.mmd.visualisations.gradient.GradientDataChartComponent.java
private JFreeChart createChart(GradientCharts gc, IntervalXYDataset dataset, ChartOptions co) { MyNumberAxis numberaxis = new MyNumberAxis(co.domainAxis); NumberAxis numberaxis1 = new NumberAxis(co.rangeAxis); XYPlot xyplot = null;//from w ww. j av a 2s . c o m JFreeChart jfreechart = null; switch (gc) { case LINEGRADIENT: MyXYErrorRenderer xyerrorrenderer = new MyXYErrorRenderer(); xyerrorrenderer.setBaseLinesVisible(co.showLines); xyerrorrenderer.setBaseShapesVisible(co.showShapes); xyerrorrenderer.setDrawYError(co.showStdDevAsT); xyerrorrenderer.setCapLength(co.stdDevTopWidth); xyerrorrenderer.setDrawStdDevAsFillRange(co.showStdDevAsFillRange); xyplot = new XYPlot(dataset, numberaxis, numberaxis1, xyerrorrenderer); if (co.stdDevLineWidth >= 0 && co.showStdDevAsT) { xyerrorrenderer.setErrorStroke(new BasicStroke(co.stdDevLineWidth)); } else { xyerrorrenderer.setErrorPaint(new Color(0, 0, 0, 0)); } // set the line width for (int i = 0; i < dataset.getSeriesCount(); i++) xyerrorrenderer.setSeriesStroke(i, new BasicStroke(co.outlineBorderWidth)); break; case BARGRADIENT: XYBarRenderer xybarrenderer = new XYBarRenderer(); xybarrenderer.setShadowVisible(false); xyplot = new XYPlot(dataset, numberaxis, numberaxis1, xybarrenderer); // this is an linechart6 attribute and barcharts have usually an errorbar XYErrorRenderer xyerrorrenderer2 = new XYErrorRenderer(); xyerrorrenderer2.setDrawYError(true); xyerrorrenderer2.setDrawXError(false); xyerrorrenderer2.setBaseSeriesVisibleInLegend(false); xyerrorrenderer2.setCapLength(co.stdDevTopWidth); xyerrorrenderer2.setBaseShapesVisible(false); xyplot.setRenderer(1, xyerrorrenderer2); xyplot.setDataset(1, dataset); Range bounds = xyplot.getRenderer(1).findRangeBounds(dataset); if (bounds != null) { if (!co.showOnlyHalfErrorBar) { xyplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // fit the RangeAxis to the errorbars xyplot.getRangeAxis().setLowerBound(bounds.getLowerBound()); } // fit the RangeAxis to the errorbars xyplot.getRangeAxis().setUpperBound(bounds.getUpperBound()); } if (co.stdDevLineWidth >= 0) { xyerrorrenderer2.setErrorStroke(new BasicStroke(co.stdDevLineWidth)); } dataset = new XYBarDataset(dataset, calculateBarWidth(dataset)); xyplot.setDataset(dataset); break; } jfreechart = new JFreeChart(null, xyplot); jfreechart.setAntiAlias(true); jfreechart.setTextAntiAlias(true); /************************************/ // plot orientation if (co.orientation.equals(org.jfree.chart.plot.PlotOrientation.HORIZONTAL)) { xyplot.setOrientation(PlotOrientation.HORIZONTAL); } else { xyplot.setOrientation(PlotOrientation.VERTICAL); numberaxis.setTickLabelAngle(-co.axisRotation * Math.PI / 180); } // chart background color if (NodeTools.getCategoryBackgroundColorB(co.ge.getGraph(), Color.WHITE).equals(Color.BLACK) && xyplot.getBackgroundPaint().getTransparency() == 1.0f) { xyplot.setBackgroundAlpha(0.0f); } else { xyplot.setBackgroundPaint(NodeTools.getCategoryBackgroundColorB(co.ge.getGraph(), Color.WHITE)); } if (co.useLogYscale) xyplot.setRangeAxis(new LogarithmicAxis(co.rangeAxis)); // specify ticks of x (domain) and y (range) axis if (co.useCustomRangeSteps) { NumberAxis na = (NumberAxis) xyplot.getRangeAxis(); NumberTickUnit unit = new NumberTickUnit(co.customRangeSteps); na.setTickUnit(unit, false, true); } boolean useCustomDomainSteps = ((Boolean) AttributeHelper.getAttributeValue(co.ge, "charting", "useCustomDomainSteps", new Boolean(false), new Boolean(false))).booleanValue(); double customStepSize = (Double) AttributeHelper.getAttributeValue(co.ge, "charting", "customDomainStepSize", new Double(300d), new Double(300d)); if (useCustomDomainSteps) { NumberAxis na = (NumberAxis) xyplot.getDomainAxis(); NumberTickUnit unit = new NumberTickUnit(customStepSize); na.setTickUnit(unit, false, true); } // specify lower and upper bounds boolean useCustomRange = ((Boolean) AttributeHelper.getAttributeValue(co.ge, "charting", "useCustomDomainBounds", new Boolean(false), new Boolean(false))).booleanValue(); double lowerBound = (Double) AttributeHelper.getAttributeValue(co.ge, "charting", "minBoundDomain", new Double(0d), new Double(0d)); double upperBound = (Double) AttributeHelper.getAttributeValue(co.ge, "charting", "maxBoundDomain", new Double(100d), new Double(100d)); if (!useCustomRange) { lowerBound = Double.NaN; upperBound = Double.NaN; } if (!Double.isNaN(lowerBound)) xyplot.getDomainAxis().setLowerBound(lowerBound); if (!Double.isNaN(upperBound)) xyplot.getDomainAxis().setUpperBound(upperBound); if (!Double.isNaN(co.lowerBound)) { xyplot.getRangeAxis().setLowerBound(co.lowerBound); } if (!Double.isNaN(co.upperBound)) xyplot.getRangeAxis().setUpperBound(co.upperBound); AbstractXYItemRenderer renderer = null; if (xyplot.getRenderer() instanceof XYBarRenderer) { renderer = (XYBarRenderer) xyplot.getRenderer(); } if (xyplot.getRenderer() instanceof XYErrorRenderer) { renderer = (XYErrorRenderer) xyplot.getRenderer(); } renderer.setBaseSeriesVisibleInLegend(co.showLegend); if (co.outlineBorderWidth > 0) { for (int i = 0; i < dataset.getSeriesCount(); i++) renderer.setSeriesOutlineStroke(i, new BasicStroke(co.outlineBorderWidth)); } if (co.shapeSize > 0) { Rectangle2D rect = new Rectangle2D.Double(-co.shapeSize / 4, -co.shapeSize / 4, co.shapeSize / 2, co.shapeSize / 2); if (renderer instanceof XYBarRenderer) { for (int i = 0; i < dataset.getSeriesCount(); i++) xyplot.getRenderer(1).setSeriesShape(i, rect); } if (renderer instanceof XYErrorRenderer) { for (int i = 0; i < dataset.getSeriesCount(); i++) renderer.setSeriesShape(i, rect); } } xyplot.getRangeAxis().setVisible(co.showRangeAxis); xyplot.getDomainAxis().setVisible(co.showCategoryAxis); ChartColorAttribute chartColorAttribute = (ChartColorAttribute) AttributeHelper.getAttributeValue(co.graph, ChartColorAttribute.attributeFolder, ChartColorAttribute.attributeName, new ChartColorAttribute(), new ChartColorAttribute()); // set the color series List<String> names = new ArrayList<String>(); for (int i = 0; i < dataset.getSeriesCount(); i++) names.add((dataset.getSeriesKey(i)).toString()); if (names.size() > 0) { ArrayList<Color> colors1 = chartColorAttribute.getSeriesColors(names); ArrayList<Color> colors2 = chartColorAttribute.getSeriesOutlineColors(names); int i = 0; for (Color c1 : colors1) renderer.setSeriesPaint(i++, c1); i = 0; for (Color c2 : colors2) if (xyplot.getRenderer() instanceof XYBarRenderer) { ((XYBarRenderer) renderer).setDrawBarOutline(true);// ((XYErrorRenderer) xyplot.getRenderer(1)).setSeriesPaint(i++, c2); } } jfreechart.setBackgroundPaint(null); renderer.getPlot().setDomainGridlinesVisible(co.showGridCategory); renderer.getPlot().setRangeGridlinesVisible(co.showGridRange); renderer.getPlot().setOutlinePaint(null); if (co.showGridCategory) renderer.getPlot().setDomainGridlineStroke(new BasicStroke((float) co.gridWidth)); if (co.showGridRange) renderer.getPlot().setRangeGridlineStroke(new BasicStroke((float) co.gridWidth)); if (co.axisWidth >= 0) { renderer.getPlot().getRangeAxis().setAxisLineStroke(new BasicStroke((float) co.axisWidth)); renderer.getPlot().getDomainAxis().setAxisLineStroke(new BasicStroke((float) co.axisWidth)); } if (co.gridColor != null) { renderer.getPlot().setRangeGridlinePaint(co.gridColor); renderer.getPlot().setDomainGridlinePaint(co.gridColor); } if (co.axisColor != null) { renderer.getPlot().getRangeAxis().setAxisLinePaint(co.axisColor); renderer.getPlot().getDomainAxis().setAxisLinePaint(co.axisColor); } if (co.axisFontSize > 0) { Font af = new Font(Axis.DEFAULT_AXIS_LABEL_FONT.getFontName(), Axis.DEFAULT_AXIS_LABEL_FONT.getStyle(), co.axisFontSize); renderer.getPlot().getRangeAxis().setTickLabelFont(af); renderer.getPlot().getDomainAxis().setTickLabelFont(af); renderer.getPlot().getDomainAxis().setLabelFont(af); renderer.getPlot().getRangeAxis().setLabelFont(af); } return jfreechart; }