Write a source record to the staging file

@param record data record to write
@throws java.io.IOException if there is anything wrong writing the record
763057
@Override
  public void write(byte[] record) throws IOException {
    Preconditions.checkNotNull(record);

    byte[] toWrite = record;
    if (this.recordDelimiter.isPresent()) {
      toWrite = Arrays.copyOf(record, record.length + 1);
      toWrite[toWrite.length - 1] = this.recordDelimiter.get();
    }
    if (this.prependSize) {
      long recordSize = toWrite.length;
      ByteBuffer buf = ByteBuffer.allocate(Longs.BYTES);
      buf.putLong(recordSize);
      toWrite = ArrayUtils.addAll(buf.array(), toWrite);
    }
    this.stagingFileOutputStream.write(toWrite);
    this.bytesWritten += toWrite.length;
    this.recordsWritten++;
  }
1022801
protected boolean writeNextRecord(T record) throws IOException {
		try {
			this.serializer.serialize(record, this.collectingView);
			this.numRecordsInBuffer++;
			return true;
		} catch (EOFException eofex) {
			return false;
		}
	}
427065
public synchronized void writeRecord(byte[] record, String header) {
        long length = record.length + nlen;
        PrintStream ps = getPrintStream(length, header);
        if (isWindows)
            ps.write(record, 0, (int) length - 2);
        else
            ps.write(record, 0, (int) length - 1);

        ps.println();
    }
668771
@Override
  public synchronized String format(final LogRecord record) {
    buffer.setLength(PREFIX.length());
    buffer.append(timestampFormatter.format(new Date(record.getMillis())));
    buffer.append(' ');
    buffer.append(levelNumberToCommonsLevelName(record.getLevel()));
    String[] parts = record.getSourceClassName().split("\\.");
    buffer.append(" [" + parts[parts.length-1] + "." + record.getSourceMethodName() + "]");
    buffer.append(SUFFIX);
    buffer.append(formatMessage(record)).append(lineSeparator);
    if (record.getThrown() != null) {
      final StringWriter trace = new StringWriter();
      record.getThrown().printStackTrace(new PrintWriter(trace));
      buffer.append(trace);
    }

    return buffer.toString();
  }
303859
private void writeTask(Task record) throws IOException
   {
      m_buffer.setLength(0);

      //
      // Write the task
      //
      int[] fields = m_taskModel.getModel();
      int field;

      m_buffer.append(MPXConstants.TASK_RECORD_NUMBER);
      for (int loop = 0; loop < fields.length; loop++)
      {
         field = fields[loop];
         if (field == -1)
         {
            break;
         }

         TaskField taskField = MPXTaskField.getMpxjField(field);
         Object value = record.getCachedValue(taskField);
         value = formatType(taskField.getDataType(), value);

         m_buffer.append(m_delimiter);
         m_buffer.append(format(value));
      }

      stripTrailingDelimiters(m_buffer);
      m_buffer.append(MPXConstants.EOL);
      m_writer.write(m_buffer.toString());

      //
      // Write the task notes
      //
      String notes = record.getNotes();
      if (notes.length() != 0)
      {
         writeNotes(MPXConstants.TASK_NOTES_RECORD_NUMBER, notes);
      }

      //
      // Write the recurring task
      //
      if (record.getRecurringTask() != null)
      {
         writeRecurringTask(record.getRecurringTask());
      }

      //
      // Write any resource assignments
      //
      if (record.getResourceAssignments().isEmpty() == false)
      {
         for (ResourceAssignment assignment : record.getResourceAssignments())
         {
            writeResourceAssignment(assignment);
         }
      }

      m_eventManager.fireTaskWrittenEvent(record);
   }
1333178
void store(final RECORD record, final String key, final String name, final Value value) {
        boolean calledASetter = false;

        if (value == null) {
            LOG.error("Got a null value to store for key={}  name={}.", key, name);
            return; // Nothing to do
        }

        final Set<Pair<Method, SetterPolicy>> methodPairs = targets.get(key);
        if (methodPairs == null) {
            LOG.error("NO methods for key={}  name={}.", key, name);
            return;
        }

        EnumSet<Casts> castsTo = castsOfTargets.get(key);
        if (castsTo == null) {
            castsTo = castsOfTargets.get(name);
            if (castsTo == null) {
                LOG.error("NO casts for \"{}\"", name);
                return;
            }
        }

        for (Pair<Method, SetterPolicy> methodPair : methodPairs) {
            Method method = methodPair.getLeft();
            if (method != null) {
                SetterPolicy setterPolicy = methodPair.getRight();
                try {
                    Class<?>[] parameters = method.getParameterTypes();
                    Class<?> valueClass = parameters[parameters.length - 1]; // Always the last one

                    if (valueClass == String.class) {
                        if (castsTo.contains(Casts.STRING)) {
                            String stringValue = value.getString();
                            if (stringValue == null) {
                                if (setterPolicy == NOT_NULL || setterPolicy == NOT_EMPTY) {
                                    calledASetter = true;
                                    continue;
                                }
                            } else {
                                if (stringValue.isEmpty() && setterPolicy == NOT_EMPTY) {
                                    calledASetter = true;
                                    continue;
                                }
                            }
                            if (parameters.length == 2) {
                                method.invoke(record, name, stringValue);
                            } else {
                                method.invoke(record, stringValue);
                            }
                            calledASetter = true;
                        }
                        continue;
                    }

                    if (valueClass == Long.class) {
                        if (castsTo.contains(Casts.LONG)) {
                            Long longValue = value.getLong();
                            if (longValue == null &&
                                (setterPolicy == NOT_NULL || setterPolicy == NOT_EMPTY)) {
                                calledASetter = true;
                                continue;
                            }
                            if (parameters.length == 2) {
                                method.invoke(record, name, longValue);
                            } else {
                                method.invoke(record, longValue);
                            }
                            calledASetter = true;
                        }
                        continue;
                    }

                    if (valueClass == Double.class) {
                        if (castsTo.contains(Casts.DOUBLE)) {
                            Double doubleValue = value.getDouble();
                            if (doubleValue == null &&
                                (setterPolicy == NOT_NULL || setterPolicy == NOT_EMPTY)) {
                                calledASetter = true;
                                continue;
                            }
                            if (parameters.length == 2) {
                                method.invoke(record, name, doubleValue);
                            } else {
                                method.invoke(record, doubleValue);
                            }
                            calledASetter = true;
                        }
                        continue;
                    }

                    throw new FatalErrorDuringCallOfSetterMethod(
                            "Tried to call setter with unsupported class :" +
                            " key = \"" + key + "\" " +
                            " name = \"" + name + "\" " +
                            " value = \"" + value + "\"" +
                            " castsTo = \"" + castsTo + "\"");

                } catch (final Exception e) {
                    throw new FatalErrorDuringCallOfSetterMethod(e.getMessage() + " caused by \"" +
                            e.getCause() + "\" when calling \"" +
                            method.toGenericString() + "\" for " +
                            " key = \"" + key + "\" " +
                            " name = \"" + name + "\" " +
                            " value = \"" + value + "\"" +
                            " castsTo = \"" + castsTo + "\"", e);
                }
            }
        }

        if (!calledASetter) {
            throw new FatalErrorDuringCallOfSetterMethod("No setter called for " +
                    " key = \"" + key + "\" " +
                    " name = \"" + name + "\" " +
                    " value = \"" + value + "\"");
        }
    }
1130456
public synchronized void writeRecord(String record) {
        long length = record.length() + nlen;
        PrintStream ps = getPrintStream(length, null);
        ps.println(record);
    }
357832
public void printEndRecordData(Rec record, PrintWriter out, int iPrintOptions)
    {
        this.getScreenFieldView().printEndRecordData(record, out, iPrintOptions);
    }
927511
@Override
	public void writeRecord(Record record) throws IOException {
		int numRecFields = record.getNumFields();
		int readPos;

		for (int i = 0; i < this.numFields; i++) {
			readPos = this.recordPositions[i];
			if (readPos < numRecFields) {
				Value v = record.getField(this.recordPositions[i], this.classes[i]);
				if (v != null) {
					if (i != 0) {
						this.wrt.write(this.fieldDelimiter);
					}
					this.wrt.write(v.toString());
				} else {
					if (this.lenient) {
						if (i != 0) {
							this.wrt.write(this.fieldDelimiter);
						}
					} else {
						throw new RuntimeException("Cannot serialize record with <null> value at position: " + readPos);
					}
				}

			} else {
				if (this.lenient) {
					if (i != 0) {
						this.wrt.write(this.fieldDelimiter);
					}
				} else {
					throw new RuntimeException("Cannot serialize record with out field at position: " + readPos);
				}
			}

		}

		// add the record delimiter
		this.wrt.write(this.recordDelimiter);
	}
154155
public void update(Record record, boolean isText) throws MPXJException
   {
      int length = record.getLength();

      for (int i = 0; i < length; i++)
      {
         if (isText == true)
         {
            add(getTaskCode(record.getString(i)));
         }
         else
         {
            add(record.getInteger(i).intValue());
         }
      }
   }
621171
public void broadcastEmit(T record) throws IOException, InterruptedException {
		checkErroneous();
		serializer.serializeRecord(record);

		boolean pruneAfterCopying = false;
		for (int channel : broadcastChannels) {
			if (copyFromSerializerToTargetChannel(channel)) {
				pruneAfterCopying = true;
			}
		}

		// Make sure we don't hold onto the large intermediate serialization buffer for too long
		if (pruneAfterCopying) {
			serializer.prune();
		}
	}
1021604
public void write(WARCWritable record) throws IOException {
        if (record.getRecord() != null) write(record.getRecord());
    }
964667
public void add(SingleCSVRecord record) {
        if (records == null)
            records = new ArrayList<>();
        records.add(record);
    }
207656
public StringRecordBuilder<D> add(String record) {
    this.records.add(apply(checkNotNull(record, "record")));
    return this;
  }
1243800
public boolean processThisRecord(Record record)
    {
        if (record != null)
        {   // Delete all the records
            this.disableAllListeners(record);
            if ((record.getDatabaseType() & (DBConstants.BASE_TABLE_CLASS | DBConstants.SHARED_TABLE)) == (DBConstants.BASE_TABLE_CLASS | DBConstants.SHARED_TABLE))
                this.initSharedRecord(record);
            record.close();
            try {
                while (record.hasNext())
                {
                    record.next();
                    record.edit();
                    record.remove();
                }
            } catch (DBException e) {
                e.printStackTrace();
            }
        }
        return true;
    }
1222878
private void writePhysicalRecord(ByteBuffer data, Record record) {
    writeBuffer.putInt(generateCrc(data.array(), data.position(), record.getBytes(),
        record.getType()));
    writeBuffer.putShort((short) record.getBytes());
    writeBuffer.put(record.getType().value());
    int oldLimit = data.limit();
    data.limit(data.position() + record.getBytes());
    writeBuffer.put(data);
    data.limit(oldLimit);
  }
1373458
public void publish(LogRecord record)
  {
    if (! isLoggable(record))
      return;
    
    int level = getLevel().intValue();

    for (int i = 0; i < _handlers.length; i++) {
      Handler handler = _handlers[i];

      if (level <= handler.getLevel().intValue())
        handler.publish(record);
    }
  }