public String serialize( final ResourceKey bundleKey, final ResourceKey key ) throws ResourceException { throw new ResourceException( "This resource Loader cannot be used to serialize ResourceKeys" ); }
DrawableLoadFilter.logger.debug( "Error while loading the drawable from " + url, e ); } else if ( DrawableLoadFilter.logger.isWarnEnabled() ) { DrawableLoadFilter.logger.warn( "Error while loading the drawable from " + url + ": " + e.getMessage() ); DrawableLoadFilter.logger.debug( "Error while loading the drawable from byte[]", e ); } else if ( DrawableLoadFilter.logger.isWarnEnabled() ) { DrawableLoadFilter.logger.warn( "Error while loading the drawable from byte[]: " + e.getMessage() );
ImageLoadFilter.logger.debug( "Error while loading the image from a blob", e ); } else if ( ImageLoadFilter.logger.isWarnEnabled() ) { ImageLoadFilter.logger.warn( "Error while loading the image from a blob: " + e.getMessage() ); ImageLoadFilter.logger.debug( "Error while loading the image from " + url, e ); } else if ( ImageLoadFilter.logger.isWarnEnabled() ) { ImageLoadFilter.logger.warn( "Error while loading the image from " + url + ": " + e.getMessage() );
/** * Creates a String version of the <code>ResourceKey</code> that can be deserialized with the * <code>deserialize()</code> method. * * @param bundleKey * @param key @throw ResourceException indicates an error trying to serialize the key * @throws NullPointerException indicates the supplied key is <code>null</code> */ public String serialize( final ResourceKey bundleKey, final ResourceKey key ) throws ResourceException { if ( key == null ) { throw new NullPointerException( "Key data must not be null." ); } final Iterator values = resourceLoaders.iterator(); while ( values.hasNext() ) { final ResourceLoader loader = (ResourceLoader) values.next(); if ( loader.isSupportedKey( key ) ) { return loader.serialize( bundleKey, key ); } } throw new ResourceException( "Unable to find resource loader for specified key: " + key ); }
writer.writeCloseTag(); } catch ( ResourceException re ) { logger.error( "Could not serialize the ResourceKey: " + re.getMessage(), re ); throw new IOException( "Could not serialize the ResourceKey: ", re );
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 DefaultImageReference( final Resource imageResource ) throws ResourceException { if ( imageResource == null ) { throw new NullPointerException(); } final Object o = imageResource.getResource(); if ( o instanceof Image == false ) { throw new ResourceException( "ImageResource does not contain a java.awt.Image object." ); } final ResourceKey resKey = imageResource.getSource(); final Object identifier = resKey.getIdentifier(); if ( identifier instanceof URL ) { this.url = (URL) identifier; } this.resourceKey = resKey; this.image = (Image) o; final WaitingImageObserver obs = new WaitingImageObserver( image ); obs.waitImageLoaded(); if ( obs.isError() ) { throw new ResourceException( "Failed to load the image. ImageObserver signaled an error." ); } this.width = image.getWidth( null ); this.height = image.getHeight( null ); }
public String serialize( final ResourceKey bundleKey, final ResourceKey key ) throws ResourceException { // Validate the parameter if ( key == null ) { throw new NullPointerException( "The ResourceKey can not be null" ); } if ( isSupportedKey( key ) == false ) { throw new IllegalArgumentException( "Key format is not recognized." ); } if ( !( key.getIdentifier() instanceof File ) ) { throw new IllegalArgumentException( "ResourceKey is invalid - identifier is not a File object" ); } // Log information logger.debug( "Serializing a File Resource Key..." ); if ( key.getParent() != null ) { throw new ResourceException ( "Unable to serialize a File-ResourceKey with a parent. This type is not expected to have a parent." ); } // Create a string version of the identifier try { final File file = (File) key.getIdentifier(); final String strIdentifier = file.getCanonicalPath(); final String result = ResourceKeyUtils.createStringResourceKey ( key.getSchema().toString(), strIdentifier, key.getFactoryParameters() ); logger.debug( "Serialized File Resource Key: [" + result + "]" ); return result; } catch ( IOException ioe ) { throw new IllegalArgumentException( "Could not determine cononical path to file specified in ResourceKey: " + ioe.getMessage() ); } }
public String serialize( ResourceKey bundleKey, final ResourceKey key ) throws ResourceException { if ( isSupportedKey( key ) == false ) { throw new IllegalArgumentException( "Not supported" ); } final ZipEntryKey entryKey = (ZipEntryKey) key.getIdentifier(); final String name = entryKey.getEntryName(); final ResourceKey zipKey = entryKey.getZipFile().getKey(); // For now, we are just going to have to pass on this one throw new ResourceException( "Can not serialize a ZipResourceKey" ); }
/** * Creates a String version of the resource key that can be used to generate a new ResourceKey object via * deserialization * * @param bundleKey * @param key */ public String serialize( final ResourceKey bundleKey, final ResourceKey key ) throws ResourceException { // Validate the parameter if ( key == null ) { throw new NullPointerException( "The ResourceKey can not be null" ); } if ( isSupportedKey( key ) == false ) { throw new IllegalArgumentException( "Key format is not recognized." ); } if ( !( key.getIdentifier() instanceof String ) ) { throw new IllegalArgumentException( "ResourceKey is invalid - identifier is not a String object" ); } // Log information logger.debug( "Serializing a Classloader Resource Key..." ); if ( key.getParent() != null ) { throw new ResourceException ( "Cannot serialize this key, it contains a parent, but should not contain one at all." ); } // Serialize the key final String result = ResourceKeyUtils.createStringResourceKey( key.getSchema().toString(), (String) key.getIdentifier(), key.getFactoryParameters() ); logger.debug( "Serialized Classloader Resource Key: [" + result + "]" ); return result; }
public static MasterReport parseLocalReport( final String name, Class<?> context ) throws ResourceException { final URL file = context.getResource( name ); if ( file == null ) { throw new ResourceException( "Unable to locate report '" + name + "' near class " + context ); } final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); return (MasterReport) mgr.createDirectly( file, MasterReport.class ).getResource(); }
public static MasterReport parseGoldenSampleReport( final String name ) throws ResourceException { final File file = GoldTestBase.locateGoldenSampleReport( name ); if ( file == null ) { throw new ResourceException( "Unable to locate report '" + name + "' in the golden samples." ); } final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); return (MasterReport) mgr.createDirectly( file, MasterReport.class ).getResource(); }