Examples of InputStreamProvider


Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

    if (sourceName == null)
      throw new NullPointerException();
    if (context == null)
      throw new NullPointerException();

    InputStreamProvider provider = resolver.getProvider(sourceName);
    Object cached = provider.getCachedResult();
    if ((cached != null) && expectedType.isInstance(cached))
      return (StyleSheetEntry)cached;

    InputStream stream = provider.openInputStream();

    try
    {
      // Store a resolver relative to the file we're about to parse. This will be used for imports.
      // Store the inputStreamProvider on the context;
      // this will be used to get the document's timestamp later on
      XMLUtils.setResolver(context, resolver.getResolver(sourceName));
      XMLUtils.setInputStreamProvider(context, provider);

      // PARSE!
      // create a SkinStyleSheetNode
      // (contains a namespaceMap and a List of SkinSelectorPropertiesNodes
      // and additional information like direction, locale, etc.)
      // (selectorName + a css propertyList))
      BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
      SkinCSSParser parser = new SkinCSSParser();
      // Send over the ParseContext so that we can get the resolver from it in case we encounter
      // an @import in the CSS file.
      SkinCSSDocumentHandler documentHandler = new SkinCSSDocumentHandler(context);
      parser.parseCSSDocument(reader, documentHandler);
      List <SkinStyleSheetNode> skinSSNodeList = documentHandler.getSkinStyleSheetNodes();
      reader.close();

      // process the SkinStyleSheetNodes to create a StyleSheetEntry object
      StyleSheetEntry styleSheetEntry =
        _createStyleSheetEntry(context, sourceName, skinSSNodeList);

      // Store the cached result (if successful)
      // otherwise, if we don't do this, we will keep reparsing. Somehow
      // this affects whether the file has been modified. STRANGE!
      //     if (value != null)
      //    provider.setCachedResult(value);

      //    return value;
      provider.setCachedResult(styleSheetEntry);

      return styleSheetEntry;
    }
    finally
    {
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

  {
    long timestamp = StyleSheetDocument.UNKNOWN_TIMESTAMP;

    // The only way to get the timestamp is through the
    // InputStreamProvider.
    InputStreamProvider provider = XMLUtils.getInputStreamProvider(context);

    if (provider != null)
    {
      // And this only works if we are using a File-based or URL-based InputStream
      Object identifier = provider.getIdentifier();
      if (identifier instanceof File)
      {
        timestamp = ((File)identifier).lastModified();
      }
      else if (identifier instanceof URL)
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

    long timestamp = StyleSheetDocument.UNKNOWN_TIMESTAMP;

    // The only way to get the timestamp is through the
    // InputStreamProvider.
    InputStreamProvider provider = XMLUtils.getInputStreamProvider(parseContext);

    if (provider != null)
    {
      // And this only works if we are using a File-based or URL-based InputStream
      Object identifier = provider.getIdentifier();
      if (identifier instanceof File)
        timestamp = ((File)identifier).lastModified();
      else if (identifier instanceof URL)
      {
        try
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

   * cannot be resolved, throw an IOException.
   * @param name the name of the target
   */
  public InputStreamProvider getProvider(String name) throws IOException
  {
    InputStreamProvider provider = _base.getProvider(name);
    InputStreamProvider cached = _getCachedProvider(provider.getIdentifier());
    if (cached != null)
      return cached;

    return new CachingProvider(provider, _cachedFiles, _msBetweenChecks);
  }
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

  private InputStreamProvider _getCachedProvider(Object o)
  {
    // We don't require the storage to be synchronized
    synchronized (_cachedFiles)
    {
      InputStreamProvider provider = _cachedFiles.get(o);
      if ((provider != null) && _checkModified())
      {
        if (provider.hasSourceChanged())
        {
          _cachedFiles.remove(o);
          provider = null;
        }
      }
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

  private static NameResolver _getNameResolverForStyleSheetFile(
    StyleContext context,
    File         localStylesDir,
    String       filename) throws IOException
  {
    InputStreamProvider provider = null;
   
    File file = StyleSheetEntry.resolveLocalFile(localStylesDir, filename);
    if (file != null)
      provider = new FileInputStreamProvider(file);
   
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

    List<NameResolver> resolvers = ClassLoaderUtils.getServices(
                                      _NAME_RESOLVER_CLASS_NAME);

    for (NameResolver customNameResolver : resolvers)
    {
      InputStreamProvider provider = null;
      try
      {
        provider = customNameResolver.getProvider(name);
      }
      catch (IOException e)
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

    ImageContext context,
    Map<Object, Object> properties,
    Object     key
    )
  {
    InputStreamProvider provider = (InputStreamProvider)
      properties.get(key);

    // If we can't get a provider, we can't get an Image
    if (provider == null)
    {
      _log(properties,
           _PROVIDER_ERROR + " (" + _getKeyName(key) + ")",
           null);

      return null;
    }

    InputStream in = null;

    try
    {
      in = provider.openInputStream();
    }
    catch (IOException e)
    {
      _log(properties, _INPUT_STREAM_ERROR, e);
      return null;
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

     
      return Collections.emptyList();
    }
   
    // Step 2. Find an InputStreamProvider. Mark a dependency on the base provider (if necessary)
    InputStreamProvider importProvider = resolver.getProvider(sourceName);
    InputStreamProvider baseProvider = XMLUtils.getInputStreamProvider(context);
    if (baseProvider instanceof CachingInputStreamProvider)
    {
      // important: hasSourceChanged takes into account this dependency
      ((CachingInputStreamProvider)baseProvider).addCacheDependency(importProvider);
    }
View Full Code Here

Examples of org.apache.myfaces.trinidad.share.io.InputStreamProvider

      return null;
    }

    // Step 2. Find an InputStreamProvider.  Mark a dependency on the base
    // provider (if necessary)
    InputStreamProvider provider = resolver.getProvider(sourceName);
    InputStreamProvider baseProvider = getInputStreamProvider(context);
    if (baseProvider instanceof CachingInputStreamProvider)
    {
      // set the dependency; hasSourceChanged also checks if the
      // dependencies have changed
      ((CachingInputStreamProvider) baseProvider).addCacheDependency(provider);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.