Package org.pentaho.reporting.libraries.resourceloader

Examples of org.pentaho.reporting.libraries.resourceloader.ResourceKey


    return backend.deriveKey(parent, path, parameters);
  }

  private ResourceKey computeContextKey(final ResourceKey key)
  {
    ResourceKey maybeParent = key.getParent();
    while (maybeParent != null && loader.isSupportedKey(maybeParent))
    {
      maybeParent = maybeParent.getParent();
    }
    return maybeParent;
  }
View Full Code Here


      {
        final FontSource fr = (FontSource) fofam.getFontRecord(false, false);
        final ResourceManager resourceManager = new ResourceManager();
        resourceManager.registerDefaults();

        final ResourceKey fontSource = resourceManager.createKey(new File(fr.getFontSource()));
        final FontDataInputSource fs =
            new ResourceFontDataInputSource(resourceManager, fontSource);
        final TrueTypeFont ttf = new TrueTypeFont(fs);
        final NameTable nt = (NameTable) ttf.getTable(NameTable.TABLE_ID);
        //PostscriptInformationTable pst = ttf.getTable(PostscriptInformationTable.TABLE_ID);
View Full Code Here

    final OutputStream outputStream = bundle.createEntry("test.properties", "text/plain");
    p1.store(outputStream, "run 1");
    outputStream.close();

    final ResourceManager resourceManager = bundle.getResourceManager();
    final ResourceKey key = resourceManager.deriveKey(bundle.getBundleMainKey(), "test.properties");
    final Resource res1 = resourceManager.create(key, null, Properties.class);
    assertEquals(p1, res1.getResource());

    bundle.removeEntry("test.properties");
View Full Code Here

    final HashMap<FactoryParameterKey, Object> map = new HashMap<FactoryParameterKey, Object>();
    map.put(new FactoryParameterKey("repository"), repository);
    map.put(new FactoryParameterKey("repository-loader"), this);

    this.bundleKey = new ResourceKey(outsideContextKey, SCHEMA, new Object(), map);
    final String bundleType = BundleUtilities.getBundleType(repository);
    final String bundleMapping = BundleUtilities.getBundleMapping(bundleType);
    if (bundleMapping == null)
    {
      throw new IllegalStateException("Invalid configuration: No Bundle-Mapping for the bundle-type " + bundleType);
    }


    this.mainKey = new ResourceKey(bundleKey, INNER_SCHEMA, bundleMapping, null);
  }
View Full Code Here

      {
        throw new ResourceKeyCreationException("Error checking whether the derived entry exists in the bundle.");
      }
    }

    return new ResourceKey(parent.getParent(), parent.getSchema(), entry, map);
  }
View Full Code Here

    final WriteableDocumentBundle docBundle = new MemoryDocumentBundle();

    // Create a temp file for processing purposes
    final File tempFile = File.createTempFile("junit", "tmp");
    tempFile.deleteOnExit();
    final ResourceKey tempKey = resourceManager.createKey(tempFile);

    // Add the temp file to the bundle
    final ResourceKey result = WriteableDocumentBundleUtils.embedResource(docBundle, resourceManager, tempKey, "test/testfile-{0}.tmp", "application/data", null);
    assertNotNull(result);
    assertTrue(result.getIdentifierAsString().startsWith("test/testfile-"));
    assertTrue(docBundle.isEntryExists(result.getIdentifierAsString()));

    // Remove the temp file with the same key
    assertTrue(WriteableDocumentBundleUtils.removeResource(docBundle, result));
    assertFalse(docBundle.isEntryExists(result.getIdentifierAsString()));

    // Remove the key again - no error but false return
    assertFalse(WriteableDocumentBundleUtils.removeResource(docBundle, result));
  }
View Full Code Here

    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());
  }
View Full Code Here

    final WriteableDocumentBundle docBundle = new MemoryDocumentBundle();

    // Create a temp file for processing purposes
    final File tempFile = File.createTempFile("junit", "tmp");
    tempFile.deleteOnExit();
    final ResourceKey tempKey = resourceManager.createKey(tempFile);

    // Add the temp file to the bundle
    final ResourceKey result = WriteableDocumentBundleUtils.embedResource(docBundle, resourceManager, tempKey, "test/testfile-{0}.tmp", "application/data", null);
    assertNotNull(result);
    assertTrue(result.getIdentifierAsString().startsWith("test/testfile-"));
    assertTrue(docBundle.isEntryExists(result.getIdentifierAsString()));

    // Create a new key with the same name
    final ResourceKey newKey = docBundle.createResourceKey(result.getIdentifierAsString(), null);

    // Remove the temp file with the new key
    assertTrue(WriteableDocumentBundleUtils.removeResource(docBundle, newKey));
    assertFalse(docBundle.isEntryExists(result.getIdentifierAsString()));
View Full Code Here

    final WriteableDocumentBundle docBundle = new MemoryDocumentBundle();

    // Create a temp file for processing purposes
    final File tempFile = File.createTempFile("junit", "tmp");
    tempFile.deleteOnExit();
    final ResourceKey tempKey = resourceManager.createKey(tempFile);

    // Add the temp file to the bundle
    final ResourceKey result = WriteableDocumentBundleUtils.embedResource(docBundle, resourceManager, tempKey, "test/testfile-{0}.tmp", "application/data", null);
    assertNotNull(result);
    assertTrue(result.getIdentifierAsString().startsWith("test/testfile-"));
    assertTrue(docBundle.isEntryExists(result.getIdentifierAsString()));

    // Add the file again, and set some factory parameters
    final Map factoryParameters = new HashMap();
    factoryParameters.put("this", "that");
    final ResourceKey result2 = WriteableDocumentBundleUtils.embedResource(docBundle, resourceManager, tempKey, "test/testfile-{0}.tmp", "application/data", factoryParameters);
    assertNotNull(result2);
    assertTrue(result2.getIdentifierAsString().startsWith("test/testfile-"));
    assertTrue(docBundle.isEntryExists(result2.getIdentifierAsString()));
    assertNotNull(result2.getFactoryParameters());
    assertEquals(1, result2.getFactoryParameters().size());
    assertTrue(result2.getFactoryParameters().containsKey("this"));
  }
View Full Code Here

    if (content instanceof CSSConstant)
    {
      if (ContentValues.DOCUMENT_URL.equals(content))
      {
        final ResourceKey baseKey = process.getContextKey();
        final ResourceManager resourceManager = process.getResourceManager();
        final URL url = resourceManager.toURL(baseKey);
        if (url != null)
        {
          return new StaticTextToken(url.toExternalForm());
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.resourceloader.ResourceKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.