Package javolution.xml

Examples of javolution.xml.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

     * @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


     */
    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

     */
    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

        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

     */
    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

     */
    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

     */
    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

  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

  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

        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

Related Classes of javolution.xml.XMLBinding

Copyright © 2018 www.massapicom. 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.