All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.Monitoring.Category Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common.Monitoring;

import Alachisoft.NCache.Common.Common;
import Alachisoft.NCache.Common.Configuration.ConfigurationAttributeAnnotation;
import Alachisoft.NCache.Common.Configuration.ConfigurationSectionAnnotation;
import Alachisoft.NCache.Common.ICloneable;
import com.alachisoft.ncache.serialization.core.io.InternalCompactSerializable;
import com.alachisoft.ncache.serialization.standard.io.CompactReader;
import com.alachisoft.ncache.serialization.standard.io.CompactWriter;

import java.io.IOException;
import java.util.ArrayList;

public class Category implements ICloneable , InternalCompactSerializable
{
    private boolean _publish = false;
    private String _name = "";
    private java.util.ArrayList _counters;
    public Category()
    {

    }
    @ConfigurationAttributeAnnotation(value = "name", appendText = "")
    public void setName(String name){ _name=name; }
    @ConfigurationAttributeAnnotation(value = "name",appendText = "")
    public String getName(){ return _name;}
    @ConfigurationAttributeAnnotation(value = "publish", appendText = "")
    public void setPublish(boolean publish){ _publish=publish;}
    @ConfigurationAttributeAnnotation(value = "publish", appendText = "")
    public boolean getPublish() { return _publish;}
    @ConfigurationSectionAnnotation("counter")
    public void setCounters(Object counters)
    {
        if (_counters == null) {
            _counters = new java.util.ArrayList();
        }

       // _counters.clear();
        if (counters != null) {
            Object[] objs = (Object[]) counters;
            for (int i = 0; i < objs.length; i++) {
                if(!_counters.contains((Counter) objs[i]))
                {
                    _counters.add((Counter) objs[i]);
                }
            }


        }
    }
    @ConfigurationSectionAnnotation("counter")
    public Counter[] getCounters()
    {
        if (_counters != null) {
            return _counters.toArray(new Counter[0]);
        }
        return null;

    }


    @Override
    public Object clone()
    {
        Category category=new Category();
        category.setPublish(_publish);
        category.setName(_name);
        category.setCounters(_counters);
        return category;
    }

    @Override
    public void Deserialize(CompactReader reader) throws IOException, ClassNotFoundException {
        setPublish(reader.ReadBoolean());
        setName(Common.as(reader.ReadObject(), String.class));
        setCounters(Common.as(reader.ReadObject(), Counter[].class));

    }

    @Override
    public void Serialize(CompactWriter writer) throws IOException {
        writer.Write(getPublish());
        writer.WriteObject(getName());
        writer.WriteObject(getCounters());

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy