SmartFrog 3.10.000

org.smartfrog.sfcore.languages.sf
Class DefaultIncludeHandler

java.lang.Object
  extended by org.smartfrog.sfcore.languages.sf.DefaultIncludeHandler
All Implemented Interfaces:
IncludeHandler

public class DefaultIncludeHandler
extends java.lang.Object
implements IncludeHandler

This is the default include handler for the SmartFrog parser. This simply creates a new parser and returns an AttributeList. The include name is located using SFSystem.stringToURl which will try to use the name as a URL, or make a file URL to locate it. Otherwise the classloader's getResourceAsStream is used to locate the include. Subclasses can override this to do more sophisticated include storage. The format of an AttributeList as returned by DefaultParser is a vector of Object[] with element 0 the name of the attribute and element 1 the value.


Constructor Summary
DefaultIncludeHandler()
          Constructor.
DefaultIncludeHandler(java.lang.String baseCodebase)
          Constructor.
 
Method Summary
protected  java.lang.String actualCodebase(java.lang.String codebase)
          build a concatenated codebase from the base codebase and the codebase passed as a parameter
protected  java.io.InputStream openInclude(java.lang.String include, java.lang.String codebase)
          Locate the include and returns an input stream on it.
 java.util.Vector parseInclude(java.lang.String include, java.lang.String codebase)
          Parses given include.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultIncludeHandler

public DefaultIncludeHandler()
Constructor.


DefaultIncludeHandler

public DefaultIncludeHandler(java.lang.String baseCodebase)
Constructor.

Parameters:
baseCodebase - the codebase for this include handler to which will be appended the codebase passed in the parseIncldue method.
Method Detail

parseInclude

public java.util.Vector parseInclude(java.lang.String include,
                                     java.lang.String codebase)
                              throws java.lang.Exception
Parses given include. This implementation constructs a new DefaultParser on the result of openInclude and uses the AttributeList methods to construct the vector of attributes

Specified by:
parseInclude in interface IncludeHandler
Parameters:
include - include file to parse
codebase - an optional codebase where the include may be found. If null, use the default codebase
Returns:
vector of attribute name X value pairs
Throws:
java.lang.Exception - error while locating or parsing include

openInclude

protected java.io.InputStream openInclude(java.lang.String include,
                                          java.lang.String codebase)
                                   throws java.lang.Exception
Locate the include and returns an input stream on it. This uses SFSystem.stringToURL to check whether include is a URL or a file. On failure it tries to use standard getResourceAsStream to get the inlude of the classpath. Subclasses can override to provide additional means of locating includes.

Parameters:
include - include to locate
codebase - an optional codebase where hte include may be found. If null, use the default code base
Returns:
input stream on located include
Throws:
java.lang.Exception - failed to locate or open include

actualCodebase

protected java.lang.String actualCodebase(java.lang.String codebase)
build a concatenated codebase from the base codebase and the codebase passed as a parameter

Parameters:
codebase - the codeebase to concatenate to the base. May be null.

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP