<cache-entry>

Purpose/Function

Accesses a cache entry either by iteration through the cache using 'next' or 'previous', or by requesting an entry by its index (e.g., the 17th entry) or id (the byte at which the entry begins).

Requires a cache reference from the environment. Note that the cache must be opened before calling this task. One could also use the bean 'get' task with 'nextEntry' and 'previousEntry' directly on the cache object. The Entry object itself can be accessed using the bean 'get' task + the entry part desired.

Attributes

NAME

TYPE

DEFAULT VALUE

DESCRIPTION

asMetadata

boolean

false

if this is a List cache, convert the entry to a FileMetadata object

cache

ncsa.tools.trebuchet.core.cache.OperationCache

(required)

cache to access

fullString

boolean

false

return the entry-string value as the full cache-line; else, use abbreviated form

id

java.lang.Long

null

get the entry with this id

index

java.lang.Integer

null

get the kth entry (k = index) in the cache

next

boolean

false

get the next entry (at the current cursor)

previous

boolean

false

get the previous entry (preceding the current cursor)

Elements

None.

ReturnValues

DEFAULT NAME

TYPE

cache-entry

ncsa.tools.trebuchet.core.data.ReverseLookupEntry

entry-string

java.lang.String

list-entry-metadata

ncsa.tools.common.types.uri.FileMetadata

NOTES

Examples

<ogrescript>
   ...
   <declare name="cache" />
   <ls dir="file:/tmp">
	<return-value assignedName="cache" defaultName="listCache" />
   </ls>
   <open-cache cache="${cache}" />
   <while condition="$E{true}">
	<declare name="entry" />
	<declare name="string" />
	<declare name="metadata" />
	<declare name="relPath" />
	<declare name="timestamp" />
	<cache-entry cache="${cache}" next="true">
		<return-value assignedName="entry" defaultName="cache-entry" />
		<return-value assignedName="string" defaultName="entry-string" />
	</cache-entry>
	<if>
		<is-null object="${entry}" />
		<break />
	</if>
	<!-- do something with entry: it's a bean, so you can use 'get', for instance-->
	<!-- The Entry object itself can be accessed using the bean 'get' task.-->
	<!-- @see ncsa.tools.trebuchet.core.data.ListEntry-->
	<!-- @see ncsa.tools.trebuchet.core.data.CopyEntry-->
	<!-- @see ncsa.tools.common.data.resource.Owner-->
	<!-- @see ncsa.tools.common.data.resource.ParsedTimestamp-->
	<!-- @see ncsa.tools.common.data.resource.Permissions-->
	<!-- @see ncsa.tools.common.data.resource.RelativeUriPath-->
	<!-- @see ncsa.tools.common.data.resource.ResourceType-->
	<get bean="${entry}" property="relativePath" assign="relPath" />
	<get bean="${entry}" property="timestamp" assign="timestamp" />
	<echo message="STRING ${string}" stdout="true" />
	<echo message="CUSTOM: ${relPath} (${timestamp})" stdout="true" />
   </while>
   <reset-cache cache="${cache}" firstEntry="true"/>
   <while condition="$E{true}">
	<declare name="entry" />
	<declare name="metadata" />
	<cache-entry cache="${cache}" next="true" asMetadata="true">
	   <return-value assignedName="entry" defaultName="cache-entry" />
	   <return-value assignedName="metadata" defaultName="list-entry-metadata" />
	</cache-entry>
	<if>
		<is-null object="${entry}" />
		<break />
	</if>
	<echo message="METADATA ${metadata}" stdout="true" />
   </while>
   <close-cache cache="${cache}" />
   <delete-cache cache="${cache}" />
   ...
</ogrescript>
  • No labels