org.apache.felix.bundlerepository.metadataparser
Class MetadataHandler

java.lang.Object
  extended by org.apache.felix.bundlerepository.metadataparser.MetadataHandler
Direct Known Subclasses:
KXml2MetadataHandler, XmlMetadataHandler

public abstract class MetadataHandler
extends java.lang.Object


Field Summary
protected  XmlCommonHandler handler
           
 
Constructor Summary
MetadataHandler()
          constructor
 
Method Summary
 void addPI(java.lang.String piname, java.lang.Class clazz)
          Add a type to process the processing instruction
 void addType(java.lang.String qname, java.lang.Object instanceFactory)
          Add a type for a element
 void addType(java.lang.String qname, java.lang.Object instanceFactory, java.lang.Class castClass)
          Add a type for a element
 void addType(java.lang.String qname, java.lang.Object instanceFactory, java.lang.Class castClass, java.lang.reflect.Method defaultAddMethod)
          Add a type for a element
 java.lang.Object getMetadata()
          return the metadata after the parsing
abstract  void parse(java.io.InputStream is)
          Called to parse the InputStream and set bundle list and package hash map
 void setDefaultType(java.lang.Object instanceFactory)
          Add a type for the default element
 void setDefaultType(java.lang.Object instanceFactory, java.lang.Class castClass)
          Add a type for the default element
 void setDefaultType(java.lang.Object instanceFactory, java.lang.Class castClass, java.lang.reflect.Method defaultAddMethod)
          Add a type for the default element
 void setMissingPIExceptionFlag(boolean flag)
          set the missing PI exception flag.
 void setTrace(boolean trace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handler

protected XmlCommonHandler handler
Constructor Detail

MetadataHandler

public MetadataHandler()
constructor

Method Detail

parse

public abstract void parse(java.io.InputStream is)
                    throws java.lang.Exception
Called to parse the InputStream and set bundle list and package hash map

Throws:
java.lang.Exception

getMetadata

public final java.lang.Object getMetadata()
return the metadata after the parsing

Returns:
a Object. Its class is the returned type of instanceFactory newInstance method for the root element of the XML document.

addType

public final void addType(java.lang.String qname,
                          java.lang.Object instanceFactory)
                   throws java.lang.Exception
Add a type for a element

Parameters:
qname - the name of the element to process
instanceFactory - the factory of objects representing an element. Must have a newInstance method. could be a class.
Throws:
java.lang.Exception

addType

public final void addType(java.lang.String qname,
                          java.lang.Object instanceFactory,
                          java.lang.Class castClass)
                   throws java.lang.Exception
Add a type for a element

Parameters:
qname - the name of the element to process
instanceFactory - the factory of objects representing an element. Must have a newInstance method. could be a class.
castClass - the class used to introspect the adder/setter and parameters in parent adder/setter. if null the castClass is by default the class returned by the newInstance method of the instanceFactory.
Throws:
java.lang.Exception

addType

public final void addType(java.lang.String qname,
                          java.lang.Object instanceFactory,
                          java.lang.Class castClass,
                          java.lang.reflect.Method defaultAddMethod)
                   throws java.lang.Exception
Add a type for a element

Parameters:
qname - the name of the element to process
instanceFactory - the factory of objects representing an element. Must have a newInstance method. could be a class.
castClass - the class used to introspect the adder/setter and parameters in parent adder/setter. if null the castClass is by default the class returned by the newInstance method of the instanceFactory.
defaultAddMethod - the method used to add the sub-elements and attributes if no adder/setter is founded. could be omitted.
Throws:
java.lang.Exception

setDefaultType

public final void setDefaultType(java.lang.Object instanceFactory)
                          throws java.lang.Exception
Add a type for the default element

Parameters:
instanceFactory - the factory of objects representing an element. Must have a newInstance method. could be a class.
Throws:
java.lang.Exception

setDefaultType

public final void setDefaultType(java.lang.Object instanceFactory,
                                 java.lang.Class castClass)
                          throws java.lang.Exception
Add a type for the default element

Parameters:
instanceFactory - the factory of objects representing an element. Must have a newInstance method. could be a class.
castClass - the class used to introspect the adder/setter and parameters in parent adder/setter. if null the castClass is by default the class returned by the newInstance method of the instanceFactory.
Throws:
java.lang.Exception

setDefaultType

public final void setDefaultType(java.lang.Object instanceFactory,
                                 java.lang.Class castClass,
                                 java.lang.reflect.Method defaultAddMethod)
                          throws java.lang.Exception
Add a type for the default element

Parameters:
instanceFactory - the factory of objects representing an element. Must have a newInstance method. could be a class.
castClass - the class used to introspect the adder/setter and parameters in parent adder/setter. if null the castClass is by default the class returned by the newInstance method of the instanceFactory.
defaultAddMethod - the method used to add the sub-elements and attributes if no adder/setter is founded. could be omitted.
Throws:
java.lang.Exception

addPI

public final void addPI(java.lang.String piname,
                        java.lang.Class clazz)
Add a type to process the processing instruction

Parameters:
piname -
clazz -

setMissingPIExceptionFlag

public final void setMissingPIExceptionFlag(boolean flag)
set the missing PI exception flag. If during parsing, the flag is true and the processing instruction is unknown, then the parser throws a exception

Parameters:
flag -

setTrace

public final void setTrace(boolean trace)
Parameters:
trace -
Since:
0.9.1