List of usage examples for javax.xml.xpath XPathConstants NUMBER
QName NUMBER
To view the source code for javax.xml.xpath XPathConstants NUMBER.
Click Source Link
The XPath 1.0 number data type.
Maps to Java Double .
From source file:com.espertech.esper.regression.event.TestNoSchemaXMLEvent.java
public void testSimpleXMLXPathProperties() throws Exception { Configuration configuration = SupportConfigFactory.getConfiguration(); ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.setRootElementName("myevent"); xmlDOMEventTypeDesc.addXPathProperty("xpathElement1", "/myevent/element1", XPathConstants.STRING); xmlDOMEventTypeDesc.addXPathProperty("xpathCountE21", "count(/myevent/element2/element21)", XPathConstants.NUMBER); xmlDOMEventTypeDesc.addXPathProperty("xpathAttrString", "/myevent/element3/@attrString", XPathConstants.STRING); xmlDOMEventTypeDesc.addXPathProperty("xpathAttrNum", "/myevent/element3/@attrNum", XPathConstants.NUMBER); xmlDOMEventTypeDesc.addXPathProperty("xpathAttrBool", "/myevent/element3/@attrBool", XPathConstants.BOOLEAN); xmlDOMEventTypeDesc.addXPathProperty("stringCastLong", "/myevent/element3/@attrNum", XPathConstants.STRING, "long"); xmlDOMEventTypeDesc.addXPathProperty("stringCastDouble", "/myevent/element3/@attrNum", XPathConstants.STRING, "double"); xmlDOMEventTypeDesc.addXPathProperty("numCastInt", "/myevent/element3/@attrNum", XPathConstants.NUMBER, "int"); xmlDOMEventTypeDesc.setXPathFunctionResolver(SupportXPathFunctionResolver.class.getName()); xmlDOMEventTypeDesc.setXPathVariableResolver(SupportXPathVariableResolver.class.getName()); configuration.addEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc); xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.setRootElementName("my.event2"); configuration.addEventType("TestXMLWithDots", xmlDOMEventTypeDesc); epService = EPServiceProviderManager.getProvider("TestNoSchemaXML", configuration); epService.initialize();/* ww w.ja v a2 s . c o m*/ updateListener = new SupportUpdateListener(); // assert type metadata EventTypeSPI type = (EventTypeSPI) ((EPServiceProviderSPI) epService).getEventAdapterService() .getExistsTypeByName("TestXMLNoSchemaType"); assertEquals(EventTypeMetadata.ApplicationType.XML, type.getMetadata().getOptionalApplicationType()); assertEquals(null, type.getMetadata().getOptionalSecondaryNames()); assertEquals("TestXMLNoSchemaType", type.getMetadata().getPrimaryName()); assertEquals("TestXMLNoSchemaType", type.getMetadata().getPublicName()); assertEquals("TestXMLNoSchemaType", type.getName()); assertEquals(EventTypeMetadata.TypeClass.APPLICATION, type.getMetadata().getTypeClass()); assertEquals(true, type.getMetadata().isApplicationConfigured()); assertEquals(true, type.getMetadata().isApplicationPreConfigured()); assertEquals(true, type.getMetadata().isApplicationPreConfiguredStatic()); EPAssertionUtil.assertEqualsAnyOrder(new Object[] { new EventPropertyDescriptor("xpathElement1", String.class, null, false, false, false, false, false), new EventPropertyDescriptor("xpathCountE21", Double.class, null, false, false, false, false, false), new EventPropertyDescriptor("xpathAttrString", String.class, null, false, false, false, false, false), new EventPropertyDescriptor("xpathAttrNum", Double.class, null, false, false, false, false, false), new EventPropertyDescriptor("xpathAttrBool", Boolean.class, null, false, false, false, false, false), new EventPropertyDescriptor("stringCastLong", Long.class, null, false, false, false, false, false), new EventPropertyDescriptor("stringCastDouble", Double.class, null, false, false, false, false, false), new EventPropertyDescriptor("numCastInt", Integer.class, null, false, false, false, false, false), }, type.getPropertyDescriptors()); String stmt = "select xpathElement1, xpathCountE21, xpathAttrString, xpathAttrNum, xpathAttrBool," + "stringCastLong," + "stringCastDouble," + "numCastInt " + "from TestXMLNoSchemaType.win:length(100)"; EPStatement joinView = epService.getEPAdministrator().createEPL(stmt); joinView.addListener(updateListener); // Generate document with the specified in element1 to confirm we have independent events sendEvent("EventA"); assertDataSimpleXPath("EventA"); sendEvent("EventB"); assertDataSimpleXPath("EventB"); }
From source file:com.espertech.esperio.representation.axiom.AxiomXPathPropertyGetter.java
public Class getResultClass() { if (resultType.equals(XPathConstants.BOOLEAN)) { return Boolean.class; }/*ww w . j a v a2s .com*/ if (resultType.equals(XPathConstants.NUMBER)) { return Double.class; } if (resultType.equals(XPathConstants.STRING)) { return String.class; } return String.class; }
From source file:org.opencastproject.remotetest.server.ServiceRegistryRestEndpointTest.java
@Test public void testGetServiceRegistrations() throws Exception { // Get a known service registration as xml HttpGet get = new HttpGet( serviceUrl + "/services.xml?serviceType=org.opencastproject.composer&host=" + remoteHost); HttpResponse response = client.execute(get); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); InputStream in = null;//from ww w . j ava 2 s . c om Document doc = null; try { in = response.getEntity().getContent(); doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); String typeFromResponse = (String) Utils.xpath(doc, "//*[local-name() = 'type']", XPathConstants.STRING); Assert.assertEquals("org.opencastproject.composer", typeFromResponse); String hostFromResponse = (String) Utils.xpath(doc, "//*[local-name() = 'host']", XPathConstants.STRING); Assert.assertEquals(BASE_URL, hostFromResponse); } finally { IOUtils.closeQuietly(in); Main.returnClient(client); } // Get a registration that is known to not exist, and ensure we get a 404 client = Main.getClient(); get = new HttpGet(serviceUrl + "/services.xml?serviceType=foo&host=" + remoteHost); response = client.execute(get); Assert.assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusLine().getStatusCode()); // Get all services on a single host client = Main.getClient(); get = new HttpGet(serviceUrl + "/services.xml?host=" + remoteHost); response = client.execute(get); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); try { in = response.getEntity().getContent(); doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); int serviceCount = ((Number) Utils.xpath(doc, "count(//*[local-name() = 'service'])", XPathConstants.NUMBER)).intValue(); Assert.assertTrue(serviceCount > 0); } finally { IOUtils.closeQuietly(in); Main.returnClient(client); } // Get all services of a single type client = Main.getClient(); get = new HttpGet(serviceUrl + "/services.xml?serviceType=org.opencastproject.composer"); response = client.execute(get); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); try { in = response.getEntity().getContent(); doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); int serviceCount = ((Number) Utils.xpath(doc, "count(//*[local-name() = 'service'])", XPathConstants.NUMBER)).intValue(); Assert.assertEquals(1, serviceCount); } finally { IOUtils.closeQuietly(in); Main.returnClient(client); } // Get statistics client = Main.getClient(); get = new HttpGet(serviceUrl + "/statistics.xml"); response = client.execute(get); Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); try { in = response.getEntity().getContent(); doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); int serviceCount = ((Number) Utils.xpath(doc, "count(//*[local-name() = 'service'])", XPathConstants.NUMBER)).intValue(); Assert.assertTrue(serviceCount > 0); } finally { IOUtils.closeQuietly(in); Main.returnClient(client); } }
From source file:de.bitzeche.video.transcoding.zencoder.ZencoderClient.java
private Integer findIdFromOutputNode(Node output) throws XPathExpressionException { Double idDouble = (Double) xPath.evaluate("output/id", output, XPathConstants.NUMBER); return idDouble == null ? null : idDouble.intValue(); }
From source file:com.act.lcms.LCMSmzMLParser.java
protected LCMSSpectrum handleSpectrumEntry(Document doc) throws XPathException { XPath xpath = getXPathFactory().newXPath(); Double spectrumIndexD = (Double) xpath.evaluate(SPECTRUM_PATH_INDEX, doc, XPathConstants.NUMBER); if (spectrumIndexD == null) { System.err.format("WARNING: found spectrum document without index attribute.\n"); return null; }/* www. java2s . c o m*/ Integer spectrumIndex = spectrumIndexD.intValue(); if (xpath.evaluate(SPECTRUM_PATH_EXPECTED_VERSION, doc, XPathConstants.NODE) == null) { // if it is not MS1 Spectrum data then we will skip from the output. // check if it entry we see here is the diode array data, those we expect to silently skip // if on the other hand, even that is not matched; we truly have some unexpected entries, so report to user if (xpath.evaluate(SPECTRUM_PATH_EXPECTED_VERSION_DIODE_ARRAY, doc, XPathConstants.NODE) == null) { System.err.format( "WARNING: found unexpected MS spectrum version in spectrum document %d. Skipping.\n", spectrumIndex); } return null; } String spectrumId = (String) xpath.evaluate(SPECTRUM_PATH_ID, doc, XPathConstants.STRING); if (spectrumId == null) { System.err.format("WARNING: no spectrum id found for documnt %d\n", spectrumIndex); return null; } Matcher matcher = SPECTRUM_EXTRACTION_REGEX.matcher(spectrumId); if (!matcher.find()) { System.err.format("WARNING: spectrum id for documnt %d did not match regex: %s\n", spectrumIndex, spectrumId); return null; } Integer spectrumFunction = Integer.parseInt(matcher.group(1)); Integer spectrumScan = Integer.parseInt(matcher.group(3)); Integer scanListCount = ((Double) xpath.evaluate(SPECTRUM_PATH_SCAN_LIST_COUNT, doc, XPathConstants.NUMBER)) .intValue(); if (!Integer.valueOf(1).equals(scanListCount)) { System.err.format("WARNING: unexpected number of scan entries in spectrum document %d: %d", spectrumIndex, scanListCount); return null; } Integer binaryDataCount = ((Double) xpath.evaluate(SPECTRUM_PATH_BINARY_DATA_ARRAY_LIST_COUNT, doc, XPathConstants.NUMBER)).intValue(); if (!Integer.valueOf(2).equals(binaryDataCount)) { System.err.format("WARNING: unexpected number of binary data entries in spectrum document %d: %d", spectrumIndex, binaryDataCount); return null; } Double basePeakMz = (Double) xpath.evaluate(SPECTRUM_PATH_BASE_PEAK_MZ, doc, XPathConstants.NUMBER); if (basePeakMz == null) { System.err.format("WARNING: no base peak m/z found for spectrum document %d\n", spectrumIndex); return null; } Double basePeakIntensity = (Double) xpath.evaluate(SPECTRUM_PATH_BASE_PEAK_INTENSITY, doc, XPathConstants.NUMBER); if (basePeakIntensity == null) { System.err.format("WARNING: no base peak intensity found for spectrum document %d\n", spectrumIndex); return null; } Double scanStartTime = (Double) xpath.evaluate(SPECTRUM_PATH_SCAN_START_TIME, doc, XPathConstants.NUMBER); if (scanStartTime == null) { System.err.format("WARNING: no scan start time found for spectrum document %d\n", spectrumIndex); return null; } String scanStartTimeUnit = (String) xpath.evaluate(SPECTRUM_PATH_SCAN_START_TIME_UNIT, doc, XPathConstants.STRING); if (scanStartTimeUnit == null) { System.err.format("WARNING: no scan start time unit found for spectrum document %d\n", spectrumIndex); return null; } String mzData = (String) xpath.evaluate(SPECTRUM_PATH_MZ_BINARY_DATA, doc, XPathConstants.STRING); if (mzData == null) { System.err.format("WARNING: no m/z data found for spectrum document %d\n", spectrumIndex); return null; } String intensityData = (String) xpath.evaluate(SPECTRUM_PATH_INTENSITY_BINARY_DATA, doc, XPathConstants.STRING); if (intensityData == null) { System.err.format("WARNING: no intensity data found for spectrum document %d\n", spectrumIndex); return null; } List<Double> mzs = base64ToDoubleList(mzData); List<Double> intensities = base64ToDoubleList(intensityData); List<Pair<Double, Double>> mzIntensityPairs = zipLists(mzs, intensities); return new LCMSSpectrum(spectrumIndex, scanStartTime, scanStartTimeUnit, mzIntensityPairs, basePeakMz, basePeakIntensity, spectrumFunction, spectrumScan, null); }
From source file:com.nebhale.cyclinglibrary.util.XmlPointParser.java
private Task parseTcxTrack(NodeList result, PointParserCallback callback) throws XPathExpressionException { Double[][] points = new Double[result.getLength()][2]; for (int i = 0; i < result.getLength(); i++) { Element element = (Element) result.item(i); points[i][0] = (Double) LATITUDE.evaluate(element, XPathConstants.NUMBER); points[i][1] = (Double) LONGITUDE.evaluate(element, XPathConstants.NUMBER); }/*from w ww .j a va2 s.c o m*/ return this.pointAugmenter.augmentPoints(points, new PointAugmenterCallbackAdapter(callback)); }
From source file:com.servicelibre.jxsl.scenario.test.xspec.XspecTestScenarioRunner.java
/** * /* w w w . ja va2 s . c o m*/ * TODO add optional Document parameter * * // TODO improve performance In order to improve performance, we should * not regenerate/recompile xspec xsl. We should instead compile it once and * change/set parameter (document URL) at each execution. This implies that * we have to keep a compiled version of the Xsl for all runs of the * testScenario with the same xspec file. */ @Override public TestReport run(File xspecFile, File outputDir, Document xmlDoc) { this.outputDir = outputDir; RunReport testRunReport = null; TestReport testReport = new TestReport(); // Generate custom test XSL RunReport generationReport = generateTestFile(xspecFile); File generatedTestFile = generationReport.mainOutputFile; if (generatedTestFile != null && generatedTestFile.exists()) { // Execute the xspec test testRunReport = executeTest(xspecFile, generatedTestFile, generationReport.outputProperties.getProperty("encoding"), xmlDoc); // Produce HTML report if transformation scenario provided if (xspecResultHtmlConvertorScenario != null) { RunReport htmlrunReport = generateHtmlReport(testRunReport.mainOutputFile); if (testRunReport != null) { testRunReport.otherOutputFiles.add(htmlrunReport.mainOutputFile); } } if (testRunReport != null) { testReport.executionTime = testRunReport.executionTime; testReport.executionDate = testRunReport.executionDate; testReport.success = getSuccess(testRunReport.mainOutputFile); if (!testReport.success) { testReport.failureReport = getFailureReport(testRunReport.mainOutputFile); } if (testRunReport.otherOutputFiles.size() > 0) { try { testReport.reportUrl = testRunReport.otherOutputFiles.get(0).toURI().toURL(); } catch (MalformedURLException e) { logger.error("Error while converting test report File to URL.", e); } } try { org.w3c.dom.Document xspecResultDoc = xmlBuilder.parse(testRunReport.mainOutputFile); testReport.testCount = ((Double) testCount.evaluate(xspecResultDoc, XPathConstants.NUMBER)) .intValue(); testReport.testFailedCount = ((Double) testFailedCount.evaluate(xspecResultDoc, XPathConstants.NUMBER)).intValue(); } catch (SAXException e) { logger.error("Error while creating failure report", e); } catch (IOException e) { logger.error("Error while creating failure report", e); } catch (XPathExpressionException e) { logger.error("Error while evaluating XPath during failure report creation", e); } } else { testReport.success = false; } } else { logger.error("Unable to find Xspec generated test file."); } return testReport; }
From source file:com.espertech.esper.client.TestConfigurationParser.java
protected static void assertFileConfig(Configuration config) throws Exception { // assert name for class assertEquals(2, config.getEventTypeAutoNamePackages().size()); assertEquals("com.mycompany.eventsone", config.getEventTypeAutoNamePackages().toArray()[0]); assertEquals("com.mycompany.eventstwo", config.getEventTypeAutoNamePackages().toArray()[1]); // assert name for class assertEquals(3, config.getEventTypeNames().size()); assertEquals("com.mycompany.myapp.MySampleEventOne", config.getEventTypeNames().get("MySampleEventOne")); assertEquals("com.mycompany.myapp.MySampleEventTwo", config.getEventTypeNames().get("MySampleEventTwo")); assertEquals("com.mycompany.package.MyLegacyTypeEvent", config.getEventTypeNames().get("MyLegacyTypeEvent")); // assert auto imports assertEquals(8, config.getImports().size()); assertEquals("java.lang.*", config.getImports().get(0)); assertEquals("java.math.*", config.getImports().get(1)); assertEquals("java.text.*", config.getImports().get(2)); assertEquals("java.util.*", config.getImports().get(3)); assertEquals("com.espertech.esper.client.annotation.*", config.getImports().get(4)); assertEquals("com.espertech.esper.dataflow.ops.*", config.getImports().get(5)); assertEquals("com.mycompany.myapp.*", config.getImports().get(6)); assertEquals("com.mycompany.myapp.ClassOne", config.getImports().get(7)); // assert XML DOM - no schema assertEquals(2, config.getEventTypesXMLDOM().size()); ConfigurationEventTypeXMLDOM noSchemaDesc = config.getEventTypesXMLDOM().get("MyNoSchemaXMLEventName"); assertEquals("MyNoSchemaEvent", noSchemaDesc.getRootElementName()); assertEquals("/myevent/element1", noSchemaDesc.getXPathProperties().get("element1").getXpath()); assertEquals(XPathConstants.NUMBER, noSchemaDesc.getXPathProperties().get("element1").getType()); assertEquals(null, noSchemaDesc.getXPathProperties().get("element1").getOptionalCastToType()); assertNull(noSchemaDesc.getXPathFunctionResolver()); assertNull(noSchemaDesc.getXPathVariableResolver()); assertFalse(noSchemaDesc.isXPathPropertyExpr()); // assert XML DOM - with schema ConfigurationEventTypeXMLDOM schemaDesc = config.getEventTypesXMLDOM().get("MySchemaXMLEventName"); assertEquals("MySchemaEvent", schemaDesc.getRootElementName()); assertEquals("MySchemaXMLEvent.xsd", schemaDesc.getSchemaResource()); assertEquals("actual-xsd-text-here", schemaDesc.getSchemaText()); assertEquals("samples:schemas:simpleSchema", schemaDesc.getRootElementNamespace()); assertEquals("default-name-space", schemaDesc.getDefaultNamespace()); assertEquals("/myevent/element2", schemaDesc.getXPathProperties().get("element2").getXpath()); assertEquals(XPathConstants.STRING, schemaDesc.getXPathProperties().get("element2").getType()); assertEquals(Long.class, schemaDesc.getXPathProperties().get("element2").getOptionalCastToType()); assertEquals("/bookstore/book", schemaDesc.getXPathProperties().get("element3").getXpath()); assertEquals(XPathConstants.NODESET, schemaDesc.getXPathProperties().get("element3").getType()); assertEquals(null, schemaDesc.getXPathProperties().get("element3").getOptionalCastToType()); assertEquals("MyOtherXMLNodeEvent", schemaDesc.getXPathProperties().get("element3").getOptionaleventTypeName()); assertEquals(1, schemaDesc.getNamespacePrefixes().size()); assertEquals("samples:schemas:simpleSchema", schemaDesc.getNamespacePrefixes().get("ss")); assertFalse(schemaDesc.isXPathResolvePropertiesAbsolute()); assertEquals("com.mycompany.OptionalFunctionResolver", schemaDesc.getXPathFunctionResolver()); assertEquals("com.mycompany.OptionalVariableResolver", schemaDesc.getXPathVariableResolver()); assertTrue(schemaDesc.isXPathPropertyExpr()); assertFalse(schemaDesc.isEventSenderValidatesRoot()); assertFalse(schemaDesc.isAutoFragment()); assertEquals("startts", schemaDesc.getStartTimestampPropertyName()); assertEquals("endts", schemaDesc.getEndTimestampPropertyName()); // assert mapped events assertEquals(1, config.getEventTypesMapEvents().size()); assertTrue(config.getEventTypesMapEvents().keySet().contains("MyMapEvent")); Map<String, String> expectedProps = new HashMap<String, String>(); expectedProps.put("myInt", "int"); expectedProps.put("myString", "string"); assertEquals(expectedProps, config.getEventTypesMapEvents().get("MyMapEvent")); assertEquals(1, config.getMapTypeConfigurations().size()); Set<String> superTypes = config.getMapTypeConfigurations().get("MyMapEvent").getSuperTypes(); EPAssertionUtil.assertEqualsExactOrder(new Object[] { "MyMapSuperType1", "MyMapSuperType2" }, superTypes.toArray());//ww w. ja va 2 s. c o m assertEquals("startts", config.getMapTypeConfigurations().get("MyMapEvent").getStartTimestampPropertyName()); assertEquals("endts", config.getMapTypeConfigurations().get("MyMapEvent").getEndTimestampPropertyName()); // assert objectarray events assertEquals(1, config.getEventTypesNestableObjectArrayEvents().size()); assertTrue(config.getEventTypesNestableObjectArrayEvents().containsKey("MyObjectArrayEvent")); Map<String, String> expectedPropsObjectArray = new HashMap<String, String>(); expectedPropsObjectArray.put("myInt", "int"); expectedPropsObjectArray.put("myString", "string"); assertEquals(expectedPropsObjectArray, config.getEventTypesNestableObjectArrayEvents().get("MyObjectArrayEvent")); assertEquals(1, config.getObjectArrayTypeConfigurations().size()); Set<String> superTypesOA = config.getObjectArrayTypeConfigurations().get("MyObjectArrayEvent") .getSuperTypes(); EPAssertionUtil.assertEqualsExactOrder( new Object[] { "MyObjectArraySuperType1", "MyObjectArraySuperType2" }, superTypesOA.toArray()); assertEquals("startts", config.getObjectArrayTypeConfigurations().get("MyObjectArrayEvent") .getStartTimestampPropertyName()); assertEquals("endts", config.getObjectArrayTypeConfigurations().get("MyObjectArrayEvent").getEndTimestampPropertyName()); // assert legacy type declaration assertEquals(1, config.getEventTypesLegacy().size()); ConfigurationEventTypeLegacy legacy = config.getEventTypesLegacy().get("MyLegacyTypeEvent"); assertEquals(ConfigurationEventTypeLegacy.CodeGeneration.ENABLED, legacy.getCodeGeneration()); assertEquals(ConfigurationEventTypeLegacy.AccessorStyle.PUBLIC, legacy.getAccessorStyle()); assertEquals(1, legacy.getFieldProperties().size()); assertEquals("myFieldName", legacy.getFieldProperties().get(0).getAccessorFieldName()); assertEquals("myfieldprop", legacy.getFieldProperties().get(0).getName()); assertEquals(1, legacy.getMethodProperties().size()); assertEquals("myAccessorMethod", legacy.getMethodProperties().get(0).getAccessorMethodName()); assertEquals("mymethodprop", legacy.getMethodProperties().get(0).getName()); assertEquals(Configuration.PropertyResolutionStyle.CASE_INSENSITIVE, legacy.getPropertyResolutionStyle()); assertEquals("com.mycompany.myapp.MySampleEventFactory.createMyLegacyTypeEvent", legacy.getFactoryMethod()); assertEquals("myCopyMethod", legacy.getCopyMethod()); assertEquals("startts", legacy.getStartTimestampPropertyName()); assertEquals("endts", legacy.getEndTimestampPropertyName()); // assert database reference - data source config assertEquals(3, config.getDatabaseReferences().size()); ConfigurationDBRef configDBRef = config.getDatabaseReferences().get("mydb1"); ConfigurationDBRef.DataSourceConnection dsDef = (ConfigurationDBRef.DataSourceConnection) configDBRef .getConnectionFactoryDesc(); assertEquals("java:comp/env/jdbc/mydb", dsDef.getContextLookupName()); assertEquals( "{java.naming.provider.url=iiop://localhost:1050, java.naming.factory.initial=com.myclass.CtxFactory}", dsDef.getEnvProperties().toString()); assertEquals(ConfigurationDBRef.ConnectionLifecycleEnum.POOLED, configDBRef.getConnectionLifecycleEnum()); assertNull(configDBRef.getConnectionSettings().getAutoCommit()); assertNull(configDBRef.getConnectionSettings().getCatalog()); assertNull(configDBRef.getConnectionSettings().getReadOnly()); assertNull(configDBRef.getConnectionSettings().getTransactionIsolation()); ConfigurationLRUCache lruCache = (ConfigurationLRUCache) configDBRef.getDataCacheDesc(); assertEquals(10, lruCache.getSize()); assertEquals(ConfigurationDBRef.ColumnChangeCaseEnum.LOWERCASE, configDBRef.getColumnChangeCase()); assertEquals(ConfigurationDBRef.MetadataOriginEnum.SAMPLE, configDBRef.getMetadataRetrievalEnum()); assertEquals(2, configDBRef.getSqlTypesMapping().size()); assertEquals("int", configDBRef.getSqlTypesMapping().get(2)); assertEquals("float", configDBRef.getSqlTypesMapping().get(6)); // assert database reference - driver manager config configDBRef = config.getDatabaseReferences().get("mydb2"); ConfigurationDBRef.DriverManagerConnection dmDef = (ConfigurationDBRef.DriverManagerConnection) configDBRef .getConnectionFactoryDesc(); assertEquals("my.sql.Driver", dmDef.getClassName()); assertEquals("jdbc:mysql://localhost", dmDef.getUrl()); assertEquals("myuser1", dmDef.getOptionalUserName()); assertEquals("mypassword1", dmDef.getOptionalPassword()); assertEquals("{user=myuser2, password=mypassword2, somearg=someargvalue}", dmDef.getOptionalProperties().toString()); assertEquals(ConfigurationDBRef.ConnectionLifecycleEnum.RETAIN, configDBRef.getConnectionLifecycleEnum()); assertEquals((Boolean) false, configDBRef.getConnectionSettings().getAutoCommit()); assertEquals("test", configDBRef.getConnectionSettings().getCatalog()); assertEquals(Boolean.TRUE, configDBRef.getConnectionSettings().getReadOnly()); assertEquals(new Integer(3), configDBRef.getConnectionSettings().getTransactionIsolation()); ConfigurationExpiryTimeCache expCache = (ConfigurationExpiryTimeCache) configDBRef.getDataCacheDesc(); assertEquals(60.5, expCache.getMaxAgeSeconds()); assertEquals(120.1, expCache.getPurgeIntervalSeconds()); assertEquals(ConfigurationCacheReferenceType.HARD, expCache.getCacheReferenceType()); assertEquals(ConfigurationDBRef.ColumnChangeCaseEnum.UPPERCASE, configDBRef.getColumnChangeCase()); assertEquals(ConfigurationDBRef.MetadataOriginEnum.METADATA, configDBRef.getMetadataRetrievalEnum()); assertEquals(1, configDBRef.getSqlTypesMapping().size()); assertEquals("java.lang.String", configDBRef.getSqlTypesMapping().get(99)); // assert database reference - data source factory and DBCP config configDBRef = config.getDatabaseReferences().get("mydb3"); ConfigurationDBRef.DataSourceFactory dsFactory = (ConfigurationDBRef.DataSourceFactory) configDBRef .getConnectionFactoryDesc(); assertEquals("org.apache.commons.dbcp.BasicDataSourceFactory", dsFactory.getFactoryClassname()); assertEquals("jdbc:mysql://localhost/test", dsFactory.getProperties().getProperty("url")); assertEquals("myusername", dsFactory.getProperties().getProperty("username")); assertEquals("mypassword", dsFactory.getProperties().getProperty("password")); assertEquals("com.mysql.jdbc.Driver", dsFactory.getProperties().getProperty("driverClassName")); assertEquals("2", dsFactory.getProperties().getProperty("initialSize")); // assert custom view implementations List<ConfigurationPlugInView> configViews = config.getPlugInViews(); assertEquals(2, configViews.size()); for (int i = 0; i < configViews.size(); i++) { ConfigurationPlugInView entry = configViews.get(i); assertEquals("ext" + i, entry.getNamespace()); assertEquals("myview" + i, entry.getName()); assertEquals("com.mycompany.MyViewFactory" + i, entry.getFactoryClassName()); } // assert custom virtual data window implementations List<ConfigurationPlugInVirtualDataWindow> configVDW = config.getPlugInVirtualDataWindows(); assertEquals(2, configVDW.size()); for (int i = 0; i < configVDW.size(); i++) { ConfigurationPlugInVirtualDataWindow entry = configVDW.get(i); assertEquals("vdw" + i, entry.getNamespace()); assertEquals("myvdw" + i, entry.getName()); assertEquals("com.mycompany.MyVdwFactory" + i, entry.getFactoryClassName()); if (i == 1) { assertEquals("abc", entry.getConfig()); } } // assert adapter loaders parsed List<ConfigurationPluginLoader> plugins = config.getPluginLoaders(); assertEquals(2, plugins.size()); ConfigurationPluginLoader pluginOne = plugins.get(0); assertEquals("Loader1", pluginOne.getLoaderName()); assertEquals("com.espertech.esper.support.plugin.SupportLoaderOne", pluginOne.getClassName()); assertEquals(2, pluginOne.getConfigProperties().size()); assertEquals("val1", pluginOne.getConfigProperties().get("name1")); assertEquals("val2", pluginOne.getConfigProperties().get("name2")); assertEquals( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><sample-initializer><some-any-xml-can-be-here>This section for use by a plugin loader.</some-any-xml-can-be-here></sample-initializer>", pluginOne.getConfigurationXML()); ConfigurationPluginLoader pluginTwo = plugins.get(1); assertEquals("Loader2", pluginTwo.getLoaderName()); assertEquals("com.espertech.esper.support.plugin.SupportLoaderTwo", pluginTwo.getClassName()); assertEquals(0, pluginTwo.getConfigProperties().size()); // assert plug-in aggregation function loaded assertEquals(4, config.getPlugInAggregationFunctions().size()); ConfigurationPlugInAggregationFunction pluginAgg = config.getPlugInAggregationFunctions().get(0); assertEquals("com.mycompany.MyMatrixAggregationMethod0DEPRECATED", pluginAgg.getFunctionClassName()); assertEquals("func1", pluginAgg.getName()); assertEquals(null, pluginAgg.getFactoryClassName()); pluginAgg = config.getPlugInAggregationFunctions().get(1); assertEquals("com.mycompany.MyMatrixAggregationMethod1DEPRECATED", pluginAgg.getFunctionClassName()); assertEquals("func2", pluginAgg.getName()); assertEquals(null, pluginAgg.getFactoryClassName()); pluginAgg = config.getPlugInAggregationFunctions().get(2); assertEquals(null, pluginAgg.getFunctionClassName()); assertEquals("func1a", pluginAgg.getName()); assertEquals("com.mycompany.MyMatrixAggregationMethod0Factory", pluginAgg.getFactoryClassName()); pluginAgg = config.getPlugInAggregationFunctions().get(3); assertEquals(null, pluginAgg.getFunctionClassName()); assertEquals("func2a", pluginAgg.getName()); assertEquals("com.mycompany.MyMatrixAggregationMethod1Factory", pluginAgg.getFactoryClassName()); // assert plug-in aggregation multi-function loaded assertEquals(1, config.getPlugInAggregationMultiFunctions().size()); ConfigurationPlugInAggregationMultiFunction pluginMultiAgg = config.getPlugInAggregationMultiFunctions() .get(0); EPAssertionUtil.assertEqualsExactOrder(new String[] { "func1", "func2" }, pluginMultiAgg.getFunctionNames()); assertEquals("com.mycompany.MyAggregationMultiFunctionFactory", pluginMultiAgg.getMultiFunctionFactoryClassName()); assertEquals(1, pluginMultiAgg.getAdditionalConfiguredProperties().size()); assertEquals("value1", pluginMultiAgg.getAdditionalConfiguredProperties().get("prop1")); // assert plug-in singlerow function loaded assertEquals(2, config.getPlugInSingleRowFunctions().size()); ConfigurationPlugInSingleRowFunction pluginSingleRow = config.getPlugInSingleRowFunctions().get(0); assertEquals("com.mycompany.MyMatrixSingleRowMethod0", pluginSingleRow.getFunctionClassName()); assertEquals("method1", pluginSingleRow.getFunctionMethodName()); assertEquals("func3", pluginSingleRow.getName()); assertEquals(ConfigurationPlugInSingleRowFunction.ValueCache.DISABLED, pluginSingleRow.getValueCache()); assertEquals(ConfigurationPlugInSingleRowFunction.FilterOptimizable.ENABLED, pluginSingleRow.getFilterOptimizable()); assertFalse(pluginSingleRow.isRethrowExceptions()); pluginSingleRow = config.getPlugInSingleRowFunctions().get(1); assertEquals("com.mycompany.MyMatrixSingleRowMethod1", pluginSingleRow.getFunctionClassName()); assertEquals("func4", pluginSingleRow.getName()); assertEquals("method2", pluginSingleRow.getFunctionMethodName()); assertEquals(ConfigurationPlugInSingleRowFunction.ValueCache.ENABLED, pluginSingleRow.getValueCache()); assertEquals(ConfigurationPlugInSingleRowFunction.FilterOptimizable.DISABLED, pluginSingleRow.getFilterOptimizable()); assertTrue(pluginSingleRow.isRethrowExceptions()); // assert plug-in guard objects loaded assertEquals(4, config.getPlugInPatternObjects().size()); ConfigurationPlugInPatternObject pluginPattern = config.getPlugInPatternObjects().get(0); assertEquals("com.mycompany.MyGuardFactory0", pluginPattern.getFactoryClassName()); assertEquals("ext0", pluginPattern.getNamespace()); assertEquals("guard1", pluginPattern.getName()); assertEquals(ConfigurationPlugInPatternObject.PatternObjectType.GUARD, pluginPattern.getPatternObjectType()); pluginPattern = config.getPlugInPatternObjects().get(1); assertEquals("com.mycompany.MyGuardFactory1", pluginPattern.getFactoryClassName()); assertEquals("ext1", pluginPattern.getNamespace()); assertEquals("guard2", pluginPattern.getName()); assertEquals(ConfigurationPlugInPatternObject.PatternObjectType.GUARD, pluginPattern.getPatternObjectType()); pluginPattern = config.getPlugInPatternObjects().get(2); assertEquals("com.mycompany.MyObserverFactory0", pluginPattern.getFactoryClassName()); assertEquals("ext0", pluginPattern.getNamespace()); assertEquals("observer1", pluginPattern.getName()); assertEquals(ConfigurationPlugInPatternObject.PatternObjectType.OBSERVER, pluginPattern.getPatternObjectType()); pluginPattern = config.getPlugInPatternObjects().get(3); assertEquals("com.mycompany.MyObserverFactory1", pluginPattern.getFactoryClassName()); assertEquals("ext1", pluginPattern.getNamespace()); assertEquals("observer2", pluginPattern.getName()); assertEquals(ConfigurationPlugInPatternObject.PatternObjectType.OBSERVER, pluginPattern.getPatternObjectType()); // assert engine defaults assertFalse(config.getEngineDefaults().getThreading().isInsertIntoDispatchPreserveOrder()); assertEquals(3000, config.getEngineDefaults().getThreading().getInsertIntoDispatchTimeout()); assertEquals(ConfigurationEngineDefaults.Threading.Locking.SUSPEND, config.getEngineDefaults().getThreading().getInsertIntoDispatchLocking()); assertFalse(config.getEngineDefaults().getThreading().isListenerDispatchPreserveOrder()); assertEquals(2000, config.getEngineDefaults().getThreading().getListenerDispatchTimeout()); assertEquals(ConfigurationEngineDefaults.Threading.Locking.SUSPEND, config.getEngineDefaults().getThreading().getListenerDispatchLocking()); assertTrue(config.getEngineDefaults().getThreading().isThreadPoolInbound()); assertTrue(config.getEngineDefaults().getThreading().isThreadPoolOutbound()); assertTrue(config.getEngineDefaults().getThreading().isThreadPoolRouteExec()); assertTrue(config.getEngineDefaults().getThreading().isThreadPoolTimerExec()); assertEquals(1, config.getEngineDefaults().getThreading().getThreadPoolInboundNumThreads()); assertEquals(2, config.getEngineDefaults().getThreading().getThreadPoolOutboundNumThreads()); assertEquals(3, config.getEngineDefaults().getThreading().getThreadPoolTimerExecNumThreads()); assertEquals(4, config.getEngineDefaults().getThreading().getThreadPoolRouteExecNumThreads()); assertEquals(1000, (int) config.getEngineDefaults().getThreading().getThreadPoolInboundCapacity()); assertEquals(1500, (int) config.getEngineDefaults().getThreading().getThreadPoolOutboundCapacity()); assertEquals(null, config.getEngineDefaults().getThreading().getThreadPoolTimerExecCapacity()); assertEquals(2000, (int) config.getEngineDefaults().getThreading().getThreadPoolRouteExecCapacity()); assertFalse(config.getEngineDefaults().getThreading().isInternalTimerEnabled()); assertEquals(1234567, config.getEngineDefaults().getThreading().getInternalTimerMsecResolution()); assertFalse(config.getEngineDefaults().getViewResources().isShareViews()); assertTrue(config.getEngineDefaults().getViewResources().isAllowMultipleExpiryPolicies()); assertEquals(Configuration.PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE, config.getEngineDefaults().getEventMeta().getClassPropertyResolutionStyle()); assertEquals(ConfigurationEventTypeLegacy.AccessorStyle.PUBLIC, config.getEngineDefaults().getEventMeta().getDefaultAccessorStyle()); assertEquals(Configuration.EventRepresentation.MAP, config.getEngineDefaults().getEventMeta().getDefaultEventRepresentation()); assertEquals(100, config.getEngineDefaults().getEventMeta().getAnonymousCacheSize()); assertTrue(config.getEngineDefaults().getLogging().isEnableExecutionDebug()); assertFalse(config.getEngineDefaults().getLogging().isEnableTimerDebug()); assertTrue(config.getEngineDefaults().getLogging().isEnableQueryPlan()); assertTrue(config.getEngineDefaults().getLogging().isEnableJDBC()); assertEquals("[%u] %m", config.getEngineDefaults().getLogging().getAuditPattern()); assertEquals(30000, config.getEngineDefaults().getVariables().getMsecVersionRelease()); assertEquals(3L, (long) config.getEngineDefaults().getPatterns().getMaxSubexpressions()); assertEquals(false, config.getEngineDefaults().getPatterns().isMaxSubexpressionPreventStart()); assertEquals(StreamSelector.RSTREAM_ISTREAM_BOTH, config.getEngineDefaults().getStreamSelection().getDefaultStreamSelector()); assertEquals(ConfigurationEngineDefaults.TimeSourceType.NANO, config.getEngineDefaults().getTimeSource().getTimeSourceType()); assertTrue(config.getEngineDefaults().getExecution().isPrioritized()); assertTrue(config.getEngineDefaults().getExecution().isFairlock()); assertTrue(config.getEngineDefaults().getExecution().isDisableLocking()); assertEquals(ConfigurationEngineDefaults.ThreadingProfile.LARGE, config.getEngineDefaults().getExecution().getThreadingProfile()); ConfigurationMetricsReporting metrics = config.getEngineDefaults().getMetricsReporting(); assertTrue(metrics.isEnableMetricsReporting()); assertEquals(4000L, metrics.getEngineInterval()); assertEquals(500L, metrics.getStatementInterval()); assertFalse(metrics.isThreading()); assertEquals(2, metrics.getStatementGroups().size()); assertTrue(metrics.isJmxEngineMetrics()); ConfigurationMetricsReporting.StmtGroupMetrics def = metrics.getStatementGroups().get("MyStmtGroup"); assertEquals(5000, def.getInterval()); assertTrue(def.isDefaultInclude()); assertEquals(50, def.getNumStatements()); assertTrue(def.isReportInactive()); assertEquals(5, def.getPatterns().size()); assertEquals(def.getPatterns().get(0), new Pair<StringPatternSet, Boolean>(new StringPatternSetRegex(".*"), true)); assertEquals(def.getPatterns().get(1), new Pair<StringPatternSet, Boolean>(new StringPatternSetRegex(".*test.*"), false)); assertEquals(def.getPatterns().get(2), new Pair<StringPatternSet, Boolean>(new StringPatternSetLike("%MyMetricsStatement%"), false)); assertEquals(def.getPatterns().get(3), new Pair<StringPatternSet, Boolean>(new StringPatternSetLike("%MyFraudAnalysisStatement%"), true)); assertEquals(def.getPatterns().get(4), new Pair<StringPatternSet, Boolean>(new StringPatternSetLike("%SomerOtherStatement%"), true)); def = metrics.getStatementGroups().get("MyStmtGroupTwo"); assertEquals(200, def.getInterval()); assertFalse(def.isDefaultInclude()); assertEquals(100, def.getNumStatements()); assertFalse(def.isReportInactive()); assertEquals(0, def.getPatterns().size()); assertTrue(config.getEngineDefaults().getLanguage().isSortUsingCollator()); assertTrue(config.getEngineDefaults().getExpression().isIntegerDivision()); assertTrue(config.getEngineDefaults().getExpression().isDivisionByZeroReturnsNull()); assertFalse(config.getEngineDefaults().getExpression().isSelfSubselectPreeval()); assertFalse(config.getEngineDefaults().getExpression().isUdfCache()); assertFalse(config.getEngineDefaults().getExpression().isExtendedAggregation()); assertTrue(config.getEngineDefaults().getExpression().isDuckTyping()); assertEquals(2, config.getEngineDefaults().getExpression().getMathContext().getPrecision()); assertEquals(RoundingMode.CEILING, config.getEngineDefaults().getExpression().getMathContext().getRoundingMode()); assertEquals(2, config.getEngineDefaults().getExceptionHandling().getHandlerFactories().size()); assertEquals("my.company.cep.LoggingExceptionHandlerFactory", config.getEngineDefaults().getExceptionHandling().getHandlerFactories().get(0)); assertEquals("my.company.cep.AlertExceptionHandlerFactory", config.getEngineDefaults().getExceptionHandling().getHandlerFactories().get(1)); assertEquals(2, config.getEngineDefaults().getConditionHandling().getHandlerFactories().size()); assertEquals("my.company.cep.LoggingConditionHandlerFactory", config.getEngineDefaults().getConditionHandling().getHandlerFactories().get(0)); assertEquals("my.company.cep.AlertConditionHandlerFactory", config.getEngineDefaults().getConditionHandling().getHandlerFactories().get(1)); assertEquals("abc", config.getEngineDefaults().getScripts().getDefaultDialect()); // variables assertEquals(3, config.getVariables().size()); ConfigurationVariable variable = config.getVariables().get("var1"); assertEquals(Integer.class.getName(), variable.getType()); assertEquals("1", variable.getInitializationValue()); assertFalse(variable.isConstant()); variable = config.getVariables().get("var2"); assertEquals(String.class.getName(), variable.getType()); assertEquals(null, variable.getInitializationValue()); assertFalse(variable.isConstant()); variable = config.getVariables().get("var3"); assertTrue(variable.isConstant()); // method references assertEquals(2, config.getMethodInvocationReferences().size()); ConfigurationMethodRef methodRef = config.getMethodInvocationReferences().get("abc"); expCache = (ConfigurationExpiryTimeCache) methodRef.getDataCacheDesc(); assertEquals(91.0, expCache.getMaxAgeSeconds()); assertEquals(92.2, expCache.getPurgeIntervalSeconds()); assertEquals(ConfigurationCacheReferenceType.WEAK, expCache.getCacheReferenceType()); methodRef = config.getMethodInvocationReferences().get("def"); lruCache = (ConfigurationLRUCache) methodRef.getDataCacheDesc(); assertEquals(20, lruCache.getSize()); // plug-in event representations assertEquals(2, config.getPlugInEventRepresentation().size()); ConfigurationPlugInEventRepresentation rep = config.getPlugInEventRepresentation() .get(new URI("type://format/rep/name")); assertEquals("com.mycompany.MyPlugInEventRepresentation", rep.getEventRepresentationClassName()); assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><anyxml>test string event rep init</anyxml>", rep.getInitializer()); rep = config.getPlugInEventRepresentation().get(new URI("type://format/rep/name2")); assertEquals("com.mycompany.MyPlugInEventRepresentation2", rep.getEventRepresentationClassName()); assertEquals(null, rep.getInitializer()); // plug-in event types assertEquals(2, config.getPlugInEventTypes().size()); ConfigurationPlugInEventType type = config.getPlugInEventTypes().get("MyEvent"); assertEquals(2, type.getEventRepresentationResolutionURIs().length); assertEquals("type://format/rep", type.getEventRepresentationResolutionURIs()[0].toString()); assertEquals("type://format/rep2", type.getEventRepresentationResolutionURIs()[1].toString()); assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><anyxml>test string event type init</anyxml>", type.getInitializer()); type = config.getPlugInEventTypes().get("MyEvent2"); assertEquals(1, type.getEventRepresentationResolutionURIs().length); assertEquals("type://format/rep2", type.getEventRepresentationResolutionURIs()[0].toString()); assertEquals(null, type.getInitializer()); // plug-in event representation resolution URIs when using a new name in a statement assertEquals(2, config.getPlugInEventTypeResolutionURIs().length); assertEquals("type://format/rep", config.getPlugInEventTypeResolutionURIs()[0].toString()); assertEquals("type://format/rep2", config.getPlugInEventTypeResolutionURIs()[1].toString()); // revision types assertEquals(1, config.getRevisionEventTypes().size()); ConfigurationRevisionEventType configRev = config.getRevisionEventTypes().get("MyRevisionEvent"); assertEquals(1, configRev.getNameBaseEventTypes().size()); assertTrue(configRev.getNameBaseEventTypes().contains("MyBaseEventName")); assertTrue(configRev.getNameDeltaEventTypes().contains("MyDeltaEventNameOne")); assertTrue(configRev.getNameDeltaEventTypes().contains("MyDeltaEventNameTwo")); EPAssertionUtil.assertEqualsAnyOrder(new String[] { "id", "id2" }, configRev.getKeyPropertyNames()); assertEquals(ConfigurationRevisionEventType.PropertyRevision.MERGE_NON_NULL, configRev.getPropertyRevision()); // variance types assertEquals(1, config.getVariantStreams().size()); ConfigurationVariantStream configVStream = config.getVariantStreams().get("MyVariantStream"); assertEquals(2, configVStream.getVariantTypeNames().size()); assertTrue(configVStream.getVariantTypeNames().contains("MyEvenTypetNameOne")); assertTrue(configVStream.getVariantTypeNames().contains("MyEvenTypetNameTwo")); assertEquals(ConfigurationVariantStream.TypeVariance.ANY, configVStream.getTypeVariance()); }
From source file:eu.europa.esig.dss.XmlDom.java
public long getCountValue(final String xPath, final Object... params) { String xpathString = format(xPath, params); try {// w w w . j a v a2s . c om XPathExpression xPathExpression = createXPathExpression(xpathString); Double number = (Double) xPathExpression.evaluate(rootElement, XPathConstants.NUMBER); return number.intValue(); } catch (XPathExpressionException e) { throw new RuntimeException(e); } }
From source file:hudson.plugins.plot.XMLSeries.java
/** * Convert a given object into a String. * // w ww.ja v a 2s . c o m * @param obj * Xpath Object * @return String representation of the node */ private String nodeToString(Object obj) { String ret = null; if (nodeType == XPathConstants.BOOLEAN) { return (((Boolean) obj)) ? "1" : "0"; } if (nodeType == XPathConstants.NUMBER) return ((Double) obj).toString().trim(); if (nodeType == XPathConstants.NODE || nodeType == XPathConstants.NODESET) { if (obj instanceof String) { ret = ((String) obj).trim(); } else { if (null == obj) { return null; } Node node = (Node) obj; NamedNodeMap nodeMap = node.getAttributes(); if ((null != nodeMap) && (null != nodeMap.getNamedItem("time"))) { ret = nodeMap.getNamedItem("time").getTextContent(); } if (null == ret) { ret = node.getTextContent().trim(); } } } if (nodeType == XPathConstants.STRING) ret = ((String) obj).trim(); // for Node/String/NodeSet, try and parse it as a double. // we don't store a double, so just throw away the result. Scanner scanner = new Scanner(ret); if (scanner.hasNextDouble()) { return String.valueOf(scanner.nextDouble()); } return null; }