Examples of XMLBinding

More advanced bindings can also be created through sub-classing.[code] // XML binding using reflection. public ReflectionBinding extends XMLBinding { protected XMLFormat getFormat(Class forClass) { Field[] fields = forClass.getDeclaredFields(); return new XMLReflectionFormat(fields); } } // XML binding read from DTD input source. public DTDBinding extends XMLBinding { public DTDBinding(InputStream dtd) { ... } } // XML binding overriding default formats. public MyBinding extends XMLBinding { // Non-static formats use unmapped XMLFormat instances. XMLFormat myStringFormat = new XMLFormat(null) {...} XMLFormat myCollectionFormat = new XMLFormat(null) {...} protected XMLFormat getFormat(Class forClass) throws XMLStreamException { if (String.class.equals(forClass)) return myStringFormat; if (Collection.class.isAssignableFrom(forClass)) return myCollectionFormat; return super.getFormat(cls); } } [/code]

The default XML binding implementation supports all static XML formats (static members of the classes being mapped) as well as the following types:

@author Jean-Marie Dautelle @version 5.4, December 1, 2009
  • org.apache.cxf.binding.xml.XMLBinding
  • org.eclipse.sapphire.modeling.xml.annotations.XmlBinding
  • org.milyn.javabean.binding.xml.XMLBinding
    XML Binding class.

    This class is designed specifically for reading and writing XML data (does not work for other data formats) to and from Java Object models using nothing more than standard <jb:bean> configurations i.e. no need to write a template for serializing the Java Objects to an output character based format, as with Smooks v1.4 and before. @author tom.fennelly@gmail.com @since 1.5


  • Examples of javolution.xml.XMLBinding

         * @param inputStream the input stream holding the xml configuration.
         */
        public static void read(InputStream inputStream) {
            try {
                XMLObjectReader reader = XMLObjectReader.newInstance(inputStream);
                XMLBinding binding = new XMLBinding() {
                    protected XMLFormat getFormat(Class forClass) throws XMLStreamException  {
                        if (Configurable.class.isAssignableFrom(forClass))
                            return new ConfigurableXMLFormat();
                        return super.getFormat(forClass);
                    }
                };
                binding.setAlias(Configurable.class, "Configurable");
                reader.setBinding(binding);
                // Reads and configures.
                reader.read("Configuration", FastTable.class);
            } catch (Exception ex) {
                LogContext.error(ex);
    View Full Code Here

    Examples of javolution.xml.XMLBinding

         */
        public final  void importData(String importFileName, Map settings)
                throws SerializerException
        {
            /** pre-processing homework... */
            XMLBinding binding = new XMLBinding();
            setupAliases(binding);
            checkSettings(settings);

           
            setSnapshot(readFile(importFileName, binding));
    View Full Code Here

    Examples of javolution.xml.XMLBinding

         */
        public final void exportData(String name, String exportFileName, Map settings)
                throws SerializerException
        {
            /** pre-processing homework... */
            XMLBinding binding = new XMLBinding();
            setupAliases(binding);
            checkSettings(settings);

            /** ensure we can work undisturbed */
            synchronized (cm)
    View Full Code Here

    Examples of javolution.xml.XMLBinding

            if (cm == null)
            {
                cm = Jetspeed.getComponentManager();
            }       
            /** pre-processing homework... */
            XMLBinding binding = new XMLBinding();
            setupAliases(binding);
            checkSettings(settings);
            setSnapshot(readFile(importFileName, binding));
            if (getSnapshot() == null)
                throw new SerializerException(
    View Full Code Here

    Examples of javolution.xml.XMLBinding

         */
        public final void exportData(String name, String exportFileName, Map settings)
                throws SerializerException
        {
            /** pre-processing homework... */
            XMLBinding binding = new XMLBinding();
            setupAliases(binding);
            checkSettings(settings);
            if (cm == null)
            {
                cm = Jetspeed.getComponentManager();
    View Full Code Here

    Examples of javolution.xml.XMLBinding

         */
        public final  void importData(String importFileName, Map settings)
                throws SerializerException
        {
            /** pre-processing homework... */
            XMLBinding binding = new XMLBinding();
            setupAliases(binding);
            checkSettings(settings);

           
            setSnapshot(readFile(importFileName, binding));
    View Full Code Here

    Examples of javolution.xml.XMLBinding

         */
        public final void exportData(String name, String exportFileName, Map settings)
                throws SerializerException
        {
            /** pre-processing homework... */
            XMLBinding binding = new XMLBinding();
            setupAliases(binding);
            checkSettings(settings);

            /** ensure we can work undisturbed */
            synchronized (cm)
    View Full Code Here

    Examples of javolution.xml.XMLBinding

      private ArrayList readOrderFile(String importFileName)
      {
        XMLObjectReader reader = null;

        XMLBinding binding = new XMLBinding();
        binding.setAlias(ArrayList.class, "ProcessOrder");
        binding.setAlias(JSGroup.class, "File");

        ArrayList snap = null;
        try
        {
          reader = XMLObjectReader.newInstance(new FileInputStream(
    View Full Code Here

    Examples of javolution.xml.XMLBinding

      private ArrayList readOrderFile(String importFileName)
      {
        XMLObjectReader reader = null;

        XMLBinding binding = new XMLBinding();
        binding.setAlias(ArrayList.class, "ProcessOrder");
        binding.setAlias(JSGroup.class, "File");

        ArrayList snap = null;
        try
        {
          reader = XMLObjectReader.newInstance(new FileInputStream(
    View Full Code Here

    Examples of javolution.xml.XMLBinding

            if (cm == null)
            {
                cm = Jetspeed.getComponentManager();
            }       
            /** pre-processing homework... */
            XMLBinding binding = new XMLBinding();
            setupAliases(binding);
            checkSettings(settings);
            setSnapshot(readFile(importFileName, binding));
            if (getSnapshot() == null)
                throw new SerializerException(
    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.