All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.docx4j.finders.RangeFinder Maven / Gradle / Ivy

Go to download

docx4j is a library which helps you to work with the Office Open XML file format as used in docx documents, pptx presentations, and xlsx spreadsheets.

There is a newer version: 11.4.11
Show newest version
package org.docx4j.finders;

import java.util.ArrayList;
import java.util.List;

import org.docx4j.TraversalUtil.CallbackImpl;
import org.docx4j.wml.CTBookmark;
import org.docx4j.wml.CTMarkupRange;

/**
 * This is a simplified version of 
 * org.docx4j.model.datastorage.BookmarkRenumber.RangeTraverser
 */
public class RangeFinder extends CallbackImpl {

	public RangeFinder() {
	}
	
	List starts = new ArrayList();
	/**
	 * @return the starts
	 */
	public List getStarts() {
		return starts;
	}

	List ends   = new ArrayList();
	/**
	 * @return the ends
	 */
	public List getEnds() {
		return ends;
	}


	@Override
	public List apply(Object o) {
		
		if (o instanceof CTBookmark) { 
			CTBookmark bookmark = (CTBookmark)o;
				starts.add(bookmark);
		} else /* need this else because CTBookmark extends CTMarkupRange */ 
		if (o instanceof CTMarkupRange) { 
			
			CTMarkupRange bookmark = (CTMarkupRange)o;
				ends.add(bookmark);
		} 

		return null;
	}
	
}