public void init( final StyleKeyRegistry styleKeyRegistry, final ResourceManager resourceManager, final ResourceKey source, final long version, final StyleRule parentRule ) { if ( styleKeyRegistry == null ) { throw new NullPointerException(); } if ( resourceManager == null ) { throw new NullPointerException(); } this.styleKeyRegistry = styleKeyRegistry; this.resourceManager = resourceManager; this.source = source; if ( source != null ) { this.dependencies = new DependencyCollector( source, version ); } this.parentRules.clear(); if ( parentRule != null ) { parentRules.push( parentRule ); } this.namespaces.clear(); }
/** * Creates a new root-handler using the given versioning information and resource-manager. * * @param manager the resource manager that loaded this xml-file. * @param source the source-key that identifies from where the file was loaded. * @param context the key that should be used to resolve relative paths. * @param version the versioning information for the root-file. */ public RootXmlReadHandler( final ResourceManager manager, final ResourceKey source, final ResourceKey context, final long version ) { if ( manager == null ) { throw new NullPointerException(); } if ( source == null ) { throw new NullPointerException(); } this.firstCall = true; this.manager = manager; this.source = source; this.context = context; this.dependencyCollector = new DependencyCollector( source, version ); this.objectRegistry = new HashMap<String, Object>(); this.parserConfiguration = new DefaultConfiguration(); this.commentHandler = new CommentHandler(); this.namespaces = new FastStack<String>(); }
public Resource create( final ResourceManager manager, final ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { final ResourceKey key = data.getKey(); final Map factoryParameters = key.getFactoryParameters(); final boolean embedded = Boolean.TRUE.equals( factoryParameters.get( BaseFontResourceFactory.EMBEDDED ) ); final String encoding = String.valueOf( factoryParameters.get( BaseFontResourceFactory.ENCODING ) ); final String fontType = String.valueOf( factoryParameters.get( BaseFontResourceFactory.FONTNAME ) ); final DependencyCollector dc = new DependencyCollector( key, data.getVersion( manager ) ); final byte[] ttfAfm = data.getResource( manager ); byte[] pfb = null; if ( embedded && ( fontType.endsWith( ".afm" ) || fontType.endsWith( ".pfm" ) ) ) { final String pfbFileName = fontType.substring( 0, fontType.length() - 4 ) + ".pfb"; try { final ResourceKey pfbKey = manager.deriveKey( key, pfbFileName ); final ResourceData res = manager.load( pfbKey ); pfb = res.getResource( manager ); dc.add( pfbKey, res.getVersion( manager ) ); } catch ( ResourceException e ) { // ignore .. } } try { final BaseFont baseFont = BaseFont.createFont( fontType, encoding, embedded, false, ttfAfm, pfb ); return new CompoundResource( key, dc, baseFont, getFactoryType() ); } catch ( Exception e ) { throw new ResourceCreationException( "Failed to create the font " + fontType, e ); } }