/** * 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 ); }
/** * This method is called at the end of an element. * * @param tagName the tag name. * @throws SAXException if there is a parsing error. */ public final void endElement( final String uri, final String tagName ) throws SAXException { if ( this.tagName.equals( tagName ) && this.uri.equals( uri ) ) { doneParsing(); this.rootHandler.unwind( uri, tagName ); } else { throw new ParseException( "Illegal Parser State." + toString(), getLocator() ); } }
/** * Parses an external file using LibLoader and returns the parsed result as an object of type * <code>targetClass</code>. The file is given as relative pathname (relative to the current source file). The current * helper-methods are used as parse-parameters for the external parsing. * * @param file the file to be parsed. * @param targetClass the target type of the parse operation. * @return the result, never null. * @throws ParseException if parsing the result failed for some reason. * @throws ResourceLoadingException if there was an IO error loading the resource. * @see #deriveParseParameters() * @see #performExternalParsing(String, Class, Map) */ protected Object performExternalParsing( final String file, final Class targetClass ) throws ParseException, ResourceLoadingException { return performExternalParsing( file, targetClass, deriveParseParameters() ); }
if ( !this.tagName.equals( tagName ) || !this.uri.equals( uri ) ) { throw new ParseException( "Expected <" + this.tagName + ">, found <" + tagName + '>', getLocator() ); startParsing( attrs ); } else { final XmlReadHandler childHandler = getHandlerForChild( uri, tagName, attrs ); if ( childHandler == null ) { logger.warn( "Unknown tag <" + uri + ':' + tagName + ">: Start to ignore this element and all of its childs. " + getLocatorString() ); logger.debug( this.getClass() ); final IgnoreAnyChildReadHandler ignoreAnyChildReadHandler = new IgnoreAnyChildReadHandler(); ignoreAnyChildReadHandler.init( getRootHandler(), uri, tagName ); this.rootHandler.recurse( ignoreAnyChildReadHandler, uri, tagName, attrs ); } else { childHandler.init( getRootHandler(), uri, tagName ); this.rootHandler.recurse( childHandler, uri, tagName, attrs );
super.doneParsing(); // To change body of overridden methods use File | Settings | File Templates. if ( pageHeaderReadHandler != null ) { report.setPageHeader( (PageHeader) pageHeaderReadHandler.getElement() );
/** * Computes a string containing the current parse location or an empty string if there is no locator. * * @return the location as debug-text. */ private String getLocatorString() { final Locator locator = getLocator(); if ( locator == null ) { return ""; } final StringBuffer message = new StringBuffer( 100 ); message.append( " [Location: Line=" ); message.append( locator.getLineNumber() ); message.append( " Column=" ); message.append( locator.getColumnNumber() ); message.append( "] " ); return message.toString(); }
/** * Creates a working copy of the current parse state. * * @return the derived parse-parameters. * @noinspection ObjectAllocationInLoop as this is a cloning operation. */ protected Map deriveParseParameters() { final RootXmlReadHandler rootHandler = getRootHandler(); final HashMap map = new HashMap(); final String[] names = rootHandler.getHelperObjectNames(); final int length = names.length; for ( int i = 0; i < length; i++ ) { final String name = names[ i ]; final FactoryParameterKey key = new FactoryParameterKey( name ); map.put( key, rootHandler.getHelperObject( name ) ); } return map; } }
/** * Parses an external file using LibLoader and returns the parsed result as an object of type * <code>targetClass</code>. The file is given as relative pathname (relative to the current source file). The current * helper-methods are used as parse-parameters for the external parsing. * * @param file the file to be parsed. * @param targetClass the target type of the parse operation. * @param map the map of parse parameters. * @return the result, never null. * @throws ParseException if parsing the result failed for some reason. * @throws ResourceLoadingException if there was an IO error loading the resource. * @see #deriveParseParameters() */ protected Object performExternalParsing( final String file, final Class targetClass, final Map map ) throws ParseException, ResourceLoadingException { try { final ResourceManager resourceManager = rootHandler.getResourceManager(); final ResourceKey source = rootHandler.getSource(); final ResourceKey target = resourceManager.deriveKey( source, file, map ); final DependencyCollector dc = rootHandler.getDependencyCollector(); final Resource resource = resourceManager.create( target, rootHandler.getContext(), targetClass ); dc.add( resource ); return resource.getResource(); } catch ( ResourceLoadingException rle ) { throw rle; } catch ( ResourceException e ) { throw new ParseException( "Failure while loading data: " + file, e, getLocator() ); } }
protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); }
/** * Starts parsing. * * @param attrs the attributes. * @throws org.xml.sax.SAXException if there is a parsing error. */ protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); name = attrs.getValue( ODFMetaAttributeNames.Meta.NAMESPACE, "name" ); valueType = attrs.getValue( ODFMetaAttributeNames.Meta.NAMESPACE, "value-type" ); value = attrs.getValue( ODFMetaAttributeNames.Office.NAMESPACE, "value" ); }
super.startParsing( attrs ); final String shape = attrs.getValue( getUri(), "shape" ); final String coordinates = attrs.getValue( getUri(), "coords" );
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 ); }
protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); table.setResultCell( row, column, null ); }
/** * 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 ); final ResourceManager resourceManager = getRootHandler().getResourceManager(); final ResourceKey context = getRootHandler().getContext(); final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig(); final Iterator keys = configuration.findPropertyKeys( ElementMetaDataParser.GLOBAL_INCLUDES_PREFIX ); while ( keys.hasNext() ) { final String key = (String) keys.next(); final String href = configuration.getConfigProperty( key ); if ( StringUtils.isEmpty( href, true ) ) { continue; } try { final ResourceKey resourceKey = resourceManager.deriveKey( context, href ); final Resource resource = resourceManager.create( resourceKey, null, GlobalMetaDefinition.class ); globalMetaDefinition.merge( (GlobalMetaDefinition) resource.getResource() ); } catch ( ResourceException e ) { logger.warn( "Failed to parse included global definitions: " + getLocator(), e ); } } }