public ResourceKey deserialize( final ResourceKey bundleKey, String stringKey ) throws ResourceKeyCreationException { // For now, we are just going to have to pass on this one throw new ResourceKeyCreationException( "Can not deserialize a ZipResourceKey" ); }
private void handleStyleNode( final DocumentContext context, final StyleReference node, final ArrayList styleRules, final ArrayList pageRules, final ArrayList counterRules ) { // do some inline parsing // (Same as the <style> element of HTML) // we also accept preparsed content ... final String styleText = node.getStyleContent(); try { final byte[] bytes = styleText.getBytes( "UTF-8" ); final ResourceKey rawKey = resourceManager.createKey( bytes ); final ResourceKey baseKey = context.getContextKey(); final StyleSheet styleSheet = parseStyleSheet( rawKey, baseKey ); if ( styleSheet == null ) { return; } addStyleRules( styleSheet, styleRules ); addPageRules( styleSheet, pageRules ); addCounterRules( styleSheet, counterRules ); } catch ( UnsupportedEncodingException e ) { e.printStackTrace(); } catch ( ResourceKeyCreationException e ) { e.printStackTrace(); } }
private void handleLinkNode( final Object styleResource, final ArrayList<ElementStyleRule> styleRules, final ArrayList<CSSCounterRule> counterRules ) { // do some external parsing // (Same as the <link> element of HTML) try { final String href = (String) styleResource; final ResourceKey baseKey = context.getContextKey(); final ResourceKey derivedKey; if ( baseKey == null ) { derivedKey = resourceManager.createKey( href ); } else { derivedKey = resourceManager.deriveKey( baseKey, String.valueOf( href ) ); } final ElementStyleDefinition styleSheet = parseStyleSheet( derivedKey, null ); if ( styleSheet == null ) { return; } addStyleRules( styleSheet, styleRules ); addCounterRules( styleSheet, counterRules ); } catch ( ResourceKeyCreationException e ) { e.printStackTrace(); } }
public ResourceKey deserialize( final ResourceKey bundleKey, final String stringKey ) throws ResourceKeyCreationException { throw new ResourceKeyCreationException( "This resource Loader cannot be used to deserialize ReousrceKeys" ); }
private void handleLinkNode( final DocumentContext context, final StyleReference node, final ArrayList styleRules, final ArrayList pageRules, final ArrayList counterRules ) { // do some external parsing // (Same as the <link> element of HTML) try { final String href = node.getStyleContent(); final ResourceKey baseKey = context.getContextKey(); final ResourceKey derivedKey; if ( baseKey == null ) { derivedKey = resourceManager.createKey( href ); } else { derivedKey = resourceManager.deriveKey( baseKey, String.valueOf( href ) ); } final StyleSheet styleSheet = parseStyleSheet( derivedKey, null ); if ( styleSheet == null ) { return; } addStyleRules( styleSheet, styleRules ); addPageRules( styleSheet, pageRules ); addCounterRules( styleSheet, counterRules ); } catch ( ResourceKeyCreationException e ) { e.printStackTrace(); } }
public synchronized ResourceKey createKey( final Object data, final Map<? extends ParameterKey, ?> parameters ) throws ResourceKeyCreationException { if ( data == null ) { throw new NullPointerException( "Key data must not be null." ); } final Iterator values = resourceLoaders.iterator(); while ( values.hasNext() ) { final ResourceLoader loader = (ResourceLoader) values.next(); try { final ResourceKey key = loader.createKey( data, parameters ); if ( key != null ) { return key; } } catch ( ResourceKeyCreationException rkce ) { // ignore it. } } throw new ResourceKeyCreationException( "Unable to create key: No loader was able to handle the given key data: " + data ); }
/** * Converts a serialized version of a <code>ResourceKey</code> into an actual <code>ResourceKey</code> by locating the * proper <code>ResourceLoader</code> that can perform the deserialization. * * @param bundleKey * @param serializedKey the String serialized key to be deserialized @returns the <code>ResourceKey</code> that has * been deserialized * @throws ResourceKeyCreationException indicates an error trying to create the <code>ResourceKey</code> from the * deserialized version */ public ResourceKey deserialize( final ResourceKey bundleKey, final String serializedKey ) throws ResourceKeyCreationException { if ( serializedKey == 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.isSupportedDeserializer( serializedKey ) ) { final ResourceKey key = loader.deserialize( bundleKey, serializedKey ); return key; } } throw new ResourceKeyCreationException ( "Unable to create key: No loader was able to handle the deserialization of the given key data: " + serializedKey ); }
/** * Creates a new resource key from the given object and the factory keys. * * @param value * @param factoryKeys * @return the created key. * @throws org.pentaho.reporting.libraries.resourceloader.ResourceKeyCreationException if creating the key failed. */ public ResourceKey createKey( final Object value, final Map factoryKeys ) throws ResourceKeyCreationException { if ( value instanceof URL ) { return new ResourceKey( SCHEMA_NAME, value, factoryKeys ); } if ( value instanceof String ) { final String valueString = (String) value; // the 'file' schema is defined to have double-slashes, but the JDK // ignores RFC 1738 in that case. So we have to check for these beasts // directly .. if ( valueString.indexOf( "://" ) >= 0 || valueString.startsWith( "file:/" ) ) { try { return new ResourceKey( SCHEMA_NAME, new URL( valueString ), factoryKeys ); } catch ( MalformedURLException mfue ) { // we dont take this easy! throw new ResourceKeyCreationException( "Malformed value: " + value ); } } } return null; }
/** * 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 ); }
throw new ResourceKeyCreationException( "Unable to build a valid key." );
/** * Parses the input string and returns a newly created ResourceKey based on the string data */ public ResourceKey deserialize( final ResourceKey bundleKey, String stringKey ) throws ResourceKeyCreationException { // Parse the data ResourceKeyData keyData = ResourceKeyUtils.parse( stringKey ); // Validate the data if ( SCHEMA_NAME.equals( keyData.getSchema() ) == false ) { throw new ResourceKeyCreationException( "Serialized version of key does not contain correct schema" ); } // Create and return a new key try { return createKey( new URL( keyData.getIdentifier() ), keyData.getFactoryParameters() ); } catch ( MalformedURLException mfue ) { throw new ResourceKeyCreationException( "Malformed value: " + keyData.getIdentifier() ); } }
public ResourceKey deserialize( final ResourceKey bundleKey, final String stringKey ) throws ResourceKeyCreationException { // Parse the data final ResourceKeyData keyData = ResourceKeyUtils.parse( stringKey ); // Validate the data if ( SCHEMA_NAME.equals( keyData.getSchema() ) == false ) { throw new ResourceKeyCreationException( "Serialized version of key does not contain correct schema" ); } // Create a new file based on the path provided final File file = new File( keyData.getIdentifier() ); return new ResourceKey( SCHEMA_NAME, file, keyData.getFactoryParameters() ); }
throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); throw new ResourceKeyCreationException( "Malformed value: " + path + " (" + target + "): File does not exist." ); throw new ResourceKeyCreationException( "Failed to create key", ioe );
throw new ResourceKeyCreationException( "The source string does not start with the string [" + SERIALIZATION_PREFIX + "]" ); throw new ResourceKeyCreationException( "Schema is missing" ); throw new ResourceKeyCreationException( "Prefix is wrong" ); throw new ResourceKeyCreationException( "Identifier is missing" );
throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); target = new File( parentResource.getCanonicalFile().getParentFile(), path ); if ( target.exists() == false || target.isDirectory() == false ) { throw new ResourceKeyCreationException( "Malformed value: " + path + " (" + target + ')' ); throw new ResourceKeyCreationException( "Failed to create key", ioe );
public ResourceKey createResourceKey( final String entryName, final Map factoryParameters ) throws ResourceKeyCreationException { if ( entryName == null ) { throw new NullPointerException(); } final ResourceKey bundleKey = getBundleMainKey().getParent(); final ResourceBundleLoader o = (ResourceBundleLoader) bundleKey.getFactoryParameters().get( new FactoryParameterKey( "repository-loader" ) ); if ( o == null ) { throw new ResourceKeyCreationException( "Unable to create a inner-bundle key, no loader available." ); } return o.deriveKey( getBundleMainKey(), entryName, factoryParameters ); }
/** * Parses the input string and returns a newly created ResourceKey based on the string data */ public ResourceKey deserialize( final ResourceKey bundleKey, String stringKey ) throws ResourceKeyCreationException { // Parse the data final ResourceKeyData keyData = ResourceKeyUtils.parse( stringKey ); // Validate the data if ( SCHEMA_NAME.equals( keyData.getSchema() ) == false ) { throw new ResourceKeyCreationException( "Serialized version of key does not contain correct schema" ); } // Create and return a new key return createKey( keyData.getIdentifier(), keyData.getFactoryParameters() ); }
/** * Parses the input string and returns a newly created ResourceKey based on the string data */ public ResourceKey deserialize( final ResourceKey bundleKey, String stringKey ) throws ResourceKeyCreationException { // Parse the data final ResourceKeyData keyData = ResourceKeyUtils.parse( stringKey ); // Validate the data if ( SCHEMA_NAME.equals( keyData.getSchema() ) == false ) { throw new ResourceKeyCreationException( "Serialized version of key does not contain correct schema" ); } final String identifier = keyData.getIdentifier(); final char[] chars = identifier.toCharArray(); final byte[] data = new byte[ chars.length ]; for ( int i = 0; i < chars.length; i++ ) { data[ i ] = (byte) chars[ i ]; } return createKey( data, keyData.getFactoryParameters() ); }
throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); throw new ResourceKeyCreationException( "Malformed value: " + path );
throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" );