Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions AnalyzerBeans Copyright (C) 2010 This copyrighted material is made available to anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the GNU Lesser General Public License, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this distribution; if not, write to: Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
 package org.eobjects.analyzer.beans;
 import java.util.List;
 @AnalyzerBean("Compare column structures")
 public class CompareColumnsAnalyzer implements Explorer<ColumnComparisonResult> {
 	private static final Logger logger = LoggerFactory.getLogger(CompareColumnsAnalyzer.class);
 	private boolean relationshipsAnalyzed;
Constructor used when this analyzer is used as a part of a table analysis. Relationship analysis will not be included because it is assumed to be handled by the calling analyzer.

 	public CompareColumnsAnalyzer(Column column1Column column2) {
 		this. = column1;
 		this. = column2;
 		this. = false;

No-args constructor used when instantiated as a standalone analysis
 	public CompareColumnsAnalyzer() {
 		this. = true;
 	public void run(DataContext dc) {
 		assert  != null;
 		assert  != null;
 		List<ColumnDifference<?>> differences = new ArrayList<ColumnDifference<?>>();
 		if ( == ) {
 			 = new ColumnComparisonResult(differences);
 		addDiff(differences"name".getName(), .getName());
 		addDiff(differences"type".getType(), .getType());
 		addDiff(differences"native type".getNativeType(), .getNativeType());
 		addDiff(differences"size".getColumnSize(), .getColumnSize());
 		addDiff(differences"nullable".isNullable(), .isNullable());
 		addDiff(differences"indexed".isIndexed(), .isIndexed());
 		addDiff(differences"column number".getColumnNumber(), .getColumnNumber());
 		addDiff(differences"remarks".getRemarks(), .getRemarks());
 			Table table1 = .getTable();
 			Table table2 = .getTable();
 			if (table1 == null || table2 == null) {
				.warn("Not analyzing relationships - could not resolve table for one or both columns");
else {
				// TODO: Include relationship analysis?
else {
			.debug("Skipping relationship analysis");
		 = new ColumnComparisonResult(differences);
	private <T> void addDiff(List<ColumnDifference<?>> differencesString valueName, T value1, T value2) {
		if (!EqualsBuilder.equals(value1value2)) {
			ColumnDifference<T> diff = new ColumnDifference<T>(valueNamevalue1value2);
		return ;
	public boolean isRelationshipsAnalyzed() {
	public void setRelationshipsAnalyzed(boolean relationshipsAnalyzed) {
		this. = relationshipsAnalyzed;
New to GrepCode? Check out our FAQ X