001package jmri.jmrix.direct;
002
003/**
004 * Contains the data payload of a serial reply packet. Note that _only_ the
005 * payload, not the header or trailer, nor the padding DLE characters are
006 * included. But it does include addressing characters, etc.
007 *
008 * @author Bob Jacobsen Copyright (C) 2002, 2008
009 */
010public class Reply extends jmri.jmrix.AbstractMRReply {
011
012    // create a new one
013    public Reply() {
014        super();
015    }
016
017    public Reply(String s) {
018        super(s);
019    }
020
021    public Reply(Reply l) {
022        super(l);
023    }
024
025    @Override
026    public String toString() {
027        StringBuilder s = new StringBuilder("");
028        for (int i = 0; i < getNumDataElements(); i++) {
029            if (i != 0) {
030                s.append(" ");
031            }
032            if (getElement(i) < 16) {
033                s.append("0");
034            }
035            s.append(Integer.toHexString(getElement(i) & 0xFF));
036        }
037        return s.toString();
038    }
039
040    // recognize format
041    public boolean isRcv() {
042        return getElement(0) == 0x02;
043    }
044
045    @Override
046    protected int skipPrefix(int index) {
047        // doesn't have to do anything
048        return index;
049    }
050
051}