public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { throw new ResourceLoadingException( "This resource Loader cannot be used to create a ResourceData object." ); }
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException { if ( caller == null ) { throw new NullPointerException(); } if ( contentItem == null ) { throw new ResourceLoadingException( "Failure: Missing data" ); } try { return contentItem.getInputStream(); } catch ( ContentIOException cioe ) { throw new ResourceLoadingException( "Failure", cioe ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failure", e ); } }
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException { if ( caller == null ) { throw new NullPointerException(); } try { final int buffer = (int) Math.max( 4096, Math.min( file.length(), 128 * 1024 ) ); return new BufferedInputStream( new FileInputStream( file ), buffer ); } catch ( FileNotFoundException e ) { throw new ResourceLoadingException( "Unable to open Stream: ", e ); } }
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException { final InputStream stream = ObjectUtilities.getResourceAsStream ( resourcePath, ClassloaderResourceData.class ); if ( stream == null ) { throw new ResourceLoadingException( "Resource is not available: " + resourcePath ); } return stream; }
public FileResourceData( final ResourceKey key ) throws ResourceLoadingException { if ( key == null ) { throw new NullPointerException(); } final File file = (File) key.getIdentifier(); if ( file.exists() == false ) { throw new ResourceLoadingException ( "File-handle given does not point to an existing file." ); } if ( file.isFile() == false ) { throw new ResourceLoadingException ( "File-handle given does not point to a regular file." ); } if ( file.canRead() == false ) { throw new ResourceLoadingException ( "File '" + file + "' is not readable." ); } this.key = key; this.file = file; }
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException { try { final URLConnection c = url.openConnection(); c.setDoOutput( false ); c.setAllowUserInteraction( false ); c.connect(); if ( isFixBrokenWebServiceDateHeader() == false ) { readMetaData( c ); } return c.getInputStream(); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to open URL connection", e ); } }
public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { if ( isSupportedKey( key ) == false ) { throw new ResourceLoadingException( "Key format is not recognized." ); } return new URLResourceData( key ); }
public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { if ( isSupportedKey( key ) == false ) { throw new ResourceLoadingException( "Key format is not recognized." ); } return new ZipResourceData( key ); }
public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { if ( isSupportedKey( key ) == false ) { throw new ResourceLoadingException( "Key format is not recognized." ); } return new FileResourceData( key ); }
public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { if ( isSupportedKey( key ) == false ) { throw new ResourceLoadingException( "The key type is not supported." ); } return new RawResourceData( key ); }
public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { if ( isSupportedKey( key ) == false ) { throw new ResourceLoadingException( "Key format is not recognized." ); } return new ClassloaderResourceData( key ); }
public byte[] getResource( final ResourceManager caller ) throws ResourceLoadingException { try { final InputStream in = getResourceAsStream( caller ); if ( in == null ) { throw new ResourceLoadingException( "Unable to read Stream: No input stream: " + getKey() ); } try { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); IOUtils.getInstance().copyStreams( in, bout ); return bout.toByteArray(); } finally { in.close(); } } catch ( ResourceLoadingException rle ) { throw rle; } catch ( IOException e ) { throw new ResourceLoadingException( "Unable to read Stream: ", e ); } }
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException { // again, this is going to hurt the performance. final ResourceKey parentKey = key.getParent(); final ResourceData data = caller.load( parentKey ); final ZipInputStream zin = new ZipInputStream( data.getResourceAsStream( caller ) ); try { try { ZipEntry zipEntry = zin.getNextEntry(); while ( zipEntry != null ) { if ( zipEntry.getName().equals( key.getIdentifier() ) == false ) { zipEntry = zin.getNextEntry(); continue; } // read from here .. return zin; } } finally { zin.close(); } } catch ( IOException e ) { throw new ResourceLoadingException ( "Reading the zip-file failed.", e ); } throw new ResourceLoadingException ( "The zip-file did not contain the specified entry" ); }
public Resource create( final ResourceManager manager, final ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { try { final Properties properties = new Properties(); final InputStream stream = data.getResourceAsStream( manager ); try { properties.load( stream ); } finally { stream.close(); } return new SimpleResource( data.getKey(), properties, Properties.class, data.getVersion( manager ) ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to load the properties file.", e ); } }
return new SimpleResource( data.getKey(), bi, Image.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 );
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { try { final long version = data.getVersion( caller ); final InputStream stream = data.getResourceAsStream( caller ); try { final WmfFile wmfFile = new WmfFile( stream, -1, -1 ); return new SimpleResource( data.getKey(), wmfFile, DrawableWrapper.class, version ); } finally { stream.close(); } } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to process WMF file", e ); } }
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { try { final long version = data.getVersion( caller ); final InputStream stream = data.getResourceAsStream( caller ); try { final WmfFile wmfFile = new WmfFile( stream, -1, -1 ); final Image image = wmfFile.replay(); return new SimpleResource( data.getKey(), image, Image.class, version ); } finally { stream.close(); } } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to process WMF file", e ); } }
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 ); } }
public Resource create( final ResourceManager manager, final ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { try { final InputStream in = data.getResourceAsStream( manager ); final ObjectInputStream oin = new ObjectInputStream( in ); try { final Object ob = oin.readObject(); // yes, that will be more generic in the future ... if ( ob instanceof External8BitEncodingData == false ) { throw new ResourceCreationException( "This is no 8Bit Encoding data" ); } final External8BitEncodingData encData = (External8BitEncodingData) ob; final External8BitEncodingCore encCore = new External8BitEncodingCore( encData ); return new SimpleResource( data.getKey(), encCore, getFactoryType(), data.getVersion( manager ) ); } finally { oin.close(); } } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to load resource", e ); } catch ( ClassNotFoundException e ) { throw new ResourceCreationException ( "Missing class definition: Failed to create encoding." ); } }
throw new ResourceCreationException( "Failed to parse the stylesheet.", e ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to load the stylesheet.", e );