Methods Summary |
---|
public com.google.common.io.protocol.ProtoBufType | addElement(int optionsAndType, int tag, java.lang.Object data)Adds a tag description. The data parameter contains the group definition
for group elements and the default value for regular elements.
while (types.length() <= tag) {
types.append((char) TYPE_UNDEFINED);
this.data.addElement(null);
}
types.setCharAt(tag, (char) optionsAndType);
this.data.setElementAt(data, tag);
return this;
|
public boolean | equals(java.lang.Object object){@inheritDoc}
Two ProtoBufTypes are equals if the fields types are the same.
if (null == object) {
// trivial check
return false;
} else if (this == object) {
// trivial check
return true;
} else if (this.getClass() != object.getClass()) {
// different class
return false;
}
ProtoBufType other = (ProtoBufType) object;
return stringEquals(types, other.types);
|
public java.lang.Object | getData(int tag)Returns the data associated to a given tag (either the default value for
regular elements or a ProtoBufType for groups and messages). For undefined
tags, null is returned.
return (tag < 0 || tag >= data.size()) ? null : data.elementAt(tag);
|
public int | getModifiers(int tag)Returns a bit combination of the modifiers for the given tag id
(OPTIONAL, REPEATED, REQUIRED). For undefined tags, OPTIONAL|REPEATED
is returned.
return (tag < 0 || tag >= types.length())
? (OPTIONAL | REPEATED)
: (types.charAt(tag) & MASK_MODIFIER);
|
public int | getType(int tag)Returns the type for the given tag id (without modifiers such as OPTIONAL,
REPEATED). For undefined tags, TYPE_UNDEFINED is returned.
return (tag < 0 || tag >= types.length())
? TYPE_UNDEFINED
: (types.charAt(tag) & MASK_TYPE);
|
public int | hashCode(){@inheritDoc}
if (types != null) {
return types.hashCode();
} else {
return super.hashCode();
}
|
public static boolean | stringEquals(java.lang.CharSequence a, java.lang.CharSequence b)
if (a == b) return true;
int length;
if (a != null && b != null && (length = a.length()) == b.length()) {
if (a instanceof String && b instanceof String) {
return a.equals(b);
} else {
for (int i = 0; i < length; i++) {
if (a.charAt(i) != b.charAt(i)) return false;
}
return true;
}
}
return false;
|
public java.lang.String | toString()Returns the type name set in the constructor for debugging purposes.
return typeName;
|