public boolean isSupportedDeserializer( final String data ) throws ResourceKeyCreationException { final ResourceKeyData resourceKeyData = ResourceKeyUtils.parse( data ); // Validate the data return ( INNER_SCHEMA.equals( resourceKeyData.getSchema() ) ); }
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() ); }
/** * 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() ); }
/** * 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 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() ); } }
/** * Creates a <code>ResourceKey</code> based off the <code>String</code> representation of the key. The * <code>String</code> should have been created using the <code>serialize</code> method. * * @param bundleKey * @param stringKey the <code>String</code> representation of the <code>ResourceKey</code> @return a * <code>ResourceKey</code> which matches the <code>String</code> representation * @throws ResourceKeyCreationException indicates an error occurred in the creation or deserialization of the * <code>ResourceKey</code> */ public ResourceKey deserialize( final ResourceKey bundleKey, final String stringKey ) throws ResourceKeyCreationException { final ResourceKeyData resourceKeyData = ResourceKeyUtils.parse( stringKey ); // Validate the data if ( INNER_SCHEMA.equals( resourceKeyData.getSchema() ) == false ) { throw new ResourceKeyCreationException( "Serialized version of key does not contain correct schema" ); } return new ResourceKey( bundleKey, resourceKeyData.getSchema(), resourceKeyData.getIdentifier(), resourceKeyData.getFactoryParameters() ); }