it.unimi.di.mg4j.tool
Interface VirtualDocumentResolver

All Superinterfaces:
Serializable
All Known Implementing Classes:
URLMPHVirtualDocumentResolver

public interface VirtualDocumentResolver
extends Serializable

A resolver for virtual documents.

Fields of virtual type return a list of virtual document fragments containing a document specification (e.g., its URI) and the virtual text associated with the document. Since there are many ways of defining the virtual document, Scan requires a virtual-document resolver for each virtual field: the resolver takes in the string defining a document, and returns a document number. See URLMPHVirtualDocumentResolver for a natural example.


Method Summary
 void context(Document document)
          Sets the context document.
 int numberOfDocuments()
          Returns the number of documents handled by this resolver, if it is known.
 int resolve(CharSequence virtualDocumentSpec)
          Resolves a virtual document specification.
 

Method Detail

context

void context(Document document)
Sets the context document. All successive calls to resolve(CharSequence) will assume the virtual-document specification was found in document.

Parameters:
document - the context document.

resolve

int resolve(CharSequence virtualDocumentSpec)
Resolves a virtual document specification.

Note that the resolution process is carried out in the context of the last document passed to context(Document) (e.g., for relative URI resolution). If context(Document) was never called, the behaviour is undefined.

Parameters:
virtualDocumentSpec - the virtual document specification.
Returns:
the document virtualDocumentSpec refers to, or -1 if the specification could not be resolved.

numberOfDocuments

int numberOfDocuments()
Returns the number of documents handled by this resolver, if it is known. A call to resolve(CharSequence) will always return a number smaller than the one returned by this method.

Returns:
the number of documents handled by this resolver.