Write the field to the specified channel.

@param channel the channel to which it should be written

@throws IOException if there is a problem writing to the channel
356891
public void write(WritableByteChannel channel) throws IOException {
        logger.debug("..writing> {}", this);
        Util.writeFully(getBytes(), channel);
    }
942479
public void setChannels(java.util.Collection<Channel> channels) {
        if (channels == null) {
            this.channels = null;
            return;
        }

        this.channels = new java.util.ArrayList<Channel>(channels);
    }
317170
public void writeAsMessageSetTo(final CodedOutputStream output)
      throws IOException {
    for (final Map.Entry<Integer, Field> entry : fields.entrySet()) {
      entry.getValue().writeAsMessageSetExtensionTo(
        entry.getKey(), output);
    }
  }
238846
public void writeTo(File file) throws IOException {
        FileChannel channel = new FileOutputStream(file).getChannel();
        try {
            writeTo(channel);
        } finally {
            channel.close();
        }
    }
1150480
public static final long write(WritableByteChannel channel, ByteBuffer[] srcs, int offset, int length) throws IOException
    {
        long res = 0;
        for  (int ii=0;ii<length;ii++)
        {
            ByteBuffer bb = srcs[ii+offset];
            if (bb.hasRemaining())
            {
                res += channel.write(bb);
                if (bb.hasRemaining())
                {
                    break;
                }
            }
        }
        return res;
    }
55666
@InterfaceAudience.Public
    public void setChannels(List<String> channels) {
        properties.put(ReplicationField.CHANNELS, channels);
        replicationInternal.setChannels(channels);
    }
741276
public void write(Writer writer)
        throws IOException
    {
        synchronized(writer)
        {
            for (int i=0;i<_fields.size();i++)
            {
                Field field=(Field)_fields.get(i);
                if (field!=null)
                    field.write(writer,_version);
            }
            writer.write(__CRLF);
        }
    }
1078603
public void write(Parameter parameter) throws IOException {
        if (parameter.getParameterValueType() == ParameterValueType.PARAMETERS) {
            if (parameter.isArray()) {
                List<Parameters> list = parameter.getValueAsParametersList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (Parameters p : list) {
                            indent();
                            openCurlyBracket();
                            write(p);
                            closeCurlyBracket();
                        }
                        closeSquareBracket();
                    } else {
                        for (Parameters p : list) {
                            writeName(parameter);
                            openCurlyBracket();
                            write(p);
                            closeCurlyBracket();
                        }
                    }
                }
            } else {
                if (nullWritable || parameter.getValueAsParameters() != null) {
                    writeName(parameter);
                    openCurlyBracket();
                    write(parameter.getValueAsParameters());
                    closeCurlyBracket();
                }
            }
        } else if (parameter.getParameterValueType() == ParameterValueType.VARIABLE) {
            if (parameter.isArray()) {
                List<?> list = parameter.getValueList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (Object value : list) {
                            indent();
                            if (value instanceof Parameters) {
                                write((Parameters)value);
                            } else if (value != null) {
                                writeString(value.toString());
                            } else {
                                writeNull();
                            }
                        }
                        closeSquareBracket();
                    } else {
                        for (Object value : list) {
                            writeName(parameter);
                            if (value instanceof Parameters) {
                                write((Parameters)value);
                            } else if (value != null) {
                                writeString(value.toString());
                            } else {
                                writeNull();
                            }
                        }
                    }
                }
            } else {
                Object value = parameter.getValue();
                if (nullWritable || value != null) {
                    writeName(parameter);
                    openCurlyBracket();
                    if (value instanceof Parameters) {
                        write((Parameters)value);
                    } else if (value != null) {
                        writeString(value.toString());
                    } else {
                        writeNull();
                    }
                    closeCurlyBracket();
                }
            }
        } else if (parameter.getParameterValueType() == ParameterValueType.STRING) {
            if (parameter.isArray()) {
                List<String> list = parameter.getValueAsStringList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (String value : list) {
                            indent();
                            writeString(value);
                        }
                        closeSquareBracket();
                    } else {
                        for (String value : list) {
                            writeName(parameter);
                            writeString(value);
                        }
                    }
                }
            } else {
                String s = parameter.getValueAsString();
                if (nullWritable || s != null) {
                    writeName(parameter);
                    writeString(s);
                }
            }
        } else if (parameter.getParameterValueType() == ParameterValueType.TEXT) {
            if (parameter.isArray()) {
                List<String> list = parameter.getValueAsStringList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (String text : list) {
                            indent();
                            openRoundBracket();
                            writeText(text);
                            closeRoundBracket();
                        }
                        closeSquareBracket();
                    } else {
                        for (String text : list) {
                            writeName(parameter);
                            openRoundBracket();
                            writeText(text);
                            closeRoundBracket();
                        }
                    }
                }
            } else {
                String text = parameter.getValueAsString();
                if (text != null) {
                    writeName(parameter);
                    openRoundBracket();
                    writeText(text);
                    closeRoundBracket();
                } else if (nullWritable) {
                    writeName(parameter);
                    writeNull();
                }
            }
        } else {
            if (parameter.isArray()) {
                List<?> list = parameter.getValueList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (Object value : list) {
                            indent();
                            write(value);
                        }
                        closeSquareBracket();
                    } else {
                        for (Object value : list) {
                            writeName(parameter);
                            write(value);
                        }
                    }
                }
            } else {
                if (nullWritable || parameter.getValue() != null) {
                    writeName(parameter);
                    write(parameter.getValue());
                }
            }
        }
    }
863702
public void writeTo(OutputStream out) throws IOException {
        if (!(out instanceof DataOutput)) {
            out = new DataOutputStream(out);
        }

        writeTo((DataOutput)out);

        out.flush();
    }
867883
public void writeTo(final OutputStream output) throws IOException {
    final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output);
    writeTo(codedOutput);
    codedOutput.flush();
  }
1334537
public void setChannels(java.util.Collection<String> channels) {
        if (channels == null) {
            this.channels = null;
            return;
        }

        this.channels = new java.util.ArrayList<String>(channels);
    }
805285
@Override
    protected void writeKey(Writer writer, FieldDescriptor key) throws IOException {
        writer.write(key.getClassDescriptor().getDottedClassName());
        writer.write(",");
        writer.write(key.getName());
        writer.write(",");
        writer.write(key.getSignature());
        writer.write(",");
        XField xField = XFactory.createXField(key);
        int flags = xField.getAccessFlags() & 0xf;
        writer.write(String.valueOf(flags));
    }
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();
    }
151034
void writeTo(OutputStream os) throws IOException
    {
        os.write(DocWriter.getISOBytes(String.valueOf(number)));
        os.write(' ');
        os.write(DocWriter.getISOBytes(String.valueOf(generation)));
        os.write(STARTOBJ);
        object.toPdf(writer, os);
        os.write(ENDOBJ);
    }
868758
public void writeMessageSetTo(final CodedOutputStream output)
                                throws IOException {
    for (int i = 0; i < fields.getNumArrayEntries(); i++) {
      writeMessageSetTo(fields.getArrayEntryAt(i), output);
    }
    for (final Map.Entry<FieldDescriptorType, Object> entry :
             fields.getOverflowEntries()) {
      writeMessageSetTo(entry, output);
    }
  }
974052
static void checkChannelValidity(Object channel) throws IOException {
    if (channel == null) {
      /* Most common reason is that original socket does not have a channel.
       * So making this an IOException rather than a RuntimeException.
       */
      throw new IOException("Channel is null. Check " +
                            "how the channel or socket is created.");
    }
    
    if (!(channel instanceof SelectableChannel)) {
      throw new IOException("Channel should be a SelectableChannel");
    }    
  }
1196802
public void write(byte[] bytes) throws IOException {
        for (int i = 0; i < bytes.length; i++) {
            write(bytes[i]);
        }
    }