List of usage examples for java.nio CharBuffer put
public abstract CharBuffer put(int index, char c);
From source file:edu.mbl.jif.imaging.mmtiff.MultipageTiffWriter.java
private void writeIFDEntry(ByteBuffer buffer, CharBuffer cBuffer, char tag, char type, long count, long value) throws IOException { cBuffer.put(bufferPosition_ / 2, tag); cBuffer.put(bufferPosition_ / 2 + 1, type); buffer.putInt(bufferPosition_ + 4, (int) count); if (type == 3 && count == 1) { //Left justify in 4 byte value field cBuffer.put(bufferPosition_ / 2 + 4, (char) value); cBuffer.put(bufferPosition_ / 2 + 5, (char) 0); } else {/* w w w .ja v a 2s . com*/ buffer.putInt(bufferPosition_ + 8, (int) value); } bufferPosition_ += 12; }
From source file:edu.mbl.jif.imaging.mmtiff.MultipageTiffWriter.java
private void writeIFD(TaggedImage img) throws IOException { char numEntries = (char) ((firstIFD_ ? ENTRIES_PER_IFD + 4 : ENTRIES_PER_IFD)); if (img.tags.has("Summary")) { img.tags.remove("Summary"); }// w w w . ja va 2 s . co m String mdString = img.tags.toString() + " "; //2 bytes for number of directory entries, 12 bytes per directory entry, 4 byte offset of next IFD //6 bytes for bits per sample if RGB, 16 bytes for x and y resolution, 1 byte per character of MD string //number of bytes for pixels int totalBytes = 2 + numEntries * 12 + 4 + (rgb_ ? 6 : 0) + 16 + mdString.length() + bytesPerImagePixels_; int IFDandBitDepthBytes = 2 + numEntries * 12 + 4 + (rgb_ ? 6 : 0); ByteBuffer ifdBuffer = ByteBuffer.allocate(IFDandBitDepthBytes).order(BYTE_ORDER); CharBuffer charView = ifdBuffer.asCharBuffer(); long tagDataOffset = filePosition_ + 2 + numEntries * 12 + 4; nextIFDOffsetLocation_ = filePosition_ + 2 + numEntries * 12; bufferPosition_ = 0; charView.put(bufferPosition_, numEntries); bufferPosition_ += 2; writeIFDEntry(ifdBuffer, charView, WIDTH, (char) 4, 1, imageWidth_); writeIFDEntry(ifdBuffer, charView, HEIGHT, (char) 4, 1, imageHeight_); writeIFDEntry(ifdBuffer, charView, BITS_PER_SAMPLE, (char) 3, rgb_ ? 3 : 1, rgb_ ? tagDataOffset : byteDepth_ * 8); if (rgb_) { tagDataOffset += 6; } writeIFDEntry(ifdBuffer, charView, COMPRESSION, (char) 3, 1, 1); writeIFDEntry(ifdBuffer, charView, PHOTOMETRIC_INTERPRETATION, (char) 3, 1, rgb_ ? 2 : 1); if (firstIFD_) { omeDescriptionTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IMAGE_DESCRIPTION, (char) 2, 0, 0); ijDescriptionTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IMAGE_DESCRIPTION, (char) 2, 0, 0); } writeIFDEntry(ifdBuffer, charView, STRIP_OFFSETS, (char) 4, 1, tagDataOffset); tagDataOffset += bytesPerImagePixels_; writeIFDEntry(ifdBuffer, charView, SAMPLES_PER_PIXEL, (char) 3, 1, (rgb_ ? 3 : 1)); writeIFDEntry(ifdBuffer, charView, ROWS_PER_STRIP, (char) 3, 1, imageHeight_); writeIFDEntry(ifdBuffer, charView, STRIP_BYTE_COUNTS, (char) 4, 1, bytesPerImagePixels_); writeIFDEntry(ifdBuffer, charView, X_RESOLUTION, (char) 5, 1, tagDataOffset); tagDataOffset += 8; writeIFDEntry(ifdBuffer, charView, Y_RESOLUTION, (char) 5, 1, tagDataOffset); tagDataOffset += 8; writeIFDEntry(ifdBuffer, charView, RESOLUTION_UNIT, (char) 3, 1, 3); if (firstIFD_) { ijMetadataCountsTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IJ_METADATA_BYTE_COUNTS, (char) 4, 0, 0); ijMetadataTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IJ_METADATA, (char) 1, 0, 0); } writeIFDEntry(ifdBuffer, charView, MM_METADATA, (char) 2, mdString.length(), tagDataOffset); tagDataOffset += mdString.length(); //NextIFDOffset ifdBuffer.putInt(bufferPosition_, (int) tagDataOffset); bufferPosition_ += 4; if (rgb_) { charView.put(bufferPosition_ / 2, (char) (byteDepth_ * 8)); charView.put(bufferPosition_ / 2 + 1, (char) (byteDepth_ * 8)); charView.put(bufferPosition_ / 2 + 2, (char) (byteDepth_ * 8)); } buffers_.add(ifdBuffer); buffers_.add(getPixelBuffer(img)); buffers_.add(getResolutionValuesBuffer()); buffers_.add(ByteBuffer.wrap(getBytesFromString(mdString))); filePosition_ += totalBytes; firstIFD_ = false; }
From source file:edu.mbl.jif.imaging.mmtiff.MultipageTiffWriter.java
private void writeBlankIFD() throws IOException { // boolean blankPixelsAlreadyWritten = blankPixelsOffset_ != -1; boolean blankPixelsAlreadyWritten = false; char numEntries = (char) (((firstIFD_ && omeTiff_) ? ENTRIES_PER_IFD + 2 : ENTRIES_PER_IFD) + (firstIFD_ ? 2 : 0));//w w w . ja v a 2 s . c o m String mdString = "NULL "; //2 bytes for number of directory entries, 12 bytes per directory entry, 4 byte offset of next IFD //6 bytes for bits per sample if RGB, 16 bytes for x and y resolution, 1 byte per character of MD string //number of bytes for pixels int totalBytes = 2 + numEntries * 12 + 4 + (rgb_ ? 6 : 0) + 16 + mdString.length() + (blankPixelsAlreadyWritten ? 0 : bytesPerImagePixels_); int IFDandBitDepthBytes = 2 + numEntries * 12 + 4 + (rgb_ ? 6 : 0); ByteBuffer ifdBuffer = ByteBuffer.allocate(IFDandBitDepthBytes).order(BYTE_ORDER); CharBuffer charView = ifdBuffer.asCharBuffer(); long tagDataOffset = filePosition_ + 2 + numEntries * 12 + 4; nextIFDOffsetLocation_ = filePosition_ + 2 + numEntries * 12; bufferPosition_ = 0; charView.put(bufferPosition_, numEntries); bufferPosition_ += 2; writeIFDEntry(ifdBuffer, charView, WIDTH, (char) 4, 1, imageWidth_); writeIFDEntry(ifdBuffer, charView, HEIGHT, (char) 4, 1, imageHeight_); writeIFDEntry(ifdBuffer, charView, BITS_PER_SAMPLE, (char) 3, rgb_ ? 3 : 1, rgb_ ? tagDataOffset : byteDepth_ * 8); if (rgb_) { tagDataOffset += 6; } writeIFDEntry(ifdBuffer, charView, COMPRESSION, (char) 3, 1, 1); writeIFDEntry(ifdBuffer, charView, PHOTOMETRIC_INTERPRETATION, (char) 3, 1, rgb_ ? 2 : 1); if (firstIFD_ && omeTiff_) { omeDescriptionTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IMAGE_DESCRIPTION, (char) 2, 0, 0); } if (firstIFD_) { ijDescriptionTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IMAGE_DESCRIPTION, (char) 2, 0, 0); } if (!blankPixelsAlreadyWritten) { //Write blank pixels writeIFDEntry(ifdBuffer, charView, STRIP_OFFSETS, (char) 4, 1, tagDataOffset); blankPixelsOffset_ = tagDataOffset; tagDataOffset += bytesPerImagePixels_; } else { writeIFDEntry(ifdBuffer, charView, STRIP_OFFSETS, (char) 4, 1, blankPixelsOffset_); } writeIFDEntry(ifdBuffer, charView, SAMPLES_PER_PIXEL, (char) 3, 1, (rgb_ ? 3 : 1)); writeIFDEntry(ifdBuffer, charView, ROWS_PER_STRIP, (char) 3, 1, imageHeight_); writeIFDEntry(ifdBuffer, charView, STRIP_BYTE_COUNTS, (char) 4, 1, bytesPerImagePixels_); writeIFDEntry(ifdBuffer, charView, X_RESOLUTION, (char) 5, 1, tagDataOffset); tagDataOffset += 8; writeIFDEntry(ifdBuffer, charView, Y_RESOLUTION, (char) 5, 1, tagDataOffset); tagDataOffset += 8; writeIFDEntry(ifdBuffer, charView, RESOLUTION_UNIT, (char) 3, 1, 3); if (firstIFD_) { ijMetadataCountsTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IJ_METADATA_BYTE_COUNTS, (char) 4, 0, 0); ijMetadataTagPosition_ = filePosition_ + bufferPosition_; writeIFDEntry(ifdBuffer, charView, IJ_METADATA, (char) 1, 0, 0); } writeIFDEntry(ifdBuffer, charView, MM_METADATA, (char) 2, mdString.length(), tagDataOffset); tagDataOffset += mdString.length(); //NextIFDOffset ifdBuffer.putInt(bufferPosition_, (int) tagDataOffset); bufferPosition_ += 4; if (rgb_) { charView.put(bufferPosition_ / 2, (char) (byteDepth_ * 8)); charView.put(bufferPosition_ / 2 + 1, (char) (byteDepth_ * 8)); charView.put(bufferPosition_ / 2 + 2, (char) (byteDepth_ * 8)); } buffers_.add(ifdBuffer); if (!blankPixelsAlreadyWritten) { buffers_.add(ByteBuffer.wrap(new byte[bytesPerImagePixels_])); } buffers_.add(getResolutionValuesBuffer()); buffers_.add(ByteBuffer.wrap(getBytesFromString(mdString))); filePosition_ += totalBytes; firstIFD_ = false; }
From source file:org.apache.ctakes.ytex.uima.annotators.NegexAnnotator.java
/** * check the negation status of the specfied term in the specified sentence * //from w ww.j ava 2 s. com * @param aJCas * for adding annotations * @param s * the sentence in which we will look * @param ne * the named entity whose negation status will be checked. * @param checkPoss * should possibility be checked? * @param negPoss * should possiblities be negated? */ private void checkNegation(JCas aJCas, Sentence s, Annotation ne) { if (storeAsInterval && ne instanceof IdentifiedAnnotation) { // default is affirmed, which is coded as confidence = 1 ((IdentifiedAnnotation) ne).setConfidence(1); } // need to add . on either side due to the way the regexs are built String sentence = "." + s.getCoveredText() + "."; // allocate array of tokens // this maps each character of the sentence to a token NegexToken[] tokens = new NegexToken[sentence.length()]; // char buffer for modify the sentence // we want to 'black out' trigger words already found and the phrase we // were looking for CharBuffer buf = CharBuffer.wrap(sentence.toCharArray()); // calculate location of the ne relative to the sentence int neRelStart = ne.getBegin() - s.getBegin() + 1; int neRelEnd = ne.getEnd() - s.getBegin() + 1; // black out the ne in the sentence buffer for (int i = neRelStart; i < neRelEnd; i++) { // black out the named entity from the char buffer buf.put(i, '_'); } // look for negex rules in the sentence for (NegexRule rule : this.listNegexRules) { Matcher m = rule.getPattern().matcher(buf); while (m.find() == true) { // see if the range has not already been marked boolean bUnoccupied = true; for (int i = m.start(); i < m.end() && bUnoccupied; i++) bUnoccupied = tokens[i] == null; if (bUnoccupied) { // mark the range in the sentence with this token // black it out so other rules do not match NegexToken t = new NegexToken(m.start(), m.end(), rule); for (int i = m.start(); i < m.end() && bUnoccupied; i++) { // black out this range from the char buffer buf.put(i, '_'); // add the token to the array tokens[i] = t; } } } } // prenegation // look for a PREN rule before the ne, without any intervening stop tags NegexToken t = this.findTokenByTag("[PREN]", new String[] { "[CONJ]", "[PSEU]", "[POST]", "[PREP]", "[POSP]" }, true, neRelStart, neRelEnd, tokens); if (t != null) { // hit - negate the ne annotateNegation(aJCas, s, ne, t, true, false); } else { // look for POST rule after the ne, without any intervening stop // tags t = this.findTokenByTag("[POST]", new String[] { "[CONJ]", "[PSEU]", "[PREN]", "[PREP]", "[POSP]" }, false, neRelStart, neRelEnd, tokens); if (t != null) { annotateNegation(aJCas, s, ne, t, true, false); } else if (this.checkPossibilities || this.negatePossibilities) { // check possibles t = this.findTokenByTag("[PREP]", new String[] { "[CONJ]", "[PSEU]", "[PREN]", "[POST]", "[POSP]" }, true, neRelStart, neRelEnd, tokens); if (t != null) { annotateNegation(aJCas, s, ne, t, false, true); } else { t = this.findTokenByTag("[POSP]", new String[] { "[CONJ]", "[PSEU]", "[PREN]", "[POST]", "[PREP]" }, false, neRelStart, neRelEnd, tokens); if (t != null) annotateNegation(aJCas, s, ne, t, true, true); } } } }
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 www .j a va2s . 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:com.arksoft.epamms.ZGlobal1_Operation.java
int AddAttributeToCSV(CharBuffer cb, int nLth, View lLibPers, String entityName, String attributeName, boolean bNumeric) { String s = null;/*from www . j av a 2s. c o m*/ cb.put(0, '"'); // opening quote // if ( bNumeric ) // { s = GetStringFromAttribute(s, lLibPers, entityName, attributeName); nLth = zstrcpy(cb, 1, s); // } // else // { // String stringAttrib; // // GetAddrForAttribute( &stringAttrib, lLibPers, entityName, stringAttribute ); // zstrcpy( stringBuffer, stringAttrib ); // } s = cb.toString(); if (s.indexOf('"', 1) > 0) { s = s.replace("\"", "\"\" "); // double any quotes ... s = s.substring(1); // except the first one } s += "\","; // terminating quote plus comma nLth = zstrcpy(cb, 0, s); return nLth; }
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;//w w w . j a v a2 s. 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.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;// ww w . j a v a2 s. 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.arksoft.epamms.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 www .ja v a 2 s.c o 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 * (int) 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 < (int) ulAttributeLth) { s = cbMemory.toString(); lEntityCnt *= 2; lTotalSize = lEntityCnt * (int) 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.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;/*w ww. ja v a 2 s . 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; }