table.put(prefix, new ValueTable()); final ValueTable subTable = (ValueTable) table.get(prefix); final String[] tokens = value.split(","); if (tokens.length == 1) {
table.put(prefix, new ValueTable()); final ValueTable subTable = (ValueTable) table.get(prefix); final String[] tokens = value.split(","); if (tokens.length == 1) {
/** * Parses details of the activated channels into the {@link #activeChannels} * data structure from the "channel" entry of the configuration. */ private void parseChannels() { final Value channels = config.get("channel"); if (!(channels instanceof ValueTable)) return; final ValueTable channelsTable = (ValueTable) channels; for (final String key : channelsTable.keySet()) { final Value value = channelsTable.get(key); // verify that the channel is active if (!b(value(value))) continue; // channel not active // parse the channel index (converting to a 1-based index!) final int channelIndex = i(key) + 1; // add the channel index to the active channels list activeChannels.add(channelIndex); } }
/** * This steps populates the original metadata table (the tables returned by * {@link #getGlobalMetadata()} and {@link #getSeriesMetadata()}). */ private void populateOriginalMetadata() { final boolean minimumMetadata = isMinimumMetadata(); if (minimumMetadata) return; // populate global metadata addGlobalMeta("cycleCount", meta.getCycleCount()); addGlobalMeta("date", meta.getDate()); addGlobalMeta("waitTime", meta.getWaitTime()); addGlobalMeta("sequenceCount", sequences.size()); final ValueTable config = meta.getConfig(); for (final String key : config.keySet()) { addGlobalMeta(key, config.get(key).toString()); } addGlobalMeta("meta", meta); // populate series metadata final int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { setSeries(s); final Sequence sequence = sequence(s); addSeriesMeta("cycle", sequence.getCycle()); addSeriesMeta("indexCount", sequence.getIndexCount()); addSeriesMeta("type", sequence.getType()); } setSeries(0); }
/** * This steps populates the original metadata table (the tables returned by * {@link #getGlobalMetadata()} and {@link #getSeriesMetadata()}). */ private void populateOriginalMetadata() { final boolean minimumMetadata = isMinimumMetadata(); if (minimumMetadata) return; // populate global metadata addGlobalMeta("cycleCount", meta.getCycleCount()); addGlobalMeta("date", meta.getDate()); addGlobalMeta("waitTime", meta.getWaitTime()); addGlobalMeta("sequenceCount", sequences.size()); final ValueTable config = meta.getConfig(); for (final String key : config.keySet()) { addGlobalMeta(key, config.get(key).toString()); } addGlobalMeta("meta", meta); // populate series metadata final int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { setSeries(s); final Sequence sequence = sequence(s); addSeriesMeta("cycle", sequence.getCycle()); addSeriesMeta("indexCount", sequence.getIndexCount()); addSeriesMeta("type", sequence.getType()); } setSeries(0); }
@Test public void testParseNewXML() throws ParserConfigurationException, SAXException, IOException { final Document xml = XMLTools.parseDOM(NEW_XML); final PrairieMetadata meta = new PrairieMetadata(xml, null, null); final ValueTable positionCurrent = (ValueTable) meta.getSequence(1).getFrame(1).getValue("positionCurrent"); final ValueTable xAxis = (ValueTable) positionCurrent.get("XAxis"); assertEquals("-621.412879412341", xAxis.value()); final ValueTable yAxis = (ValueTable) positionCurrent.get("YAxis"); assertEquals("255.652372573538", yAxis.value()); final ValueTable zAxis = (ValueTable) positionCurrent.get("ZAxis"); assertEquals("28.15", zAxis.get(0).value()); assertEquals("111.23", zAxis.get(1).value()); } }
/** * Parses details of the activated channels into the {@link #activeChannels} * data structure from the "channel" entry of the configuration. */ private void parseChannels() { final Value channels = config.get("channel"); if (!(channels instanceof ValueTable)) return; final ValueTable channelsTable = (ValueTable) channels; for (final String key : channelsTable.keySet()) { final Value value = channelsTable.get(key); // verify that the channel is active if (!b(value(value))) continue; // channel not active // parse the channel index (converting to a 1-based index!) final int channelIndex = i(key) + 1; // add the channel index to the active channels list activeChannels.add(channelIndex); } }
@Test public void testParseOldXML() throws ParserConfigurationException, SAXException, IOException { final Document xml = XMLTools.parseDOM(OLD_XML); final PrairieMetadata meta = new PrairieMetadata(xml, null, null); final Value positionCurrent = meta.getSequence(1).getFrame(1).getValue("positionCurrent"); final Value xAxis = positionCurrent.get("XAxis"); assertEquals("0.95", xAxis.value()); final Value yAxis = positionCurrent.get("YAxis"); assertEquals("-4.45", yAxis.value()); final ValueTable zAxis = (ValueTable) positionCurrent.get("ZAxis"); assertEquals("-9", zAxis.get(0).value()); assertEquals("62.45", zAxis.get(1).value()); }
@Override public Value get(int index) { return get("" + index); }
/** Gets the {@code value} of the given configuration {@code key}. */ public Value getConfig(final String key) { return config.get(key); }
@Override public Value get(int index) { return get("" + index); }
/** * Gets the {@code value} of the given {@code key}, at the top-level * {@code <PVScan>} element. */ public Value getValue(final String key) { return scanValues.get(key); }
/** * Gets the {@code value} of the given {@code key}, at the top-level * {@code <PVScan>} element. */ public Value getValue(final String key) { return scanValues.get(key); }
/** Gets the {@code value} of the given configuration {@code key}. */ public Value getConfig(final String key) { return config.get(key); }
/** * Gets the {@code value} of the given {@code key}, beneath this * {@code Sequence}, inferring the value from the parent {@code <PVScan>} * section as needed. */ public Value getValue(final String key) { if (sequenceValues.containsKey(key)) return sequenceValues.get(key); return PrairieMetadata.this.getValue(key); }
/** * Gets the {@code value} of the given {@code key}, beneath this * {@code Frame}, inferring the value from the parent {@code <Sequence>} * or grandparent {@code <PVScan>} section as needed. */ public Value getValue(final String key) { if (frameValues.containsKey(key)) return frameValues.get(key); return getSequence().getValue(key); }
/** * Gets the {@code value} of the given {@code key}, beneath this * {@code Sequence}, inferring the value from the parent {@code <PVScan>} * section as needed. */ public Value getValue(final String key) { if (sequenceValues.containsKey(key)) return sequenceValues.get(key); return PrairieMetadata.this.getValue(key); }
/** * Gets the {@code value} of the given {@code key}, beneath this * {@code Frame}, inferring the value from the parent {@code <Sequence>} * or grandparent {@code <PVScan>} section as needed. */ public Value getValue(final String key) { if (frameValues.containsKey(key)) return frameValues.get(key); return getSequence().getValue(key); }