internal package Foswiki::Contrib::DBCacheContrib::Array

See PublishedAPI for packages intended to be used by Plugin and Contrib authors, or browse all packages.
See also Developing plugins, Developer's Bible, Technical Overview

package Foswiki::Contrib::DBCacheContrib::Array

This is an interface that is implemented by all back-end stores (archivists). Objects of this class can be tied to perl arrays.

Objects of this class are created using the newArray interface defined by Foswiki::Contrib::DBCacheContrib::Archivist. You can use references in the content of an Array, but you can only refer to other objects that were created using the same Archivist. If you point anywhere else, expect fireworks. Note that all references stored in an Array are strong references (see the doc on Foswiki::Contrib::DBCacheContrib::Map for more information on what that means).

If you have an object ($obj) created this way, you can tie it to a perl array like this:
my @array;
tie(@array, ref($obj), $obj);

find($object) → integer

  • $object datum of the same type as the content of the array
Uses equals to find the given element in the array and return its index

getValues() → @values

Overridable method that returns a list even when the object isn't tied.

add($object)

  • $object any perl data type
Add an element to the end of the array

remove($index)

  • $index - integer index
Remove an entry at an index from the array.

get($key, $root) → datum

  • $k - key
  • $root - what # refers to
Subfield syntax
  • get("9", $r) where $n is a number will get the 9th entry in the array
  • get("[9]", $r) will also get the 9th entry
  • get(".9", $r) will also get the 9th entry
  • get(".X", $r) will return the sum of the subfield X of each entry
  • get("[?search]", $r) will perform the given search over the entries in the array. Always returns an array result, even when there is only one result. For example: [?name='Sam'] will return an array of all the entries that have their subfield name set to Sam.
  • # means "reset to root". So get("#[3]", $r) will return the 4th entry of $r (assuming $r is an array!).
  • get("[*X]", $r) will get a new array made from subfield X of each entry in this array.

Where the result of a subfield expansion is another object (a Map or an Array) then further subfield expansions can be used. For example,
get("parent.UserTable[?SubTopic='ThisTopic'].UserName", $web);

See also Foswiki::Contrib::DBCacheContrib::Map for syntax that applies to maps.

size() → integer

Get the size of the array

sum($field) → number

  • $field - name of a field in the class of objects stored by this array
Returns the sum of values of the given field in the objects stored in this array.

search($search) → search result

Search the array for matches with the given object. values. Return a Foswiki::Contrib::DBCacheContrib::Array of matching entries.

toString($limit, $level, $strung) → string

  • $limit - recursion limit for expansion of elements
  • $level - currentl recursion level
Generates an HTML string representation of the object.

This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Wasserstoff-Fahrer Forum? Send feedback
This website is using cookies. More info. That's Fine