Package org.pentaho.reporting.libraries.resourceloader

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


    Image image = null;
    // The image has an assigned URL ...
    if (reference instanceof URLImageContainer)
    {
      final URLImageContainer urlImage = (URLImageContainer) reference;
      final ResourceKey url = urlImage.getResourceKey();
      // if we have an source to load the image data from ..
      if (url != null && urlImage.isLoadable())
      {
        // and the image is one of the supported image formats ...
        // we we can embedd it directly ...
View Full Code Here


  public Resource create(final ResourceManager manager,
                         final ResourceData data,
                         final ResourceKey context)
      throws ResourceCreationException, ResourceLoadingException
  {
    final ResourceKey key = data.getKey();
    final Map factoryParameters = key.getFactoryParameters();
    final boolean embedded = Boolean.TRUE.equals(factoryParameters.get(BaseFontResourceFactory.EMBEDDED));
    final String encoding = String.valueOf(factoryParameters.get(BaseFontResourceFactory.ENCODING));
    final String fontType = String.valueOf(factoryParameters.get(BaseFontResourceFactory.FONTNAME));

    final DependencyCollector dc = new DependencyCollector
        (key, data.getVersion(manager));

    final byte[] ttfAfm = data.getResource(manager);
    byte[] pfb = null;
    if (embedded && (fontType.endsWith(".afm") || fontType.endsWith(".pfm")))
    {
      final String pfbFileName = fontType.substring
          (0, fontType.length() - 4) + ".pfb";
      try
      {
        final ResourceKey pfbKey = manager.deriveKey(key, pfbFileName);
        final ResourceData res = manager.load(pfbKey);
        pfb = res.getResource(manager);
        dc.add(pfbKey, res.getVersion(manager));
      }
      catch (ResourceException e)
View Full Code Here

    Object identity = null;
    java.awt.Image image = null;
    if (reference instanceof URLImageContainer)
    {
      final URLImageContainer urlImageContainer = (URLImageContainer) reference;
      final ResourceKey url = urlImageContainer.getResourceKey();
      if (url != null && urlImageContainer.isLoadable())
      {
        identity = url;
        final Image cached = (Image) cachedImages.get(identity);
        if (cached != null)
View Full Code Here

      throws ResourceException
  {
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();

    final ResourceKey contextKey = resourceManager.createKey(contentBase);

    // Build the main key. That key also contains all context/parse-time
    // parameters as they will influence the resulting report. It is not
    // wise to keep caching independent from that.
    final HashMap map = new HashMap();
    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 = resourceManager.createKey(file, map);
    final Resource resource = resourceManager.create(key, contextKey, MasterReport.class);
    return (MasterReport) resource.getResource();
  }
View Full Code Here

    }
    final File contentBase = file.getCanonicalFile().getParentFile();
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();

    final ResourceKey contextKey = resourceManager.createKey(contentBase);

    // Build the main key. That key also contains all context/parse-time
    // parameters as they will influence the resulting report. It is not
    // wise to keep caching independent from that.
    final HashMap map = new HashMap();
    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 = resourceManager.createKey(file, map);
    final Resource resource = resourceManager.create(key, contextKey, MasterReport.class);
    return (MasterReport) resource.getResource();
  }
View Full Code Here

    final byte[] bytes = extractData(input);
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();

    final ResourceKey contextKey;
    if (contentBase != null)
    {
      contextKey = resourceManager.createKey(contentBase);
    }
    else
    {
      contextKey = null;
    }
    final HashMap map = new HashMap();

    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 = resourceManager.createKey(bytes, map);
    final Resource resource = resourceManager.create(key, contextKey, MasterReport.class);
    return (MasterReport) resource.getResource();
  }
View Full Code Here

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

    try
    {
      final RootXmlReadHandler rootHandler = getRootHandler();
      final ResourceManager resourceManager = rootHandler.getResourceManager();
      final ResourceKey source = rootHandler.getSource();

      final HashMap map = new HashMap();
      final String[] names = rootHandler.getHelperObjectNames();
      for (int i = 0; i < names.length; i++)
      {
        final String name = names[i];
        final FactoryParameterKey key = new FactoryParameterKey(name);
        map.put(key, rootHandler.getHelperObject(name));
      }
      map.put(new FactoryParameterKey(ReportParserUtil.INCLUDE_PARSING_KEY), ReportParserUtil.INCLUDE_PARSING_VALUE);

      final ResourceKey target = resourceManager.deriveKey(source, file, map);
      final DependencyCollector dc = rootHandler.getDependencyCollector();

      final Object maybeReport = getRootHandler().getHelperObject(ReportParserUtil.HELPER_OBJ_REPORT_NAME);
      if (maybeReport == null)
      {
View Full Code Here

    {
      // replace it ..
      report = new MasterReport();
      report.setAttribute(AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.FILEFORMAT, "unified-fileformat");

      final ResourceKey key = getRootHandler().getSource();
      if (key.getParent() != null)
      {
        final ResourceManager resourceManager = getRootHandler().getResourceManager();
        try
        {
          final Resource bundleData = resourceManager.create(key.getParent(), null, DocumentBundle.class);
          report.setBundle((DocumentBundle) bundleData.getResource());
        }
        catch (ResourceException e)
        {
          getRootHandler().warning(new SAXParseException
View Full Code Here

      throw new NullPointerException();
    }
    final String propertyRole = metaData.getPropertyRole();
    if ("Content".equals(propertyRole))
    {
      final ResourceKey contentBase = reportElement.getContentBase();
      final ResourceKey elementSource = reportElement.getDefinitionSource();
      if (attributeValue instanceof ResourceKey)
      {
        final ResourceKey path = (ResourceKey) attributeValue;
        final boolean linked = BundleUtilities.isSameBundle(elementSource, path);
        return new ResourceReference[]{new ResourceReference(path, linked)};
      }
      else if (attributeValue instanceof String && contentBase != null)
      {
        try
        {
          // not a resource-key, so try to make one ..
          final ResourceKey path = resourceManager.deriveKey(contentBase, String.valueOf(attributeValue));
          // the content base may not point to a bundle location, so that the path does not point to a
          // bundle location as well. If linked is computed to false, we can be sure that the resource is loaded
          // from within the bundle, which means that the attribute value was a relative path inside the bundle.
          final boolean linked = BundleUtilities.isSameBundle(elementSource, path) == false;
          return new ResourceReference[]{new ResourceReference(path, linked)};
        }
        catch (ResourceKeyCreationException rce)
        {
          // ignore ..
        }
      }
      else if (attributeValue != null)
      {
        try
        {
          // not a resource-key, so try to make one ..
          final ResourceKey path = resourceManager.createKey(attributeValue);
          final boolean linked = BundleUtilities.isSameBundle(elementSource, path) == false;
          return new ResourceReference[]{new ResourceReference(path, linked)};
        }
        catch (ResourceKeyCreationException rce)
        {
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.