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

org.simpleframework.xml.convert.Convert Maven / Gradle / Ivy

Go to download

Simple is a high performance XML serialization and configuration framework for Java

The newest version!
/*
 * Convert.java January 2010
 *
 * Copyright (C) 2010, Niall Gallagher 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.
 */

package org.simpleframework.xml.convert;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * The Convert annotation is used to specify a converter
 * class to use for serialization. This annotation is used when an
 * object needs to be serialized but can not be annotated or when the
 * object can not conform to an existing XML structure. In order to
 * specify a Converter object a field or method can be
 * annotated like the field below.
 * 
 * 
 *    @Element
 *    @Convert(ExampleConverter.class)
 *    private Example example;
 * 
 * 
* Note that for the above field the Element annotation * is required. If this is used with any other XML annotation such * as the ElementList or Text annotation * then an exception will be thrown. As well as field and methods * this can be used to suggest a converter for a class. Take the * class below which is annotated. *
 * 
 *    @Root
 *    @Convert(DemoConverter.class)
 *    public class Demo {
 *       ...
 *    }
 * 
 * 
* For the above class the specified converter will be used. This is * useful when the class is used within a java.util.List * or another similar collection. Finally, in order for this to work * it must be used with the AnnotationStrategy which is * used to scan for annotations in order to delegate to converters. * * @author Niall Gallagher * * @see org.simpleframework.xml.convert.AnnotationStrategy */ @Retention(RetentionPolicy.RUNTIME) public @interface Convert { /** * Specifies the Converter implementation to be used * to convert the annotated object. The converter specified will * be used to convert the object to XML by intercepting the * serialization and deserialization process as it happens. A * converter should typically be used to handle an object of * a specific type. * * @return this returns the converter that has been specified */ Class value(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy