com.hcl.domino.jna.internal.views.NotesSearchKeyEncoder Maven / Gradle / Ivy
The newest version!
/*
* ==========================================================================
* Copyright (C) 2019-2022 HCL America, Inc. ( http://www.hcl.com/ )
* All rights reserved.
* ==========================================================================
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. You may obtain a
* copy of the License at .
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
* ==========================================================================
*/
package com.hcl.domino.jna.internal.views;
import static java.text.MessageFormat.format;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.temporal.TemporalAccessor;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Objects;
import com.hcl.domino.commons.data.DefaultDominoDateRange;
import com.hcl.domino.commons.util.InnardsConverter;
import com.hcl.domino.commons.util.NotesDateTimeUtils;
import com.hcl.domino.data.ItemDataType;
import com.hcl.domino.jna.data.JNADominoDateTime;
import com.hcl.domino.jna.internal.JNANotesConstants;
import com.hcl.domino.jna.internal.NotesStringUtils;
import com.hcl.domino.jna.internal.structs.NotesItemValueTableStruct;
import com.hcl.domino.jna.internal.structs.NotesNumberPairStruct;
import com.hcl.domino.jna.internal.structs.NotesRangeStruct;
import com.hcl.domino.jna.internal.structs.NotesTableItemStruct;
import com.hcl.domino.jna.internal.structs.NotesTimeDatePairStruct;
import com.hcl.domino.jna.internal.structs.NotesTimeDateStruct;
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, 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 encodeKeys(Object[] keys) throws Exception {
ByteArrayOutputStream metaDataByteOut = new ByteArrayOutputStream();
ByteArrayOutputStream valueDataByteOut = new ByteArrayOutputStream();
for (int i=0; i format("Keys cannot be null. keys={0}", Arrays.toString(keys)));
}
//write placeholder for the total buffer size and the number of items, will be filled later
metaDataByteOut.write(0);
metaDataByteOut.write(0);
metaDataByteOut.write(0);
metaDataByteOut.write(0);
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(format("Double search key array must have exactly 2 elements. We found {0}", currKey.length));
}
Memory itemMem = new Memory(JNANotesConstants.tableItemSize);
NotesTableItemStruct item = NotesTableItemStruct.newInstance(itemMem);
item.NameLength = 0;
item.ValueLength = (short) ((JNANotesConstants.rangeSize + JNANotesConstants.numberPairSize + 2) & 0xffff);
item.write();
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy