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

org.eclipse.persistence.jaxb.javamodel.xjc.XJCJavaModelInputImpl Maven / Gradle / Ivy

There is a newer version: 5.0.0-B03
Show newest version
/*
 * Copyright (c) 2011, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0,
 * or the Eclipse Distribution License v. 1.0 which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 */

// Contributors:
//     Rick Barkhouse - 2.1 - Initial implementation
package org.eclipse.persistence.jaxb.javamodel.xjc;

import java.lang.reflect.Type;

import org.eclipse.persistence.jaxb.TypeMappingInfo;
import org.eclipse.persistence.jaxb.javamodel.JavaClass;
import org.eclipse.persistence.jaxb.javamodel.JavaModel;
import org.eclipse.persistence.jaxb.javamodel.JavaModelInput;

/**
 * INTERNAL:
 * 

* Purpose: JavaModelInput implementation for XJC. Used when * bootstrapping a DynamicJAXBContext from an XML Schema. *

* *

* Responsibilities: *

*
    *
  • Create an array of JavaClass instances from an array of Classes/JavaClasses/Types/TypeMappingInfos.
  • *
  • Return an array of JavaClass objects to be used by the generator.
  • *
  • Return the JavaModel to be used during generation.
  • *
* * @since EclipseLink 2.1 * * @see org.eclipse.persistence.jaxb.javamodel.JavaModelInput */ public class XJCJavaModelInputImpl implements JavaModelInput { private JavaClass[] jClasses; private JavaModel jModel; /** * Construct a new instance of XJCJavaModelInputImpl. * * @param types - an array of JavaClasses for which to generate mappings. * @param javaModel - the JavaModel to be used. */ public XJCJavaModelInputImpl(JavaClass[] types, JavaModel javaModel) { this.jModel = javaModel; this.jClasses = types; } /** * Construct a new instance of XJCJavaModelInputImpl. * * @param types - an array of Types for which to generate mappings. * @param javaModel - the JavaModel to be used. */ public XJCJavaModelInputImpl(Type[] types, JavaModel javaModel) { this.jModel = javaModel; this.jClasses = new JavaClass[types.length]; for (int i = 0; i < types.length; i++) { TypeMappingInfo typeMappingInfo = new TypeMappingInfo(); Type type = types[i]; typeMappingInfo.setType(type); jClasses[i] = jModel.getClass((Class) type); } } /** * Construct a new instance of XJCJavaModelInputImpl. * * @param types - an array of TypeMappingInfos for which to generate mappings. * @param javaModel - the JavaModel to be used. */ public XJCJavaModelInputImpl(TypeMappingInfo[] types, JavaModel javaModel) { this.jModel = javaModel; this.jClasses = new JavaClass[types.length]; for (int i = 0; i < types.length; i++) { TypeMappingInfo typeMappingInfo = types[i]; Type type = typeMappingInfo.getType(); jClasses[i] = jModel.getClass((Class) type); } } /** * Construct a new instance of XJCJavaModelInputImpl. * * @param classes - an array of Java Classes for which to generate mappings. * @param javaModel - the JavaModel to be used. */ public XJCJavaModelInputImpl(Class[] classes, JavaModel javaModel) { this.jModel = javaModel; this.jClasses = new JavaClass[classes.length]; for (int i = 0; i < classes.length; i++) { jClasses[i] = jModel.getClass(classes[i]); } } /** * Returns this JavaModelInput's array of JavaClasses. * * @return this JavaModelInput's array of JavaClasses. */ @Override public JavaClass[] getJavaClasses() { return jClasses; } /** * Returns this JavaModelInput's JavaModel. * * @return this JavaModelInput's JavaModel. */ @Override public JavaModel getJavaModel() { return jModel; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy