protected AbstractRootLevelBand createElement() throws ParseException { try { return (AbstractRootLevelBand) elementType.create(); } catch ( Exception e ) { throw new ParseException( e ); } }
protected void doneParsing() throws SAXException { final ArrayList<IDatabaseConnection> connections = new ArrayList<IDatabaseConnection>(); for ( int i = 0; i < readHandlers.size(); i++ ) { final DatabaseMetaReadHandler readHandler = readHandlers.get( i ); connections.add( readHandler.getObject() ); } try { collection = new DatabaseConnectionCollection( connections.toArray( new IDatabaseConnection[connections.size()] ) ); } catch ( IOException e ) { throw new ParseException( e, getLocator() ); } }
private Class<?> parseValueType( final Attributes attrs ) throws ParseException { final String valueTypeText = attrs.getValue( getUri(), "value-type" ); // NON-NLS if ( valueTypeText == null ) { throw new ParseException( "Attribute 'value-type' is undefined", getLocator() ); } try { final ClassLoader classLoader = ObjectUtilities.getClassLoader( getClass() ); return Class.forName( valueTypeText, false, classLoader ); } catch ( final Exception e ) { throw new ParseException( "Attribute 'value-type' is not valid", e, getLocator() ); } }
private String parseNamespace( final Attributes attrs ) throws ParseException { String namespace = attrs.getValue( getUri(), "namespace" ); if ( namespace == null ) { throw new ParseException( "Attribute 'namespace' is undefined", getLocator() ); } return namespace; }
protected String parseName( final Attributes attrs ) throws ParseException { String name = attrs.getValue( getUri(), "name" ); // NON-NLS if ( name == null ) { throw new ParseException( "Attribute 'name' is undefined", getLocator() ); } return name; }
private Class<? extends ElementType> parseElementType( final Attributes attrs ) throws ParseException { final String elementTypeText = attrs.getValue( getUri(), "implementation" ); if ( elementTypeText == null ) { throw new ParseException( "Attribute 'implementation' is undefined", getLocator() ); } Class<? extends ElementType> c = ObjectUtilities.loadAndValidate( elementTypeText, ElementReadHandler.class, ElementType.class ); if ( c == null ) { throw new ParseException( "Attribute 'implementation' is not valid", getLocator() ); } return c; }
/** * Starts parsing. * * @param attrs the attributes. * @throws SAXException if there is a parsing error. */ protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); name = attrs.getValue( getUri(), nameAttribute ); if ( nameMandatory && name == null ) { throw new ParseException( "Required attribute '" + nameAttribute + "' missing", getLocator() ); } }
protected Element createElement() throws ParseException { try { final ElementType elementTypeObj = metaData.create(); return (Element) elementTypeObj.create(); } catch ( InstantiationException e ) { // This should not happen at this point, as there is no way to instantiate the class if the // element is not there. But it could happen if the element is not registered, which indicates // a user error (Engine not booted). throw new ParseException( "Unable to instantiate element for type '" + metaData.getName() + '"' ); } }
@Override public void startParsing( PropertyAttributes attrs ) throws SAXException { propertyName = attrs.getValue( getUri(), ExpressionPropertyReadHandler.NAME_ATT ); if ( propertyName == null ) { throw new ParseException( "Required attribute 'name' is null.", getLocator() ); } }
protected void startParsing( final Attributes attrs ) throws SAXException { name = attrs.getValue( getUri(), "name" ); if ( StringUtils.isEmpty( name ) ) { throw new ParseException( "Attribute 'name' is not defined.", getLocator() ); } super.startParsing( attrs ); }
private void handleFieldName( final PropertyAttributes atts ) throws SAXException { final String fieldName = atts.getValue( getUri(), "fieldname" ); if ( fieldName == null ) { throw new ParseException( "Required attribute 'fieldname' is missing.", getLocator() ); } elementFactory.setFieldname( fieldName ); }
private int parseOrDie( final String attrName, final Attributes attrs ) throws ParseException { final String value = attrs.getValue( getUri(), attrName ); if ( StringUtils.isEmpty( value ) ) { throw new ParseException( "Attribute '" + attrName + "' is missing.", getLocator() ); } try { return Integer.parseInt( value ); } catch ( Exception e ) { throw new ParseException( "Attribute '" + attrName + "' with value '" + value + "'is invalid.", getLocator() ); } } }
private long parseLongOrDie( final String attrName, final Attributes attrs ) throws ParseException { final String value = attrs.getValue( getUri(), attrName ); if ( StringUtils.isEmpty( value ) ) { throw new ParseException( "Attribute '" + attrName + "' is missing.", getLocator() ); } try { return Long.parseLong( value ); } catch ( Exception e ) { throw new ParseException( "Attribute '" + attrName + "' with value '" + value + "'is invalid.", getLocator() ); } }
private int parseOrDie( final String attrName, final Attributes attrs ) throws ParseException { final String value = attrs.getValue( getUri(), attrName ); if ( StringUtils.isEmpty( value ) ) { throw new ParseException( "Attribute '" + attrName + "' is missing.", getLocator() ); } try { return Integer.parseInt( value ); } catch ( Exception e ) { throw new ParseException( "Attribute '" + attrName + "' with value '" + value + "'is invalid.", getLocator() ); } } }
protected void startParsing( final PropertyAttributes attrs ) throws SAXException { name = attrs.getValue( getUri(), "name" ); if ( name == null ) { throw new ParseException( "Required attribute 'name' is missing.", getLocator() ); } alias = attrs.getValue( getUri(), "alias" ); if ( alias == null ) { alias = name; } }
protected void startParsing( final Attributes attrs ) throws SAXException { final float pageWidth = ParserUtil.parseFloat( attrs.getValue( getUri(), "page-width" ), "No page width given?" ); if ( pageWidth <= 0 ) { throw new ParseException( "The page-width must be greater than zero" ); } validationSequence.setPageWidth( (int) pageWidth ); final String mode = attrs.getValue( getUri(), "mode" ); validationSequence.setStrict( "strict".equals( mode ) ); }
protected void doneParsing() throws SAXException { super.doneParsing(); try { final NamespaceCollection namespaceCollection = StyleSheetParserUtil.getInstance().getNamespaceCollection(); final SelectorList selectorList = StyleSheetParserUtil.getInstance().parseSelector( namespaceCollection, getResult() ); for ( int i = 0; i < selectorList.getLength(); i += 1 ) { selector.add( (CSSSelector) selectorList.item( i ) ); } } catch ( CSSParseException e ) { throw new ParseException( "Failed to parse selector", e, getLocator() ); } }
protected void startParsing( final Attributes attrs ) throws SAXException { source = attrs.getValue( getUri(), "source" ); if ( StringUtils.isEmpty( source ) ) { throw new ParseException( "Mandatory attribute 'source' is missing", getLocator() ); } localFontMetricsBase = new LocalFontMetricsBase(); }
protected void autoInit() throws ParseException { String tagName = getTagName(); String uri = getUri(); ElementMetaData elementType = ElementTypeRegistry.getInstance().getElementType( tagName ); if ( ObjectUtilities.equal( uri, elementType.getNamespace() ) == false ) { throw new ParseException( "Metadata not registered, and auto-registration does not match namespace" ); } this.metaData = elementType; this.element = createElement(); }
@Override public void startParsing( PropertyAttributes attrs ) throws SAXException { propertyName = attrs.getValue( getUri(), ExpressionPropertyReadHandler.NAME_ATT ); if ( propertyName == null ) { throw new ParseException( "Required attribute 'name' is null.", getLocator() ); } }