/** * Creates a Resource object for the given product. By default this returns a compound-resource that holds all the key * that identify the resources used during the content production. * * @param targetKey the target key. * @param handler the root handler used for the parsing. * @param createdProduct the created product. * @param createdType the type information for the object that has been parsed. * @return the product wrapped into a resource object. */ protected Resource createResource( final ResourceKey targetKey, final RootXmlReadHandler handler, final Object createdProduct, final Class createdType ) { return new CompoundResource( targetKey, handler.getDependencyCollector(), createdProduct, createdType ); }
public Object getResource() throws ResourceException { try { final Object resource = super.getResource(); if ( cloneable ) { return ObjectUtilities.clone( resource ); } return resource; } catch ( CloneNotSupportedException e ) { throw new ResourceException( "Unable to retrieve the resource.", e ); } } }
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 ); } }
return new CompoundResource ( data.getKey(), dependencies, handler.getStyleSheet(), getFactoryType() ); } catch ( CSSParserInstantiationException e ) {
throw new ResourceCreationException( "Damn, the style rule is null" ); return new CompoundResource( data.getKey(), dependencies, styleRule, getFactoryType() ); } catch ( CSSParserInstantiationException e ) { throw new ResourceCreationException( "Failed to parse the stylesheet." );