Package org.harctoolbox.irp
Class IrpDatabase
java.lang.Object
org.harctoolbox.irp.IrpDatabase
- All Implemented Interfaces:
Serializable
,Iterable<NamedProtocol>
This class is a data bases manager for the data base of IRP protocols.
It reads a configuration file containing definitions for IR format in the IRP-Notation.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorDescriptionReturns an empty IrpDatabase.IrpDatabase
(File file) IrpDatabase
(InputStream inputStream) IrpDatabase
(Reader reader) IrpDatabase
(Iterable<File> files) IrpDatabase
(String file) IrpDatabase
(Document doc) IrpDatabase
(Element protocolsElement) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProperty
(String protocolName, String key, String value) void
addProtocol
(String protocolName, String irp) void
addProtocol
(String protocolName, String irp, DocumentFragment doc) Checks if the data base is sorted with respect to the protocol name's.evaluateProtocols
(List<String> protocols, boolean sort, boolean regexp, boolean urlDecode) expandAlias
(String protocol) getDocumentation
(String protocolName) getDocumentationExpandAlias
(String protocolName) getFirstProperty
(String protocolName, String key) getHtmlDocumentation
(String protocolName) static String
Static version of getIrp.getIrpExpandAlias
(String name) getKeys()
Returns the keys of the protocol data base, which happens to be the protocol names converted to lower case.getMatchingNames
(Iterable<String> iterable, boolean regexp, boolean urlDecode) getMatchingNamesExact
(String string) getMatchingNamesRegexp
(String regexp) getNamedProtocol
(String protocolName) getNamedProtocol
(Collection<String> protocolNames) getNamedProtocolExpandAlias
(String protocolName) getNameExpandAlias
(String name) getNames()
getNonRecycledProtocol
(String protocolName) Returns a Protocol with the prescribed name.getNormalFormIrp
(String protocolName, int radix) getProperties
(String protocolName, String key) getProtocol
(String protocolName) Returns a Protocol with the prescribed name.getProtocolExpandAlias
(String protocolName) static Schema
getXmlProperties
(String protocolName, String key) boolean
boolean
isEmpty()
boolean
static boolean
boolean
isKnownExpandAlias
(String protocol) static boolean
iterator()
This is a comparatively expensive operation, while its next() performs actual parsing of the IRP string.static IrpDatabase
static IrpDatabase
static IrpDatabase
parseIrp
(String protocolName, String irp, DocumentFragment documentation) static IrpDatabase
void
void
void
void
patch
(IrpDatabase irpDatabase) void
void
void
void
removeProperties
(String protocolName, String key) void
removeXmlProperties
(String protocolName, String key) void
setDocumentation
(String protocolName, String string) void
setDocumentation
(String protocolName, DocumentFragment fragment) void
setProperties
(String protocolName, String key, List<String> properties) static void
setValidating
(boolean newValidating) void
setXmlProperties
(String protocolName, String key, List<DocumentFragment> properties) int
size()
toDocument
(Iterable<String> protocolsNames) toDocument
(Iterable<String> protocolsNames, boolean includeComments) toDocument
(Iterable<String> protocolNames, Double absoluteTolerance, Double relativeTolerance, Double frequencyTolerance, Double minimumLeadout) toElement
(Document document, Iterable<String> protocolNames, Double absoluteTolerance, Double relativeTolerance, Double frequencyTolerance, Double minimumLeadout) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_CONFIG_FILE
- See Also:
-
IRP_PROTOCOL_NS
- See Also:
-
IRP_SCHEMA_FILE
- See Also:
-
IRP_PROTOCOL_SCHEMA_LOCATION
- See Also:
-
IRP_NAMESPACE_PREFIX
- See Also:
-
UNNAMED
- See Also:
-
PROTOCOL_NAME
- See Also:
-
PROTOCOLS_NAME
- See Also:
-
NAME_NAME
- See Also:
-
IRP_NAME
- See Also:
-
IRP_ELEMENT_NAME
- See Also:
-
USABLE_NAME
- See Also:
-
VERSION_NAME
- See Also:
-
PROG_VERSION_NAME
- See Also:
-
DOCUMENTATION_NAME
- See Also:
-
DOCUMENTATION_ELEMENT_NAME
- See Also:
-
PARAMETER_NAME
- See Also:
-
DECODABLE_NAME
- See Also:
-
FREQUENCY_TOLERANCE_NAME
- See Also:
-
FREQUENCY_LOWER_NAME
- See Also:
-
FREQUENCY_UPPER_NAME
- See Also:
-
RELATIVE_TOLERANCE_NAME
- See Also:
-
ABSOLUTE_TOLERANCE_NAME
- See Also:
-
MINIMUM_LEADOUT_NAME
- See Also:
-
PREFER_OVER_NAME
- See Also:
-
ALT_NAME_NAME
- See Also:
-
REJECT_REPEATLESS_NAME
- See Also:
-
TYPE_NAME
- See Also:
-
XML_NAME
- See Also:
-
FALSE_NAME
- See Also:
-
HTML_NAME
- See Also:
-
VALUE_NAME
- See Also:
-
PARAMETERS_NAME
- See Also:
-
PARAMETER_ELEMENT_NAME
- See Also:
-
NAMED_PROTOCOLS_NAME
- See Also:
-
DECODE_ONLY_NAME
- See Also:
-
PROTOCOL_NAME_NAME
- See Also:
-
PROTOCOL_CNAME_NAME
- See Also:
-
META_DATA_NAME
- See Also:
-
YES_NAME
- See Also:
-
NO_NAME
- See Also:
-
-
Constructor Details
-
IrpDatabase
- Throws:
IOException
IrpParseException
SAXException
-
IrpDatabase
- Throws:
IOException
IrpParseException
SAXException
-
IrpDatabase
- Throws:
IOException
IrpParseException
SAXException
-
IrpDatabase
- Throws:
IOException
IrpParseException
SAXException
-
IrpDatabase
- Throws:
IrpParseException
IOException
SAXException
-
IrpDatabase
public IrpDatabase()Returns an empty IrpDatabase. -
IrpDatabase
- Throws:
IrpParseException
-
IrpDatabase
- Throws:
IrpParseException
-
-
Method Details
-
isValidating
public static boolean isValidating() -
setValidating
- Throws:
SAXException
-
getSchema
-
isKnown
public static boolean isKnown(String protocolsPath, String protocol) throws IOException, IrpParseException, SAXException - Throws:
IOException
IrpParseException
SAXException
-
getIrp
public static String getIrp(String configFilename, String protocolName) throws IrpParseException, UnknownProtocolException, IOException, SAXException Static version of getIrp.- Parameters:
configFilename
-protocolName
-- Returns:
- String with IRP representation
- Throws:
IrpParseException
UnknownProtocolException
IOException
SAXException
-
parseIrp
public static IrpDatabase parseIrp(String protocolName, String irp, String documentation) throws IrpParseException - Throws:
IrpParseException
-
parseIrp
public static IrpDatabase parseIrp(String protocolName, String irp, DocumentFragment documentation) throws IrpParseException - Throws:
IrpParseException
-
parseIrp
- Throws:
IrpParseException
-
newDefaultIrpDatabase
-
patch
-
patch
- Throws:
IOException
SAXException
IrpParseException
-
patch
- Throws:
IOException
SAXException
IrpParseException
-
patch
- Throws:
IOException
SAXException
IrpParseException
-
patch
- Throws:
IrpParseException
-
addProtocol
- Throws:
IrpParseException
-
addProtocol
public void addProtocol(String protocolName, String irp, DocumentFragment doc) throws IrpParseException - Throws:
IrpParseException
-
toDocument
-
toDocument
-
toDocument
-
toDocument
-
toElement
-
toElement
-
toElement
-
getConfigFileVersion
- Returns:
- the configFileVersion
-
isAlias
-
expandAlias
-
isKnown
-
isKnownExpandAlias
-
getIrp
- Throws:
UnknownProtocolException
-
getIrpExpandAlias
- Throws:
UnknownProtocolException
-
getKeys
Returns the keys of the protocol data base, which happens to be the protocol names converted to lower case.- Returns:
-
getNames
-
getAliases
-
getName
- Throws:
UnknownProtocolException
-
getNameExpandAlias
- Throws:
UnknownProtocolException
-
size
public int size() -
isEmpty
public boolean isEmpty() -
getMatchingNamesRegexp
-
getMatchingNamesExact
-
getMatchingNames
-
getDocumentation
- Throws:
UnknownProtocolException
-
getHtmlDocumentation
- Throws:
UnknownProtocolException
-
setDocumentation
- Throws:
UnknownProtocolException
-
setDocumentation
public void setDocumentation(String protocolName, DocumentFragment fragment) throws UnknownProtocolException - Throws:
UnknownProtocolException
-
getDocumentationExpandAlias
- Throws:
UnknownProtocolException
-
getFirstProperty
- Throws:
UnknownProtocolException
-
getProperties
- Throws:
UnknownProtocolException
-
addProperty
public void addProperty(String protocolName, String key, String value) throws UnknownProtocolException - Throws:
UnknownProtocolException
-
setProperties
public void setProperties(String protocolName, String key, List<String> properties) throws UnknownProtocolException - Throws:
UnknownProtocolException
-
removeProperties
- Throws:
UnknownProtocolException
-
getXmlProperties
public List<DocumentFragment> getXmlProperties(String protocolName, String key) throws UnknownProtocolException - Throws:
UnknownProtocolException
-
setXmlProperties
public void setXmlProperties(String protocolName, String key, List<DocumentFragment> properties) throws UnknownProtocolException - Throws:
UnknownProtocolException
-
removeXmlProperties
- Throws:
UnknownProtocolException
-
getNamedProtocol
public NamedProtocol getNamedProtocol(String protocolName) throws UnknownProtocolException, InvalidNameException, UnsupportedRepeatException, IrpInvalidArgumentException, NameUnassignedException -
getNamedProtocolExpandAlias
public NamedProtocol getNamedProtocolExpandAlias(String protocolName) throws UnknownProtocolException, InvalidNameException, UnsupportedRepeatException, IrpInvalidArgumentException, NameUnassignedException -
getNamedProtocol
-
remove
- Throws:
UnknownProtocolException
-
remove
- Throws:
UnknownProtocolException
-
evaluateProtocols
-
getNonRecycledProtocol
public Protocol getNonRecycledProtocol(String protocolName) throws UnknownProtocolException, UnsupportedRepeatException, NameUnassignedException, InvalidNameException, IrpInvalidArgumentException Returns a Protocol with the prescribed name. As opposed togetProtocol(String)
, the Protocol is guaranteed to be newly constructed, and it will not be recycled.- Parameters:
protocolName
-- Returns:
- Protocol, guaranteed new.
- Throws:
UnknownProtocolException
UnsupportedRepeatException
NameUnassignedException
InvalidNameException
IrpInvalidArgumentException
-
getProtocol
public Protocol getProtocol(String protocolName) throws UnknownProtocolException, UnsupportedRepeatException, NameUnassignedException, InvalidNameException, IrpInvalidArgumentException Returns a Protocol with the prescribed name. If this has been called previously with the same argument, the previously constructed Protocol is recycled and returned. See alsogetNonRecycledProtocol(String)
.- Parameters:
protocolName
-- Returns:
- Protocol, possibly recycled.
- Throws:
UnknownProtocolException
UnsupportedRepeatException
NameUnassignedException
InvalidNameException
IrpInvalidArgumentException
-
getProtocolExpandAlias
public Protocol getProtocolExpandAlias(String protocolName) throws UnknownProtocolException, UnsupportedRepeatException, NameUnassignedException, InvalidNameException, IrpInvalidArgumentException -
getNormalFormIrp
public String getNormalFormIrp(String protocolName, int radix) throws UnknownProtocolException, InvalidNameException, UnsupportedRepeatException, NameUnassignedException, IrpInvalidArgumentException -
checkSorted
Checks if the data base is sorted with respect to the protocol name's.- Returns:
- First offending protocol, or null if the database is sorted.
-
render
- Throws:
IrpException
-
iterator
This is a comparatively expensive operation, while its next() performs actual parsing of the IRP string.- Specified by:
iterator
in interfaceIterable<NamedProtocol>
- Returns:
-
getVersion
-