com.mindoo.domino.jna.internal.NotesSearchKeyEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of domino-jna Show documentation
Show all versions of domino-jna Show documentation
Java project to access the HCL Domino C API using Java Native Access (JNA)
package com.mindoo.domino.jna.internal;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import com.mindoo.domino.jna.NotesDateRange;
import com.mindoo.domino.jna.NotesItem;
import com.mindoo.domino.jna.NotesTimeDate;
import com.mindoo.domino.jna.internal.structs.NotesItemValueTableStruct;
import com.mindoo.domino.jna.internal.structs.NotesNumberPairStruct;
import com.mindoo.domino.jna.internal.structs.NotesRangeStruct;
import com.mindoo.domino.jna.internal.structs.NotesTableItemStruct;
import com.mindoo.domino.jna.internal.structs.NotesTimeDatePairStruct;
import com.mindoo.domino.jna.internal.structs.NotesTimeDateStruct;
import com.mindoo.domino.jna.utils.NotesDateTimeUtils;
import com.mindoo.domino.jna.utils.NotesStringUtils;
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
public class NotesSearchKeyEncoder {
/**
* Produces the keybuffer for NIFFindByKey
*
* @param keys array of String, Double, Integer, Calendar, Date, Calendar[] (with two elements lower/upper), Date[] (with two elements lower/upper)
* @return buffer with encoded keys
* @throws Exception in case of errors
*/
public static Memory b32_encodeKeys(Object[] keys) throws Exception {
return b64_encodeKeys(keys);
}
/**
* Produces the keybuffer for NIFFindByKey
*
* @param keys array of String, Double, Integer, NotesTimeDate, Calendar, Date, NotesDateRange, Calendar[] (with two elements lower/upper), Date[] (with two elements lower/upper)
* @return buffer with encoded keys
* @throws Exception in case of errors
*/
public static Memory b64_encodeKeys(Object[] keys) throws Exception {
ByteArrayOutputStream metaDataByteOut = new ByteArrayOutputStream();
ByteArrayOutputStream valueDataByteOut = new ByteArrayOutputStream();
for (int i=0; idocumentation says.
*
* @param itemOut output stream for ITEM structure
* @param valueDataOut output stream for search key value
* @param currKey search key
* @throws Exception in case of errors
*/
private static void addNumberRangeKey(OutputStream itemOut, OutputStream valueDataOut, double[] currKey) throws Exception {
if (currKey.length!=2)
throw new IllegalArgumentException("Double search key array must have exactly 2 elements. We found "+currKey.length);
Memory itemMem = new Memory(NotesConstants.tableItemSize);
NotesTableItemStruct item = NotesTableItemStruct.newInstance(itemMem);
item.NameLength = 0;
item.ValueLength = (short) ((NotesConstants.rangeSize + NotesConstants.numberPairSize + 2) & 0xffff);
item.write();
for (int i=0; i