Package com.itextpdf.xmp.options
Class Options
- java.lang.Object
-
- com.itextpdf.xmp.options.Options
-
- Direct Known Subclasses:
AliasOptions
,IteratorOptions
,ParseOptions
,PropertyOptions
,SerializeOptions
public abstract class Options extends java.lang.Object
The base class for a collection of 32 flag bits. Individual flags are defined as enum value bit masks. Inheriting classes add convenience accessor methods.- Since:
- 24.01.2006
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
optionNames
a map containing the bit namesprivate int
options
the internal int containing all options
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
assertConsistency(int options)
The inheriting option class can do additional checks on the options.private void
assertOptionsValid(int options)
Checks options before they are set.void
clear()
Resets the options.boolean
containsAllOptions(int optionBits)
boolean
containsOneOf(int optionBits)
protected abstract java.lang.String
defineOptionName(int option)
To be implemeted by inheritants.boolean
equals(java.lang.Object obj)
protected boolean
getOption(int optionBit)
private java.lang.String
getOptionName(int option)
Looks up or asks the inherited class for the name of an option bit.int
getOptions()
Is friendly to access it during the tests.java.lang.String
getOptionsString()
Creates a human readable string from the set options.protected abstract int
getValidOptions()
To be implemeted by inheritants.int
hashCode()
boolean
isExactly(int optionBits)
private java.util.Map
procureOptionNames()
void
setOption(int optionBits, boolean value)
void
setOptions(int options)
java.lang.String
toString()
-
-
-
Constructor Detail
-
Options
public Options()
The default constructor.
-
Options
public Options(int options) throws XMPException
Constructor with the options bit mask.- Parameters:
options
- the options bit mask- Throws:
XMPException
- If the options are not correct
-
-
Method Detail
-
clear
public void clear()
Resets the options.
-
isExactly
public boolean isExactly(int optionBits)
- Parameters:
optionBits
- an option bitmask- Returns:
- Returns true, if this object is equal to the given options.
-
containsAllOptions
public boolean containsAllOptions(int optionBits)
- Parameters:
optionBits
- an option bitmask- Returns:
- Returns true, if this object contains all given options.
-
containsOneOf
public boolean containsOneOf(int optionBits)
- Parameters:
optionBits
- an option bitmask- Returns:
- Returns true, if this object contain at least one of the given options.
-
getOption
protected boolean getOption(int optionBit)
- Parameters:
optionBit
- the binary bit or bits that are requested- Returns:
- Returns if
all of the requested bits are set or not.
-
setOption
public void setOption(int optionBits, boolean value)
- Parameters:
optionBits
- the binary bit or bits that shall be set to the given valuevalue
- the boolean value to set
-
getOptions
public int getOptions()
Is friendly to access it during the tests.- Returns:
- Returns the options.
-
setOptions
public void setOptions(int options) throws XMPException
- Parameters:
options
- The options to set.- Throws:
XMPException
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
getOptionsString
public java.lang.String getOptionsString()
Creates a human readable string from the set options. Note: This method is quite expensive and should only be used within tests or as- Returns:
- Returns a String listing all options that are set to
true
by their name, like "option1 | option4".
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- Returns the options as hex bitmask.
-
getValidOptions
protected abstract int getValidOptions()
To be implemeted by inheritants.- Returns:
- Returns a bit mask where all valid option bits are set.
-
defineOptionName
protected abstract java.lang.String defineOptionName(int option)
To be implemeted by inheritants.- Parameters:
option
- a single, valid option bit.- Returns:
- Returns a human readable name for an option bit.
-
assertConsistency
protected void assertConsistency(int options) throws XMPException
The inheriting option class can do additional checks on the options. Note: For performance reasons this method is only called when setting bitmasks directly. When get- and set-methods are used, this method must be called manually, normally only when the Options-object has been created from a client (it has to be made public therefore).- Parameters:
options
- the bitmask to check.- Throws:
XMPException
- Thrown if the options are not consistent.
-
assertOptionsValid
private void assertOptionsValid(int options) throws XMPException
Checks options before they are set. First it is checked if only defined options are used, second the additionalassertConsistency(int)
-method is called.- Parameters:
options
- the options to check- Throws:
XMPException
- Thrown if the options are invalid.
-
getOptionName
private java.lang.String getOptionName(int option)
Looks up or asks the inherited class for the name of an option bit. Its save that there is only one valid option handed into the method.- Parameters:
option
- a single option bit- Returns:
- Returns the option name or undefined.
-
procureOptionNames
private java.util.Map procureOptionNames()
- Returns:
- Returns the optionNames map and creates it if required.
-
-