/** * Creates a new InputSource using the given resource-data and resource-manager as source. * * @param data the resource-data object holding the raw-data. * @param caller the resource manager that is loading the current resource. * @throws ResourceLoadingException if an error occurs. * @see #setPublicId * @see #setSystemId * @see #setByteStream * @see #setCharacterStream * @see #setEncoding */ public ResourceDataInputSource( final ResourceData data, final ResourceManager caller ) throws ResourceLoadingException { if ( data == null ) { throw new NullPointerException( "Data must not be null" ); } if ( caller == null ) { throw new NullPointerException( "ResourceManager must not be null" ); } this.data = data; this.version = data.getVersion( caller ); this.caller = caller; final URL url = caller.toURL( data.getKey() ); if ( url != null ) { setSystemId( url.toExternalForm() ); } }
private int getImageFormat( final ResourceKey key ) { final URL url = resourceManager.toURL( key ); if ( url == null ) { return -1; } final String file = url.getFile(); if ( StringUtils.endsWithIgnoreCase( file, ".png" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_PNG; } if ( StringUtils.endsWithIgnoreCase( file, ".jpg" ) || // NON-NLS StringUtils.endsWithIgnoreCase( file, ".jpeg" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_JPEG; } if ( StringUtils.endsWithIgnoreCase( file, ".bmp" ) || // NON-NLS StringUtils.endsWithIgnoreCase( file, ".ico" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_DIB; } return -1; }
final DocumentLoader loader = new DocumentLoader( userAgent ); final ResourceKey key = data.getKey(); URL url = caller.toURL( key ); if ( url == null ) { url = new File( "." ).toURI().toURL();
/** * Builds a default configuration from a given report definition object. * <p/> * This will only create a valid definition, if the report has a valid content base object set. * * @param report * the report for which to create the writer configuration. * @return the generated configuration. */ public static Configuration createDefaultConfiguration( final MasterReport report ) { final ModifiableConfiguration repConf = new HierarchicalConfiguration( report.getReportConfiguration() ); final ResourceKey contentBase = report.getContentBase(); if ( contentBase != null ) { final ResourceManager resourceManager = report.getResourceManager(); final URL value = resourceManager.toURL( contentBase ); if ( value != null ) { repConf.setConfigProperty( AbstractXmlResourceFactory.CONTENTBASE_KEY, value.toExternalForm() ); } } return repConf; }
final URL url = resourceManager.toURL( key ); if ( url == null ) { return false;
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { try { final long version = data.getVersion( caller ); final HeadlessSVGUserAgent userAgent = new HeadlessSVGUserAgent(); final DocumentLoader loader = new DocumentLoader( userAgent ); final ResourceKey key = data.getKey(); URL url = caller.toURL( key ); if ( url == null ) { url = new File( "." ).toURI().toURL(); } final SVGDocument document = (SVGDocument) loader.loadDocument ( url.toURI().toASCIIString(), data.getResourceAsStream( caller ) ); final BridgeContext ctx = new BridgeContext( userAgent, loader ); final GVTBuilder builder = new GVTBuilder(); final GraphicsNode node = builder.build( ctx, document ); return new SimpleResource( data.getKey(), new SVGDrawable( node ), DrawableWrapper.class, version ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to process SVG file", e ); } catch ( URISyntaxException e ) { throw new ResourceLoadingException( "Failed to process SVG file", e ); } }
final URL value = manager.toURL( contextKey ); if ( value != null ) { parserConfiguration.setConfigProperty( CONTENTBASE_KEY, value.toExternalForm() );
/** * Starts parsing. * * @param atts * the attributes. * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected void startParsing( final PropertyAttributes atts ) throws SAXException { super.startParsing( atts ); final String content = atts.getValue( getUri(), "src" ); if ( content == null ) { throw new SAXException( "Required attribute 'src' is missing." ); } elementFactory.setContent( content ); final ResourceManager resourceManager = getRootHandler().getResourceManager(); elementFactory.setBaseURL( resourceManager.toURL( getRootHandler().getContext() ) ); }
/** * Starts parsing. * * @param atts * the attributes. * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected void startParsing( final PropertyAttributes atts ) throws SAXException { super.startParsing( atts ); final String fieldName = atts.getValue( getUri(), "fieldname" ); if ( fieldName == null ) { throw new SAXException( "Required attribute 'fieldname' is missing." ); } elementFactory.setFieldname( fieldName ); final ResourceManager resourceManager = getRootHandler().getResourceManager(); elementFactory.setBaseURL( resourceManager.toURL( getRootHandler().getContext() ) ); }
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 ) ); }
final ResourceKey baseKey = process.getContextKey(); final ResourceManager resourceManager = process.getResourceManager(); final URL url = resourceManager.toURL( baseKey ); if ( url != null ) { return new StaticTextToken( url.toExternalForm() );
final URL value = manager.toURL( contextKey ); if ( value != null ) { parserConfiguration.setConfigProperty( CONTENTBASE_KEY, value.toExternalForm() );
final ResourceKey baseKey = process.getContextKey(); final ResourceManager resourceManager = process.getResourceManager(); final URL url = resourceManager.toURL( baseKey ); if ( url != null ) { return new StaticTextToken( url.toExternalForm() );
private ContentToken createToken( final DocumentContext process, final LayoutElement element, final CSSValue content ) { if ( content instanceof CSSStringValue ) { final CSSStringValue sval = (CSSStringValue) content; if ( CSSStringType.STRING.equals( sval.getType() ) ) { return new StaticTextToken( sval.getValue() ); } else { // this is an external URL, so try to load it. final CSSFunctionValue function = new CSSFunctionValue ( "url", new CSSValue[] { sval } ); return evaluateFunction( function, process, element ); } } if ( content instanceof CSSFunctionValue ) { return evaluateFunction( (CSSFunctionValue) content, process, element ); } if ( content instanceof CSSConstant ) { if ( ContentValues.DOCUMENT_URL.equals( content ) ) { final ResourceKey baseKey = process.getContextKey(); final ResourceManager resourceManager = process.getResourceManager(); final URL url = resourceManager.toURL( baseKey ); if ( url != null ) { return new StaticTextToken( url.toExternalForm() ); } return null; } } return null; }
final byte[] imageData = data.getResource( resourceManager ); final String mimeType = queryMimeType( imageData ); final URL maybeRealURL = resourceManager.toURL( url ); if ( maybeRealURL != null ) { final String originalFileName = IOUtils.getInstance().getFileName( maybeRealURL ); final String originalFileName; if ( url != null ) { final URL maybeRealURL = resourceManager.toURL( url ); if ( maybeRealURL != null ) { originalFileName = IOUtils.getInstance().getFileName( maybeRealURL );