// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

package llnl.visit;

import java.lang.Integer;
import java.util.Vector;

// ****************************************************************************
// Class: avtVarMetaData
//
// Purpose:
//    Contains metadata attributes associated with all mesh variables
//
// Notes:      Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

public class avtVarMetaData extends avtBaseVarMetaData
{
    private static int avtVarMetaData_numAdditionalAtts = 7;

    public avtVarMetaData()
    {
        super(avtVarMetaData_numAdditionalAtts);

        centering = 0;
        hasUnits = false;
        units = new String("");
        hasDataExtents = false;
        minDataExtents = 0;
        maxDataExtents = 0;
        matRestricted = new Vector();
    }

    public avtVarMetaData(int nMoreFields)
    {
        super(avtVarMetaData_numAdditionalAtts + nMoreFields);

        centering = 0;
        hasUnits = false;
        units = new String("");
        hasDataExtents = false;
        minDataExtents = 0;
        maxDataExtents = 0;
        matRestricted = new Vector();
    }

    public avtVarMetaData(avtVarMetaData obj)
    {
        super(obj);

        int i;

        centering = obj.centering;
        hasUnits = obj.hasUnits;
        units = new String(obj.units);
        hasDataExtents = obj.hasDataExtents;
        minDataExtents = obj.minDataExtents;
        maxDataExtents = obj.maxDataExtents;
        matRestricted = new Vector();
        for(i = 0; i < obj.matRestricted.size(); ++i)
        {
            Integer iv = (Integer)obj.matRestricted.elementAt(i);
            matRestricted.addElement(new Integer(iv.intValue()));
        }

        SelectAll();
    }

    public int Offset()
    {
        return super.Offset() + super.GetNumAdditionalAttributes();
    }

    public int GetNumAdditionalAttributes()
    {
        return avtVarMetaData_numAdditionalAtts;
    }

    public boolean equals(avtVarMetaData obj)
    {
        int i;

        // Compare the elements in the matRestricted vector.
        boolean matRestricted_equal = (obj.matRestricted.size() == matRestricted.size());
        for(i = 0; (i < matRestricted.size()) && matRestricted_equal; ++i)
        {
            // Make references to Integer from Object.
            Integer matRestricted1 = (Integer)matRestricted.elementAt(i);
            Integer matRestricted2 = (Integer)obj.matRestricted.elementAt(i);
            matRestricted_equal = matRestricted1.equals(matRestricted2);
        }
        // Create the return value
        return (super.equals(obj) && (centering == obj.centering) &&
                (hasUnits == obj.hasUnits) &&
                (units.equals(obj.units)) &&
                (hasDataExtents == obj.hasDataExtents) &&
                (minDataExtents == obj.minDataExtents) &&
                (maxDataExtents == obj.maxDataExtents) &&
                matRestricted_equal);
    }

    // Property setting methods
    public void SetCentering(int centering_)
    {
        centering = centering_;
        Select((new avtVarMetaData()).Offset() + 0);
    }

    public void SetHasUnits(boolean hasUnits_)
    {
        hasUnits = hasUnits_;
        Select((new avtVarMetaData()).Offset() + 1);
    }

    public void SetUnits(String units_)
    {
        units = units_;
        Select((new avtVarMetaData()).Offset() + 2);
    }

    public void SetHasDataExtents(boolean hasDataExtents_)
    {
        hasDataExtents = hasDataExtents_;
        Select((new avtVarMetaData()).Offset() + 3);
    }

    public void SetMinDataExtents(double minDataExtents_)
    {
        minDataExtents = minDataExtents_;
        Select((new avtVarMetaData()).Offset() + 4);
    }

    public void SetMaxDataExtents(double maxDataExtents_)
    {
        maxDataExtents = maxDataExtents_;
        Select((new avtVarMetaData()).Offset() + 5);
    }

    public void SetMatRestricted(Vector matRestricted_)
    {
        matRestricted = matRestricted_;
        Select((new avtVarMetaData()).Offset() + 6);
    }

    // Property getting methods
    public int     GetCentering() { return centering; }
    public boolean GetHasUnits() { return hasUnits; }
    public String  GetUnits() { return units; }
    public boolean GetHasDataExtents() { return hasDataExtents; }
    public double  GetMinDataExtents() { return minDataExtents; }
    public double  GetMaxDataExtents() { return maxDataExtents; }
    public Vector  GetMatRestricted() { return matRestricted; }

    // Write and read methods.
    public void WriteAtts(CommunicationBuffer buf)
    {
        super.WriteAtts(buf);

        int offset = (new avtVarMetaData()).Offset();
        if(WriteSelect(offset + 0, buf))
            buf.WriteInt(centering);
        if(WriteSelect(offset + 1, buf))
            buf.WriteBool(hasUnits);
        if(WriteSelect(offset + 2, buf))
            buf.WriteString(units);
        if(WriteSelect(offset + 3, buf))
            buf.WriteBool(hasDataExtents);
        if(WriteSelect(offset + 4, buf))
            buf.WriteDouble(minDataExtents);
        if(WriteSelect(offset + 5, buf))
            buf.WriteDouble(maxDataExtents);
        if(WriteSelect(offset + 6, buf))
            buf.WriteIntVector(matRestricted);
    }

    public void ReadAtts(int id, CommunicationBuffer buf)
    {
        int offset = (new avtVarMetaData()).Offset();
        int index = id - offset;
        switch(index)
        {
        case 0:
            SetCentering(buf.ReadInt());
            break;
        case 1:
            SetHasUnits(buf.ReadBool());
            break;
        case 2:
            SetUnits(buf.ReadString());
            break;
        case 3:
            SetHasDataExtents(buf.ReadBool());
            break;
        case 4:
            SetMinDataExtents(buf.ReadDouble());
            break;
        case 5:
            SetMaxDataExtents(buf.ReadDouble());
            break;
        case 6:
            SetMatRestricted(buf.ReadIntVector());
            break;
        default:
            super.ReadAtts(id, buf);
            break;
        }
    }

    public String toString(String indent)
    {
        String str = new String();
        str = str + intToString("centering", centering, indent) + "\n";
        str = str + boolToString("hasUnits", hasUnits, indent) + "\n";
        str = str + stringToString("units", units, indent) + "\n";
        str = str + boolToString("hasDataExtents", hasDataExtents, indent) + "\n";
        str = str + doubleToString("minDataExtents", minDataExtents, indent) + "\n";
        str = str + doubleToString("maxDataExtents", maxDataExtents, indent) + "\n";
        str = str + intVectorToString("matRestricted", matRestricted, indent) + "\n";
        return super.toString(indent) + str;
    }


    // Attributes
    private int     centering;
    private boolean hasUnits;
    private String  units;
    private boolean hasDataExtents;
    private double  minDataExtents;
    private double  maxDataExtents;
    private Vector  matRestricted; // vector of Integer objects
}

