//
// CIMElement.java
//
// The contents of this file are subject to the SNIA Public License Version 1.0
// (the "License"); you may not use this file except in compliance with the
// License. You may obtain a copy of the License at
//
//	http://www.snia.org/resources/openSource.html
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is CIMElement.java
// 
// The Initial Developer of the Original Code is David Simons.
//
// Contributor(s):
//
//
// This source uses the Solaris WBEM APIs version 2.2. 
// Synchronization will be maintained with the Solaris WBEM APIS,
// which are being standardized through the Java Community Process.
//
//
// $Id: CIMElement.java,v 1.1 2003/07/17 18:32:55 kumpf Exp $
//
// $Log: CIMElement.java,v $
// Revision 1.1  2003/07/17 18:32:55  kumpf
// HP-BAPU: PEP-64 CIM Client and CIM Listener Java Interface
//
// Revision 1.1.1.1  2001/10/31 18:14:19  karl
// import of SNIA 0_7
//
// Revision 1.5  2000/08/16 05:59:52  shawn
// merge P_TOMCAT31 branch
//
// Revision 1.4.8.1  2000/08/10 00:03:27  shawn
// head merge
//
// Revision 1.4  2000/05/11 10:12:19  davidsi
// - Fixed tabs.
//
// Revision 1.3  2000/05/06 17:04:21  davidsi
// - Modifications to bring classes inline with the SUN WBEM APIs 2.2.
//
// Revision 1.2  2000/02/13 15:09:06  davidsi
// - Added text to cover re-use of Solaris WBEM APIs.
//
// Revision 1.1.1.1  2000/02/06 16:41:03  davidsi
// Initial version.
//
//
//
package org.snia.wbem.cim;

import java.io.Serializable;

/**
    Base class for managed system elements.  Creates and instantiates
    a CIM element.
 */

public class CIMElement extends Object implements Serializable {
    private String name;
    private String identifier;
    
    public CIMElement() {}
    
    public CIMElement(CIMElement in) {
	name=in.name;
	identifier=in.identifier;
    }
    public CIMElement(String elename) {
	name=elename;
	identifier=elename.toLowerCase();
    }
    
    //
    // Returns the name of the element 
    //
    public String getName() {
	return(name);
    }

    //
    // Sets the name of the element instance, note that the caller
    // is responsible for duping the string
    // 
    public void setName(String iname) {
	name=iname;
	identifier=iname.toLowerCase();
    }

    // 
    // Returns a string identifying the name
    //
    public String toString() {
	return(name);
    }

    //
    // Performs a comparison on elements
    //
    public boolean equals(Object rhs) {
	if (!(rhs instanceof CIMElement))
	    return(false);
	CIMElement newRHS=(CIMElement)rhs;
	if (identifier==null ||newRHS.identifier==null)
	    return(false);
	return (newRHS.identifier.equals(identifier));
    }

 
    // 
    // Assigns this CIM element to the values of another
    //
    public CIMElement assign(CIMElement rhs) {
	name=rhs.name;
	identifier=rhs.identifier;
	return(this);
    }

    //
    // Performs a comparison without case. 
    // 
    public boolean lessThan(CIMElement rhs) {
	return(identifier.compareTo(rhs.identifier)<0);
    }
}    
