added an optional name argument to Document.prototype.getFields() for retrieving all fields with the specified name
This commit is contained in:
parent
f1577494a6
commit
a2640a9b70
1 changed files with 12 additions and 5 deletions
|
@ -1159,16 +1159,23 @@ helma.Search.Document.prototype.getField = function(name) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fields of a document object.
|
* Returns the fields of a document object. If a name is passed as argument,
|
||||||
|
* this method returns only the fields with the given name
|
||||||
|
* @param {String} name Optional name of the fields to return
|
||||||
* @returns An array containing all fields in this document object.
|
* @returns An array containing all fields in this document object.
|
||||||
* @type Array
|
* @type Array
|
||||||
*/
|
*/
|
||||||
helma.Search.Document.prototype.getFields = function() {
|
helma.Search.Document.prototype.getFields = function(name) {
|
||||||
var fields = this.getDocument().getFields();
|
var fields;
|
||||||
var size = fields.size();
|
if (name != null) {
|
||||||
|
fields = this.getDocument().getFields(name);
|
||||||
|
} else {
|
||||||
|
fields = this.getDocument().getFields().toArray();
|
||||||
|
}
|
||||||
|
var size = fields.length;
|
||||||
var result = new Array(size);
|
var result = new Array(size);
|
||||||
for (var i=0; i<size; i+=1) {
|
for (var i=0; i<size; i+=1) {
|
||||||
result[i] = new helma.Search.Document.Field(fields.get(i));
|
result[i] = new helma.Search.Document.Field(fields[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue