1 22 package org.jboss.xb.binding.sunday.unmarshalling; 23 24 import javax.xml.namespace.QName ; 25 import org.jboss.xb.binding.metadata.PropertyMetaData; 26 import org.jboss.xb.binding.metadata.ValueMetaData; 27 import org.jboss.xb.binding.JBossXBRuntimeException; 28 import org.jboss.xb.binding.sunday.marshalling.AttributeMarshaller; 29 import org.jboss.xb.binding.sunday.marshalling.DefaultAttributeMarshaller; 30 31 35 public class AttributeBinding 36 { 37 private final SchemaBinding schema; 38 private final QName qName; 39 private final TypeBinding type; 40 private AttributeHandler handler; 41 private AttributeMarshaller marshaller = DefaultAttributeMarshaller.INSTANCE; 42 private PropertyMetaData propertyMetaData; 43 private ValueMetaData valueMetaData; 44 45 private String defaultConstraint; 46 private boolean mapEntryKey; 47 private boolean mapEntryValue; 48 private ValueAdapter valueAdapter; 49 private boolean required; 50 51 public AttributeBinding(SchemaBinding schema, QName qName, TypeBinding type, AttributeHandler handler) 52 { 53 this.schema = schema; 54 this.qName = qName; 55 this.type = type; 56 this.handler = handler; 57 58 if(qName == null) 59 { 60 throw new JBossXBRuntimeException("Each attribute should have a non-null QName!"); 61 } 62 } 63 64 public QName getQName() 65 { 66 return qName; 67 } 68 69 public TypeBinding getType() 70 { 71 return type; 72 } 73 74 public AttributeHandler getHandler() 75 { 76 return handler; 77 } 78 79 public void setHandler(AttributeHandler handler) 80 { 81 this.handler = handler; 82 } 83 84 public AttributeMarshaller getMarshaller() 85 { 86 return marshaller; 87 } 88 89 public void setMarshaller(AttributeMarshaller marshaller) 90 { 91 this.marshaller = marshaller; 92 } 93 94 public PropertyMetaData getPropertyMetaData() 95 { 96 return propertyMetaData; 97 } 98 99 public void setPropertyMetaData(PropertyMetaData propertyMetaData) 100 { 101 this.propertyMetaData = propertyMetaData; 102 } 103 104 public ValueMetaData getValueMetaData() 105 { 106 return valueMetaData != null ? valueMetaData : type.getValueMetaData(); 107 } 108 109 public void setValueMetaData(ValueMetaData valueMetaData) 110 { 111 this.valueMetaData = valueMetaData; 112 } 113 114 public void setMapEntryKey(boolean mapEntryKey) 115 { 116 this.mapEntryKey = mapEntryKey; 117 } 118 119 public boolean isMapEntryKey() 120 { 121 return mapEntryKey; 122 } 123 124 public boolean isMapEntryValue() 125 { 126 return mapEntryValue; 127 } 128 129 public void setMapEntryValue(boolean mapEntryValue) 130 { 131 this.mapEntryValue = mapEntryValue; 132 } 133 134 public String getDefaultConstraint() 135 { 136 return defaultConstraint; 137 } 138 139 public void setDefaultConstraint(String value) 140 { 141 defaultConstraint = value; 142 } 143 144 public SchemaBinding getSchema() 145 { 146 return schema; 147 } 148 149 public ValueAdapter getValueAdapter() 150 { 151 return valueAdapter == null ? type.getValueAdapter() : valueAdapter; 152 } 153 154 public void setValueAdapter(ValueAdapter valueAdapter) 155 { 156 this.valueAdapter = valueAdapter; 157 } 158 159 public String toString() 160 { 161 return super.toString() + "[" + qName + "]"; 162 } 163 164 public void setRequired(boolean required) 165 { 166 this.required = required; 167 } 168 169 public boolean getRequired() 170 { 171 return required; 172 } 173 } 174 | Popular Tags |