21 package org.matsim.utils.objectattributes.attributable;
23 import java.util.HashMap;
25 import java.util.Stack;
37 private final Map<String, String>
stringCache =
new HashMap<>(1000);
45 final static String ATTR_ATTRIBUTENAME =
"name";
46 final static String ATTR_ATTRIBUTECLASS =
"class";
54 org.xml.sax.Attributes atts,
55 Stack<String> context,
57 if (TAG_ATTRIBUTE.equals(name)) {
58 String attributeName = atts.getValue(ATTR_ATTRIBUTENAME);
59 this.currentAttribute = this.stringCache.computeIfAbsent(attributeName, k -> attributeName);
60 this.currentAttributeClass = atts.getValue(ATTR_ATTRIBUTECLASS);
61 }
else if (TAG_ATTRIBUTES.equals(name)) {
66 public void endTag(String name, String content, Stack<String> context) {
67 if (TAG_ATTRIBUTE.equals(name)) {
68 Object o = converter.
convert(this.currentAttributeClass, content);
69 if (o == null)
return;
71 this.currentAttributes.
putAttribute( this.currentAttribute, o);
87 return this.converter.putAttributeConverter(clazz, converter);
final Map< String, String > stringCache
static final String TAG_ATTRIBUTE
Attributes getCurrentAttributes()
static final String TAG_ATTRIBUTES
AttributeConverter removeAttributeConverter(final Class<?> clazz)
ObjectAttributesConverter getObjectAttributesConverter()
AttributeConverter<?> removeAttributeConverter(final Class<?> clazz)
Object putAttribute(final String attribute, final Object value)
static void assertNotNull(Object obj)
String currentAttributeClass
Attributes currentAttributes
Object convert(String className, String value)
void endTag(String name, String content, Stack< String > context)
final ObjectAttributesConverter converter
void putAttributeConverters(final Map< Class<?>, AttributeConverter<?>> converters)
AttributeConverter<?> putAttributeConverter(final Class<?> clazz, final AttributeConverter<?> converter)
void startTag(String name, org.xml.sax.Attributes atts, Stack< String > context, Attributes currentAttributes)