public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { throw new ResourceLoadingException( "This resource Loader cannot be used to create a ResourceData object." ); }
public void readFullyAt( final long position, final byte[] buffer, final int length ) throws IOException { if ( rawData == null ) { try { rawData = loader.load( source ); } catch ( ResourceLoadingException e ) { throw new IOException( "Failed to load the raw data." ); } } final int iPos = (int) ( position & 0x7fffffff ); try { rawData.getResource( loader, buffer, iPos, length ); } catch ( ResourceLoadingException e ) { throw new IOException( "Unable to load data: " + e.getMessage() ); } } //
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" ); }
throw new ResourceLoadingException( "Unable to read Stream: No input stream: " + getKey() ); throw new ResourceLoadingException ( "Unable to read Stream: Skipping content failed: " + getKey() ); throw rle; } catch ( IOException e ) { throw new ResourceLoadingException( "Unable to read Stream: ", e );
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 ); } }
throw new ResourceLoadingException( "Failed", 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 ); } }