KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > schema > RepeatableSchemaObject


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc P_MIN_OCCURS="min_occurs"; //$NON-NLS-1$
18
public static final String JavaDoc 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 JavaDoc 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 JavaDoc oldValue = new Integer JavaDoc(maxOccurs);
39     maxOccurs = newMaxOccurs;
40     getSchema().fireModelObjectChanged(this, P_MAX_OCCURS, oldValue, new Integer JavaDoc(maxOccurs));
41 }
42 public void setMinOccurs(int newMinOccurs) {
43     Integer JavaDoc oldValue = new Integer JavaDoc(minOccurs);
44     minOccurs = newMinOccurs;
45     getSchema().fireModelObjectChanged(this, P_MIN_OCCURS, oldValue, new Integer JavaDoc(minOccurs));
46 }
47 }
48
Popular Tags