1 11 12 package org.eclipse.core.internal.databinding; 13 14 import java.util.Arrays ; 15 16 import org.eclipse.core.databinding.util.Policy; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.MultiStatus; 19 20 26 public class BindingStatus extends MultiStatus { 27 35 public BindingStatus(String pluginId, int code, String message, 36 Throwable exception) { 37 super(pluginId, code, message, exception); 38 } 39 40 46 public void add(IStatus status) { 47 if (status.getSeverity() >= getSeverity()) { 48 setMessage((status.getMessage() != null) ? status.getMessage() : ""); setException(status.getException()); 50 setPlugin(status.getPlugin()); 51 setCode(status.getCode()); 52 } 53 54 super.add(status); 55 } 56 57 69 public static BindingStatus ok() { 70 return new BindingStatus(Policy.JFACE_DATABINDING, 0, "", null); } 72 73 private static int hashCode(Object [] array) { 74 final int prime = 31; 75 if (array == null) 76 return 0; 77 int result = 1; 78 for (int index = 0; index < array.length; index++) { 79 result = prime * result 80 + (array[index] == null ? 0 : array[index].hashCode()); 81 } 82 return result; 83 } 84 85 public int hashCode() { 86 final int prime = 31; 87 int result = 1; 88 result = prime * result + BindingStatus.hashCode(getChildren()); 89 return result; 90 } 91 92 public boolean equals(Object obj) { 93 if (this == obj) 94 return true; 95 if (obj == null) 96 return false; 97 if (getClass() != obj.getClass()) 98 return false; 99 final BindingStatus other = (BindingStatus) obj; 100 if (!Arrays.equals(getChildren(), other.getChildren())) 101 return false; 102 return true; 103 } 104 } 105 | Popular Tags |