List of usage examples for java.nio CharBuffer allocate
public static CharBuffer allocate(int capacity)
From source file:com.quinsoft.swauopencuas.ZGLOBAL1_Operation.java
public int StartEmailClientForListReus(View vResult, String entityName, String attributeName, String contextName, String stringScope, int bUseOnlySelectedEntities, int bUseParentSelectedEntities, String stringSubject, String stringCopyTo, // comma separated list String stringBlindCopy, // comma separated list String stringBody, String stringAttachment, String stringEmailClient, int lFlags, String stringBlindCopyFlag) // reserved { String stringParentEntity = null; String s = null;//from w ww . j a v a2s. co m int lEntityCnt; int ulAttributeLth = 0; int lTotalSize; int lLth = 0; int lRC; if (bUseParentSelectedEntities != 0) stringParentEntity = MiGetParentEntityNameForView(stringParentEntity, vResult, entityName); lEntityCnt = CountEntitiesForView(vResult, entityName); ulAttributeLth = GetAttributeDisplayLength(ulAttributeLth, vResult, entityName, attributeName, contextName); lTotalSize = lEntityCnt * ulAttributeLth; // a starting point CharBuffer cbMemory = CharBuffer.allocate(lTotalSize + 1); // DrAllocTaskMemory( cbMemory, lTotalSize + 1 ); // For each entity, append the specified data to the list. // lRC = SetCursorFirstEntity( vResult, entityName, stringScope ); lRC = SetEntityCursor(vResult, entityName, "", zPOS_FIRST, "", "", "", 0, stringScope, ""); while (lRC > zCURSOR_UNCHANGED) { if (bUseOnlySelectedEntities == 0 || ((bUseOnlySelectedEntities != 0) && GetSelectStateOfEntity(vResult, entityName) != 0) || ((bUseParentSelectedEntities != 0) && GetSelectStateOfEntity(vResult, stringParentEntity) != 0)) { s = GetVariableFromAttribute(s, 0, zTYPE_STRING, lTotalSize - lLth - 1, vResult, entityName, attributeName, contextName, contextName != null && contextName.isEmpty() == false ? 0 : zUSE_DEFAULT_CONTEXT); lLth = zstrcpy(cbMemory, lLth, s); while (lLth > 0 && cbMemory.charAt(lLth - 1) == ' ') { lLth--; cbMemory.put(lLth, '\0'); } } // lRC = SetCursorNextEntity( vResult, entityName, stringScope ); lRC = SetEntityCursor(vResult, entityName, "", zPOS_NEXT, "", "", "", 0, stringScope, ""); if (lRC > zCURSOR_UNCHANGED) { // lLth = zstrlen( stringMemory ); if (lTotalSize - lLth < ulAttributeLth) { s = cbMemory.toString(); lEntityCnt *= 2; lTotalSize = lEntityCnt * ulAttributeLth; cbMemory = CharBuffer.allocate(lTotalSize + 1); zstrcpy(cbMemory, 0, s); } if (lLth > 0 && cbMemory.charAt(lLth - 1) != ',') { cbMemory.put(lLth++, ','); cbMemory.put(lLth, '\0'); } } } if (stringBlindCopyFlag.charAt(0) == 'Y') { // Email Addresses are to be put in Blind Copy parameter. TraceLineS("Blind Copies: ", cbMemory.toString()); lRC = m_ZDRVROPR.StartEmailClient(stringBlindCopy, // Regular send parameter stringSubject, stringCopyTo, // comma separated list cbMemory.toString(), // Blind Copy parameter stringBody, stringAttachment, "", lFlags); // reserved } else { // Email Addresses are to be put in regular Send parameter. TraceLineS("Regular Copies: ", cbMemory.toString()); lRC = m_ZDRVROPR.StartEmailClient(cbMemory.toString(), // comma separated list stringSubject, stringCopyTo, // comma separated list stringBlindCopy, // comma separated list stringBody, stringAttachment, stringEmailClient, lFlags); // reserved } // DrFreeTaskMemory( (String) cbMemory ); return lRC; }
From source file:com.arksoft.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 a v a 2 s . c o m zVIEW wXferO = 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(wXferO, "wXferO", 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.arksoft.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;/*from w ww .j a v a 2s . co m*/ zVIEW wXferO = 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(wXferO, "wXferO", 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; }
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 www .ja v a 2 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;/*from w w w . jav a 2 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 != 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; }
From source file:com.arksoft.epamms.ZGlobal1_Operation.java
int WriteCSV_RecordFromEntity(View lLibPers, String entityName, int lFile) throws IOException { CharBuffer charBuffer = CharBuffer.allocate(32000); int nLth;/*from w w w. j a va2 s. c o m*/ charBuffer.put(0, '"'); charBuffer.put(1, entityName.charAt(0)); // S E P (Student Employee Prospect) charBuffer.put(2, '"'); charBuffer.put(3, ','); nLth = 4; nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, entityName, "Status", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "CampusID", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "ID", true); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "LastName", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "FirstName", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "MiddleName", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "Suffix", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "PreferedFirstName", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "Gender", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "MaritalStatus", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "HomePhone", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "WorkPhone", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "Extension", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "eMailAddress", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Person", "DateOfBirth", false); if (CheckExistenceOfEntity(lLibPers, "Address") == 0) { nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Address", "Line1", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Address", "City", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Address", "StateProvince", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Address", "PostalCode", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "Address", "Country", false); } else { charBuffer.put(nLth++, ','); charBuffer.put(nLth++, ','); charBuffer.put(nLth++, ','); charBuffer.put(nLth++, ','); charBuffer.put(nLth++, ','); } nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, entityName, "ID", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, entityName, "eMailAddress", false); if (entityName.charAt(0) == 'S') { nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, entityName, "CurrentLevel", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, "AdministrativeDivision", "Name", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, entityName, "ClearingHouseGradDate", false); } else if (entityName.charAt(0) == 'P') { nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, entityName, "ExpectedEntryTerm", false); nLth += AddAttributeToCSV(charBuffer, nLth, lLibPers, entityName, "ExpectedEntryYear", false); } if (nLth > 0 && charBuffer.get(nLth - 1) == ',') charBuffer.put(nLth - 1, '\0'); // drop terminating ',' and null terminate else charBuffer.put(nLth++, '\0'); // ensure null termination m_KZOEP1AA.SysWriteLine(lLibPers, lFile, charBuffer.toString()); return nLth; }
From source file:org.alfresco.extension.wcmdeployment.NaiveFilesystemDeploymentTarget.java
/** * @see org.alfresco.deployment.DeploymentTarget#getCurrentVersion(java.lang.String, java.lang.String) *///from w w w . ja v a 2 s . c o m public int getCurrentVersion(final String target, final String storeName) { log.trace("NaiveFilesystemDeploymentTarget.getCurrentVersion(" + target + ", " + storeName + ")"); int result = 0; File targetMetaDirectory = new File(metadataDirectory, target); File storeMetaDirectory = new File(targetMetaDirectory, storeName); File versionFile = new File(storeMetaDirectory, VERSION_FILENAME); if (versionFile.exists()) { CharBuffer buffer = CharBuffer.allocate(16); Reader reader = null; try { reader = new InputStreamReader(new FileInputStream(versionFile)); reader.read(buffer); result = Integer.valueOf(buffer.toString().trim()); } catch (final IOException ioe) { log.warn("Unable to retrieve version infomation from '" + getPath(versionFile) + "'.", ioe); } catch (final NumberFormatException nfe) { log.warn("Unable to parse version number '" + buffer.toString() + "'.", nfe); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { // *Gulp* - if this occurs there's not a lot else we can do but swallow it... } } } } return (result); }
From source file:org.apache.fop.fonts.MultiByteFont.java
/** * Map sequence GS, comprising a sequence of Glyph Indices, to output sequence CS, * comprising a sequence of UTF-16 encoded Unicode Code Points. * @param gs a GlyphSequence containing glyph indices * @returns a CharSequence containing UTF-16 encoded Unicode characters *///from www . j ava 2s. c o m private CharSequence mapGlyphsToChars(GlyphSequence gs) { int ng = gs.getGlyphCount(); CharBuffer cb = CharBuffer.allocate(ng); int ccMissing = Typeface.NOT_FOUND; for (int i = 0, n = ng; i < n; i++) { int gi = gs.getGlyph(i); int cc = findCharacterFromGlyphIndex(gi); if ((cc == 0) || (cc > 0x10FFFF)) { cc = ccMissing; log.warn("Unable to map glyph index " + gi + " to Unicode scalar in font '" + getFullName() + "', substituting missing character '" + (char) cc + "'"); } if (cc > 0x00FFFF) { int sh; int sl; cc -= 0x10000; sh = ((cc >> 10) & 0x3FF) + 0xD800; sl = ((cc >> 0) & 0x3FF) + 0xDC00; cb.put((char) sh); cb.put((char) sl); } else { cb.put((char) cc); } } cb.flip(); return (CharSequence) cb; }
From source file:org.apache.ofbiz.base.util.UtilIO.java
/** Copy a Reader to an Appendable, optionally closing the input. * * @param reader the Reader to copy from * @param closeIn whether to close the input when the copy is done * @param out the Appendable to copy to//from w w w.j a v a2 s.c o m * @throws IOException if an error occurs */ public static void copy(Reader reader, boolean closeIn, Appendable out) throws IOException { try { CharBuffer buffer = CharBuffer.allocate(4096); while (reader.read(buffer) > 0) { buffer.flip(); buffer.rewind(); out.append(buffer); } } finally { if (closeIn) IOUtils.closeQuietly(reader); } }
From source file:org.archive.io.GenericReplayCharSequence.java
/** * Converts the first <code>Integer.MAX_VALUE</code> characters from the * file <code>backingFilename</code> from encoding <code>encoding</code> to * encoding <code>WRITE_ENCODING</code> and saves as * <code>this.decodedFile</code>, which is named <code>backingFilename * + "." + WRITE_ENCODING</code>./* www .j av a 2s . c o m*/ * * @throws IOException */ protected void decode(InputStream inStream, int prefixMax, String backingFilename, Charset charset) throws IOException { this.charset = charset; // TODO: consider if BufferedReader is helping any // TODO: consider adding TBW 'LimitReader' to stop reading at // Integer.MAX_VALUE characters because of charAt(int) limit BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, charset)); logger.fine("backingFilename=" + backingFilename + " encoding=" + charset + " decodedFile=" + decodedFile); this.prefixBuffer = CharBuffer.allocate(prefixMax); long count = 0; while (count < prefixMax) { int read = reader.read(prefixBuffer); if (read < 0) { break; } count += read; } int ch = reader.read(); if (ch >= 0) { count++; // more to decode to file overflow this.decodedFile = new File(backingFilename + "." + WRITE_ENCODING); FileOutputStream fos; try { fos = new FileOutputStream(this.decodedFile); } catch (FileNotFoundException e) { // Windows workaround attempt System.gc(); System.runFinalization(); this.decodedFile = new File(decodedFile.getAbsolutePath() + ".win"); logger.info("Windows 'file with a user-mapped section open' " + "workaround gc/finalization/name-extension performed."); // try again fos = new FileOutputStream(this.decodedFile); } Writer writer = new OutputStreamWriter(fos, WRITE_ENCODING); writer.write(ch); count += IOUtils.copyLarge(reader, writer); writer.close(); reader.close(); } this.length = Ints.saturatedCast(count); if (count > Integer.MAX_VALUE) { logger.warning("input stream is longer than Integer.MAX_VALUE=" + NumberFormat.getInstance().format(Integer.MAX_VALUE) + " characters -- only first " + NumberFormat.getInstance().format(Integer.MAX_VALUE) + " are accessible through this GenericReplayCharSequence"); } logger.fine("decode: decoded " + count + " characters" + ((decodedFile == null) ? "" : " (" + (count - prefixBuffer.length()) + " to " + decodedFile + ")")); }