/** * Creates a new DPT translator for the specified property type. * * <p>The translator is initialized with a subtype as specified by the property map. Also, * appending of units is disabled in the returned translator. * * @param dataType property data type to get the associated translator for * @return the created DPT translator * @throws KNXException on PDT not found or translator could not be created * @see TranslatorTypes#createTranslator(int, String) */ public static DPTXlator createTranslator(final int dataType) throws KNXException { final DPTID dpt = pt.get(dataType); if (dpt == null) throw new KNXException("PDT not found"); final DPTXlator t = TranslatorTypes.createTranslator(dpt.getMainNumber(), dpt.getDPT()); t.setAppendUnit(false); return t; }
/** * Does a lookup if the given property data type (PDT) has an associated translator available. * * <p>The translator looked for is specified in the property map. An available translator is * implemented and can be used for translation. * * @param dataType property data type (PDT) to lookup * @return <code>true</code> iff translator and its subtype was found, <code>false</code> * otherwise */ public static boolean hasTranslator(final int dataType) { final DPTID dpt = pt.get(dataType); if (dpt != null) try { final MainType t = TranslatorTypes.getMainType(dpt.getMainNumber()); if (t != null) return t.getSubTypes().get(dpt.getDPT()) != null; } catch (final NumberFormatException e) { } catch (final KNXException e) { } return false; }