1. /*
  2. * Copyright 2001-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.io.read;
  17. import org.apache.commons.betwixt.ElementDescriptor;
  18. import org.xml.sax.Attributes;
  19. /**
  20. * Describes a mapping between an xml element and a betwixt element.
  21. *
  22. * @author Robert Burrell Donkin
  23. * @since 0.5
  24. */
  25. public class ElementMapping {
  26. /** Namespace of the xml element */
  27. private String namespace;
  28. /** Name of the element */
  29. private String name;
  30. /** Attributes associated with this element */
  31. private Attributes attributes;
  32. /** The base type of the mapped bean */
  33. private Class type;
  34. /** The mapped descriptor */
  35. private ElementDescriptor descriptor;
  36. /** Base constructor */
  37. public ElementMapping() {}
  38. /**
  39. * Gets the namespace URI or an empty string if the parser is not namespace aware
  40. * or the element has no namespace.
  41. * @return namespace possibly null
  42. */
  43. public String getNamespace() {
  44. return namespace;
  45. }
  46. /**
  47. * Sets the namespace URI for this element
  48. * @param namespace the namespace uri, possibly null
  49. */
  50. public void setNamespace(String namespace) {
  51. this.namespace = namespace;
  52. }
  53. /**
  54. * Gets the local name if the parser is namespace aware, otherwise the name.
  55. * @return the element name, possibly null
  56. */
  57. public String getName() {
  58. return name;
  59. }
  60. /**
  61. * Sets the local name for this element.
  62. * @param name the element name, possibly null
  63. */
  64. public void setName(String name) {
  65. this.name = name;
  66. }
  67. /**
  68. * Gets the element's attributes.
  69. * @return the Attributes for this element, possibly null.
  70. */
  71. public Attributes getAttributes() {
  72. return attributes;
  73. }
  74. /**
  75. * Sets the element's attributes
  76. * @param attributes the element's attributes, possibly null
  77. */
  78. public void setAttributes(Attributes attributes) {
  79. this.attributes = attributes;
  80. }
  81. /**
  82. * Gets the base type for this element.
  83. * The base type may - or may not - correspond to the created type.
  84. * @return the Class of the base type for this element
  85. */
  86. public Class getType() {
  87. return type;
  88. }
  89. /**
  90. * Sets the base type for this element.
  91. * The base type may - or may not - correspond to the created type.
  92. * @param type the Class of the base type for this element
  93. */
  94. public void setType(Class type) {
  95. this.type = type;
  96. }
  97. /**
  98. * Gets the mapped element descriptor.
  99. * @return the mapped ElementDescriptor
  100. */
  101. public ElementDescriptor getDescriptor() {
  102. return descriptor;
  103. }
  104. /**
  105. * Sets the mapped element descriptor.
  106. * @param descriptor set this descriptor
  107. */
  108. public void setDescriptor(ElementDescriptor descriptor) {
  109. this.descriptor = descriptor;
  110. }
  111. }