01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.schema;
11:
12: import org.eclipse.pde.internal.core.ischema.ISchemaObject;
13: import org.eclipse.pde.internal.core.ischema.ISchemaRepeatable;
14:
15: public abstract class RepeatableSchemaObject extends SchemaObject
16: implements ISchemaRepeatable {
17: public static final String P_MIN_OCCURS = "min_occurs"; //$NON-NLS-1$
18: public static final String P_MAX_OCCURS = "max_occurs"; //$NON-NLS-1$
19: private int minOccurs = 1;
20: private int maxOccurs = 1;
21:
22: public RepeatableSchemaObject(ISchemaObject parent, String name) {
23: super (parent, name);
24: }
25:
26: public int getMaxOccurs() {
27: return maxOccurs;
28: }
29:
30: public int getMinOccurs() {
31: return minOccurs;
32: }
33:
34: public boolean isRequired() {
35: return minOccurs > 0;
36: }
37:
38: public boolean isUnbounded() {
39: return maxOccurs == Integer.MAX_VALUE;
40: }
41:
42: public void setMaxOccurs(int newMaxOccurs) {
43: Integer oldValue = new Integer(maxOccurs);
44: maxOccurs = newMaxOccurs;
45: getSchema().fireModelObjectChanged(this , P_MAX_OCCURS,
46: oldValue, new Integer(maxOccurs));
47: }
48:
49: public void setMinOccurs(int newMinOccurs) {
50: Integer oldValue = new Integer(minOccurs);
51: minOccurs = newMinOccurs;
52: getSchema().fireModelObjectChanged(this , P_MIN_OCCURS,
53: oldValue, new Integer(minOccurs));
54: }
55: }
|