Example usage for java.nio CharBuffer put

List of usage examples for java.nio CharBuffer put

Introduction

In this page you can find the example usage for java.nio CharBuffer put.

Prototype

public abstract CharBuffer put(int index, char c);

Source Link

Document

Writes a char to the specified index of this buffer; the position is not changed.

Usage

From source file:com.quinsoft.zeidon.vml.VmlOperation.java

protected static final int zstrcpy(CharBuffer charBuffer, int nOffset, String s) {
    int k;//from   w ww  .j  a  v a 2 s.c o m

    for (k = 0; k < s.length(); k++) {
        charBuffer.put(nOffset++, s.charAt(k));
    }

    return nOffset; // current used length of charBuffer
}

From source file:com.quinsoft.zeidon.vml.VmlOperation.java

protected static final int zstrncpy(CharBuffer cb, int nOffset, String s, int nLth) {
    int k;//from  w w  w . j a  v  a 2  s. c om

    if (s.length() < nLth) {
        nLth = s.length();
    }

    for (k = 0; k < nLth; k++) {
        cb.put(nOffset++, s.charAt(k));
    }

    return nOffset; // current used length of charBuffer
}

From source file:com.quinsoft.epamms.ZGlobal1_Operation.java

public int SendEmailForFiles(View ViewToWindow, View ResultSet, String stringSmtpServer,
        String stringRecipientEMailAddress, String stringSenderEMailAddress, String stringEMailUserName,
        String stringEMailPassword, String stringSubjectLine, String stringBodyFileName,
        String stringAltTextFileName, String stringEmbeddedImages, String stringAttachmentFileName,
        int nMimeType, // 1-Text, 2-HTML
        int lConnection) {
    // String stringBodyMemoryStart;
    CharBuffer cbAtBodyFileName = CharBuffer.allocate(256);
    CharBuffer cbAtAltTextFileName = CharBuffer.allocate(256);
    // int  selBodyMemory;
    // int  lFileLth;
    zVIEW zqMDocOLST = null;//from ww w.j av  a2  s.c  o  m
    zVIEW wWebXfer = null;
    int nRC;

    // TraceLine( "SendEmailForFiles Server: %s   Sender: %s   Recipient: %s"
    //            "   Subject: %s   Mime Type: %d"
    //            "   User: %s   Password %s",
    //            stringSmtpServer, stringSenderEMailAddress, stringRecipientEMailAddress,
    //            stringSubjectLine, nMimeType, stringEMailUserName, stringEMailPassword );

    // First make sure the email address is valid. If not exit with return code of 2.
    if (IsEmailAddressValid(stringRecipientEMailAddress) == false)
        return 2;

    GetViewByName(zqMDocOLST, "zqMDocOLST", ResultSet, zLEVEL_TASK);
    GetViewByName(wWebXfer, "wWebXfer", ViewToWindow, zLEVEL_TASK);

    if (stringBodyFileName != null) {
        if (stringBodyFileName.isEmpty() == false && stringBodyFileName.charAt(0) != '@') {
            cbAtBodyFileName.put(0, '@');
            zstrcpy(cbAtBodyFileName, 1, stringBodyFileName);
        } else
            zstrcpy(cbAtBodyFileName, 0, stringBodyFileName);
    } else
        cbAtBodyFileName.put(0, '\0');

    if (stringAltTextFileName != null) {
        if (stringAltTextFileName.isEmpty() == false && stringAltTextFileName.charAt(0) != '@') {
            cbAtAltTextFileName.put(0, '@');
            zstrcpy(cbAtAltTextFileName, 1, stringAltTextFileName);
        } else
            zstrcpy(cbAtAltTextFileName, 0, stringAltTextFileName);
    } else
        cbAtAltTextFileName.put(0, '\0');

    // Read the data from the Body and Attachment files into memory and call
    // StartEmailClient with those values.

    // Read the Body into memory.
    // lFileLth = ReadFileDataIntoMemory( ResultSet, stringBodyFileName,
    //                                    &selBodyMemory, &stringBodyMemoryStart );

    // Exit if the file is empty or if there is an error opening it.
    // if ( lFileLth <= 0 )
    // {
    // The memory allocated to hold the body has been freed.
    //    IssueError( ResultSet, 0, 0, "Can't open Email file." );
    //    return -1;
    // }

    if (stringSubjectLine == null || stringSubjectLine.isEmpty())
        stringSubjectLine = " ";

    // TraceLine( "SendEmailForFiles2 Server: %s   Sender: %s   Recipient: %s"
    //            "   Subject: %s   Mime Type: %d"
    //            "   User: %s   Password %s",
    //            stringSmtpServer, stringSenderEMailAddress, stringRecipientEMailAddress,
    //            stringSubjectLine, nMimeType, stringEMailUserName, stringEMailPassword );

    // If there is an attachment file, also read it into memory.
    // Then call CreateSeeMessage with or without an attachment.
    if (stringAttachmentFileName.isEmpty() == false) {
        nRC = m_ZDRVROPR.CreateSeeMessage(lConnection, stringSmtpServer, stringSenderEMailAddress,
                stringRecipientEMailAddress, "", "", stringSubjectLine, nMimeType, cbAtBodyFileName.toString(),
                cbAtAltTextFileName.toString(), stringEmbeddedImages, 1, // has attachment
                stringAttachmentFileName, stringEMailUserName, stringEMailPassword);
    } else {
        nRC = m_ZDRVROPR.CreateSeeMessage(lConnection, stringSmtpServer, stringSenderEMailAddress,
                stringRecipientEMailAddress, "", "", stringSubjectLine, nMimeType, cbAtBodyFileName.toString(),
                cbAtAltTextFileName.toString(), stringEmbeddedImages, 0, // no attachment
                "", // blank attachment file name
                stringEMailUserName, stringEMailPassword);
    }

    // SysFreeMemory( selBodyMemory );
    // DrFreeTaskMemory( stringBodyMemoryStart );

    return nRC;

}

From source file:com.quinsoft.epamms.ZGlobal1_Operation.java

public int SendEmailForFilesWithCC(View ViewToWindow, View ResultSet, String stringSmtpServer,
        String stringRecipientEMailAddress, String stringSenderEMailAddress, String stringCC_EMailAddresses,
        String stringBCC_EMailAddresses, String stringEMailUserName, String stringEMailPassword,
        String stringSubjectLine, String stringBodyFileName, String stringAltTextFileName,
        String stringEmbeddedImages, String stringAttachmentFileName, int nMimeType, // 1-Text, 2-HTML
        int lConnection) {
    // String stringBodyMemoryStart;
    CharBuffer cbAtBodyFileName = CharBuffer.allocate(256);
    CharBuffer cbAtAltTextFileName = CharBuffer.allocate(256);
    // int  selBodyMemory;
    // int  lFileLth;
    zVIEW zqMDocOLST = null;// w w w  . j av a2  s .  c om
    zVIEW wWebXfer = null;
    int nRC;

    // TraceLine( "SendEmailForFiles Server: %s   Sender: %s   Recipient: %s"
    //            "   Subject: %s   Mime Type: %d"
    //            "   User: %s   Password %s",
    //            stringSmtpServer, stringSenderEMailAddress, stringRecipientEMailAddress,
    //            stringSubjectLine, nMimeType, stringEMailUserName, stringEMailPassword );

    // First make sure the email address is valid. If not exit with return code of 2.
    if (IsEmailAddressValid(stringRecipientEMailAddress) == false)
        return 2;

    GetViewByName(zqMDocOLST, "zqMDocOLST", ResultSet, zLEVEL_TASK);
    GetViewByName(wWebXfer, "wWebXfer", ViewToWindow, zLEVEL_TASK);

    if (stringBodyFileName != null) {
        if (stringBodyFileName.isEmpty() == false && stringBodyFileName.charAt(0) != '@') {
            cbAtBodyFileName.put(0, '@');
            zstrcpy(cbAtBodyFileName, 1, stringBodyFileName);
        } else
            zstrcpy(cbAtBodyFileName, 0, stringBodyFileName);
    } else
        cbAtBodyFileName.put(0, '\0');

    if (stringAltTextFileName != null) {
        if (stringAltTextFileName.isEmpty() == false && stringAltTextFileName.charAt(0) != '@') {
            cbAtAltTextFileName.put(0, '@');
            zstrcpy(cbAtAltTextFileName, 1, stringAltTextFileName);
        } else
            zstrcpy(cbAtAltTextFileName, 0, stringAltTextFileName);
    } else
        cbAtAltTextFileName.put(0, '\0');

    // Read the data from the Body and Attachment files into memory and call
    // StartEmailClient with those values.

    // Read the Body into memory.
    // lFileLth = ReadFileDataIntoMemory( ResultSet, stringBodyFileName,
    //                                    &selBodyMemory, &stringBodyMemoryStart );

    // Exit if the file is empty or if there is an error opening it.
    // if ( lFileLth <= 0 )
    // {
    // The memory allocated to hold the body has been freed.
    //    IssueError( ResultSet, 0, 0, "Can't open Email file." );
    //    return -1;
    // }

    if (stringSubjectLine == null || stringSubjectLine.isEmpty())
        stringSubjectLine = " ";

    // TraceLine( "SendEmailForFiles2 Server: %s   Sender: %s   Recipient: %s"
    //            "   Subject: %s   Mime Type: %d"
    //            "   User: %s   Password %s",
    //            stringSmtpServer, stringSenderEMailAddress, stringRecipientEMailAddress,
    //            stringSubjectLine, nMimeType, stringEMailUserName, stringEMailPassword );

    // If there is an attachment file, also read it into memory.
    // Then call CreateSeeMessage with or without an attachment.
    if (stringAttachmentFileName != null && stringAttachmentFileName.isEmpty() == false) {
        nRC = m_ZDRVROPR.CreateSeeMessage(lConnection, stringSmtpServer, stringSenderEMailAddress,
                stringRecipientEMailAddress, stringCC_EMailAddresses, stringBCC_EMailAddresses,
                stringSubjectLine, nMimeType, cbAtBodyFileName.toString(), cbAtAltTextFileName.toString(),
                stringEmbeddedImages, 1, // has attachment
                stringAttachmentFileName, stringEMailUserName, stringEMailPassword);
    } else {
        nRC = m_ZDRVROPR.CreateSeeMessage(lConnection, stringSmtpServer, stringSenderEMailAddress,
                stringRecipientEMailAddress, stringCC_EMailAddresses, stringBCC_EMailAddresses,
                stringSubjectLine, nMimeType, cbAtBodyFileName.toString(), cbAtAltTextFileName.toString(),
                stringEmbeddedImages, 0, // no attachment
                "", // blank attachment file name
                stringEMailUserName, stringEMailPassword);
    }

    // SysFreeMemory( selBodyMemory );
    // DrFreeTaskMemory( stringBodyMemoryStart );

    return nRC;

}