com.levigo.jadice.document
Class Format

java.lang.Object
  extended by com.levigo.jadice.document.Format
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
AbstractAnnotationFormat

public abstract class Format
extends Object
implements Cloneable

Used to gain information about the format that a given document class supports.


Field Summary
protected static ProductInformation.Artifact BASE_FORMAT_VERSION
          The format version artifact of this abstract base format.
protected static int DEFAULT_PRIORITY
           
protected static int MAX_PRIORITY
           
protected static int MIN_PRIORITY
           
 
Constructor Summary
protected Format()
          Default-constructor.
 
Method Summary
 boolean canRead()
          Return whether this Format can be read, i.e.
 boolean canWrite()
          Return whether this Format can be written, i.e.
 Format create(MimeType type)
          Create an instance of this format corresponding to the given MIME type.
 FormatReader createReader()
          Instantiate a new FormatReader for this format.
 FormatWriter createWriter()
          Instantiate a new FormatWriter for this format.
 boolean equals(Object obj)
          The default equality implementation for formats is based on class equality.
abstract  String[] getDefaultExtensions()
          The default file-extension for the format.
abstract  String getDescription()
          Describes the format represented by this instance.
abstract  MimeType getMimeType()
          Return the string-encoded MIME-Type of the format.
abstract  String getName()
          Return the format's name.
 int getPriority()
          Return the priority with which this format will be selected, if there are multiple eligible ones.
abstract  String getVersion()
          The version of the format support.
 int hashCode()
          The default hash-code implementation for formats is based on the class hash-code.
 boolean isSecondary()
          Return whether this format is a secondary format.
 boolean isSupported(MimeType type)
          Determine whether this format supports the given MIME type.
abstract  boolean matches(SeekableInputStream stream)
          Within the read process this method is called to auto-determine the format of the data passed.
 String toString()
          A String-representation of this Format
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE_FORMAT_VERSION

protected static final ProductInformation.Artifact BASE_FORMAT_VERSION
The format version artifact of this abstract base format.
It could be used as default format information for all formats existing in this artifact module.


MIN_PRIORITY

protected static final int MIN_PRIORITY
See Also:
Constant Field Values

MAX_PRIORITY

protected static final int MAX_PRIORITY
See Also:
Constant Field Values

DEFAULT_PRIORITY

protected static final int DEFAULT_PRIORITY
See Also:
Constant Field Values
Constructor Detail

Format

protected Format()
Default-constructor. Hidden from the outer world

Method Detail

toString

public String toString()
A String-representation of this Format

Overrides:
toString in class Object
Returns:
java.lang.String

getDefaultExtensions

public abstract String[] getDefaultExtensions()
The default file-extension for the format.

Returns:
an array of default file extension of this format

getDescription

public abstract String getDescription()
Describes the format represented by this instance.

Returns:
a description of this format

getName

public abstract String getName()
Return the format's name.

Returns:
the format's name

getVersion

public abstract String getVersion()
The version of the format support.

Returns:
the version of format support

getMimeType

public abstract MimeType getMimeType()
Return the string-encoded MIME-Type of the format.

Returns:
the MIME-Type

matches

public abstract boolean matches(SeekableInputStream stream)
                         throws IOException
Within the read process this method is called to auto-determine the format of the data passed. When called, the implementation must determine whether or not the passed information matches the signature.

Parameters:
stream - contains the data to be tested.
Returns:
True if the data matches, otherwise false.
Throws:
IOException - if an io error occurs

getPriority

public int getPriority()
Return the priority with which this format will be selected, if there are multiple eligible ones. Formats with lower priorities are tried after ones with higher values.

Returns:
the priority
See Also:
MIN_PRIORITY, DEFAULT_PRIORITY, MAX_PRIORITY

canRead

public boolean canRead()
Return whether this Format can be read, i.e. whether createReader() is able to create a reader.

Returns:
true if we can.

createReader

public FormatReader createReader()
Instantiate a new FormatReader for this format.

Returns:
a FormatReader for this format
Throws:
UnsupportedOperationException - if this format does not support reading

canWrite

public boolean canWrite()
Return whether this Format can be written, i.e. whether createWriter() is able to create a writer.

Returns:
true if we can.

createWriter

public FormatWriter createWriter()
Instantiate a new FormatWriter for this format.

Returns:
a FormatWriter for this format
Throws:
UnsupportedOperationException - if this format does not support writing

isSecondary

public boolean isSecondary()
Return whether this format is a secondary format. Secondary formats do not, in their own right, carry document pages, but add information to other pages. All annotation formats are secondary formats.

Returns:
true if this format is a secondary format

hashCode

public int hashCode()
The default hash-code implementation for formats is based on the class hash-code.

Overrides:
hashCode in class Object
See Also:
Object.equals(java.lang.Object)

equals

public boolean equals(Object obj)
The default equality implementation for formats is based on class equality.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

isSupported

public boolean isSupported(MimeType type)
Determine whether this format supports the given MIME type. The match will usually be performed based on just the base type alone.

Parameters:
type -
Returns:

create

public Format create(MimeType type)
Create an instance of this format corresponding to the given MIME type. This operation may encompass configuring the format from the given type's parameters.

Parameters:
type -
Returns:
Throws:
IllegalArgumentException - if the given type is not supported by this format.


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.