Read a JournalEntry from the journal, to produce a
<code>ConsumerJournalEntry</code> instance. Concrete sub-classes should
insure that the XMLEventReader is positioned at the beginning of a
JournalEntry before calling this method.
770709
protected ConsumerJournalEntry readJournalEntry(XMLEventReader reader)
            throws JournalException, XMLStreamException {
        StartElement startTag = getJournalEntryStartTag(reader);
        String methodName =
                getRequiredAttributeValue(startTag, QNAME_ATTR_METHOD);

        JournalEntryContext context =
                new ContextXmlReader().readContext(reader);
        ConsumerJournalEntry cje =
                new ConsumerJournalEntry(methodName, context);

        readArguments(reader, cje);

        return cje;
    }
523364
@Override
    protected XMLEvent internalNextEvent() throws XMLStreamException {
        // If there is an iterator to read from reset was called, use the iterator
        // until it runs out of events.
        if (this.bufferReader != null) {
            final XMLEvent event = this.bufferReader.next();

            // If nothing left in the iterator, remove the reference and fall through to direct
            // reading
            if (!this.bufferReader.hasNext()) {
                this.bufferReader = null;
            }

            return event;
        }

        // Get the next event from the underlying reader
        final XMLEvent event = this.getParent().nextEvent();

        // if buffering add the event
        if (this.eventLimit != 0) {
            this.eventBuffer.offer(event);

            // If limited buffer size and buffer is too big trim the buffer.
            if (this.eventLimit > 0 && this.eventBuffer.size() > this.eventLimit) {
                this.eventBuffer.poll();
            }
        }

        return event;
    }
1300275
@Override
    public synchronized ManifestEntry read()
        throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {

        if (this.reader == null) {
            this.reader = new BufferedReader(new FileReader(manifestFile));
            long linesRead = getItemsRead();

            if (linesRead > 0) {
                for (long i = 0; i < linesRead; i++) {
                    this.reader.readLine();
                }
            }
        }

        String line = this.reader.readLine();
        if (line != null) {
            return ManifestFileHelper.parseManifestEntry(line);
        } else {
            return null;
        }

    }
1355742
public void getPresenter(final Consumer<Object> presenterConsumer) {

		presenterProperty.addListener(
				(final ObservableValue<? extends Object> o, final Object oldValue, final Object newValue) -> {
					presenterConsumer.accept(newValue);
				});
	}
861482
@XmlElementDecl(namespace = "http://schema.intuit.com/finance/v3", name = "JournalEntry", substitutionHeadNamespace = "http://schema.intuit.com/finance/v3", substitutionHeadName = "IntuitObject")
    public JAXBElement<JournalEntry> createJournalEntry(JournalEntry value) {
        return new JAXBElement<JournalEntry>(_JournalEntry_QNAME, JournalEntry.class, null, value);
    }
1034794
@Override
    public synchronized ConsumerJournalEntry readJournalEntry()
            throws JournalException, XMLStreamException {
        if (!open) {
            return null;
        }

        if (!advancedPastHeader) {
            advanceIntoFile();
            advancedPastHeader = true;
        }

        XMLEvent next = reader.peek();

        // advance past any whitespace events.
        while (next.isCharacters() && next.asCharacters().isWhiteSpace()) {
            reader.nextEvent();
            next = reader.peek();
        }
        if (isStartTagEvent(next, QNAME_TAG_JOURNAL_ENTRY)) {
            String identifier = peekAtJournalEntryIdentifier();
            ConsumerJournalEntry journalEntry = super.readJournalEntry(reader);
            journalEntry.setIdentifier(identifier);
            return journalEntry;
        } else if (isEndTagEvent(next, QNAME_TAG_JOURNAL)) {
            return null;
        } else {
            throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_JOURNAL,
                                                        QNAME_TAG_JOURNAL_ENTRY,
                                                        next);
        }
    }
411162
private void readArguments(XMLEventReader reader, ConsumerJournalEntry cje)
            throws XMLStreamException, JournalException {
        while (true) {
            XMLEvent nextTag = reader.nextTag();
            if (isStartTagEvent(nextTag, QNAME_TAG_ARGUMENT)) {
                readArgument(nextTag, reader, cje);
            } else if (isEndTagEvent(nextTag, QNAME_TAG_JOURNAL_ENTRY)) {
                return;
            } else {
                throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_JOURNAL_ENTRY,
                                                            QNAME_TAG_ARGUMENT,
                                                            nextTag);
            }
        }
    }
465971
MappableJournalSegmentReader<E> createReader() {
    checkOpen();
    MappableJournalSegmentReader<E> reader = new MappableJournalSegmentReader<>(
        openChannel(file.file()), this, maxEntrySize, index, namespace);
    MappedByteBuffer buffer = writer.buffer();
    if (buffer != null) {
      reader.map(buffer);
    }
    readers.add(reader);
    return reader;
  }
1281030
@Override
    public void prepareToWriteJournalEntry() throws JournalException {
        if (open) {
            currentJournal.closeIfAppropriate();

            if (!currentJournal.isOpen()) {
                currentJournal =
                        new JournalOutputFile(this,
                                              filenamePrefix,
                                              journalDirectory,
                                              sizeLimit,
                                              ageLimit);
            }
        }
    }
991425
public static <T> Predicate<T> peek(Consumer<T> consumer) {
		return target -> JMLambda
				.getTrueAfterRunning(() -> consumer.accept(target));
	}
1265927
private void createInitialReader() throws IOException, JspCoreException {

	// wrap this stream in RewindableInputStream
	stream = new RewindableInputStream(stream);

	// perform auto-detect of encoding if necessary
	if (encoding == null) {
	    // read first four bytes and determine encoding
	    final byte[] b4 = new byte[4];
	    int count = 0;
	    for (; count<4; count++ ) {
		b4[count] = (byte)stream.read();
	    }
	    if (count == 4) {
		Object [] encodingDesc = getEncodingName(b4, count);
		encoding = (String)(encodingDesc[0]);
		isBigEndian = (Boolean)(encodingDesc[1]);
        if (encodingDesc.length > 2) {
            isBomPresent = (Boolean)(encodingDesc[2]);
        } else {
            isBomPresent = true;
        }

		stream.reset();
		// Special case UTF-8 files with BOM created by Microsoft
		// tools. It's more efficient to consume the BOM than make
		// the reader perform extra checks. -Ac
		if (count > 2 && encoding.equals("UTF-8")) {
		    int b0 = b4[0] & 0xFF;
		    int b1 = b4[1] & 0xFF;
		    int b2 = b4[2] & 0xFF;
		    if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
			// ignore first three bytes...
			stream.skip(3);
		    }
		}
		reader = createReader(stream, encoding, isBigEndian);
	    } else {
		reader = createReader(stream, encoding, isBigEndian);
	    }
	}
    }
1210319
@SuppressWarnings("unchecked")
    @Override
    public final PipelineEventReader<R, E> getEventReader(
            HttpServletRequest request, HttpServletResponse response) {
        if (Included.PLAIN == this.resourcesElementsProvider.getDefaultIncludedType()) {
            this.logger.trace(
                    "{} - Resoure Aggregation Disabled, ignoring event cache and returning parent event reader directly",
                    this.beanName);
            return this.wrappedComponent.getEventReader(request, response);
        }

        // Get the key for this request from the target component and see if there is a cache entry
        final CacheKey cacheKey = this.wrappedComponent.getCacheKey(request, response);
        Element element = this.cache.get(cacheKey);
        CachedEventReader<E> cachedEventReader = null;
        if (element != null) {
            cachedEventReader = (CachedEventReader<E>) element.getObjectValue();
        }

        // If there was a cached reader return it immediately
        if (cachedEventReader == null) {
            // No cached data for key, call target component to get events and an updated cache key
            logger.debug(
                    "{} - No cached events found for key {}, calling parent",
                    this.beanName,
                    cacheKey);
            final PipelineEventReader<R, E> pipelineEventReader =
                    this.wrappedComponent.getEventReader(request, response);

            // Copy the events from the reader into a buffer to be cached
            final List<E> eventCache = new LinkedList<E>();
            for (final E event : pipelineEventReader) {
                // TODO add de-duplication logic here
                eventCache.add(event);
            }

            final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
            cachedEventReader =
                    new CachedEventReader<E>(
                            eventCache, new LinkedHashMap<String, String>(outputProperties));

            // Cache the buffer
            element = new Element(cacheKey, cachedEventReader);
            this.cache.put(element);
            logger.debug(
                    "{} - Cached {} events for key {}", this.beanName, eventCache.size(), cacheKey);
        } else {
            logger.debug("{} - Found cached events for key {}", this.beanName, cacheKey);
        }

        final List<E> eventCache = cachedEventReader.getEventCache();
        final Map<String, String> outputProperties = cachedEventReader.getOutputProperties();

        final R eventReader = this.createEventReader(eventCache.listIterator());
        return new PipelineEventReaderImpl<R, E>(eventReader, outputProperties);
    }
360187
public ApacheHttpdLogfileRecordReader createRecordReader() {
        try {
            return new ApacheHttpdLogfileRecordReader(getLogFormat(), getRequestedFields(), getTypeRemappings(), getAdditionalDissectors());
        } catch (IOException e) {
            return null;
        }
    }
194227
protected void prepareXMLReader() throws VerifierConfigurationException {
		try {
			SAXParserFactory factory = SAXParserFactory.newInstance();
			factory.setNamespaceAware(true);
			reader = factory.newSAXParser().getXMLReader();
		} catch( SAXException e ) {
			throw new VerifierConfigurationException(e);
		} catch( ParserConfigurationException pce ) {
			throw new VerifierConfigurationException(pce);
		}
	}
981673
public void parseEvents(MarcXchangeEventConsumer consumer) throws XMLStreamException {
        Objects.requireNonNull(consumer);
        if (builder.getMarcListeners() != null) {
            for (Map.Entry<String, MarcListener> entry : builder.getMarcListeners().entrySet()) {
                consumer.setMarcListener(entry.getKey(), entry.getValue());
            }
        }
        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLEventReader xmlEventReader = inputFactory.createXMLEventReader(builder.getInputStream());
        while (xmlEventReader.hasNext()) {
            consumer.add(xmlEventReader.nextEvent());
        }
        xmlEventReader.close();
    }
851584
@Override
    public RecordReader createReader(InputSplit split) throws IOException, InterruptedException {
        RecordReader reader = new ListStringRecordReader();
        reader.initialize(split);
        return reader;
    }
808872
private void startConsumerThread() {
        stopped = false;
        thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (!stopped) {
                    processQueue();
                }
            }
        }, "JdbcMetricsConsumer"); //$NON-NLS-1$
        thread.setDaemon(true);
        thread.start();        
    }