FileDocCategorySizeDatePackage
PersistenceElement.javaAPI DocGlassfish v2 API10190Fri May 04 22:34:42 BST 2007com.sun.jdo.api.persistence.model.jdo

PersistenceElement

public abstract class PersistenceElement extends Object implements Comparable, PersistenceElementProperties
author
raccah
version
%I%

Fields Summary
private static final ResourceBundle
_messages
I18N message handler
Impl
_impl
Implementation
Constructors Summary
public PersistenceElement()
Create new PersistenceElement with no implementation. This constructor should only be used for cloning and archiving.


	                 	 
	  
	
		this(null);
	
protected PersistenceElement(Impl impl)
Create new PersistenceElement with the provided implementation. The implementation is responsible for storing all properties of the object.

param
impl the implementation to use

		setImpl(impl);
	
Methods Summary
public final voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a property change listener.

param
l the listener to add
see
PersistenceElementProperties

		getImpl().addPropertyChangeListener(l);
	
public final voidaddVetoableChangeListener(java.beans.VetoableChangeListener l)
Add a vetoable change listener.

param
l the listener to add
see
PersistenceElementProperties

		getImpl().addVetoableChangeListener(l);
	
public intcompareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The specified object must be persistence element, meaning it must be an instance of class PersistenceElement or any subclass. If not a ClassCastException is thrown. The order of PersistenceElement objects is defined by the order of their names. Persistence elements without name are considered to be less than any named persistence element.

param
o the Object to be compared.
return
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
exception
ClassCastException - if the specified object is null or is not an instance of PersistenceElement

        // null is not allowed
        if (o == null)
            throw new ClassCastException();
        if (o == this)
            return 0;

        String thisName = getName();
        // the following statement throws a ClassCastException if o is not a PersistenceElement
        String otherName = ((PersistenceElement)o).getName();
        // if this does not have a name it should compare less than any named object
        if (thisName == null)
            return (otherName == null) ? 0 : -1;
        // if this is named and o does not have a name it should compare greater
        if (otherName == null)
            return 1;
        // now we know that this and o are named persistence elements => 
        // use locale-sensitive String comparison 
        int ret = Collator.getInstance().compare(thisName, otherName);
        // if both names are equal, both objects might have different types. 
        // If so order both objects by their type names (necessary to be consistent with equals)
        if ((ret == 0) && (getClass() != o.getClass()))
            ret = getClass().getName().compareTo(o.getClass().getName());
        return ret;
    
public booleanequals(java.lang.Object obj)
Overrides Object's equals method by comparing the name of this persistence element with the name of the argument obj. The method returns false if obj does not have the same dynamic type as this persistence element.

return
true if this object is the same as the obj argument; false otherwise.
param
obj the reference object with which to compare.

        if (obj == null)
            return false;
        if (obj == this)
            return true;

        // check for the right class and then do the name check by calling compareTo.
        return (getClass() == obj.getClass()) && (compareTo(obj) == 0);
    
public final com.sun.jdo.api.persistence.model.jdo.PersistenceElement$ImplgetImpl()

return
implemetation factory for this element

 return _impl; 
protected static final java.util.ResourceBundlegetMessages()

return
I18N message handler for this element

 return _messages; 
public java.lang.StringgetName()
Get the name of this persistence element.

return
the name

 return getImpl().getName(); 
public inthashCode()
Overrides Object's hashCode method to return the hashCode of this persistence element's name.

return
a hash code value for this object.

        return (getName()==null) ? 0 : getName().hashCode();
    
public final voidremovePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a property change listener.

param
l the listener to remove
see
PersistenceElementProperties

		getImpl().removePropertyChangeListener(l);
	
public final voidremoveVetoableChangeListener(java.beans.VetoableChangeListener l)
Remove a vetoable change listener.

param
l the listener to remove
see
PersistenceElementProperties

		getImpl().removeVetoableChangeListener(l);
	
public voidsetImpl(com.sun.jdo.api.persistence.model.jdo.PersistenceElement$Impl impl)
Set the implementation factory of this persistence element. This method should only be used internally and for cloning and archiving.

param
impl the implementation to use

		_impl = impl;

		if (_impl != null)
			getImpl().attachToElement(this);
	
public voidsetName(java.lang.String name)
Set the name of this persistence element.

param
name the name
exception
ModelException if impossible

		getImpl().setName(name);
	
public java.lang.StringtoString()
Overrides Object's toString method to return the name of this persistence element.

return
a string representation of the object

 return getName();