KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > model > impl > SequenceImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.model.impl;
21
22 import org.netbeans.modules.xml.schema.model.*;
23 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor;
24 import org.w3c.dom.Element JavaDoc;
25
26 /**
27  * @author Chris Webster
28  */

29 public class SequenceImpl extends SchemaComponentImpl
30     implements Sequence, Cardinality {
31
32     public SequenceImpl(SchemaModelImpl model) {
33     this(model, createNewComponent(SchemaElements.SEQUENCE,model));
34     }
35
36     public SequenceImpl(SchemaModelImpl model, Element JavaDoc e) {
37     super(model,e);
38     }
39
40     public void removeContent(SequenceDefinition definition) {
41     removeChild(CONTENT_PROPERTY, definition);
42     }
43     
44     public void addContent(SequenceDefinition definition, int position) {
45     insertAtIndex(CONTENT_PROPERTY, definition, position,
46         SequenceDefinition.class);
47     }
48     
49     public void appendContent(SequenceDefinition definition) {
50     appendChild(CONTENT_PROPERTY, definition);
51     }
52     
53     public java.util.List JavaDoc<SequenceDefinition> getContent() {
54     return getChildren(SequenceDefinition.class);
55     }
56     
57     public Class JavaDoc<? extends SchemaComponent> getComponentType() {
58     return Sequence.class;
59     }
60     
61     public void accept(SchemaVisitor v) {
62     v.visit(this);
63     }
64     
65     public void setMinOccurs(Integer JavaDoc min) {
66     setAttribute(MIN_OCCURS_PROPERTY, SchemaAttributes.MIN_OCCURS, min);
67     }
68     
69     public void setMaxOccurs(String JavaDoc max) {
70     setAttribute(MAX_OCCURS_PROPERTY, SchemaAttributes.MAX_OCCURS, max);
71     }
72     
73     public Integer JavaDoc getMinOccurs() {
74     String JavaDoc s = getAttribute(SchemaAttributes.MIN_OCCURS);
75     return s == null ? null : Integer.valueOf(s);
76     }
77     
78     public String JavaDoc getMaxOccurs() {
79     return getAttribute(SchemaAttributes.MAX_OCCURS);
80     }
81     
82     public int getMinOccursEffective() {
83     Integer JavaDoc v = getMinOccurs();
84     return v == null ? getMinOccursDefault() : v;
85     }
86     
87     public int getMinOccursDefault() {
88     return 1;
89     }
90     
91     public String JavaDoc getMaxOccursEffective() {
92     String JavaDoc v = getMaxOccurs();
93     return v == null ? getMaxOccursDefault() : v;
94     }
95     
96     public String JavaDoc getMaxOccursDefault() {
97     return String.valueOf(1);
98     }
99     
100     public Cardinality getCardinality() {
101     return getParent() instanceof GlobalGroup ? null: this;
102     }
103
104 }
105
Popular Tags