All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javolution.xml.XMLContext Maven / Gradle / Ivy

The newest version!
/*
 * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
 * Copyright (C) 2012 - Javolution (http://javolution.org/)
 * All rights reserved.
 * 
 * Permission to use, copy, modify, and distribute this software is
 * freely granted, provided that this notice is preserved.
 */
package javolution.xml;

import javolution.context.AbstractContext;
import javolution.context.FormatContext;
import javolution.osgi.internal.OSGiServices;
import javolution.text.TextFormat;

/**
 * 

A context for xml serialization/deserialization. * The default xml format for any class is given by the * {@link javolution.text.DefaultTextFormat Format} inheritable annotation.

* *

A default xml format exists for the following predefined types: *

    *
  • java.lang.Object (value attribute parsed/formatted using {@link TextFormat})
  • *
  • java.util.Collection
  • *
  • java.util.Map
  • *

* * @author Jean-Marie Dautelle * @version 6.0 December 12, 2012 */ public abstract class XMLContext extends FormatContext { /** * Default constructor. */ protected XMLContext() {} /** * Enters and returns a new xml context instance. */ public static XMLContext enter() { return (XMLContext) XMLContext.currentXMLContext().enterInner(); } /** * Returns the xml format for the specified type; if none defined * the default object xml format (based on {@link TextFormat}) is returned. */ public static XMLFormat getFormat(Class type) { return XMLContext.currentXMLContext().searchFormat(type); } /** * Sets the xml format for the specified type (and its sub-types). */ public abstract void setFormat(Class type, XMLFormat format); /** * Searches the xml format for the specified type. */ protected abstract XMLFormat searchFormat( Class type); /** * Returns the current xml context. */ private static XMLContext currentXMLContext() { XMLContext ctx = AbstractContext.current(XMLContext.class); if (ctx != null) return ctx; return OSGiServices.getXMLContext(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy