Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* ==========================================================================
* 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.data;
import java.lang.ref.ReferenceQueue;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.hcl.domino.DominoException;
import com.hcl.domino.commons.errors.UnsupportedItemValueError;
import com.hcl.domino.commons.gc.APIObjectAllocations;
import com.hcl.domino.commons.gc.IAPIObject;
import com.hcl.domino.commons.gc.IGCDominoClient;
import com.hcl.domino.commons.util.NotesErrorUtils;
import com.hcl.domino.commons.util.StringUtil;
import com.hcl.domino.data.Document;
import com.hcl.domino.data.DominoDateTime;
import com.hcl.domino.data.Formula;
import com.hcl.domino.data.FormulaAnalyzeResult;
import com.hcl.domino.data.FormulaAnalyzeResult.FormulaAttributes;
import com.hcl.domino.data.IAdaptable;
import com.hcl.domino.data.ItemDataType;
import com.hcl.domino.exception.FormulaCompilationException;
import com.hcl.domino.exception.IncompatibleImplementationException;
import com.hcl.domino.exception.ObjectDisposedException;
import com.hcl.domino.jna.BaseJNAAPIObject;
import com.hcl.domino.jna.internal.ItemDecoder;
import com.hcl.domino.jna.internal.Mem;
import com.hcl.domino.jna.internal.capi.NotesCAPI;
import com.hcl.domino.jna.internal.gc.allocations.JNADocumentAllocations;
import com.hcl.domino.jna.internal.gc.allocations.JNAFormulaAllocations;
import com.hcl.domino.jna.internal.gc.handles.DHANDLE;
import com.hcl.domino.jna.internal.gc.handles.LockUtil;
import com.hcl.domino.misc.DominoEnumUtil;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.ShortByReference;
/**
* Utility class to execute a Domino formula on one or more {@link Document} objects.
*
* @author Karsten Lehmann
*/
public class JNAFormula extends BaseJNAAPIObject implements IAdaptable, Formula {
private String m_formula;
private Set m_disallowedActions;
/**
* Creates a new instance. The constructure compiles the formula and throws a {@link FormulaCompilationException},
* if there are any compilation errors
*
* @param parent API parent object
* @param formula formula
* @throws FormulaCompilationException if formula has wrong syntax
*/
public JNAFormula(IAPIObject> parent, String formula) throws FormulaCompilationException {
super(parent);
m_formula = formula;
m_disallowedActions = new HashSet<>();
getAllocations().initWithFormula(formula);
setInitialized();
}
@SuppressWarnings("rawtypes")
@Override
protected JNAFormulaAllocations createAllocations(IGCDominoClient> parentDominoClient,
APIObjectAllocations parentAllocations, ReferenceQueue super IAPIObject> queue) {
return new JNAFormulaAllocations(parentDominoClient, parentAllocations, this, queue);
}
@Override
@SuppressWarnings("unchecked")
protected T getAdapterLocal(Class clazz) {
if (clazz == byte[].class) {
return (T) getAllocations().getCompiledFormula();
}
return null;
}
@Override
public String getFormula() {
return m_formula;
}
@Override
public String toStringLocal() {
if (isDisposed()) {
return MessageFormat.format("Compiled formula [disposed, formula={0}]", m_formula); //$NON-NLS-1$
}
else {
return MessageFormat.format("Compiled formula [formula={0}]", m_formula); //$NON-NLS-1$
}
}
@Override
public Formula disallow(Collection actions) {
m_disallowedActions.addAll(actions);
return this;
}
@Override
public Formula disallow(Disallow action) {
m_disallowedActions.add(action);
return this;
}
@Override
public boolean isDisallowed(Disallow action) {
return m_disallowedActions.contains(action);
}
private List