KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
21  * AnyImpl.java
22  *
23  * Created on October 7, 2005, 8:44 AM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.schema.model.impl;
30
31 import org.netbeans.modules.xml.schema.model.AnyElement;
32 import org.netbeans.modules.xml.schema.model.SchemaComponent;
33 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor;
34 import org.w3c.dom.Element JavaDoc;
35
36 /**
37  *
38  * @author Vidhya Narayanan
39  */

40 public class AnyImpl extends CommonAnyImpl implements AnyElement {
41
42     public AnyImpl(SchemaModelImpl model) {
43     this(model,createNewComponent(SchemaElements.ANY,model));
44     }
45     
46     /**
47      * Creates a new instance of AnyImpl
48      */

49     public AnyImpl(SchemaModelImpl model, Element el) {
50     super(model, el);
51     }
52
53     /**
54      *
55      *
56      */

57     public Class JavaDoc<? extends SchemaComponent> getComponentType() {
58         return AnyElement.class;
59     }
60     
61     /**
62      *
63      */

64     public void setMinOccurs(Integer JavaDoc occurs) {
65     setAttribute(MIN_OCCURS_PROPERTY, SchemaAttributes.MIN_OCCURS, occurs);
66     }
67     
68     /**
69      *
70      */

71     public void setMaxOccurs(String JavaDoc occurs) {
72     setAttribute(MAX_OCCURS_PROPERTY, SchemaAttributes.MAX_OCCURS, occurs);
73     }
74     
75     /**
76      *
77      */

78     public Integer JavaDoc getMinOccurs() {
79         String JavaDoc v = getAttribute(SchemaAttributes.MIN_OCCURS);
80     return v == null ? null : Integer.valueOf(v);
81     }
82     
83     /**
84      *
85      */

86     public String JavaDoc getMaxOccurs() {
87     return getAttribute(SchemaAttributes.MAX_OCCURS);
88     }
89     
90     public int getMinOccursDefault() {
91         return 1;
92     }
93     
94     public int getMinOccursEffective() {
95         String JavaDoc s = getAttribute(SchemaAttributes.MIN_OCCURS);
96         return s == null ? getMinOccursDefault() : Integer.valueOf(s).intValue();
97     }
98     
99     public String JavaDoc getMaxOccursDefault() {
100         return String.valueOf(1);
101     }
102     
103     public String JavaDoc getMaxOccursEffective() {
104         String JavaDoc s = getAttribute(SchemaAttributes.MAX_OCCURS);
105         return s == null ? getMaxOccursDefault() : s;
106     }
107     
108     /**
109      *
110      */

111     public void accept(SchemaVisitor v) {
112     v.visit(this);
113     }
114 }
Popular Tags