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

com.mindoo.domino.jna.ViewEntryImpl Maven / Gradle / Ivy

There is a newer version: 0.9.53
Show newest version
package com.mindoo.domino.jna;

import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.Vector;

import com.mindoo.domino.jna.internal.NotesConstants;

import lotus.domino.Base;
import lotus.domino.Document;
import lotus.domino.NotesException;
import lotus.domino.View;
import lotus.domino.ViewEntry;

/**
 * Bridge between a {@link ViewEntry} and data we retrieve from C API calls
 * 
 * @author Karsten Lehmann
 */
public class ViewEntryImpl implements ViewEntry {
	private View m_parent;
	private NotesViewEntryData m_data;
	private Vector m_colValues;
	
	public ViewEntryImpl(View parent, NotesViewEntryData data) {
		m_data = data;
	}

	@Override
	public void recycle() throws NotesException {
		//noop, because we don't have a handle to release
	}

	@Override
	public void recycle(Vector paramVector) throws NotesException {
		if (paramVector!=null) {
			for (int i=0; i0)
				sb.append(paramChar);
			
			sb.append(Integer.toString(pos[i]));
		}
		return sb.toString();
	}

	@Override
	public String getNoteID() throws NotesException {
		return Integer.toString(m_data.getNoteId(), 16);
	}

	@Override
	public int getNoteIDAsInt() throws NotesException {
		return m_data.getNoteId();
	}

	@Override
	public String getUniversalID() throws NotesException {
		return m_data.getUNID();
	}

	@Override
	public boolean isConflict() throws NotesException {
		return m_data.isConflict();
	}

	public boolean isResponse() {
		return m_data.isResponse();
	}
	
	@Override
	public Vector getColumnValues() throws NotesException {
		if (m_colValues==null) {
			m_colValues = new Vector();
			
			TreeMap columnValuesByColValuesIndex = new TreeMap();
			NotesCollection parentCol = m_data.getParent();
			
			Iterator colNames = parentCol.getColumnNames();
			while (colNames.hasNext()) {
				String currColName = colNames.next();
				int colValuesIndex = m_data.getParent().getColumnValuesIndex(currColName);
				if (colValuesIndex<65535) {
					Object currColValue = m_data.get(currColName);
					
					if (currColValue instanceof Calendar) {
						currColValue = ((Calendar)currColValue).getTime();
					}
					else if (currColValue instanceof List) {
						List currColValueAsList = (List) currColValue;
						
						//convert column value to a Vector
						Vector currColValueAsVector = new Vector(currColValueAsList.size());
						
						for (int i=0; i currDateRangeValuesAsVector = new Vector(2);
								currDateRangeValuesAsVector.add(startDateTime.toDate());
								currDateRangeValuesAsVector.add(endDateTime.toDate());
								
								currListVal = currDateRangeValuesAsVector;
							}
							else if (currListVal instanceof Calendar[]) {
								//replace Calendar[] with date range info with a Vector of Date
								Calendar[] calArr = (Calendar[]) currListVal;
								Vector currDateRangeValuesAsVector = new Vector(calArr.length);
								for (int j=0; j currEntry : columnValuesByColValuesIndex.entrySet()) {
				colValuesArr[currEntry.getKey()] = currEntry.getValue();
			}
			m_colValues = new Vector(colValuesArr.length);
			for (int i=0; i getColumnNamesWithValues() {
		return m_data.getColumnNames();
	}
	
	public Object getColumnValue(String columnName) {
		return m_data.get(columnName);
	}
	
	public int getNumberOfColumnsWithValues() {
		return m_data.getNumberOfColumnsWithValues();
	}
	
	@Override
	public int getFTSearchScore() throws NotesException {
		return m_data.getFTScore();
	}

	@Override
	public boolean isValid() throws NotesException {
		return m_data.getNoteId()!=0;
	}

	@Override
	public boolean getRead() throws NotesException {
		return !m_data.isUnread();
	}

	@Override
	public boolean getRead(String paramString) throws NotesException {
		return false;
	}

	@Override
	public boolean isPreferJavaDates() throws NotesException {
		return true;
	}

	@Override
	public void setPreferJavaDates(boolean paramBoolean) throws NotesException {
	}
	
}