1 11 package org.eclipse.pde.internal.core.schema; 12 13 import org.eclipse.pde.internal.core.ischema.ISchemaObject; 14 import org.eclipse.pde.internal.core.ischema.ISchemaRepeatable; 15 16 public abstract class RepeatableSchemaObject extends SchemaObject implements ISchemaRepeatable { 17 public static final String P_MIN_OCCURS="min_occurs"; public static final String P_MAX_OCCURS="max_occurs"; private int minOccurs = 1; 20 private int maxOccurs = 1; 21 22 public RepeatableSchemaObject(ISchemaObject parent, String name) { 23 super(parent, name); 24 } 25 public int getMaxOccurs() { 26 return maxOccurs; 27 } 28 public int getMinOccurs() { 29 return minOccurs; 30 } 31 public boolean isRequired() { 32 return minOccurs >0; 33 } 34 public boolean isUnbounded() { 35 return maxOccurs ==Integer.MAX_VALUE; 36 } 37 public void setMaxOccurs(int newMaxOccurs) { 38 Integer oldValue = new Integer (maxOccurs); 39 maxOccurs = newMaxOccurs; 40 getSchema().fireModelObjectChanged(this, P_MAX_OCCURS, oldValue, new Integer (maxOccurs)); 41 } 42 public void setMinOccurs(int newMinOccurs) { 43 Integer oldValue = new Integer (minOccurs); 44 minOccurs = newMinOccurs; 45 getSchema().fireModelObjectChanged(this, P_MIN_OCCURS, oldValue, new Integer (minOccurs)); 46 } 47 } 48 | Popular Tags |