1 package org.jboss.cache.buddyreplication; 2 3 import org.jboss.cache.Fqn; 4 import org.jboss.cache.Node; 5 6 import java.util.ArrayList ; 7 import java.util.List ; 8 9 public class GravitateResult 10 { 11 private boolean dataFound; 12 13 17 private List <Node> subtree; 18 19 private byte marshalledData[]; 20 21 private Fqn buddyBackupRegion; 22 23 public static GravitateResult noDataFound() 24 { 25 return new GravitateResult(false, null, null, null); 26 } 27 28 public static GravitateResult subtreeResult(List <Node> subtree, Fqn fqn) 29 { 30 return new GravitateResult(true, subtree, null, fqn); 31 } 32 33 public static GravitateResult marshalledResult(byte[] marshalledData, Fqn fqn) 34 { 35 return new GravitateResult(true, null, marshalledData, fqn); 36 } 37 38 private GravitateResult(boolean dataFound, List <Node> subtree, byte[] marshalledData, Fqn buddyBackupRegion) 39 { 40 this.dataFound = dataFound; 41 this.subtree = subtree; 42 this.marshalledData = marshalledData; 43 this.buddyBackupRegion = buddyBackupRegion; 44 } 45 46 49 public Fqn getBuddyBackupRegion() 50 { 51 return buddyBackupRegion; 52 } 53 54 57 public boolean getDataFound() 58 { 59 return dataFound; 60 } 61 62 65 public byte[] getMarshalledData() 66 { 67 return marshalledData; 68 } 69 70 73 public List <Node> getSubtree() 74 { 75 return subtree; 76 } 77 78 public String toString() 79 { 80 return "Result dataFound=" + dataFound + 81 " subtree=" + subtree + 82 " data=" + marshalledData + 83 " fqn=" + buddyBackupRegion; 84 } 85 86 89 public List asList() 90 { 91 List l = new ArrayList (); 92 l.add(dataFound); 93 if (dataFound) 94 { 95 if (marshalledData != null) 96 l.add(marshalledData); 97 else 98 l.add(subtree); 99 l.add(buddyBackupRegion); 100 } 101 return l; 102 } 103 104 } 105 | Popular Tags |