aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: /* aoqi@0: * Use is subject to the license terms. aoqi@0: */ aoqi@0: package com.sun.tools.internal.xjc.outline; aoqi@0: aoqi@0: import java.util.List; aoqi@0: aoqi@0: import com.sun.codemodel.internal.JClass; aoqi@0: import com.sun.codemodel.internal.JDefinedClass; aoqi@0: import com.sun.tools.internal.xjc.model.CClassInfo; aoqi@0: import com.sun.tools.internal.xjc.model.CPropertyInfo; aoqi@0: import com.sun.istack.internal.NotNull; aoqi@0: aoqi@0: /** aoqi@0: * Outline object that provides per-{@link CClassInfo} information aoqi@0: * for filling in methods/fields for a bean. aoqi@0: * aoqi@0: * This interface is accessible from {@link Outline} aoqi@0: * aoqi@0: * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) aoqi@0: */ aoqi@0: public abstract class ClassOutline { aoqi@0: aoqi@0: /** aoqi@0: * A {@link Outline} that encloses all the class outlines. aoqi@0: */ aoqi@0: public abstract @NotNull Outline parent(); aoqi@0: aoqi@0: /** aoqi@0: * {@link PackageOutline} that contains this class. aoqi@0: */ aoqi@0: public @NotNull PackageOutline _package() { aoqi@0: return parent().getPackageContext(ref._package()); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * This {@link ClassOutline} holds information about this {@link CClassInfo}. aoqi@0: */ aoqi@0: public final @NotNull CClassInfo target; aoqi@0: aoqi@0: /** aoqi@0: * The exposed aspect of the a bean. aoqi@0: * aoqi@0: * implClass is always assignable to this type. aoqi@0: *

aoqi@0: * Usually this is the public content interface, but aoqi@0: * it could be the same as the implClass. aoqi@0: */ aoqi@0: public final @NotNull JDefinedClass ref; aoqi@0: aoqi@0: /** aoqi@0: * The implementation aspect of a bean. aoqi@0: * The actual place where fields/methods should be generated into. aoqi@0: */ aoqi@0: public final @NotNull JDefinedClass implClass; aoqi@0: aoqi@0: /** aoqi@0: * The implementation class that shall be used for reference. aoqi@0: *

aoqi@0: * Usually this field holds the same value as the {@link #implClass} method, aoqi@0: * but sometimes it holds the user-specified implementation class aoqi@0: * when it is specified. aoqi@0: *

aoqi@0: * This is the type that needs to be used for generating fields. aoqi@0: */ aoqi@0: public final @NotNull JClass implRef; aoqi@0: aoqi@0: aoqi@0: aoqi@0: aoqi@0: protected ClassOutline( CClassInfo _target, JDefinedClass exposedClass, JClass implRef, JDefinedClass _implClass) { aoqi@0: this.target = _target; aoqi@0: this.ref = exposedClass; aoqi@0: this.implRef = implRef; aoqi@0: this.implClass = _implClass; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Gets all the {@link FieldOutline}s newly declared aoqi@0: * in this class. aoqi@0: */ aoqi@0: public final FieldOutline[] getDeclaredFields() { aoqi@0: List props = target.getProperties(); aoqi@0: FieldOutline[] fr = new FieldOutline[props.size()]; aoqi@0: for( int i=0; i