// This file automatically generated by protocol-compiler
// from java/com/google/net/resolver/proto/addressresolver.proto
// DO NOT EDIT!
package com.google.net.resolver.proto;
import com.google.io.protocol.ProtocolMessage;
import com.google.io.protocol.ProtocolSink;
import com.google.io.protocol.ProtocolSource;
import com.google.io.protocol.ProtocolSupport;
import com.google.io.protocol.ProtocolType;
import com.google.io.protocol.UninterpretedTags;
import com.google.io.protocol.MessageAppender;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@SuppressWarnings({"JavaDoc"})
public class ResolvedAddr extends ProtocolMessage<ResolvedAddr> {
private static final long serialVersionUID = 1L;
private int port_ = 0;
private List<byte[]> ipv4_ = null; // lazy new ArrayList<byte[]>(4)
private byte[] hostname_ = ProtocolSupport.EMPTY_BYTE_ARRAY;
private int dns_ttl_ = 0;
private List<byte[]> ipv6_ = null; // lazy new ArrayList<byte[]>(4)
private UninterpretedTags uninterpreted;
private int optional_0_;
// REQUIRED INT32 port = 1
public final int port() {
return port_;
}
public final boolean has_port() {
return (optional_0_ & 0x1) != 0;
}
public ResolvedAddr clear_port() {
optional_0_ &= ~0x1;
port_ = 0;
return this;
}
public ResolvedAddr set_port(int x) {
optional_0_ |= 0x1;
port_ = x;
return this;
}
// REPEATED STRING ipv4 = 2
public final int ipv4_size() {
return ((ipv4_ != null) ? ipv4_.size() : 0);
}
public final byte[] ipv4(int i) {
assert i >= 0 && i < ((ipv4_ != null) ? ipv4_.size() : 0);
return ipv4_.get(i);
}
public ResolvedAddr clear_ipv4() {
if (ipv4_ != null) { ipv4_.clear(); }
return this;
}
public final String ipv4_unicode(int i) {
return ProtocolSupport.toStringUtf8(ipv4_.get(i));
}
public ResolvedAddr set_ipv4(int i, byte[] v) {
ipv4_.set(i, v);
return this;
}
public ResolvedAddr set_ipv4_unicode(int i, String v) {
if (v == null) { throw new NullPointerException(); }
ipv4_.set(i, ProtocolSupport.toBytesUtf8(v));
return this;
}
public ResolvedAddr add_ipv4(byte[] v) {
if (ipv4_ == null) { ipv4_ = new ArrayList<byte[]>(4); }
ipv4_.add(v);
return this;
}
public ResolvedAddr add_ipv4_unicode(String v) {
if (v == null) { throw new NullPointerException(); }
if (ipv4_ == null) { ipv4_ = new ArrayList<byte[]>(4); }
ipv4_.add(ProtocolSupport.toBytesUtf8(v));
return this;
}
public final Iterator<String> ipv4_unicode_iterator() {
return ProtocolSupport.byteArrayToUnicodeIterator(ipv4_);
}
public final List<String> ipv4_iterable() {
return ProtocolSupport.byteArrayToUnicodeList(ipv4_);
}
// OPTIONAL STRING hostname = 3
public final byte[] hostname() {
return hostname_;
}
public final boolean has_hostname() {
return (optional_0_ & 0x2) != 0;
}
public ResolvedAddr clear_hostname() {
optional_0_ &= ~0x2;
hostname_ = ProtocolSupport.EMPTY_BYTE_ARRAY;
return this;
}
public ResolvedAddr set_hostname(byte[] x) {
optional_0_ |= 0x2;
hostname_ = x;
return this;
}
public final String hostname_unicode() {
return ProtocolSupport.toStringUtf8(hostname_);
}
public ResolvedAddr set_hostname_unicode(String v) {
if (v == null) { throw new NullPointerException(); }
optional_0_ |= 0x2;
hostname_ = ProtocolSupport.toBytesUtf8(v);
return this;
}
// OPTIONAL INT32 dns_ttl = 4
public final int dns_ttl() {
return dns_ttl_;
}
public final boolean has_dns_ttl() {
return (optional_0_ & 0x4) != 0;
}
public ResolvedAddr clear_dns_ttl() {
optional_0_ &= ~0x4;
dns_ttl_ = 0;
return this;
}
public ResolvedAddr set_dns_ttl(int x) {
optional_0_ |= 0x4;
dns_ttl_ = x;
return this;
}
// REPEATED STRING ipv6 = 5
public final int ipv6_size() {
return ((ipv6_ != null) ? ipv6_.size() : 0);
}
public final byte[] ipv6(int i) {
assert i >= 0 && i < ((ipv6_ != null) ? ipv6_.size() : 0);
return ipv6_.get(i);
}
public ResolvedAddr clear_ipv6() {
if (ipv6_ != null) { ipv6_.clear(); }
return this;
}
public final String ipv6_unicode(int i) {
return ProtocolSupport.toStringUtf8(ipv6_.get(i));
}
public ResolvedAddr set_ipv6(int i, byte[] v) {
ipv6_.set(i, v);
return this;
}
public ResolvedAddr set_ipv6_unicode(int i, String v) {
if (v == null) { throw new NullPointerException(); }
ipv6_.set(i, ProtocolSupport.toBytesUtf8(v));
return this;
}
public ResolvedAddr add_ipv6(byte[] v) {
if (ipv6_ == null) { ipv6_ = new ArrayList<byte[]>(4); }
ipv6_.add(v);
return this;
}
public ResolvedAddr add_ipv6_unicode(String v) {
if (v == null) { throw new NullPointerException(); }
if (ipv6_ == null) { ipv6_ = new ArrayList<byte[]>(4); }
ipv6_.add(ProtocolSupport.toBytesUtf8(v));
return this;
}
public final Iterator<String> ipv6_unicode_iterator() {
return ProtocolSupport.byteArrayToUnicodeIterator(ipv6_);
}
public final List<String> ipv6_iterable() {
return ProtocolSupport.byteArrayToUnicodeList(ipv6_);
}
public ResolvedAddr() {
}
@Override public ResolvedAddr mergeFrom(ResolvedAddr that) {
assert that != this;
int this_t0 = optional_0_;
int that_t0 = that.optional_0_;
// REQUIRED INT32 port = 1
if ((that_t0 & 0x1) != 0) {
this_t0 |= 0x1;
port_ = that.port_;
}
// REPEATED STRING ipv4 = 2
if (that.ipv4_ != null && that.ipv4_.size() > 0) {
if (this.ipv4_ == null) {
this.ipv4_ = new ArrayList<byte[]>(that.ipv4_);
} else {
this.ipv4_.addAll(that.ipv4_);
}
}
// OPTIONAL STRING hostname = 3
if ((that_t0 & 0x2) != 0) {
this_t0 |= 0x2;
hostname_ = that.hostname_;
}
// OPTIONAL INT32 dns_ttl = 4
if ((that_t0 & 0x4) != 0) {
this_t0 |= 0x4;
dns_ttl_ = that.dns_ttl_;
}
// REPEATED STRING ipv6 = 5
if (that.ipv6_ != null && that.ipv6_.size() > 0) {
if (this.ipv6_ == null) {
this.ipv6_ = new ArrayList<byte[]>(that.ipv6_);
} else {
this.ipv6_.addAll(that.ipv6_);
}
}
// uninterpreted
if (that.uninterpreted != null) {
getUninterpretedForWrite().putAll(that.uninterpreted);
}
optional_0_ = this_t0;
return this;
}
@Override public boolean equalsIgnoreUninterpreted(ResolvedAddr that) {
return equals(that, true);
}
@Override public boolean equals(ResolvedAddr that) {
return equals(that, false);
}
@Override public boolean equals(ResolvedAddr that, boolean ignoreUninterpreted) {
if (that == null) { return false; }
if (that == this) { return true; }
int this_t0 = optional_0_;
int that_t0 = that.optional_0_;
if (this_t0 != that_t0) { return false; }
// REQUIRED INT32 port = 1
if ((this_t0 & 0x1) != 0) {
if (port_ != that.port_) { return false; }
}
// REPEATED STRING ipv4 = 2
int n;
if ((n = ((ipv4_ != null) ? ipv4_.size() : 0)) != ((that.ipv4_ != null) ? that.ipv4_.size() : 0)) { return false; }
for (int i = 0; i < n; i++) {
if (!Arrays.equals(ipv4_.get(i), that.ipv4_.get(i))) { return false; }
}
// OPTIONAL STRING hostname = 3
if ((this_t0 & 0x2) != 0) {
if (!Arrays.equals(hostname_, that.hostname_)) { return false; }
}
// OPTIONAL INT32 dns_ttl = 4
if ((this_t0 & 0x4) != 0) {
if (dns_ttl_ != that.dns_ttl_) { return false; }
}
// REPEATED STRING ipv6 = 5
if ((n = ((ipv6_ != null) ? ipv6_.size() : 0)) != ((that.ipv6_ != null) ? that.ipv6_.size() : 0)) { return false; }
for (int i = 0; i < n; i++) {
if (!Arrays.equals(ipv6_.get(i), that.ipv6_.get(i))) { return false; }
}
// uninterpreted
return ignoreUninterpreted || UninterpretedTags.equivalent(
uninterpreted, that.uninterpreted);
}
@Override public boolean equals(Object that) {
return (that instanceof ResolvedAddr) && equals((ResolvedAddr) that);
}
@Override public int hashCode() {
int hash = 1117011028;
// REQUIRED INT32 port = 1
int this_t0 = optional_0_;
hash = hash * 31 + (((this_t0 & 0x1) != 0) ? port_ : -113);
// REPEATED STRING ipv4 = 2
hash *= 31;
for (int i = 0, n = ((ipv4_ != null) ? ipv4_.size() : 0); i < n; i++) {
hash = hash * 31 + Arrays.hashCode(ipv4_.get(i));
}
// OPTIONAL STRING hostname = 3
hash = hash * 31 + (((this_t0 & 0x2) != 0) ? Arrays.hashCode(hostname_) : -113);
// OPTIONAL INT32 dns_ttl = 4
hash = hash * 31 + (((this_t0 & 0x4) != 0) ? dns_ttl_ : -113);
// REPEATED STRING ipv6 = 5
hash *= 31;
for (int i = 0, n = ((ipv6_ != null) ? ipv6_.size() : 0); i < n; i++) {
hash = hash * 31 + Arrays.hashCode(ipv6_.get(i));
}
if (uninterpreted != null && !uninterpreted.isEmpty()) {
hash = hash * 31 + uninterpreted.hashCode();
}
return hash;
}
@Override public boolean isInitialized() {
int this_t0 = optional_0_;
if ((this_t0 & 0x1) != 0x1) {
return false;
}
return true;
}
@Override public int encodingSize() {
// REQUIRED INT32 port = 1, tag_size = 1; fixed_size = 0; variable_part
int n = 1 + com.google.io.protocol.Protocol.varLongSize(port_);
// REPEATED STRING ipv4 = 2, tag_size = 1; fixed_size = 0; variable_part
int m;
n += (m = ((ipv4_ != null) ? ipv4_.size() : 0));
for (int i = 0; i < m; i++) {
n += com.google.io.protocol.Protocol.stringSize(ipv4_.get(i).length);
}
// REPEATED STRING ipv6 = 5, tag_size = 1; fixed_size = 0; variable_part
n += (m = ((ipv6_ != null) ? ipv6_.size() : 0));
for (int i = 0; i < m; i++) {
n += com.google.io.protocol.Protocol.stringSize(ipv6_.get(i).length);
}
int this_t0 = optional_0_;
if ((this_t0 & 0x6) != 0) {
if ((this_t0 & 0x2) != 0) {
// OPTIONAL STRING hostname = 3, tag_size = 1; fixed_size = 0; variable_part
n += 1 + com.google.io.protocol.Protocol.stringSize(hostname_.length);
}
if ((this_t0 & 0x4) != 0) {
// OPTIONAL INT32 dns_ttl = 4, tag_size = 1; fixed_size = 0; variable_part
n += 1 + com.google.io.protocol.Protocol.varLongSize(dns_ttl_);
}
}
// uninterpreted
return (uninterpreted != null) ?
(n + uninterpreted.encodingSize()) : n;
}
@Override public int maxEncodingSize() {
// REQUIRED INT32 port = 1, tag_size = 1; fixed_size = 10;
// OPTIONAL INT32 dns_ttl = 4, tag_size = 1; fixed_size = 10;
int n = 22;
// REPEATED STRING ipv4 = 2, tag_size = 1; fixed_size = 5; variable_part
int m;
n += 6 * (m = ((ipv4_ != null) ? ipv4_.size() : 0));
for (int i = 0; i < m; i++) {
n += ipv4_.get(i).length;
}
// REPEATED STRING ipv6 = 5, tag_size = 1; fixed_size = 5; variable_part
n += 6 * (m = ((ipv6_ != null) ? ipv6_.size() : 0));
for (int i = 0; i < m; i++) {
n += ipv6_.get(i).length;
}
int this_t0 = optional_0_;
if ((this_t0 & 0x2) != 0) {
// OPTIONAL STRING hostname = 3, tag_size = 1; fixed_size = 5; variable_part
n += 6 + hostname_.length;
}
// uninterpreted
return (uninterpreted != null) ?
(n + uninterpreted.maxEncodingSize()) : n;
}
@Override public MessageAppender getMessageAppender() {
return getUninterpretedForWrite();
}
@Override public void clear() {
optional_0_ = 0;
port_ = 0;
if (ipv4_ != null) { ipv4_.clear(); }
hostname_ = ProtocolSupport.EMPTY_BYTE_ARRAY;
dns_ttl_ = 0;
if (ipv6_ != null) { ipv6_.clear(); }
uninterpreted = null;
}
@Override public ResolvedAddr newInstance() {
return new ResolvedAddr();
}
@Override public ProtocolType getProtocolType() {
return StaticHolder.protocolType;
}
private static class StaticHolder {
private static final ProtocolType protocolType = ProtocolType.newProtocolType(
ResolvedAddr.class,
"\132\070\152\141\166\141\057\143\157\155\057\147\157\157\147" +
"\154\145\057\156\145\164\057\162\145\163\157\154\166\145\162" +
"\057\160\162\157\164\157\057\141\144\144\162\145\163\163\162" +
"\145\163\157\154\166\145\162\056\160\162\157\164\157\012\014" +
"\122\145\163\157\154\166\145\144\101\144\144\162\023\032\004" +
"\160\157\162\164\040\001\050\000\060\005\070\002\024\023\032" +
"\004\151\160\166\064\040\002\050\002\060\011\070\003\024\023" +
"\032\010\150\157\163\164\156\141\155\145\040\003\050\002\060" +
"\011\070\001\024\023\032\007\144\156\163\137\164\164\154\040" +
"\004\050\000\060\005\070\001\024\023\032\004\151\160\166\066" +
"\040\005\050\002\060\011\070\003\024"
,
new ProtocolType.FieldType("port", "port", 1, 0,
ProtocolType.FieldBaseType.INT32, ProtocolType.Presence.REQUIRED),
new ProtocolType.FieldType("ipv4", "ipv4", 2, -1,
ProtocolType.FieldBaseType.STRING, ProtocolType.Presence.REPEATED),
new ProtocolType.FieldType("hostname", "hostname", 3, 1,
ProtocolType.FieldBaseType.STRING, ProtocolType.Presence.OPTIONAL),
new ProtocolType.FieldType("dns_ttl", "dns_ttl", 4, 2,
ProtocolType.FieldBaseType.INT32, ProtocolType.Presence.OPTIONAL),
new ProtocolType.FieldType("ipv6", "ipv6", 5, -1,
ProtocolType.FieldBaseType.STRING, ProtocolType.Presence.REPEATED));
}
@Override public void outputTo(ProtocolSink sink) {
// REQUIRED INT32 port = 1
sink.putByte((byte) 8); // sink.putVarInt(8)
sink.putVarLong(port_);
// REPEATED STRING ipv4 = 2
for (int i = 0, m = ((ipv4_ != null) ? ipv4_.size() : 0); i < m; i++) {
byte[] v = ipv4_.get(i);
sink.putByte((byte) 18); // sink.putVarInt(18)
sink.putPrefixedData(v);
}
// OPTIONAL STRING hostname = 3
int this_t0 = optional_0_;
if ((this_t0 & 0x2) != 0) {
sink.putByte((byte) 26); // sink.putVarInt(26)
sink.putPrefixedData(hostname_);
}
// OPTIONAL INT32 dns_ttl = 4
if ((this_t0 & 0x4) != 0) {
sink.putByte((byte) 32); // sink.putVarInt(32)
sink.putVarLong(dns_ttl_);
}
// REPEATED STRING ipv6 = 5
for (int i = 0, m = ((ipv6_ != null) ? ipv6_.size() : 0); i < m; i++) {
byte[] v = ipv6_.get(i);
sink.putByte((byte) 42); // sink.putVarInt(42)
sink.putPrefixedData(v);
}
// uninterpreted
if (uninterpreted != null) {
uninterpreted.put(sink);
}
}
@Override public boolean merge(ProtocolSource source) {
boolean result = true;
int this_t0 = optional_0_;
loop:
while (source.hasRemaining()) {
int tt = source.getVarInt();
switch (tt) {
case 0:
// tag 0 is special: it's used to indicate an error.
// so if we see it we return false, to indicate "error!"
result = false;
break loop;
case 8:
// REQUIRED INT32 port = 1
port_ = source.getVarInt();
this_t0 |= 0x1;
break;
case 18:
// REPEATED STRING ipv4 = 2
add_ipv4(source.getPrefixedData());
break;
case 26:
// OPTIONAL STRING hostname = 3
hostname_ = source.getPrefixedData();
this_t0 |= 0x2;
break;
case 32:
// OPTIONAL INT32 dns_ttl = 4
dns_ttl_ = source.getVarInt();
this_t0 |= 0x4;
break;
case 42:
// REPEATED STRING ipv6 = 5
add_ipv6(source.getPrefixedData());
break;
default:
getUninterpretedForWrite().putBytes(
tt, source.getUninterpreted(tt));
break;
}
}
optional_0_ = this_t0;
return result;
}
@Override
public ResolvedAddr getDefaultInstanceForType() {
return IMMUTABLE_DEFAULT_INSTANCE;
}
public static final ResolvedAddr getDefaultInstance() {
return IMMUTABLE_DEFAULT_INSTANCE;
}
@SuppressWarnings("hiding")
public static final ResolvedAddr IMMUTABLE_DEFAULT_INSTANCE = new ResolvedAddr() {
private static final long serialVersionUID = 1L;
{
super.freeze();
}
// REQUIRED INT32 port = 1
@Override public ResolvedAddr clear_port() {
return this;
}
@Override public ResolvedAddr set_port(int x) {
ProtocolSupport.unsupportedOperation();
return this;
}
// REPEATED STRING ipv4 = 2
@Override public ResolvedAddr clear_ipv4() {
return this;
}
@Override public ResolvedAddr set_ipv4(int i, byte[] v) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr set_ipv4_unicode(int i, String v) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr add_ipv4(byte[] v) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr add_ipv4_unicode(String v) {
ProtocolSupport.unsupportedOperation();
return this;
}
// OPTIONAL STRING hostname = 3
@Override public ResolvedAddr clear_hostname() {
return this;
}
@Override public ResolvedAddr set_hostname(byte[] x) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr set_hostname_unicode(String v) {
ProtocolSupport.unsupportedOperation();
return this;
}
// OPTIONAL INT32 dns_ttl = 4
@Override public ResolvedAddr clear_dns_ttl() {
return this;
}
@Override public ResolvedAddr set_dns_ttl(int x) {
ProtocolSupport.unsupportedOperation();
return this;
}
// REPEATED STRING ipv6 = 5
@Override public ResolvedAddr clear_ipv6() {
return this;
}
@Override public ResolvedAddr set_ipv6(int i, byte[] v) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr set_ipv6_unicode(int i, String v) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr add_ipv6(byte[] v) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr add_ipv6_unicode(String v) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public ResolvedAddr mergeFrom(ResolvedAddr that) {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public boolean merge(ProtocolSource source) {
ProtocolSupport.unsupportedOperation();
return false;
}
@Override public ResolvedAddr freeze() {
return this;
}
@Override public ResolvedAddr unfreeze() {
ProtocolSupport.unsupportedOperation();
return this;
}
@Override public boolean isFrozen() {
return true;
}
};
@Override
public com.google.protobuf.Parser<ResolvedAddr> getParserForType() {
return PARSER;
}
public static final com.google.protobuf.Parser<ResolvedAddr> PARSER =
new com.google.io.protocol.Proto2ParserAdapter<ResolvedAddr>(
getDefaultInstance());
@Override public ResolvedAddr freeze() {
ipv4_ = ProtocolSupport.freezeStrings(ipv4_);
hostname_ = ProtocolSupport.freezeString(hostname_);
ipv6_ = ProtocolSupport.freezeStrings(ipv6_);
return this;
}
@Override public ResolvedAddr unfreeze() {
ipv4_ = ProtocolSupport.unfreezeStrings(ipv4_);
ipv6_ = ProtocolSupport.unfreezeStrings(ipv6_);
return this;
}
@Override public boolean isFrozen() {
return ProtocolSupport.isFrozenStrings(ipv4_)
|| ProtocolSupport.isFrozenStrings(ipv6_);
}
public UninterpretedTags getUninterpretedForWrite() {
if (uninterpreted == null) {
uninterpreted = new UninterpretedTags();
}
return uninterpreted;
}
public static final int kport = 1;
public static final int kipv4 = 2;
public static final int khostname = 3;
public static final int kdns_ttl = 4;
public static final int kipv6 = 5;
public static final String[] text = new String[6];
static {
text[ 0] = "ErrorCode";
text[ 1] = "port";
text[ 2] = "ipv4";
text[ 3] = "hostname";
text[ 4] = "dns_ttl";
text[ 5] = "ipv6";
}
public static final int[] types = new int[6];
static {
Arrays.fill(types, com.google.io.protocol.Protocol.MAX_TYPE);
types[ 0] = com.google.io.protocol.Protocol.NUMERIC;
types[ 1] = com.google.io.protocol.Protocol.NUMERIC;
types[ 2] = com.google.io.protocol.Protocol.STRING;
types[ 3] = com.google.io.protocol.Protocol.STRING;
types[ 4] = com.google.io.protocol.Protocol.NUMERIC;
types[ 5] = com.google.io.protocol.Protocol.STRING;
}
// stylesheet for XML output
public static final String style = "";
public static final String style_content_type = "";
}