Knopflerfish OSGi 5.2.0

org.knopflerfish.util.metatype
Class Loader

java.lang.Object
  extended by org.knopflerfish.util.metatype.Loader

public class Loader
extends java.lang.Object

Helper class which loads (and saves) KF Metatype XML, as well as the R4 Metatype XML.

This implementation uses the nanoxml package for KF Metatype XML, and kXML for R4 Metatype XML.

NanoXML is distributed under the zlib/libpng license.
See http://nanoxml .sourceforge.net/orig/copyright.html for details.
The full license text is also include in the kf_metatype bundle jar.

Nanoxml is Copyrighted 2000-2002 Marc De Scheemaecker, All Rights Reserved.


Constructor Summary
Loader()
           
 
Method Summary
protected static void endElement(java.lang.String element, java.lang.String content)
           
static BundleMetaTypeResource loadBMTIfromUrl(BundleContext bc, Bundle b, java.net.URL url)
           
static java.lang.Object loadContent(AttributeDefinition attr, net.n3.nanoxml.XMLElement el)
          Load the contents of a tag into a java object.
static java.util.List<java.util.Dictionary<java.lang.String,java.lang.Object>> loadDefaultsFromURL(MTP mtp, java.net.URL url)
          Load defaults from an XML file into an MTP.
static MTP loadMTP(Bundle bundle, java.net.URL sourceURL, net.n3.nanoxml.XMLElement el)
          Load a MetaTypeProvider from an XML "config" element.
static MTP loadMTPFromURL(Bundle bundle, java.net.URL url)
          Load a MetaTypeProvider from an XML file.
static java.util.Vector<java.lang.Object> loadSequence(AttributeDefinition attr, net.n3.nanoxml.XMLElement el, int max, java.lang.String tagName)
           
static java.lang.Object loadValue(AttributeDefinition attr, net.n3.nanoxml.XMLElement el)
          Load a java object from an XML element using type info in the specified definition.
static java.util.Dictionary<java.lang.String,java.lang.Object> loadValues(AttributeDefinition[] attrs, net.n3.nanoxml.XMLElement el)
           
static java.util.List<java.util.Dictionary<java.lang.String,java.lang.Object>> loadValues(MetaTypeProvider mtp, net.n3.nanoxml.XMLElement el)
           
static void printMetatypeXML(MetaTypeProvider mtp, java.lang.String[] servicePIDs, java.lang.String[] factoryPIDs, boolean bXMLHeader, boolean bMetatypeTag, java.util.List<?> propList, java.io.PrintWriter out)
          Print sets of definitions to an XML file.
static void printOCDXML(MetaTypeProvider mtp, java.lang.String[] pids, int maxOccurs, java.io.PrintWriter out)
          Print a set of ObjectClassDefinitions as XML.
static void printValuesXML(java.util.List<?> propList, boolean bXMLHeader, java.io.PrintWriter out)
           
static void printXML(java.io.PrintWriter out, AttributeDefinition ad)
          Print an attribute definition as XML.
static void setDefaultValues(MetaTypeProvider mtp, java.util.List<java.util.Dictionary<java.lang.String,java.lang.Object>> propList)
          Overwrite default values in MTP using a set of dictionaries.
protected static void startElement(java.lang.String element, java.net.URL sourceURL)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Loader

public Loader()
Method Detail

loadMTPFromURL

public static MTP loadMTPFromURL(Bundle bundle,
                                 java.net.URL url)
                          throws java.io.IOException
Load a MetaTypeProvider from an XML file.

Throws:
java.io.IOException

loadDefaultsFromURL

public static java.util.List<java.util.Dictionary<java.lang.String,java.lang.Object>> loadDefaultsFromURL(MTP mtp,
                                                                                                          java.net.URL url)
                                                                                                   throws java.io.IOException
Load defaults from an XML file into an MTP.

Throws:
java.io.IOException

loadMTP

public static MTP loadMTP(Bundle bundle,
                          java.net.URL sourceURL,
                          net.n3.nanoxml.XMLElement el)
Load a MetaTypeProvider from an XML "config" element.
  1. Load all service and factory definitions into a MetaTypeProvider instance.
  2. Load any default data.
  3. Insert default data into definitions in MetaTypeProvider using the setDefaultValues method.


setDefaultValues

public static void setDefaultValues(MetaTypeProvider mtp,
                                    java.util.List<java.util.Dictionary<java.lang.String,java.lang.Object>> propList)
Overwrite default values in MTP using a set of dictionaries.

Parameters:
mtp - MetaTypeProvider containing instances of AD
propList - List of Dictionary

loadValues

public static java.util.List<java.util.Dictionary<java.lang.String,java.lang.Object>> loadValues(MetaTypeProvider mtp,
                                                                                                 net.n3.nanoxml.XMLElement el)
Returns:
String (pid) -> Dictionary

loadValues

public static java.util.Dictionary<java.lang.String,java.lang.Object> loadValues(AttributeDefinition[] attrs,
                                                                                 net.n3.nanoxml.XMLElement el)

loadValue

public static java.lang.Object loadValue(AttributeDefinition attr,
                                         net.n3.nanoxml.XMLElement el)
Load a java object from an XML element using type info in the specified definition.


loadSequence

public static java.util.Vector<java.lang.Object> loadSequence(AttributeDefinition attr,
                                                              net.n3.nanoxml.XMLElement el,
                                                              int max,
                                                              java.lang.String tagName)

loadContent

public static java.lang.Object loadContent(AttributeDefinition attr,
                                           net.n3.nanoxml.XMLElement el)
Load the contents of a tag into a java object.

Parameters:
el - element which content should be converted to a java object.
attr - definition defining type.

printMetatypeXML

public static void printMetatypeXML(MetaTypeProvider mtp,
                                    java.lang.String[] servicePIDs,
                                    java.lang.String[] factoryPIDs,
                                    boolean bXMLHeader,
                                    boolean bMetatypeTag,
                                    java.util.List<?> propList,
                                    java.io.PrintWriter out)
Print sets of definitions to an XML file.


printOCDXML

public static void printOCDXML(MetaTypeProvider mtp,
                               java.lang.String[] pids,
                               int maxOccurs,
                               java.io.PrintWriter out)
Print a set of ObjectClassDefinitions as XML.

Parameters:
mtp - Metatype provider
pids - Set of String (PIDs)
out - writer to print to.

printXML

public static void printXML(java.io.PrintWriter out,
                            AttributeDefinition ad)
Print an attribute definition as XML.


printValuesXML

public static void printValuesXML(java.util.List<?> propList,
                                  boolean bXMLHeader,
                                  java.io.PrintWriter out)

loadBMTIfromUrl

public static BundleMetaTypeResource loadBMTIfromUrl(BundleContext bc,
                                                     Bundle b,
                                                     java.net.URL url)
                                              throws java.io.IOException
Throws:
java.io.IOException

startElement

protected static void startElement(java.lang.String element,
                                   java.net.URL sourceURL)
                            throws java.lang.Exception
Throws:
java.lang.Exception

endElement

protected static void endElement(java.lang.String element,
                                 java.lang.String content)
                          throws java.lang.Exception
Throws:
java.lang.Exception

Knopflerfish OSGi 5.2.0