/** * Used by NetworkObject to encode the object to a network stream. * * @see org.ccnx.ccn.impl.encoding.XMLEncodable */ public void encode(XMLEncoder encoder) throws ContentEncodingException { if (!validate()) { throw new ContentEncodingException( "Cannot encode " + this.getClass().getName() + ": field values missing."); } encoder.writeStartElement(getElementLabel()); if (null != _action && _action.length() != 0) encoder.writeElement(CCNProtocolDTags.Action, _action); if (null != _ccndID) { _ccndID.encode(encoder); } if (null != _faceID) { encoder.writeElement(CCNProtocolDTags.FaceID, _faceID); } if (null != _ipProto) { encoder.writeElement(CCNProtocolDTags.IPProto, _ipProto.value()); } if (null != _host && _host.length() != 0) { encoder.writeElement(CCNProtocolDTags.Host, _host); } if (null != _port) { encoder.writeElement(CCNProtocolDTags.Port, _port); } if (null != _multicastInterface && _multicastInterface.length() != 0) { encoder.writeElement(CCNProtocolDTags.MulticastInterface, _multicastInterface); } if (null != _multicastTTL) { encoder.writeElement(CCNProtocolDTags.MulticastTTL, _multicastTTL); } if (null != _lifetime) { encoder.writeElement(CCNProtocolDTags.FreshnessSeconds, _lifetime); } encoder.writeEndElement(); }