/** * 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; }
/** * Utility method, like {@link #createTranslator(int)}, with the additional capability to set the * data to be used by the DPT translator. * * @param dataType property data type to get the associated translator for * @param data array with KNX DPT formatted data, the number of contained items is determined by * the used DPT * @return the created DPT translator with the set data * @throws KNXException on PDT not found or translator could not be created * @see #createTranslator(int) */ public static DPTXlator createTranslator(final int dataType, final byte[] data) throws KNXException { final DPTXlator t = createTranslator(dataType); t.setData(data); return t; }