Item.java 1.84 KB
Newer Older
Alexander Ivanov's avatar
Alexander Ivanov committed
1 2
/**
 * Copyright (c) 2013, Redsolution LTD. All rights reserved.
3
 *
Alexander Ivanov's avatar
Alexander Ivanov committed
4 5
 * This file is part of Xabber project; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License, Version 3.
6
 *
Alexander Ivanov's avatar
Alexander Ivanov committed
7 8 9 10
 * Xabber is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
11
 *
Alexander Ivanov's avatar
Alexander Ivanov committed
12 13 14 15 16 17 18 19 20 21 22 23 24
 * You should have received a copy of the GNU General Public License,
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */
package com.xabber.xmpp.archive;

import java.io.IOException;

import org.xmlpull.v1.XmlSerializer;

import com.xabber.xmpp.SerializerUtils;

public class Item extends AbstractSettings {

25
    public static final String ELEMENT_NAME = "item";
Alexander Ivanov's avatar
Alexander Ivanov committed
26

27 28
    public static final String EXACTMATCH_ATTRIBUTE = "exactmatch";
    public static final String JID_ATTRIBUTE = "jid";
Alexander Ivanov's avatar
Alexander Ivanov committed
29

30 31
    private Boolean exactmatch;
    private String jid;
Alexander Ivanov's avatar
Alexander Ivanov committed
32

33 34 35 36
    @Override
    public boolean isValid() {
        return super.isValid() && jid != null;
    }
Alexander Ivanov's avatar
Alexander Ivanov committed
37

38 39 40 41
    @Override
    String getElementName() {
        return ELEMENT_NAME;
    }
Alexander Ivanov's avatar
Alexander Ivanov committed
42

43 44 45 46 47 48 49 50 51
    @Override
    protected void serializeAttributes(XmlSerializer serializer)
            throws IOException {
        if (exactmatch != null)
            SerializerUtils.setBooleanAttribute(serializer,
                    EXACTMATCH_ATTRIBUTE, exactmatch);
        SerializerUtils.setTextAttribute(serializer, JID_ATTRIBUTE, jid);
        super.serializeAttributes(serializer);
    }
Alexander Ivanov's avatar
Alexander Ivanov committed
52

53 54 55
    public Boolean getExactmatch() {
        return exactmatch;
    }
Alexander Ivanov's avatar
Alexander Ivanov committed
56

57 58 59
    public void setExactmatch(Boolean exactmatch) {
        this.exactmatch = exactmatch;
    }
Alexander Ivanov's avatar
Alexander Ivanov committed
60

61 62 63
    public String getJid() {
        return jid;
    }
Alexander Ivanov's avatar
Alexander Ivanov committed
64

65 66 67
    public void setJid(String jid) {
        this.jid = jid;
    }
Alexander Ivanov's avatar
Alexander Ivanov committed
68 69

}