Represented as a list of name/value pairs.
| Method from org.apache.nutch.searcher.HitDetails Detail: |
public String getField(int i) {
return fields[i];
}
Returns the name of the ith field. |
public int getLength() {
return length;
}
Returns the number of fields contained in this. |
public String getValue(int i) {
return values[i];
}
Returns the value of the ith field. |
public String getValue(String field) {
for (int i = 0; i < length; i++) {
if (fields[i].equals(field))
return values[i];
}
return null;
}
Returns the value of the first field with the specified name. |
public String[] getValues(String field) {
ArrayList< String > vals = new ArrayList< String >();
for (int i=0; i< length; i++) {
if (fields[i].equals(field)) {
vals.add(values[i]);
}
}
return (vals.size() > 0)
? vals.toArray(new String[vals.size()])
: null;
}
Returns all the values with the specified name. |
public static HitDetails read(DataInput in) throws IOException {
HitDetails result = new HitDetails();
result.readFields(in);
return result;
}
Constructs, reads and returns an instance. |
public void readFields(DataInput in) throws IOException {
length = in.readInt();
fields = new String[length];
values = new String[length];
for (int i = 0; i < length; i++) {
fields[i] = in.readUTF();
values[i] = in.readUTF();
}
}
|
public String toHtml() {
StringBuffer buffer = new StringBuffer();
buffer.append("< ul >\n");
for (int i = 0; i < length; i++) {
buffer.append("< li >");
buffer.append(fields[i]);
buffer.append(" = ");
buffer.append(Entities.encode(values[i]));
buffer.append("< /li >\n");
}
buffer.append("< /ul >\n");
return buffer.toString();
}
|
public String toString() {
return getValue("segment") + "/" + getValue("url");
}
|
public void write(DataOutput out) throws IOException {
out.writeInt(length);
for (int i = 0; i < length; i++) {
out.writeUTF(fields[i]);
out.writeUTF(values[i]);
}
}
|