Java Code Examples for com.sun.jna.ptr.ShortByReference#getValue()
The following examples show how to use
com.sun.jna.ptr.ShortByReference#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageQueue.java From domino-jna with Apache License 2.0 | 6 votes |
/** * Retrieves a message from a message queue, provided the queue is not in a QUIT state. * The message will be stored in the buffer specified in the Buffer argument.<br> * Note: The error code {@link INotesErrorConstants#ERR_MQ_QUITTING} indicates that the * message queue is in the QUIT state, denoting that applications that are reading * the message queue should terminate. For instance, a server addin's message queue * will be placed in the QUIT state when a "tell <addin> quit" command is input at the console. * @param buffer buffer used to read data * @param waitForMessage if the specified message queue is empty, wait for a message to appear in the queue. The timeout argument specifies the amount of time to wait for a message. * @param timeoutMillis if waitForMessage is set to <code>true</code>, the number of milliseconds to wait for a message before timing out. Specify 0 to wait forever. If the message queue goes into a QUIT state before the Timeout expires, MQGet will return immediately. * @param offset the offset in the buffer where to start writing the message * @param length the max length of the message in the buffer * @return Number of bytes written to the buffer */ public int get(Memory buffer, boolean waitForMessage, int timeoutMillis, int offset, int length) { checkHandle(); if (length > NotesConstants.MQ_MAX_MSGSIZE) { throw new IllegalArgumentException("Max size for the buffer is "+NotesConstants.MQ_MAX_MSGSIZE+" bytes. You specified one with "+length+" bytes."); } ShortByReference retMsgLength = new ShortByReference(); short result = NotesNativeAPI.get().MQGet(m_queue, buffer, (short) (length & 0xffff), waitForMessage ? NotesConstants.MQ_WAIT_FOR_MSG : 0, timeoutMillis, retMsgLength); NotesErrorUtils.checkResult(result); return retMsgLength.getValue(); }
Example 2
Source File: NotesOOOUtils.java From domino-jna with Apache License 2.0 | 6 votes |
/** * OOO supports two sets of messages. They are called General message/subject and * Special message/subject.<br> * This function returns the text of the general message. * * @return message */ public String getGeneralMessage() { checkHandle(); //first get the length ShortByReference retGeneralMessageLen = new ShortByReference(); short result = NotesNativeAPI.get().OOOGetGeneralMessage(m_pOOOContext, null, retGeneralMessageLen); NotesErrorUtils.checkResult(result); int iGeneralMessageLen = (int) (retGeneralMessageLen.getValue() & 0xffff); if (iGeneralMessageLen==0) return ""; DisposableMemory retMessage = new DisposableMemory(iGeneralMessageLen + 1); try { result = NotesNativeAPI.get().OOOGetGeneralMessage(m_pOOOContext, retMessage, retGeneralMessageLen); NotesErrorUtils.checkResult(result); String msg = NotesStringUtils.fromLMBCS(retMessage, retGeneralMessageLen.getValue()); return msg; } finally { retMessage.dispose(); } }
Example 3
Source File: LMBCSStringList.java From domino-jna with Apache License 2.0 | 6 votes |
/** * Removes all entries from the list */ public void clear() { if (m_values.isEmpty()) { return; } checkHandle(); ShortByReference retListSize = new ShortByReference(); short result; if (PlatformUtils.is64Bit()) { result = NotesNativeAPI64.get().ListRemoveAllEntries(m_handle64, m_prefixDataType ? 1 : 0, retListSize); } else { result = NotesNativeAPI32.get().ListRemoveAllEntries(m_handle32, m_prefixDataType ? 1 : 0, retListSize); } NotesErrorUtils.checkResult(result); m_listSizeBytes = (int) (retListSize.getValue() & 0xffff); m_values.clear(); }
Example 4
Source File: NotesCollection.java From domino-jna with Apache License 2.0 | 5 votes |
/** * Returns the currently active collation * * @return collation */ private short getCollation() { checkHandle(); short result; ShortByReference retCollationNum = new ShortByReference(); if (PlatformUtils.is64Bit()) { result = NotesNativeAPI64.get().NIFGetCollation(m_hCollection64, retCollationNum); } else { result = NotesNativeAPI32.get().NIFGetCollation(m_hCollection32, retCollationNum); } NotesErrorUtils.checkResult(result); return retCollationNum.getValue(); }
Example 5
Source File: NotesOOOUtils.java From domino-jna with Apache License 2.0 | 5 votes |
/** * This function returns the version (agent, service) and the state (disabled, enabled) * of the out of office functionality.<br> * The version information can be used to show or hide UI elements that might not be * supported for a given version.<br> * For example, the agent does not support durations of less than 1 day and some * clients might choose not to show the hours in the user interface.<br> * When you need to make {@link #getState(Ref, Ref)} as efficient as possible, call * {@link NotesOOOUtils#startOperation(String, String, boolean, NotesDatabase)} * with the home mail server and the opened mail database.<br> * This function is read only and does not return an error if user ACL rights * are below Editor (which are required to turn on/off the Out of office functionality).<br> * If {@link #getState(Ref, Ref)} is called immediately following OOOEnable it will * not reflect the state set by the OOOEnable.<br> * To see the current state call {@link #free()} and start a new operation using * {@link NotesOOOUtils#startOperation(String, String, boolean, NotesDatabase)}, * {@link NotesOOOContext#getState(Ref, Ref)} and {@link #free()}. * @param retType returns the type of the OOO system (agent or service) * @param retIsEnabled returns whether the service is enabled for the user */ public void getState(Ref<OOOType> retType, Ref<Boolean> retIsEnabled) { checkHandle(); ShortByReference retVersion = new ShortByReference(); ShortByReference retState = new ShortByReference(); short result = NotesNativeAPI.get().OOOGetState(m_pOOOContext, retVersion, retState); NotesErrorUtils.checkResult(result); if (retType!=null) { if (retVersion.getValue() == 1) { retType.set(OOOType.AGENT); } else if (retVersion.getValue() == 2) { retType.set(OOOType.SERVICE); } } if (retIsEnabled!=null) { if (retState.getValue()==1) { retIsEnabled.set(Boolean.TRUE); } else { retIsEnabled.set(Boolean.FALSE); } } }
Example 6
Source File: ItemDecoder.java From domino-jna with Apache License 2.0 | 5 votes |
public static List<Object> decodeTextListValue(Pointer ptr, boolean convertStringsLazily) { //read a text list item value int listCountAsInt = ptr.getShort(0) & 0xffff; List<Object> listValues = new ArrayList<Object>(listCountAsInt); Memory retTextPointer = new Memory(Native.POINTER_SIZE); ShortByReference retTextLength = new ShortByReference(); for (short l=0; l<listCountAsInt; l++) { short result = NotesNativeAPI.get().ListGetText(ptr, false, l, retTextPointer, retTextLength); NotesErrorUtils.checkResult(result); //retTextPointer[0] points to the list entry text Pointer pointerToTextInMem = retTextPointer.getPointer(0); int retTextLengthAsInt = retTextLength.getValue() & 0xffff; if (retTextLengthAsInt==0) { listValues.add(""); } else { if (convertStringsLazily) { byte[] stringDataArr = new byte[retTextLengthAsInt]; pointerToTextInMem.read(0, stringDataArr, 0, retTextLengthAsInt); LMBCSString lmbcsString = new LMBCSString(stringDataArr); listValues.add(lmbcsString); } else { String currListEntry = NotesStringUtils.fromLMBCS(pointerToTextInMem, (short) retTextLengthAsInt); listValues.add(currListEntry); } } } return listValues; }
Example 7
Source File: JnaBlob.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
@Override public byte[] getSegment(int sizeRequested) throws SQLException { try { if (sizeRequested <= 0) { throw new FbExceptionBuilder().exception(jb_blobGetSegmentNegative) .messageParameter(sizeRequested) .toSQLException(); } // TODO Honour request for larger sizes by looping? sizeRequested = Math.min(sizeRequested, getMaximumSegmentSize()); final ByteBuffer responseBuffer; final ShortByReference actualLength = new ShortByReference(); synchronized (getSynchronizationObject()) { checkDatabaseAttached(); checkTransactionActive(); checkBlobOpen(); responseBuffer = getByteBuffer(sizeRequested); clientLibrary.isc_get_segment(statusVector, getJnaHandle(), actualLength, (short) sizeRequested, responseBuffer); final int status = statusVector[1].intValue(); // status 0 means: more to come, isc_segment means: buffer was too small, rest will be returned on next call if (!(status == 0 || status == ISCConstants.isc_segment)) { if (status == ISCConstants.isc_segstr_eof) { setEof(); } else { processStatusVector(); } } } final int actualLengthInt = ((int) actualLength.getValue()) & 0xFFFF; final byte[] segment = new byte[actualLengthInt]; responseBuffer.get(segment); return segment; } catch (SQLException e) { exceptionListenerDispatcher.errorOccurred(e); throw e; } }
Example 8
Source File: NotesTimeDate.java From domino-jna with Apache License 2.0 | 4 votes |
/** * Converts a {@link NotesTimeDate} to string with formatting options. * * @param intl the internationalization settings in effect. Can be <code>null</code>, in which case this function works with the client/server default settings for the duration of the call. * @param dFormat how to format the date part * @param tFormat how to format the time part * @param zFormat how to format the timezone * @param dtStructure overall structure of the result, e.g. {@link DateTimeStructure} for date only * @return string with formatted timedate */ public String toString(NotesIntlFormat intl, DateFormat dFormat, TimeFormat tFormat, ZoneFormat zFormat, DateTimeStructure dtStructure) { NotesTimeDateStruct struct = lazilyCreateStruct(); if (struct.Innards==null || struct.Innards.length<2) return ""; if (struct.Innards[0]==0 && struct.Innards[1]==0) return "MINIMUM"; if (struct.Innards[0]==0 && struct.Innards[1]==0xffffff) return "MAXIMUM"; IntlFormatStruct intlStruct = intl==null ? null : intl.getAdapter(IntlFormatStruct.class); NotesTFMTStruct tfmtStruct = NotesTFMTStruct.newInstance(); tfmtStruct.Date = dFormat==null ? NotesConstants.TDFMT_FULL : dFormat.getValue(); tfmtStruct.Time = tFormat==null ? NotesConstants.TTFMT_FULL : tFormat.getValue(); tfmtStruct.Zone = zFormat==null ? NotesConstants.TZFMT_ALWAYS : zFormat.getValue(); tfmtStruct.Structure = dtStructure==null ? NotesConstants.TSFMT_DATETIME : dtStructure.getValue(); tfmtStruct.write(); String txt; int outBufLength = 40; DisposableMemory retTextBuffer = new DisposableMemory(outBufLength); while (true) { ShortByReference retTextLength = new ShortByReference(); short result = NotesNativeAPI.get().ConvertTIMEDATEToText(intlStruct, tfmtStruct.getPointer(), struct, retTextBuffer, (short) retTextBuffer.size(), retTextLength); if (result==1037) { // "Invalid Time or Date Encountered", return empty string like Notes UI does return ""; } if (result!=1033) { // "Output Buffer Overflow" NotesErrorUtils.checkResult(result); } if (result==1033 || (retTextLength.getValue() >= retTextBuffer.size())) { retTextBuffer.dispose(); outBufLength = outBufLength * 2; retTextBuffer = new DisposableMemory(outBufLength); continue; } else { txt = NotesStringUtils.fromLMBCS(retTextBuffer, retTextLength.getValue()); break; } } retTextBuffer.dispose(); return txt; }