Package org.jasig.portal.character.stream

Examples of org.jasig.portal.character.stream.CharacterEventSource


        return event;
    }

    private XMLEvent tryChunking(StartElement startElement) throws XMLStreamException {
        QName elementName = startElement.getName();
        CharacterEventSource characterEventSource = this.chunkingElements.get(elementName.getLocalPart());
        while (characterEventSource != null) {
            final XMLEvent previousEvent = this.getPreviousEvent();
            if (previousEvent != null && previousEvent.isStartElement()) {
                this.captureEvent = startElement;
               
                //Write an empty Character event to force the serializer to finish writing the previous StartElement
                //It is left open since ATTRIBUTE events can follow a START_ELEMENT event.
                return EVENT_FACTORY.createCharacters("");
            }
           
            //Capture the characters written out to this point then clear the buffer
            this.captureCharacterDataEvent();
           
            //Get the generated events for the element
            final XMLEventReader parent = this.getParent();
            characterEventSource.generateCharacterEvents(this.request, parent, startElement, this.characterEvents);
           
            //Read the next event off the reader
            final XMLEvent nextEvent = parent.nextEvent();
            if (nextEvent.isStartElement()) {
                startElement = nextEvent.asStartElement();
View Full Code Here


        for (; patternIndex < this.chunkingPatterns.length; patternIndex++) {
            final Pattern pattern = this.chunkingPatterns[patternIndex];

            final Matcher matcher = pattern.matcher(buffer);
            if (matcher.find()) {
                final CharacterEventSource eventSource = this.chunkingPatternEventSources.get(pattern);
                int prevMatchEnd = 0;

                do {
                    //Add all of the text up to the match as a new chunk, use subSequence to avoid extra string alloc
                    this.chunkString(characterEvents,
                            buffer.subSequence(prevMatchEnd, matcher.start()),
                            patternIndex + 1);

                    //Get the generated CharacterEvents for the match
                    final MatchResult matchResult = matcher.toMatchResult();
                    eventSource.generateCharacterEvents(this.request, matchResult, characterEvents);
                   
                    prevMatchEnd = matcher.end();
                } while (matcher.find());

                //Add any remaining text from the original CharacterDataEvent
View Full Code Here

        final Map<Pattern, CharacterEventSource> compiledChunkingPatternEventSources = new LinkedHashMap<Pattern, CharacterEventSource>();
       
        for (final Map.Entry<String, CharacterEventSource> chunkingPatternEntry : chunkingPatterns.entrySet()) {
            final String key = chunkingPatternEntry.getKey();
            final Pattern pattern = Pattern.compile(key);
            final CharacterEventSource value = chunkingPatternEntry.getValue();
            compiledChunkingPatternEventSources.put(pattern, value);
        }
       
        this.chunkingPatternEventSources = compiledChunkingPatternEventSources;
        this.chunkingPatterns = this.chunkingPatternEventSources.keySet().toArray(new Pattern[this.chunkingPatternEventSources.size()]);
View Full Code Here

TOP

Related Classes of org.jasig.portal.character.stream.CharacterEventSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.