// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   AdContent.java

package com.keyshop.shop.channel.model;

import com.keyshop.pub.model.PubOneToManyBean;
import com.keyshop.pub.util.*;
import com.keyshop.shop.channel.bo.AdCategoryBO;
import com.keyshop.shop.channel.util.ChannelConst;
import java.util.ArrayList;

// Referenced classes of package com.keyshop.shop.channel.model:
//            AdElement, AdCategory

public class AdContent extends PubOneToManyBean
{

    String name;
    String category;
    boolean status;
    String displayName;
    int width;
    int height;
    String viewType;
    String createTime;
    int rows;
    ArrayList elements;
    AdCategory categoryObject;
    String content;

    public AdContent()
    {
        name = "";
        category = "";
        status = true;
        displayName = "";
        width = 0;
        height = 0;
        viewType = ChannelConst.AD_VIEWTYPE_HORI;
        createTime = DateUtil.getSysDateTimeString();
        rows = 1;
        elements = new ArrayList();
        categoryObject = null;
        content = "";
    }

    public void init(String mappingFileName)
    {
        if(!StringUtil.isEmpty(content))
            try
            {
                AdContent ac = XMLHelper.unmarshalAdElement(mappingFileName, content);
                rows = ac.getRows();
                elements = ac.getElements();
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
    }

    public AdElement getElement(int index)
    {
        AdElement defaultEl = new AdElement();
        defaultEl.setColumIndex(index);
        if(elements == null || elements.size() <= 0)
        {
            elements.add(defaultEl);
            return defaultEl;
        }
        for(int i = 0; i < elements.size(); i++)
        {
            AdElement el = (AdElement)elements.get(i);
            if(el.getColumIndex() == index)
                return el;
        }

        elements.add(defaultEl);
        return defaultEl;
    }

    public String getCategory()
    {
        return category;
    }

    public String getDisplayName()
    {
        return displayName;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public void setCategory(String category)
    {
        this.category = category;
    }

    public void addEelment(AdElement e)
    {
        elements.add(e);
    }

    public AdCategory getCategoryObject()
    {
        if(StringUtil.isEmpty(category))
        {
            categoryObject = null;
            return null;
        }
        if(categoryObject != null && categoryObject.getId().equals(category))
            return categoryObject;
        try
        {
            AdCategoryBO bo = new AdCategoryBO();
            categoryObject = (AdCategory)bo.get(category);
            return categoryObject;
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return null;
    }

    public int getRows()
    {
        return rows;
    }

    public void setRows(int rows)
    {
        this.rows = rows;
    }

    public ArrayList getElements()
    {
        return elements;
    }

    public void setElements(ArrayList elements)
    {
        this.elements = elements;
    }

    public String getContent()
    {
        return content;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    public void setDisplayName(String displayName)
    {
        this.displayName = displayName;
    }

    public String getViewType()
    {
        return viewType;
    }

    public void setViewType(String viewType)
    {
        this.viewType = viewType;
    }

    public String getCreateTime()
    {
        return createTime;
    }

    public void setCreateTime(String createTime)
    {
        this.createTime = createTime;
    }

    public int getHeight()
    {
        return height;
    }

    public void setHeight(int height)
    {
        this.height = height;
    }

    public int getWidth()
    {
        return width;
    }

    public void setWidth(int width)
    {
        this.width = width;
    }

    public boolean isStatus()
    {
        return status;
    }

    public void setStatus(boolean status)
    {
        this.status = status;
    }
}
