Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2007 Daniel Spiewak
   * 
   * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 
   * 
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package net.java.ao.schema.ddl;
 

Database-agnostic representation of any supported DDL action (usually one or two statements). The idea behind this class is to allow ActiveObjects to internally represent actions to be taken on a database schema without coupling to a database-specific rendering of the action.

As this class is meant to be a generic container of different action types, some fields may not be relevant to certain action types, and thus these fields will contain null values. For example, the equivalent of an ALTER TABLE DROP FIELD action will return null for getIndex(). However, code should not depend on this behavior; instead testing the action type and only retrieving relevant data.

Author(s):
Daniel Spiewak
 
 public class DDLAction {
 
 	private DDLTable table;
 	private DDLField oldFieldfield;
 	private DDLForeignKey key;
 	private DDLIndex index;
     private DDLValue[] values;
 
     private DDLAction()
     {}
 
 	public DDLAction(DDLActionType actionType) {
 		this. = actionType;
 	}
 
 	public DDLTable getTable() {
 		return ;
 	}
 
 	public void setTable(DDLTable table) {
 		this. = table;
 	}
 
 	public DDLField getField() {
 		return ;
 	}
 
 	public void setField(DDLField field) {
 		this. = field;
 	}
 
 	public DDLForeignKey getKey() {
 		return ;
 	}
 
 	public void setKey(DDLForeignKey key) {
 		this. = key;
 	}
 
 		return ;
 	}
 
 
 	public DDLField getOldField() {
 		return ;
 	}
 
 	public void setOldField(DDLField oldField) {
 		this. = oldField;
 	}
 
 	public DDLIndex getIndex() {
 		return ;
 	}
 
 	public void setIndex(DDLIndex index) {
 		this. = index;
 	}
 
     public DDLValue[] getValues()
     {
        return ;
    }
    public void setValues(DDLValue[] values)
    {
        this. = values;
    }
    @Override
	public int hashCode() {
		int back = 0;
		if ( != null) {
			back += .hashCode();
		}
		if ( != null) {
			back += .hashCode();
		}
		if ( != null) {
			back += .hashCode();
		}
		if ( != null) {
			back += .hashCode();
		}
		if ( != null) {
			back += .hashCode();
		}
		if ( != null) {
			back += .hashCode();
		}
        if ( != null) {
            back += Arrays.hashCode();
        }
		back %= 2 << 15;
		return back;
	}
	public boolean equals(Object obj) {
		if (obj instanceof DDLAction) {
			DDLAction action = (DDLActionobj;
			if (action == this) {
				return true;
			}
			if ((action.getTable() == null || action.getTable().equals())
					&& (action.getActionType() == )
					&& (action.getOldField() == null || action.getOldField().equals())
					&& (action.getField() == null || action.getField().equals())
					&& (action.getKey() == null || action.getKey().equals())
					&& (action.getIndex() == null || action.getIndex().equals())
                    && (action.getValues() == null || Arrays.equals(action.getValues(), ))) {
				return true;
			}
			return false;
		}
		return super.equals(obj);
	}
New to GrepCode? Check out our FAQ X