SmartFrog 3.10.000

org.smartfrog.sfcore.parser
Class SFParser

java.lang.Object
  extended by org.smartfrog.sfcore.parser.SFParser
All Implemented Interfaces:
MessageKeys, Parser, StreamParser

public class SFParser
extends java.lang.Object
implements Parser, MessageKeys

Implements the Parser interface for SmartFrog parsers. This implementation uses the SFParser class from the various languages to implement the methods. The language to use is either given as part of the method or the default language is used. This is determined by the value of the system property org.smartfrog.sfcore.parser.Language", and this in turn defaults to "sf". The language package is determined by the package prefix constructed from the value of the system property "org.smartfrog.sfcore.parser.LanguagePrefix" and defaults to "org.smartfrog.Languages". The lnaguage to be used is added as part of that package to generate the actual package name.


Field Summary
static java.lang.String language
          Language name system property key.
 java.lang.String languagesPrefix
          The package prefix for all language implementations.
 
Fields inherited from interface org.smartfrog.sfcore.common.MessageKeys
CANNOT_LINK_TO_PREDICATE, COMPONENT_TERMINATED, COPY_FAILED, COPY_SERIALIZE_FAILED, ERROR_NO_SECURITY_BUT_REQUIRED, ILLEGAL_BOOLEAN_PARAMETER, ILLEGAL_NUMERIC_PARAMETER, ILLEGAL_STRING_PARAMETER, ILLEGAL_VECTOR_PARAMETER, LIVENESS_SEND_FAILURE, LIVENESS_SEND_FAILURE_IN, MISSING_PARAMETER, MSG_CLASS_NOT_FOUND, MSG_CONNECT_ERR, MSG_CONT_OTHER_DEPLOY, MSG_DEPLOY_COMP_TERMINATED, MSG_DEPLOY_SUCCESS, MSG_DEPLOYWITH_PHASE_FAILED, MSG_DETACH_SUCCESS, MSG_DETACH_TERMINATE_SUCCESS, MSG_ERR_DEPLOY_FROM_URL, MSG_ERR_PARSE, MSG_ERR_RESOLVE_PHASE, MSG_ERR_SF_RUNNING, MSG_ERR_TERM, MSG_FAILED_INET_ADDRESS_LOOKUP, MSG_FAILED_TO_CONTACT_PARENT, MSG_FILE_NOT_FOUND, MSG_HOOK_ACTION_FAILED, MSG_ILLEGAL_ACCESS, MSG_ILLEGAL_CLASS_TYPE, MSG_ILLEGAL_CLASS_TYPE_EXPECTING_GOT, MSG_ILLEGAL_REFERENCE, MSG_INPUTSTREAM_NULL, MSG_INSTANTIATION_ERROR, MSG_INVALID_OBJECT_TYPE, MSG_INVOCATION_TARGET, MSG_LANG_NOT_FOUND, MSG_LIVENESS_START_FAILED, MSG_LOADING_URL, MSG_METHOD_NOT_FOUND, MSG_NON_REP_ATTRIB, MSG_NOT_COMPONENT_REFERENCE, MSG_NOT_FOUND_ATTRIBUTE, MSG_NOT_FOUND_REFERENCE, MSG_NOT_VALUE_REFERENCE, MSG_NULL_DEF_METHOD, MSG_NULL_URL, MSG_OBJECT_REGISTRATION_FAILED, MSG_PARENT_LOCATION_FAILED, MSG_PING_SUCCESS, MSG_RANDM_ERR, MSG_REMOTE_CONNECT_ERR, MSG_REPEATED_ATTRIBUTE, MSG_SF_DEAD, MSG_SF_READY, MSG_SF_TERMINATED, MSG_STACKTRACE_FOLLOWS, MSG_START_COMP_TERMINATED, MSG_TERMINATE_SUCCESS, MSG_UNHANDLED_EXCEPTION, MSG_UNKNOWN_HOST, MSG_UNRESOLVED_REFERENCE, MSG_UNRESOLVED_REFERENCE_IN, MSG_UPDATE_SUCCESS, MSG_URL_NOT_FOUND, MSG_URL_TO_PARSE_NOT_FOUND, MSG_WARNING_LIVENESS_ENABLED, MSG_WARNING_STACKTRACE_DISABLED, MSG_WARNING_STACKTRACE_ENABLED, ROOT_MUST_BE_COMPONENT, WARN_NO_SECURITY
 
Constructor Summary
SFParser()
          Constructor for an instance of the parser for the default language.
SFParser(java.lang.String languageOrUrl)
          Constructor for an instance of the parser for the given language.
 
Method Summary
static java.lang.String getLanguageFromUrl(java.lang.String url)
          Gets language from the URL
 Phases sfParse(java.io.InputStream is)
          Parses component(s) from an input stream.
 Phases sfParse(java.io.InputStream is, java.lang.String codebase)
          Parses component(s) from an input stream.
 Phases sfParse(java.lang.String str)
          Parses component(s) from a string.
 Phases sfParse(java.lang.String str, java.lang.String codebase)
          Parses component(s) from a string.
 java.lang.Object sfParseAnyValue(java.io.InputStream is)
          Parses any value from an input stream.
 java.lang.Object sfParseAnyValue(java.lang.String txt)
          Parses any value from a string.
 ComponentDescription sfParseComponentDescription(java.io.InputStream is)
          Parses a component description from an input stream.
 ComponentDescription sfParseComponentDescription(java.lang.String txt)
          Parses a component description from a string.
 java.lang.Object sfParsePrimitiveValue(java.io.InputStream is)
          Parses a primitive value from an input stream.
 java.lang.Object sfParsePrimitiveValue(java.lang.String txt)
          Parses a primitive value from a string.
 Reference sfParseReference(java.io.InputStream is)
          Parses a reference from an input stream.
 Reference sfParseReference(java.lang.String txt)
          Parses a reference from a string.
 Phases sfParseResource(java.lang.String url)
          Parses component(s) from an resource url.
 Phases sfParseResource(java.lang.String url, java.lang.String codebase)
          Parses component(s) from an resource url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

language

public static java.lang.String language
Language name system property key. This is the propBase + Language. This sets the parser to construct if no language is specified. Default is "sf"


languagesPrefix

public java.lang.String languagesPrefix
The package prefix for all language implementations. This is the propBase + LanguagesPackagePrefix. This sets the parser to construct when getParser is called. Default is "org.smartfrog.sfcore.languages" defined in "SmartFrogCoreProperty.parserPackages".

Constructor Detail

SFParser

public SFParser()
         throws SmartFrogException
Constructor for an instance of the parser for the default language.

Throws:
SmartFrogException - error creating insatnce of parser

SFParser

public SFParser(java.lang.String languageOrUrl)
         throws SmartFrogException
Constructor for an instance of the parser for the given language.

Parameters:
languageOrUrl - the name of the language to use or the url with suffixed by language extension.
Throws:
SmartFrogException - error crearing instance of parser
Method Detail

sfParse

public Phases sfParse(java.io.InputStream is)
               throws SmartFrogParseException
Parses component(s) from an input stream. Returns a root component which contains the parsed components. Includes should be handled by some default include handler.

Specified by:
sfParse in interface StreamParser
Parameters:
is - input stream to parse and compile from
Returns:
root component containing parsed component(s)
Throws:
SmartFrogParseException - error parsing stream

sfParse

public Phases sfParse(java.io.InputStream is,
                      java.lang.String codebase)
               throws SmartFrogParseException
Parses component(s) from an input stream. Returns a root component which contains the parsed components. Includes should be handled by some default include handler.

Specified by:
sfParse in interface StreamParser
Parameters:
is - input stream to parse and compile from
codebase - an optional codebase where the include may be found. If null, use the default code base
Returns:
root component containing parsed component(s)
Throws:
SmartFrogParseException - error parsing stream

sfParseResource

public Phases sfParseResource(java.lang.String url)
                       throws SmartFrogParseException
Parses component(s) from an resource url. Returns a root component which contains the parsed components. Includes should be handled by some default include handler.

Specified by:
sfParseResource in interface Parser
Parameters:
url - to resource to parse and compile from
Returns:
Phases root component containing parsed component(s)
Throws:
SmartFrogParseException - error parsing stream

sfParseResource

public Phases sfParseResource(java.lang.String url,
                              java.lang.String codebase)
                       throws SmartFrogParseException
Parses component(s) from an resource url. Returns a root component which contains the parsed components. Includes should be handled by some default include handler.

Parameters:
url - to resource to parse and compile from
codebase - suggested codebase for the classloader
Returns:
Phases root component containing parsed component(s)
Throws:
SmartFrogParseException - error parsing stream

sfParse

public Phases sfParse(java.lang.String str)
               throws SmartFrogParseException
Parses component(s) from a string. Returns the root component. This is a utility access method which currently does not support localization.

Specified by:
sfParse in interface Parser
Parameters:
str - string to parse
Returns:
root component containing parsed component(s)
Throws:
SmartFrogParseException - error parsing string

sfParse

public Phases sfParse(java.lang.String str,
                      java.lang.String codebase)
               throws SmartFrogParseException
Parses component(s) from a string. Returns the root component. This is a utility access method which currently does not support localization.

Parameters:
str - string to parse
codebase - suggested codebase for the classloader
Returns:
root component containing parsed component(s)
Throws:
SmartFrogParseException - error parsing string

sfParseReference

public Reference sfParseReference(java.io.InputStream is)
                           throws SmartFrogCompilationException
Parses a reference from an input stream. Used by components and developers to quickly build references from a string (eg. sfResolve in Prim). It applies the ReferencePhases conversion method to Referemnce.

Specified by:
sfParseReference in interface StreamParser
Parameters:
is - input stream to parse for a reference
Returns:
parsed reference
Throws:
SmartFrogCompilationException - failed to parse reference

sfParseReference

public Reference sfParseReference(java.lang.String txt)
                           throws SmartFrogCompilationException
Parses a reference from a string. Used by components and developers to quickly build references from a string (eg. sfResolve in Prim)

Specified by:
sfParseReference in interface Parser
Parameters:
txt - textual representation of the reference
Returns:
parsed reference
Throws:
SmartFrogParseException - failed to parse reference
SmartFrogCompilationException

sfParseAnyValue

public java.lang.Object sfParseAnyValue(java.io.InputStream is)
                                 throws SmartFrogCompilationException
Parses any value from an input stream. (the meaning of "any" is language dependant)

Specified by:
sfParseAnyValue in interface StreamParser
Parameters:
is - input stream to parse for a value
Returns:
parsed value
Throws:
SmartFrogParseException - failed to parse any value
SmartFrogCompilationException

sfParseAnyValue

public java.lang.Object sfParseAnyValue(java.lang.String txt)
                                 throws SmartFrogCompilationException
Parses any value from a string. (the meaning of "any" is language dependant)

Specified by:
sfParseAnyValue in interface Parser
Parameters:
txt - string to parse for a value
Returns:
parsed value
Throws:
SmartFrogParseException - failed to parse any value
SmartFrogCompilationException

sfParsePrimitiveValue

public java.lang.Object sfParsePrimitiveValue(java.io.InputStream is)
                                       throws SmartFrogCompilationException
Parses a primitive value from an input stream. (the meaning of primitive is language dependant)

Specified by:
sfParsePrimitiveValue in interface StreamParser
Parameters:
is - input stream to parse for a value
Returns:
parsed value
Throws:
SmartFrogParseException - failed to parse primtiive value
SmartFrogCompilationException

sfParsePrimitiveValue

public java.lang.Object sfParsePrimitiveValue(java.lang.String txt)
                                       throws SmartFrogCompilationException
Parses a primitive value from a string. (the meaning of primitive is language dependant)

Specified by:
sfParsePrimitiveValue in interface Parser
Parameters:
txt - string to parse for a value
Returns:
parsed value
Throws:
SmartFrogParseException - failed to parse primtiive value
SmartFrogCompilationException

sfParseComponentDescription

public ComponentDescription sfParseComponentDescription(java.io.InputStream is)
                                                 throws SmartFrogCompilationException
Parses a component description from an input stream. All the langauge phases will have been applied, and the conversion to ComponentDescription carried out.

Specified by:
sfParseComponentDescription in interface StreamParser
Parameters:
is - input stream to parse for a value
Returns:
parsed component description
Throws:
SmartFrogParseException - failed to parse primtiive value
SmartFrogCompilationException

sfParseComponentDescription

public ComponentDescription sfParseComponentDescription(java.lang.String txt)
                                                 throws SmartFrogCompilationException
Parses a component description from a string. All the langauge phases will have been applied, and the conversion to ComponentDescription carried out.

Specified by:
sfParseComponentDescription in interface Parser
Parameters:
txt - input to parse for a value
Returns:
parsed component description
Throws:
SmartFrogParseException - failed to parse primtiive value
SmartFrogCompilationException

getLanguageFromUrl

public static java.lang.String getLanguageFromUrl(java.lang.String url)
                                           throws SmartFrogParseException
Gets language from the URL

Parameters:
url - URL passed to application
Returns:
Language string
Throws:
SmartFrogParseException - In case any error while getting the language string

SmartFrog CORE 3.10.000

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