public enum DominoNativeUtils extends Enum<DominoNativeUtils>
Modifier and Type | Field and Description |
---|---|
static com.ibm.commons.log.LogMgr |
NAPI_LOG |
static com.ibm.commons.log.LogMgr |
NAPI_MEMORY_LOG |
static TimeZone |
TIMEZONE_UTC |
static Charset |
UTF_8
This static constant for the charset allows classes to avoid looking it up each time
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
coerceValue(Object[] value,
Class<T> clazz) |
static <T> T |
coerceValue(Object value,
Class<T> clazz) |
static Object[] |
concatNSFItemValues(Collection<NSFItem> items) |
static <T> T |
concatNSFItemValues(Collection<NSFItem> items,
Class<T> clazz) |
static String |
decompileFormula(DominoAPI api,
byte[] formulaData,
boolean selectionFormula)
Decompiles a given formula and returns its text as a
String . |
static void |
fillTimeDate(TIMEDATE timedate,
Object val)
Sets the provided TIMEDATE value to an appropriate value based on the type of val
|
static void |
fillTimeDatePair(TIMEDATE_PAIR timedatepair,
Object val)
Sets the provided TIMEDATE_PAIR value to an appropriate value based on the type of val
|
static void |
free(Object... objects)
Frees any
BaseStruct and NSFBase objects in the provided array. |
static String |
getExtensionForMIMEType(String mimeType)
Returns the file extension (without the dot) for the provided MIME type, according to Domino.
|
static String |
getMIMETypeForExtension(String ext)
Returns the MIME type for the provided extension (without the dot), according to Domino.
|
static Calendar |
getReusableCalendarInstance(TimeZone timeZone,
boolean initTime)
|
static TimeZone |
getTimeZoneForOffset(int offset) |
static int |
indexOf(byte[] bytes,
byte value) |
static boolean |
isDateRangeType(Class<?> valClass)
Determines whether the class is a supported date/time range class.
|
static boolean |
isDateRangeType(Object val)
Determines whether the object is of a supported date/time range class.
|
static boolean |
isDateTimeType(Class<?> valClass)
Determines whether the class is a supported date/time class.
|
static boolean |
isDateTimeType(Object val)
Determines whether the object is of a supported date/time class.
|
static boolean |
isDeletedId(int noteId) |
static boolean |
isLinux_x64() |
static boolean |
isLinux_x86() |
static boolean |
isMac_x64() |
static boolean |
isMac_x86() |
static boolean |
isWinx64() |
static boolean |
isWinx86() |
static void |
loadLibraryFromJar(ClassLoader cl,
String path) |
static boolean |
matchesFlagsPattern(String flags,
String pattern) |
static String |
quoteForFormulaString(String value)
Escapes the provided value in a way suitable for inclusion in place of a string in a Notes formula.
|
static Object |
readItemValue(DominoAPI api,
long valuePtr,
int size,
long hNote)
Reads the value of the reference item into Java objects when possible and, when not, into copies of
the struct objects in memory.
|
static Object[] |
readItemValueArray(DominoAPI api,
long valuePtr,
int size,
long hNote) |
static String |
readLMBCSString(byte[] bytes) |
static String |
readString(byte[] bytes)
Reads a null-terminated UTF-8 String from the given byte array, stopping at the first null character or the end of the array.
|
static List<String> |
splitDesignNames(String[] names)
Returns a
List of the names and aliases in the provided array. |
static ITEM_TABLE |
toItemTable(Object... values)
Convert the provided values into an
ITEM_TABLE with no item names. |
static int |
toNonDeletedId(int noteId) |
static Object[] |
toObjectArray(Object value) |
static String |
toUnid(NSFDateTime dt1,
NSFDateTime dt2)
Converts the two provided
NSFDateTime s (typically the "File" and "Note" components
of an OID) to a hex string UNID. |
static String |
toUnid(TIMEDATE td1,
TIMEDATE td2)
Converts the two provided
TIMEDATE s (typically the "File" and "Note" components
of an OID) to a hex string UNID. |
static DominoNativeUtils |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DominoNativeUtils[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
static Object |
wrapNativeStruct(Object nativeStruct,
boolean freeOriginal)
This method attempts to wrap a native struct object with its wrapper class equivalent,
e.g.
|
static Object[] |
wrapNativeStructs(Object[] nativeStructs,
boolean freeOriginal)
This method attempts to wrap an array of native struct objects with their wrapper class equivalents,
e.g.
|
public static final Charset UTF_8
public static final com.ibm.commons.log.LogMgr NAPI_LOG
public static final com.ibm.commons.log.LogMgr NAPI_MEMORY_LOG
public static final TimeZone TIMEZONE_UTC
public static DominoNativeUtils[] values()
for (DominoNativeUtils c : DominoNativeUtils.values()) System.out.println(c);
public static DominoNativeUtils valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static boolean isWinx86()
public static boolean isWinx64()
public static boolean isMac_x86()
public static boolean isMac_x64()
public static boolean isLinux_x86()
public static boolean isLinux_x64()
public static String getMIMETypeForExtension(String ext)
public static String getExtensionForMIMEType(String mimeType)
public static int indexOf(byte[] bytes, byte value)
public static String readString(byte[] bytes)
public static String readLMBCSString(byte[] bytes)
public static ITEM_TABLE toItemTable(Object... values) throws DominoException
Convert the provided values into an ITEM_TABLE
with no item names.
The caller is responsible for freeing the returned object.
ITEM_TABLE
containing the provided values with no item namesIllegalArgumentException
- if the provided values cannot be converted to NSF-friendly formats
or if the total size exceeds the capacity of an ITEM_TABLENullPointerException
- if the provided value array contains a null
valueDominoException
public static boolean isDateTimeType(Object val)
Currently supported classes are Date
, Calendar
, TimeOnly
,
DateOnly
, and NSFDateTime
.
public static boolean isDateTimeType(Class<?> valClass)
Currently supported classes are Date
, Calendar
, TimeOnly
,
DateOnly
, and NSFDateTime
.
public static boolean isDateRangeType(Object val)
Currently supported classes are DateOnlyRange
, TimeOnlyRange
,
and NSFDateRange
.
public static boolean isDateRangeType(Class<?> valClass)
Currently supported classes are DateOnlyRange
, TimeOnlyRange
,
and NSFDateRange
.
public static void fillTimeDate(TIMEDATE timedate, Object val) throws DominoException
DominoException
public static void fillTimeDatePair(TIMEDATE_PAIR timedatepair, Object val) throws DominoException
DominoException
public static Object readItemValue(DominoAPI api, long valuePtr, int size, long hNote) throws DominoException
The resultant type and its level of wrapping depends on the data type:
null
String
LIST
Double
RANGE
TIMEDATE
RANGE
NSFFormula
String
OBJECT_DESCRIPTOR
or FILEOBJECT
UNIVERSALNOTEID
[]NSFUserData
MIME_PART
NSFViewFormat
DominoException
- in the case of a general problem reading the valuecom.ibm.commons.util.NotImplementedException
- when reading the specified value type has not yet been implemented but will beUnsupportedOperationException
- when reading the specified value type will not be implementedIllegalArgumentException
- when the specified value type is illegalpublic static Object[] readItemValueArray(DominoAPI api, long valuePtr, int size, long hNote) throws DominoException
DominoException
public static String quoteForFormulaString(String value)
For example: StringUtil.format("foo={0}", quoteForFormulaString("bar"))
will result in a
formula of foo={bar}
value
- the String value to escapepublic static String decompileFormula(DominoAPI api, byte[] formulaData, boolean selectionFormula) throws DominoException
String
.api
- the DominoAPI
instance to use for decompilationformulaData
- the compiled formula dataselectionFormula
- whether the provided formula should be treated as a selection formulaString
DominoException
public static List<String> splitDesignNames(String[] names)
List
of the names and aliases in the provided array. This checks each element
for the "|" and splits it into multiple elements in the result if needed. It also filters out
empty name values.public static void free(Object... objects)
BaseStruct
and NSFBase
objects in the provided array.public static boolean matchesFlagsPattern(String flags, String pattern)
flags
- a design flag value to testpattern
- a flag pattern to test against (DFLAGPAT_*)public static String toUnid(TIMEDATE td1, TIMEDATE td2)
TIMEDATE
s (typically the "File" and "Note" components
of an OID) to a hex string UNID.td1
- the first component ("File")td2
- the second component ("Note")public static String toUnid(NSFDateTime dt1, NSFDateTime dt2)
NSFDateTime
s (typically the "File" and "Note" components
of an OID) to a hex string UNID.dt1
- the first component ("File")dt2
- the second component ("Note")public static boolean isDeletedId(int noteId)
noteId
- the note ID to checkpublic static int toNonDeletedId(int noteId)
noteId
- the note ID to cleanpublic static Object[] concatNSFItemValues(Collection<NSFItem> items) throws DominoException
DominoException
public static <T> T concatNSFItemValues(Collection<NSFItem> items, Class<T> clazz) throws DominoException
DominoException
public static Object wrapNativeStruct(Object nativeStruct, boolean freeOriginal) throws DominoException
TIMEDTAE
→ NSFDateTime
.
If the provided object is not a BaseStruct
or does not have a matching wrapper,
it is returned as-is.
nativeStruct
- the native struct object to wrapfreeOriginal
- whether the original struct should be freed when a reference-less wrapper is foundDominoException
public static Object[] wrapNativeStructs(Object[] nativeStructs, boolean freeOriginal) throws DominoException
TIMEDTAE
→ NSFDateTime
.
If the provided objects are not BaseStruct
s or do not have a matching wrapper,
they are returned as-is. Each individual element is checked and treated this way.
nativeStructs
- the array of native struct objects to wrapfreeOriginal
- whether the original struct should be freed when a reference-less wrapper is foundDominoException
public static Calendar getReusableCalendarInstance(TimeZone timeZone, boolean initTime)
Calendar
instance for the specified TimeZone
. This
differs from Calendar.getInstance()
in that it uses a thread-local pool
of existing calendar objects for efficiency. Accordingly, this should only be used
when the calendar is being used for temporary processing, not kept around or
returned to a caller.timeZone
- the time zone to get the calendar forinitTime
- whether the calendar should be re-initialized to the current timeCalendar
instancepublic static TimeZone getTimeZoneForOffset(int offset)
public static void loadLibraryFromJar(ClassLoader cl, String path) throws IOException
IOException
Copyright © 2014–2018. All rights reserved.