Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010 Daniel Murphy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Created at 2:47:16 PM, Apr 5, 2010
 package com.dmurph.mvc.util;
com.dmurph.mvc.ICloneable and com.dmurph.mvc.IDirtyable Array List. Will clone all values that implement com.dmurph.mvc.ICloneable in the clone() and cloneFrom(com.dmurph.mvc.ICloneable) methods. TODO reverting changes, saving, etc

Daniel Murphy
 public class MVCArrayList<E extends Objectextends ArrayList<E> implements ICloneableIDirtyable {
 	private static final long serialVersionUID = 4890270966369581329L;
 	private boolean dirty = false;
 	public boolean add(E e) {
 		 = true;
 		return super.add(e);
 	public void clear() {
 		if(size() > 0){
 			 = true;
 	public E remove(int index) {
 		 = true;
 		return super.remove(index);
 	public boolean remove(Object o) {
 		 = true;
 		return super.removeo);
 	public E set(int index, E element) {
 		 = true;
 		return super.setindexelement);

Clones from another java.util.ArrayList, if the values are com.dmurph.mvc.ICloneable, then they will be cloned to this one. Otherwise it's a shallow copy (just sets the same values).

 	public void cloneFromICloneable argOther) {
 		ArrayList<E> other = (ArrayList<E>) argOther;
 		for(E e : other){
 			if(e instanceof ICloneable){
 				add((E) ((ICloneablee).clone());

Clones this object to another MVCArrayList. If the array values are also com.dmurph.mvc.ICloneable, then they will be cloned as well. If not, the values are just set (shallow copy).

	public ICloneable clone(){
		MVCArrayList<E> other = new MVCArrayList<E>();
		return other;

	public boolean isDirty() {
		return ;

Just sets the dirty variable

	public boolean setDirtyboolean argDirty) {
		boolean oldDirty = ;
		 = argDirty;
		return oldDirty;
New to GrepCode? Check out our FAQ X