1 18 package sync4j.framework.engine.source; 19 20 import sync4j.framework.engine.source.ContentType; 21 22 38 public class SyncSourceInfo implements java.io.Serializable { 39 40 42 private ContentType[] supportedTypes = null; 43 44 48 public ContentType[] getSupportedTypes() { 49 return this.supportedTypes; 50 } 51 52 56 public void setSupportedTypes(ContentType[] supportedTypes) { 57 this.supportedTypes = supportedTypes; 58 this.preferred = 0; 59 } 60 61 64 private int preferred = 0; 65 66 70 public int getPreferred() { 71 return preferred; 72 } 73 74 78 public void setPreferred(int preferred) { 79 this.preferred = preferred; 80 } 81 82 88 public ContentType getPreferredType() { 89 assert ((supportedTypes != null) && (preferred >= 0) && (preferred < supportedTypes.length)); 90 return supportedTypes[preferred]; 91 } 92 93 103 public SyncSourceInfo(ContentType[] supportedTypes, int preferred) { 104 if ((supportedTypes == null) || (supportedTypes.length == 0)) { 105 throw new IllegalArgumentException ("supportedTypes cannot be null"); 106 } 107 108 if ((preferred<0) || (preferred >= supportedTypes.length)) { 109 throw new IllegalArgumentException ( "preferred is " 110 + preferred 111 + " when the supported type are " 112 + supportedTypes.length); 113 } 114 115 this.supportedTypes = supportedTypes; 116 this.preferred = preferred; 117 } 118 119 public SyncSourceInfo() { 120 } 121 } | Popular Tags |