1 16 package com.google.gwt.dev.util.xml; 17 18 import com.google.gwt.core.ext.TreeLogger; 19 import com.google.gwt.core.ext.UnableToCompleteException; 20 21 import java.lang.reflect.Method ; 22 23 27 public class DefaultSchema extends Schema { 28 29 private final TreeLogger logger; 30 31 public DefaultSchema(TreeLogger logger) { 32 this.logger = logger; 33 34 registerAttributeConverter(int.class, new AttributeConverterForInteger()); 37 registerAttributeConverter(Integer .class, 38 new AttributeConverterForInteger()); 39 registerAttributeConverter(String .class, new AttributeConverterForString()); 40 registerAttributeConverter(boolean.class, 41 new AttributeConverterForBoolean()); 42 registerAttributeConverter(Boolean .class, 43 new AttributeConverterForBoolean()); 44 } 45 46 public void onBadAttributeValue(int line, String elem, String attr, 47 String value, Class paramType) throws UnableToCompleteException { 48 Messages.XML_ATTRIBUTE_CONVERSION_ERROR.log(logger, line, attr, paramType, 49 null); 50 throw new UnableToCompleteException(); 51 } 52 53 public void onHandlerException(int line, String elem, Method method, 54 Throwable e) throws UnableToCompleteException { 55 Messages.XML_ELEMENT_HANDLER_EXCEPTION.log(logger, line, elem, e); 56 throw new UnableToCompleteException(); 57 } 58 59 public void onMissingAttribute(int line, String elem, String attr) 60 throws UnableToCompleteException { 61 Messages.XML_REQUIRED_ATTRIBUTE_MISSING.log(logger, elem, line, attr, null); 62 throw new UnableToCompleteException(); 63 } 64 65 public void onUnexpectedAttribute(int line, String elem, String attr, 66 String value) throws UnableToCompleteException { 67 Messages.XML_ATTRIBUTE_UNEXPECTED.log(logger, elem, line, attr, null); 68 throw new UnableToCompleteException(); 69 } 70 71 public void onUnexpectedChild(int line, String childElem) 72 throws UnableToCompleteException { 73 Messages.XML_CHILDREN_NOT_ALLOWED.log(logger, childElem, line, null); 74 throw new UnableToCompleteException(); 75 } 76 77 public void onUnexpectedElement(int line, String elem) 78 throws UnableToCompleteException { 79 Messages.XML_ELEMENT_UNEXPECTED.log(logger, line, elem, null); 80 throw new UnableToCompleteException(); 81 } 82 } 83 | Popular Tags |