/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key * @return */ public boolean isSupportedKey( final ResourceKey key ) { return SCHEMA_NAME.equals( key.getSchema() ); }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key * @return */ public boolean isSupportedKey( final ResourceKey key ) { if ( SCHEMA_NAME.equals( key.getSchema() ) ) { return true; } return false; }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key the key that should be tested. * @return true, if the key is supported. */ public boolean isSupportedKey( final ResourceKey key ) { if ( RepositoryResourceBundleLoader.SCHEMA.equals( key.getSchema() ) == false ) { return false; } return true; }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key * @return */ public boolean isSupportedKey( final ResourceKey key ) { if ( SCHEMA_NAME.equals( key.getSchema() ) ) { return true; } return false; }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key * @return */ public boolean isSupportedKey( final ResourceKey key ) { if ( SCHEMA_NAME.equals( key.getSchema() ) ) { return true; } return false; }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key * @return */ public boolean isSupportedKey( final ResourceKey key ) { if ( key == null ) { throw new NullPointerException(); } if ( SCHEMA_NAME.equals( key.getSchema() ) ) { return true; } return false; }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key * @return */ public boolean isSupportedKey( final ResourceKey key ) { if ( key == null ) { throw new NullPointerException(); } if ( DirectoryResourceLoader.class.getName().equals( key.getSchema() ) ) { return true; } return false; }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key the key that should be tested. * @return true, if the key is supported. */ public boolean isSupportedKey( final ResourceKey key ) { final ResourceKey parent = key.getParent(); if ( parent == null ) { return false; } if ( DirectoryResourceLoader.class.getName().equals( parent.getSchema() ) == false ) { return false; } if ( DirectoryResourceBundleLoader.class.getName().equals( key.getSchema() ) == false ) { return false; } return true; }
/** * Checks, whether this resource loader implementation was responsible for creating this key. * * @param key the key that should be tested. * @return true, if the key is supported. */ public boolean isSupportedKey( final ResourceKey key ) { if ( key == null ) { throw new NullPointerException(); } if ( key.getParent() == null ) { return false; } if ( ZipResourceBundleLoader.class.getName().equals( key.getSchema() ) == false ) { return false; } return true; }
public ResourceData loadRawData( final ResourceManager frontEnd, final ResourceKey key ) throws UnrecognizedLoaderException, ResourceLoadingException { if ( frontEnd == null ) { throw new NullPointerException(); } if ( key == null ) { throw new NullPointerException(); } final ResourceLoader loader = findBySchema( key ); if ( loader == null ) { throw new UnrecognizedLoaderException( "Invalid key: No resource-loader registered for schema: " + key.getSchema() ); } logger.debug( "Loaded " + key ); return loader.load( key ); }
private ResourceKey localizeKey( final ResourceManager resourceManager, final ResourceKey valueKey ) { final Object object = valueKey.getFactoryParameters().get( ClassicEngineFactoryParameters.EMBED ); if ( "false".equals( object ) ) { return valueKey; } if ( "org.pentaho.reporting.libraries.docbundle.bundleloader.RepositoryResourceBundleLoader".equals( valueKey .getSchema() ) == false && object == null ) { return valueKey; } try { final ResourceData resourceData = resourceManager.load( valueKey ); final byte[] resource = resourceData.getResource( resourceManager ); return resourceManager.createKey( resource, valueKey.getFactoryParameters() ); } catch ( ResourceException e ) { if ( logger.isDebugEnabled() ) { logger.info( "Unable to normalize embedded resource-key, using ordinary key-object instead.", e ); } else { logger.info( "Unable to normalize embedded resource-key, using ordinary key-object instead." ); } } return valueKey; }
/** * 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 byte[] ) ) { throw new IllegalArgumentException( "ResourceKey is invalid - identifier is not a byte[] object" ); } final byte[] data = (byte[]) key.getIdentifier(); final char[] cdata = new char[ data.length ]; for ( int i = 0; i < data.length; i++ ) { cdata[ i ] = (char) ( data[ i ] & 0xFF ); } return ResourceKeyUtils.createStringResourceKey ( String.valueOf( key.getSchema() ), new String( cdata ), key.getFactoryParameters() ); }
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() ); } }
/** * Serializes the resource key to a String representation which can be recreated using the * <code>deserialize(ResourceKey)<code> method. * * @param bundleKey * @param key * @return a <code>String<code> which is a serialized version of the <code>ResourceKey</code> * @throws ResourceException indicates an error serializing the resource 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 byte[] object" ); } final String data = (String) key.getIdentifier(); return ResourceKeyUtils.createStringResourceKey ( String.valueOf( key.getSchema() ), data, key.getFactoryParameters() ); }
( key.getSchema().toString(), url.toExternalForm(), key.getFactoryParameters() ); logger.debug( "Serialized Classloader Resource Key: [" + result + "]" ); return result;
/** * 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; }
map = parent.getFactoryParameters(); return new ResourceKey( parent.getSchema(), resource, map );
/** * Parses the report using the provided resource manager. * * @param manager * the resource manager (can be null). * @param input * the resource key pointing to the report definition. * @param contextKey * the report's context (used to load content that has been referenced with relative URLs). * @return the parsed report. * @throws ResourceException * if parsing or loading failed for some reason. */ public MasterReport parseReport( ResourceManager manager, final ResourceKey input, final ResourceKey contextKey ) throws ResourceException { if ( manager == null ) { manager = new ResourceManager(); } final HashMap map = new HashMap( input.getFactoryParameters() ); final Iterator it = this.helperObjects.keySet().iterator(); while ( it.hasNext() ) { final String name = (String) it.next(); map.put( new FactoryParameterKey( name ), helperObjects.get( name ) ); } final ResourceKey key = new ResourceKey( input.getParent(), input.getSchema(), input.getIdentifier(), input.getFactoryParameters() ); final Resource resource = manager.create( key, contextKey, MasterReport.class ); return (MasterReport) resource.getResource(); }
/** * Derives a new resource key from the given key. If neither a path nor new factory-keys are given, the parent key is * returned. * * @param parent the parent * @param path the derived path (can be null). * @param factoryKeys the optional factory keys (can be null). * @return the derived key. * @throws org.pentaho.reporting.libraries.resourceloader.ResourceKeyCreationException if the key cannot be derived * for any reason. */ public ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ) throws ResourceKeyCreationException { if ( path != null ) { throw new ResourceKeyCreationException( "Unable to derive key for new path." ); } if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); } if ( factoryKeys == null ) { return parent; } final HashMap map = new HashMap(); map.putAll( parent.getFactoryParameters() ); map.putAll( factoryKeys ); return new ResourceKey( parent.getSchema(), parent.getIdentifier(), map ); }
map = parent.getFactoryParameters(); return new ResourceKey( parent.getParent(), parent.getSchema(), entry, map );