Object
This class provides a ranking mechanism to allow multiple handlers to negotiate for precedence in opening documents. One major task a document handler has is to identify the documents that it understands. Since multiple document handlers may understand the same file, this interface provides a way to rank the level of understanding so th at the document service can provide the "best" handler for a given document. The ranking mechanism is called Priority.
Each priority value represents the level of understanding of the file. It is primarily used simply to order the handlers. More general handlers should usually have lower priorities so that more specific handlers can override them by providing a higher priority value.
While priority may be declared in the extension XML, it is often the case that a handler needs to examine the contents of the file in order to determine what priority it should be. In this case the priority in the XML should be declared as "unknown". The document service will allow each "unknown" level handler to examine the file and return it's true level.
In the event that multiple handlers return the same priority value, the first such handler found will be invoked. Since there is no ordering to handlers, "the first" is not a very precise definition. Care should therefore be taken to insure that new handlers use as yet unused priority levels for a particular document. If there is sufficient need, the set of handler priority levels can easily be increased to accomodate more values.
Because two handlers of the same level are a tie, if one or more handlers statically registers in the XML as "highest", the "unknown" handlers will not be invoked to examine the contents.
One final note on priority resolution. Static xml registration allows a file-extension pattern of "*" meaning any file-extension. However, handlers that register for all file-extensions will only be allowed to resolve a handler if there are no handlers registered (of any level!) that have registered with the specific file extension.
For example, a text handler might register as "low" for all file-extensions (not recommended since it is so general). However, if another handler registers as the handler for the .xml extension, it will always get .xml files, even if it's priority is lower than "low".
Object
IDocumentHandler.Priority
IDocumentHandler
Field Summary |
public static int |
|
public static int |
|
public static int |
|
public static int |
|
public static int |
|
public static int |
|
public static int |
|
public static int |
|
Constructor Summary |
Method Summary |
Methods from class java.lang. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int HIGH
public static int HIGHEST
public static int IGNORE
public static int INFO_ONLY
public static int LOW
public static int LOWEST
public static int MEDIUM
public static int UNKNOWN
IDocumentHandler.resolveUnknownPriority(IDocumentHandler.IHandlerContext)
method and is considered an error.
Constructor Detail |
public IDocumentHandler.Priority()