1. /*
  2. * Copyright 2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.betwixt.schema;
  17. import java.beans.IntrospectionException;
  18. import org.apache.commons.betwixt.ElementDescriptor;
  19. /**
  20. * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
  21. * @version $Revision: 1.2 $
  22. */
  23. public class ElementReference extends GlobalElement {
  24. protected String maxOccurs = "1";
  25. protected int minOccurs = 0;
  26. public ElementReference(String string, GlobalComplexType complexType) {
  27. super(string, complexType);
  28. }
  29. public ElementReference(String name, String type) {
  30. super(name, type);
  31. }
  32. public ElementReference(TranscriptionConfiguration configuration, ElementDescriptor elementDescriptor, Schema schema) throws IntrospectionException {
  33. setName(elementDescriptor.getLocalName());
  34. if (elementDescriptor.isHollow()) {
  35. setComplexType( new GlobalComplexType(configuration, elementDescriptor, schema));
  36. schema.addComplexType(getComplexType());
  37. if (elementDescriptor.isCollective()) {
  38. maxOccurs = "unbounded";
  39. }
  40. } else {
  41. setType("xsd:string");
  42. }
  43. }
  44. public int getMinOccurs() {
  45. return minOccurs;
  46. }
  47. public void setMinOccurs(int minOccurs) {
  48. this.minOccurs = minOccurs;
  49. }
  50. public String getMaxOccurs() {
  51. return maxOccurs;
  52. }
  53. public void setMaxOccurs(String maxOccurs) {
  54. this.maxOccurs = maxOccurs;
  55. }
  56. }