protected Resource createResource( final ResourceKey targetKey, final RootXmlReadHandler handler, final Object createdProduct, final Class createdType ) { if ( ReportParserUtil.INCLUDE_PARSING_VALUE .equals( handler.getHelperObject( ReportParserUtil.INCLUDE_PARSING_KEY ) ) ) { return new ReportResource( targetKey, handler.getDependencyCollector(), createdProduct, createdType, false ); } return new ReportResource( targetKey, handler.getDependencyCollector(), createdProduct, createdType, true ); }
/** * Returns the locator as provided by the XML parser. This method may return null if the XML parser has no locator * support. * * @return the locator or null. */ public Locator getLocator() { return rootHandler.getDocumentLocator(); }
/** * 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; } }
/** * Process character data. * * @param ch the character buffer. * @param start the start index. * @param length the length of the character data. * @throws SAXException if there is a parsing error. */ public void characters( final char[] ch, final int start, final int length ) throws SAXException { try { getCurrentHandler().characters( ch, start, length ); } catch ( SAXException se ) { throw se; } catch ( Exception e ) { throw new ParseException ( "Failed at handling character data", e, getDocumentLocator() ); } }
final String file = attrs.getValue( getUri(), "src" ); if ( file == null ) { throw new ParseException( "Required attribute 'src' is missing.", getRootHandler().getDocumentLocator() ); final ResourceManager resourceManager = rootHandler.getResourceManager(); final ResourceKey source = rootHandler.getSource(); final String[] names = rootHandler.getHelperObjectNames(); for ( int i = 0; i < names.length; i++ ) { final String name = names[i]; final FactoryParameterKey key = new FactoryParameterKey( name ); map.put( key, rootHandler.getHelperObject( name ) ); final DependencyCollector dc = rootHandler.getDependencyCollector(); final Object maybeReport = getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); if ( maybeReport == null ) { throw new ParseException( "Illegal State: No valid report", getRootHandler().getDocumentLocator() ); targetType = MasterReport.class; } else { throw new ParseException( "Illegal State: No valid report", getRootHandler().getDocumentLocator() ); final Resource resource = resourceManager.create( target, rootHandler.getContext(), targetType ); dc.add( resource );
final Object maybeReport = rootHandler.getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); final SubReport report; if ( maybeReport instanceof SubReport == false ) { report.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); } else { report = (SubReport) maybeReport; if ( rootHandler.getHelperObject( ExtSubReportReadHandler.ELEMENT_FACTORY_KEY ) == null ) { final ElementFactoryCollector elementFactory = new ElementFactoryCollector(); rootHandler.setHelperObject( ExtSubReportReadHandler.ELEMENT_FACTORY_KEY, elementFactory ); if ( rootHandler.getHelperObject( ExtSubReportReadHandler.STYLE_FACTORY_KEY ) == null ) { final StyleKeyFactoryCollector styleKeyFactory = new StyleKeyFactoryCollector(); rootHandler.setHelperObject( ExtSubReportReadHandler.STYLE_FACTORY_KEY, styleKeyFactory ); if ( rootHandler.getHelperObject( ExtSubReportReadHandler.CLASS_FACTORY_KEY ) == null ) { final ClassFactoryCollector classFactory = new ClassFactoryCollector(); classFactory.configure( rootHandler.getParserConfiguration() ); rootHandler.setHelperObject( ExtSubReportReadHandler.CLASS_FACTORY_KEY, classFactory ); if ( rootHandler.getHelperObject( ExtSubReportReadHandler.DATASOURCE_FACTORY_KEY ) == null ) { final DataSourceCollector dataSourceFactory = new DataSourceCollector(); dataSourceFactory.configure( rootHandler.getParserConfiguration() ); rootHandler.setHelperObject( ExtSubReportReadHandler.DATASOURCE_FACTORY_KEY, dataSourceFactory ); if ( rootHandler.getHelperObject( ExtSubReportReadHandler.TEMPLATE_FACTORY_KEY ) == null ) { final TemplateCollector templateFactory = new TemplateCollector(); templateFactory.configure( rootHandler.getParserConfiguration() );
final RootXmlReadHandler handler = createRootHandler( manager, targetKey, rootHandlers, contextKey, -1 ); final DefaultConfiguration parserConfiguration = handler.getParserConfiguration(); final URL value = manager.toURL( contextKey ); if ( value != null ) { reader.setContentHandler( handler ); reader.setDTDHandler( handler ); reader.setEntityResolver( handler.getEntityResolver() ); reader.setErrorHandler( getErrorHandler() ); if ( o instanceof FactoryParameterKey ) { final FactoryParameterKey fpk = (FactoryParameterKey) o; handler.setHelperObject( fpk.getName(), parameters.get( fpk ) ); return finishResult( handler.getResult(), manager, new RawResourceData( targetKey ), contextKey ); } catch ( ParserConfigurationException e ) { throw new ResourceCreationException
protected Object performInitialLookup( final String name ) { return rootXmlReadHandler.getHelperObject( name ); } }
final Object maybeReport = getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); if ( maybeReport instanceof MasterReport == false ) { report.setAttribute( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.FILEFORMAT, "unified-fileformat" ); final ResourceKey key = getRootHandler().getSource(); if ( key.getParent() != null ) { final ResourceManager resourceManager = getRootHandler().getResourceManager(); try { final Resource bundleData = resourceManager.create( key.getParent(), null, DocumentBundle.class ); || ( versionMajorRaw == 0 && versionMinorRaw == 0 && versionPatchRaw == 0 ) ) { getRootHandler().setHelperObject( PRPT_SPEC_VERSION, ClassicEngineBoot.computeVersionId( 3, 8, 0 ) ); } else { validateVersionNumbers( versionMajorRaw, versionMinorRaw, versionPatchRaw ); getRootHandler().setHelperObject( PRPT_SPEC_VERSION, ClassicEngineBoot.computeVersionId( versionMajorRaw, versionMinorRaw, versionPatchRaw ) ); getRootHandler().warning( new SAXParseException( "Unable to load the bundle. Bundle data may be unavailable.", getLocator() ) );
String className = CompatibilityMapperUtil.mapClassName( attrs.getValue( getUri(), "class" ) ); if ( className == null ) { throw new ParseException( "Attribute 'class' is missing.", getRootHandler().getDocumentLocator() ); (ClassFactoryCollector) getRootHandler().getHelperObject( ReportDefinitionReadHandler.CLASS_FACTORY_KEY ); factory.configure( getRootHandler().getParserConfiguration() ); fc.addFactory( factory );
/** * 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() ); } }
private void handleSource( final PropertyAttributes atts ) { final ResourceManager resourceManager = getRootHandler().getResourceManager(); elementFactory.setBaseURL( resourceManager.toURL( getRootHandler().getContext() ) ); elementFactory.setContent( atts.getValue( getUri(), ImageRefReadHandler.SRC_ATT ) ); }
if ( rootHandler.getHelperObject( ReportDefinitionReadHandler.ELEMENT_FACTORY_KEY ) == null || rootHandler.getHelperObject( ReportDefinitionReadHandler.STYLE_FACTORY_KEY ) == null || rootHandler.getHelperObject( ReportDefinitionReadHandler.CLASS_FACTORY_KEY ) == null || rootHandler.getHelperObject( ReportDefinitionReadHandler.DATASOURCE_FACTORY_KEY ) == null || rootHandler.getHelperObject( ReportDefinitionReadHandler.TEMPLATE_FACTORY_KEY ) == null ) { final ElementFactoryCollector elementFactory = new ElementFactoryCollector(); elementFactory.addFactory( new DefaultElementFactory() ); templateFactory.addTemplateCollection( new DefaultTemplateCollection() ); classFactory.configure( rootHandler.getParserConfiguration() ); dataSourceFactory.configure( rootHandler.getParserConfiguration() ); templateFactory.configure( rootHandler.getParserConfiguration() ); rootHandler.setHelperObject( ReportDefinitionReadHandler.ELEMENT_FACTORY_KEY, elementFactory ); rootHandler.setHelperObject( ReportDefinitionReadHandler.STYLE_FACTORY_KEY, styleKeyFactory ); rootHandler.setHelperObject( ReportDefinitionReadHandler.CLASS_FACTORY_KEY, classFactory ); rootHandler.setHelperObject( ReportDefinitionReadHandler.DATASOURCE_FACTORY_KEY, dataSourceFactory ); rootHandler.setHelperObject( ReportDefinitionReadHandler.TEMPLATE_FACTORY_KEY, templateFactory );
final Object maybeReport = rootHandler.getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); if ( maybeReport instanceof SubReport ) { report = (SubReport) maybeReport; } else { report = new SubReport(); report.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, rootHandler.getSource() ); if ( rootHandler.getHelperObject( ReportParserUtil.HELPER_OBJ_LEGACY_STYLES ) instanceof HashMap == false ) { rootHandler.setHelperObject( ReportParserUtil.HELPER_OBJ_LEGACY_STYLES, new HashMap<String, ElementStyleSheet>() ); rootHandler.setHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME, report );
/** * Starts parsing. * * @param attrs * the attributes. * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected void startParsing( final PropertyAttributes attrs ) throws SAXException { final String className = CompatibilityMapperUtil.mapClassName( attrs.getValue( getUri(), "class" ) ); if ( className == null ) { throw new ParseException( "Attribute 'class' is missing.", getRootHandler().getDocumentLocator() ); } final StyleKeyFactoryCollector fc = (StyleKeyFactoryCollector) getRootHandler().getHelperObject( ReportDefinitionReadHandler.STYLE_FACTORY_KEY ); final StyleKeyFactory factory = (StyleKeyFactory) ObjectUtilities.loadAndInstantiate( className, getClass(), StyleKeyFactory.class ); fc.addFactory( factory ); }
/** * Starts parsing. * * @param attrs * the attributes. * @throws SAXException * if there is a parsing error. */ protected void startParsing( final Attributes attrs ) throws SAXException { final Object maybeReport = getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); if ( maybeReport instanceof SubReport == false ) { // replace it .. report = new SubReport(); getRootHandler().setHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME, report ); } else { report = (SubReport) maybeReport; } }
final ResourceKey key = getRootHandler().getSource(); final ResourceManager manager = getRootHandler().getResourceManager(); try { final ResourceKey derivedKey = manager.deriveKey( key, href ); final Resource resource = manager.create( derivedKey, null, DataFactory.class ); getRootHandler().getDependencyCollector().add( resource ); dataFactory = (DataFactory) resource.getResource(); } catch ( ResourceKeyCreationException e ) {
/** * Initialises the handler. * * @param rootHandler * the root handler. * @param tagName * the tag name. */ public void init( final RootXmlReadHandler rootHandler, final String uri, final String tagName ) throws SAXException { super.init( rootHandler, uri, tagName ); rootHandler.setHelperObject( "property-expansion", Boolean.TRUE ); }
protected Resource createResource( final ResourceKey targetKey, final RootXmlReadHandler handler, final Object createdProduct, final Class createdType ) { return new ReportResource( targetKey, handler.getDependencyCollector(), createdProduct, createdType, true ); } }
/** * Starts parsing. * * @param attrs * the attributes. * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected void startParsing( final PropertyAttributes attrs ) throws SAXException { final String groupName = attrs.getValue( getUri(), GroupReadHandler.NAME_ATT ); if ( groupName != null ) { final AbstractReportDefinition report = (AbstractReportDefinition) getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); final Group maybeDefaultGroup = report.getGroupByName( groupName ); if ( maybeDefaultGroup instanceof RelationalGroup ) { group = (RelationalGroup) maybeDefaultGroup; } else { group = new RelationalGroup(); group.setName( groupName ); group.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); } } else { group = new RelationalGroup(); group.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.SOURCE, getRootHandler().getSource() ); } }