Logo Search packages:      
Sourcecode: libloader version File versions  Download package

synchronized Resource org::jfree::resourceloader::factory::AbstractResourceFactory::create ( final ResourceManager  manager,
final ResourceData  data,
final ResourceKey  context 
) throws ResourceCreationException, ResourceLoadingException [inline, inherited]

Parameters:
data 
context 
Returns:
Exceptions:
ResourceCreationException 
ResourceLoadingException 

Implements org::jfree::resourceloader::ResourceFactory.

Definition at line 174 of file AbstractResourceFactory.java.

References org::jfree::resourceloader::factory::FactoryModule::canHandleResource(), and org::jfree::resourceloader::factory::AbstractResourceFactory::factoryModules.

  {
    final TreeSet sortedEntries = new TreeSet();
    final Iterator factoryModulesIt = factoryModules.iterator();
    while (factoryModulesIt.hasNext())
    {
      final FactoryModule mod = (FactoryModule) factoryModulesIt.next();
      int weight = mod.canHandleResource(manager, data);
      if (weight >= 0)
      {
        sortedEntries.add(new ResourceFactoryEntry(mod, weight));
      }
    }

    final Iterator it = sortedEntries.iterator();
    while (it.hasNext())
    {
      final ResourceFactoryEntry entry = (ResourceFactoryEntry) it.next();
      try
      {
        return entry.getModule().create(manager, data, context);
      }
      catch(Exception ex)
      {
        // ok, that one failed, try the next one ...
      }
    }
    throw new ContentNotRecognizedException
            ("No valid handler for the given content.");
  }


Generated by  Doxygen 1.6.0   Back to index