Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Created on Aug 17, 2010, 12:44:33 PM
 
 package com.dmurph.mvc.support;
 
For for internal use, this includes methods that the user can override to control the mvc support of the class.

Author(s):
Daniel Murphy
public abstract class AbstractMVCSupport extends AbstractModel implements ICloneableIDirtyableIRevertible {
	private static final long serialVersionUID = 1L;

	public abstract ICloneable clone();

Default just calls com.dmurph.mvc.ICloneable.clone() (if the object is com.dmurph.mvc.ICloneable), but override to implement your own cloning and to protect against loops (if the property tree goes in a loop).

	protected Object cloneImpl(String argPropertyObject o){
		if(o instanceof ICloneable && isDeepMVCEnabled(argProperty)){
			return ((ICloneableo).clone();
		}else{
			return o;
		}
	}

Default just calls com.dmurph.mvc.IDirtyable.setDirty(boolean) if the object is com.dmurph.mvc.IDirtyable, but override to protect against loops (if the property tree goes in a loop).

	protected void setDirtyImpl(String argPropertyObject argObject){
		if(isDeepMVCEnabled(argProperty) && argObject instanceof IDirtyable){
			((IDirtyable)argObject).setDirty(false);
		}
	}

Default just calls com.dmurph.mvc.IDirtyable.isDirty() if the object is com.dmurph.mvc.IDirtyable, but override to protect against loops (if the property tree goes in a loop).

	protected boolean isDirtyImpl(String argPropertyObject argObject){
		if(isDeepMVCEnabled(argProperty) && argObject instanceof IDirtyable){
			return ((IDirtyableargObject).isDirty();
		}else{
			return false;
		}
	}

Override to disable deep MVC support for a property. This prevents forwarding MVC calls (like com.dmurph.mvc.IDirtyable.setDirty(boolean) or com.dmurph.mvc.IRevertible.revertChanges()) to stored properties. The default is just to return true;

Parameters:
argProperty name of the property in question
Returns:
if deeper
	protected boolean isDeepMVCEnabled(String argProperty){
		return true;
	}

Default just calls com.dmurph.mvc.IRevertible.revertChanges(), but override to protect against loops (if the property tree goes in a loop).

	protected void revertChangesImpl(String argPropertyObject argObject){
		if(isDeepMVCEnabled(argProperty) && argObject instanceof IRevertible){
			((IRevertible)argObject).revertChanges();
		}
	}

Default just calls com.dmurph.mvc.IRevertible.saveChanges(), but override to protect against loops (if the property tree goes in a loop).

	protected void saveChangesImpl(String argPropertyObject argObject){
		if(isDeepMVCEnabled(argProperty) && argObject instanceof IRevertible){
			((IRevertible)argObject).saveChanges();
		}
	}
New to GrepCode? Check out our FAQ X