Write an {@code sfixed32} field, including tag, to the stream.
190614
public void writeSFixed32(final int fieldNumber, final int value)
                            throws IOException {
    writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED32);
    writeSFixed32NoTag(value);
  }
256653
private void writeSimple(String currentIndent, String tagName, StringBuilder attrs, Class<?> declaredType, Object value) throws IOException {
        Class<?> effectiveType;
        if (declaredType == Object.class) {
            Class<?> realType = value.getClass();
            if (realType != String.class) {
                effectiveType = settings.getConverter().findTypedConverter(realType).getEffectiveType();
                String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
                appendAttribute(attrs, TYPE, typeStr);
            } else {
                effectiveType = realType;
            }
        } else if (settings.getConverter().isConvertible(declaredType) == false) {
            effectiveType = settings.getConverter().findTypedConverter(value.getClass()).getEffectiveType();
            String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
            appendAttribute(attrs, TYPE, typeStr);
        } else {
            effectiveType = declaredType;
        }
        try {
            String converted = settings.getConverter().convertToString(effectiveType, value);
            if (converted == null) {
                throw new IllegalArgumentException("Unable to write because converter returned a null string: " + value);
            }
            output.append(currentIndent).append('<').append(tagName).append(attrs).append('>');
            appendEncoded(converted);
            output.append('<').append('/').append(tagName).append('>').append(settings.getNewLine());
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException("Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
        }
    }
391887
private synchronized void writeObject(final ObjectOutputStream s) throws IOException {
        if ( null != field ) {
            this.object = field.getDeclaringClass();
            this.varName = field.getName();
            this.field = null;
        }
        s.defaultWriteObject();
    }
531557
public void xmlWriteOn(FormattedWriter writer) throws IOException {

        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd @ HH:mm:ss.SSS");
        String timeNow = dateFormat.format(new Date());
        writer.newLine();
        writer.startTag(XML_CACHE_LOADER);
        writer.indent();

        writer.newLine();
        writer.taggedValue("timeNow", timeNow);
        writer.newLine();
        writer.taggedValue("interval", interval);
        writer.newLine();
        writer.taggedValue("enabled", Boolean.valueOf(enabled));
        writer.newLine();
        writer.taggedValue("maxStreamsPerCycle", maxStreamsPerCycle);
        writer.newLine();
        writer.taggedValue("loaderStartTime", dateFormat.format(new Date(loaderStartTime)));
        writer.newLine();
        writer.taggedValue("loaderStopTime", dateFormat.format(new Date(loaderStopTime)));
        writer.newLine();
        writer.taggedValue("totalStreams", totalStreams);
        writer.newLine();

        for (int i = 0; i < MAX_DIAG_LOG; i++)
        {
            String str =
            "Cycle="
            + i
            + (diagIndex == i ? ":*" : ": ")
            + dateFormat.format(new Date(cycleTime[i]))
            + " streamsLoaded="
            + logStreamsLoaded[i]
            + " duration="
            + logDuration[i];
            writer.taggedValue("info", str);
            writer.newLine();
        }

        writer.startTag(XML_STORED_EXCEPTION);
        if (lastException == null)
        {
            writer.write("No exceptions recorded");
        }
        else
        {
            writer.indent();
            writer.newLine();
            writer.taggedValue("time", new Date(lastExceptionTime));
            writer.outdent();
            writer.write(lastException);
            writer.newLine();
        }
        writer.endTag(XML_STORED_EXCEPTION);

        writer.outdent();
        writer.newLine();
        writer.endTag(XML_CACHE_LOADER);
    }
1246603
private void writeFieldInstBegin(OutputStream result) throws IOException 
    {
        result.write(OPEN_GROUP);        
        result.write(FIELD_INSTRUCTIONS);
        result.write(DELIMITER);
    }
109530
public static void writeXmlToUTF8(Element ele, Writer out) 
            throws IOException {
        XMLSerializer serializer =
                new XMLSerializer(out, XML_TO_UTF8);
        serializer.serialize(ele);
    }
996209
private void writeTagValue(TagValue tag) throws IOException {
    int id = tag.getId();

    // Write tag value
    for (abstractTiffType tt : tag.getValue()) {
      if (id == 700) {
        // XMP
        XMP xmp = (XMP)tt;
        try {
          xmp.write(data);
        }catch (Exception ex) {
          XmlType xml = (XmlType)tt;
          try {
            xml.writeXml(data);
          } catch (Exception exx) {
            exx.printStackTrace();
            throw new IOException();
          }
        }
      } else if (id == 33723) {
        // IPTC
        abstractTiffType att = tag.getValue().get(0);
        if (att instanceof IPTC) {
          IPTC iptc = (IPTC) att;
          iptc.write(data);
          //for (int i = 0; i < iptc.getOriginal().size(); i++) data.put(iptc.getOriginal().get(i).toByte());
          //data.put((byte) 0);
        } else {
          for (int i = 0; i < tag.getValue().size(); i++) {
            data.put(tag.getValue().get(i).toByte());
          }
          data.put((byte) 0);
        }
      } else if (id == 330) {
        // SubIFD
        IFD subifd = ((IFD) tag.getValue().get(0));
        writeIFD(subifd);
      } else if (id == 34665) {
        // EXIF
        IFD exif = (IFD) tag.getValue().get(0);
        writeIFD(exif);
      } else if (id == 34675) {
        // ICC
        for (int off = tag.getReadOffset(); off < tag.getReadOffset() + tag.getReadlength(); off++) {
          data.put(input.readByte(off).toByte());
        }
        data.put((byte) 0);
      } else {
        switch (tag.getType()) {
          case 3:
            data.putShort((short) tt.toInt());
            break;
          case 8:
            data.putSShort((SShort) tt);
            break;
          case 4:
            data.putLong((Long) tt);
            break;
          case 9:
            data.putSLong((SLong) tt);
            break;
          case 11:
            data.putFloat((Float) tt);
            break;
          case 13:
            data.putInt(tt.toInt());
            break;
          case 5:
            data.putRational((Rational) tt);
            break;
          case 10:
            data.putSRational((SRational) tt);
            break;
          case 12:
            data.putDouble((Double) tt);
            break;
          case 2:
            data.put(tt.toByte());
            break;
          default:
            data.put(tt.toByte());
            break;
        }
      }
    }
  }
874884
public static void writeTag(OutputStream out, Tag tag) throws IOException {
        writeTag(out, tag, false);
    }
1307700
public void readWriteElement(String tagName) throws WLFormatException {
        try {
            while (xmlEventReader.hasNext()) {
                XMLEvent event = xmlEventReader.nextEvent();
                switch (event.getEventType()) {
                    case XMLStreamConstants.END_ELEMENT:
                        add(event);
                        if (event.asEndElement().getName().getLocalPart().equals(tagName)) {
                            return;
                        }
                        break;
                    default:
                        add(event);
                        break;
                }
            }

        } catch (XMLStreamException e) {
            throw new WLFormatException(e.getMessage(), e);
        } catch (NoSuchElementException e) {
            throw new WLFormatException(e.getMessage(), e);
        } 

    }
84736
public void writeBytes(final int fieldNumber, final ByteString value)
                         throws IOException {
    writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
    writeBytesNoTag(value);
  }
1062228
public void writeBundleStream(BundleStreamSource source, WritableByteChannel output) throws IOException {
    ByteBuffer buffer = ByteBuffer.allocateDirect(INITIAL_BUFFER);

    DBIDVar var = DBIDUtil.newVar();
    ByteBufferSerializer<?>[] serializers = null;
    loop: while(true) {
      BundleStreamSource.Event ev = source.nextEvent();
      switch(ev){
      case NEXT_OBJECT:
        if(serializers == null) {
          serializers = writeHeader(source, buffer, output);
        }
        if(serializers[0] != null) {
          if(!source.assignDBID(var)) {
            throw new AbortException("An object did not have an DBID assigned.");
          }
          DBID id = DBIDUtil.deref(var);
          @SuppressWarnings("unchecked")
          ByteBufferSerializer<DBID> ser = (ByteBufferSerializer<DBID>) serializers[0];
          int size = ser.getByteSize(id);
          buffer = ensureBuffer(size, buffer, output);
          ser.toByteBuffer(buffer, id);
        }
        for(int i = 1, j = 0; i < serializers.length; ++i, ++j) {
          @SuppressWarnings("unchecked")
          ByteBufferSerializer<Object> ser = (ByteBufferSerializer<Object>) serializers[i];
          int size = ser.getByteSize(source.data(j));
          buffer = ensureBuffer(size, buffer, output);
          ser.toByteBuffer(buffer, source.data(j));
        }
        break; // switch
      case META_CHANGED:
        if(serializers != null) {
          throw new AbortException("Meta changes are not supported, once the block header has been written.");
        }
        break; // switch
      case END_OF_STREAM:
        break loop;
      default:
        LOG.warning("Unknown bundle stream event. API inconsistent? " + ev);
        break; // switch
      }
    }
    if(buffer.position() > 0) {
      flushBuffer(buffer, output);
    }
  }
225791
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("remoteMEUuid", remoteMEUuid);
    writer.newLine();
    writer.taggedValue("streamID", streamID);
    writer.newLine();
    writer.taggedValue("initialData", initialData);
    writer.newLine();
    writer.taggedValue("type", type);
  }
479815
public void write(XMLStreamWriter writer, String xmlElementName, AttributeDefinition<?>... defs) throws XMLStreamException {
      boolean skip = true;
      for (AttributeDefinition def : defs) {
         skip = skip && !attribute(def).isModified();
      }
      if (!skip) {
         writer.writeStartElement(xmlElementName);
         for (AttributeDefinition def : defs) {
            Attribute attr = attribute(def);
            attr.write(writer, attr.getAttributeDefinition().xmlName());
         }
         writer.writeEndElement();
      }
   }
1058518
protected void writeInputs( String varType, Stream<IVarDef> varDefs)
    {
    xmlWriter_
      .element( INPUT_TAG)
      .attribute( TYPE_ATR, varType)
      .content( () -> varDefs.forEach( this::writeVarDef))
      .write();
    }
849941
protected void writeVarDef( IVarDef varDef)
    {
    Stream<VarValueDef> values =
      varDef.getValues() == null
      ? null
      : toStream( varDef.getValues());

    Stream<IVarDef> members = 
      varDef.getMembers() == null
      ? null
      : toStream( varDef.getMembers());

    String varTag =
      members == null
      ? VAR_TAG
      : VARSET_TAG;

    ConditionWriter conditionWriter = new ConditionWriter( varDef.getCondition());

    xmlWriter_
      .element( varTag)
      .attribute( NAME_ATR, varDef.getName())
      .attributeIf( WHEN_ATR, conditionWriter.getWhenAttribute())
      .content( () ->
        {
        writeAnnotations( varDef);
        conditionWriter.writeWhenElement();
        if( varTag.equals( VAR_TAG))
          {
          values.forEach( this::writeValue);
          }
        else
          {
          members.forEach( this::writeVarDef);
          }
        })
      .write();
    }
1216089
void writeRest(RecordOutput rout, String tag) throws IOException {
    rout.writeInt(typeInfos.size(), tag);
    for (FieldTypeInfo ti : typeInfos) {
      ti.write(rout, tag);
    }
  }
54948
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:magicnumber"})
	public void writeRecord(AttributeProvider element) throws IOException, AttributeException {

		if (this.columns == null) {
			throw new MustCallWriteHeaderFunctionException();
		}

		//Field deleted flag (value : 2Ah (*) => Record is deleted, 20h (blank) => Record is valid)
		this.stream.writeByte(0x20);

		for (final DBaseFileField field : this.columns) {
			// Get attribute
			final DBaseFieldType dbftype = field.getType();
			final String fieldName = field.getName();

			AttributeValue attr = element != null ? element.getAttribute(fieldName) : null;

			if (attr == null) {
				attr = new AttributeValueImpl(dbftype.toAttributeType());
				attr.setToDefault();
			} else {
				if (attr.isAssigned()) {
					attr = new AttributeValueImpl(attr);
					attr.cast(dbftype.toAttributeType());
				} else {
					attr = new AttributeValueImpl(attr);
					attr.setToDefaultIfUninitialized();
				}
			}

			// Write value
			switch (dbftype) {
			case BOOLEAN:
				writeDBFBoolean(attr.getBoolean());
				break;
			case DATE:
				writeDBFDate(attr.getDate());
				break;
			case STRING:
				writeDBFString(attr.getString(), field.getLength(), (byte) ' ');
				break;
			case INTEGER_2BYTES:
				writeDBFInteger((short) attr.getInteger());
				break;
			case INTEGER_4BYTES:
				writeDBFLong((int) attr.getInteger());
				break;
			case DOUBLE:
				writeDBFDouble(attr.getReal());
				break;
			case FLOATING_NUMBER:
			case NUMBER:
				if (attr.getType() == AttributeType.REAL) {
					writeDBFNumber(attr.getReal(), field.getLength(), field.getDecimalPointPosition());
				} else {
					writeDBFNumber(attr.getInteger(), field.getLength(), field.getDecimalPointPosition());
				}
				break;
			case BINARY:
			case GENERAL:
			case MEMORY:
			case PICTURE:
			case VARIABLE:
				// not yet supported
				writeDBFString((String) null, 10, (byte) 0);
				break;
			default:
				throw new IllegalStateException();
			}
		}

		// Be sure that the memory was not fully filled by the saving process
		if (element != null) {
			element.freeMemory();
		}
	}