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

org.eclipse.birt.report.engine.internal.index.v1.DocumentIndexReaderV1 Maven / Gradle / Ivy

There is a newer version: 4.6.0-20160607
Show newest version
/*******************************************************************************
 * Copyright (c) 2008 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.engine.internal.index.v1;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.eclipse.birt.report.engine.api.impl.ReportDocumentConstants;
import org.eclipse.birt.report.engine.content.impl.BookmarkContent;
import org.eclipse.birt.report.engine.internal.index.IDocumentIndexReader;
import org.eclipse.birt.report.engine.toc.TOCBuilder;

public class DocumentIndexReaderV1
		implements
			IDocumentIndexReader,
			ReportDocumentConstants
{

	private HashMap bookmarks;
	private HashMap reportlets;
	private HashMap pageNumbers;

	public DocumentIndexReaderV1( HashMap bookmarks,
			HashMap reportlets, HashMap pageNumbers )
			throws IOException
	{
		this.bookmarks = bookmarks;
		this.reportlets = reportlets;
		this.pageNumbers = pageNumbers;
	}

	public int getVersion( )
	{
		return VERSION_1;
	}

	public void close( )
	{
	}

	public long getOffsetOfBookmark( String bookmark ) throws IOException
	{
		if ( bookmarks != null )
		{
			Long offset = bookmarks.get( bookmark );
			if ( offset != null )
			{
				return offset.longValue( );
			}
		}
		return -1L;
	}

	public long getOffsetOfInstance( String instanceId ) throws IOException
	{
		if ( reportlets != null )
		{
			Long offset = reportlets.get( instanceId );
			if ( offset != null )
			{
				return offset.longValue( );
			}
		}
		return -1L;
	}

	public long getPageOfBookmark( String bookmark ) throws IOException
	{
		if ( pageNumbers != null )
		{
			Long pageNumber = pageNumbers.get( bookmark );
			if ( pageNumber != null )
			{
				return pageNumber.longValue( );
			}
		}
		return -1L;
	}

	public List getBookmarks( ) throws IOException
	{
		if ( pageNumbers != null )
		{
			ArrayList list = new ArrayList( );
			for ( String bookmark : pageNumbers.keySet( ) )
			{
				if ( bookmark != null
						&& !bookmark.startsWith( TOCBuilder.TOC_PREFIX ) )
				{
					list.add( bookmark );
				}
			}
			return list;
		}
		return null;
	}

	public BookmarkContent getBookmark( String bookmark )
	{
		return null;
	}

	public List getBookmarkContents( ) throws IOException
	{
		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy