src/share/jaxws_classes/com/sun/tools/internal/xjc/outline/ClassOutline.java

changeset 0
373ffda63c9a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/outline/ClassOutline.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,125 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +/*
    1.30 + * Use is subject to the license terms.
    1.31 + */
    1.32 +package com.sun.tools.internal.xjc.outline;
    1.33 +
    1.34 +import java.util.List;
    1.35 +
    1.36 +import com.sun.codemodel.internal.JClass;
    1.37 +import com.sun.codemodel.internal.JDefinedClass;
    1.38 +import com.sun.tools.internal.xjc.model.CClassInfo;
    1.39 +import com.sun.tools.internal.xjc.model.CPropertyInfo;
    1.40 +import com.sun.istack.internal.NotNull;
    1.41 +
    1.42 +/**
    1.43 + * Outline object that provides per-{@link CClassInfo} information
    1.44 + * for filling in methods/fields for a bean.
    1.45 + *
    1.46 + * This interface is accessible from {@link Outline}
    1.47 + *
    1.48 + * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
    1.49 + */
    1.50 +public abstract class ClassOutline {
    1.51 +
    1.52 +    /**
    1.53 +     * A {@link Outline} that encloses all the class outlines.
    1.54 +     */
    1.55 +    public abstract @NotNull Outline parent();
    1.56 +
    1.57 +    /**
    1.58 +     * {@link PackageOutline} that contains this class.
    1.59 +     */
    1.60 +    public @NotNull PackageOutline _package() {
    1.61 +        return parent().getPackageContext(ref._package());
    1.62 +    }
    1.63 +
    1.64 +    /**
    1.65 +     * This {@link ClassOutline} holds information about this {@link CClassInfo}.
    1.66 +     */
    1.67 +    public final @NotNull CClassInfo target;
    1.68 +
    1.69 +    /**
    1.70 +     * The exposed aspect of the a bean.
    1.71 +     *
    1.72 +     * implClass is always assignable to this type.
    1.73 +     * <p>
    1.74 +     * Usually this is the public content interface, but
    1.75 +     * it could be the same as the implClass.
    1.76 +     */
    1.77 +    public final @NotNull JDefinedClass ref;
    1.78 +
    1.79 +    /**
    1.80 +     * The implementation aspect of a bean.
    1.81 +     * The actual place where fields/methods should be generated into.
    1.82 +     */
    1.83 +    public final @NotNull JDefinedClass implClass;
    1.84 +
    1.85 +    /**
    1.86 +     * The implementation class that shall be used for reference.
    1.87 +     * <p>
    1.88 +     * Usually this field holds the same value as the {@link #implClass} method,
    1.89 +     * but sometimes it holds the user-specified implementation class
    1.90 +     * when it is specified.
    1.91 +     * <p>
    1.92 +     * This is the type that needs to be used for generating fields.
    1.93 +     */
    1.94 +    public final @NotNull JClass implRef;
    1.95 +
    1.96 +
    1.97 +
    1.98 +
    1.99 +    protected ClassOutline( CClassInfo _target, JDefinedClass exposedClass, JClass implRef, JDefinedClass _implClass) {
   1.100 +        this.target = _target;
   1.101 +        this.ref = exposedClass;
   1.102 +        this.implRef = implRef;
   1.103 +        this.implClass = _implClass;
   1.104 +    }
   1.105 +
   1.106 +    /**
   1.107 +     * Gets all the {@link FieldOutline}s newly declared
   1.108 +     * in this class.
   1.109 +     */
   1.110 +    public final FieldOutline[] getDeclaredFields() {
   1.111 +        List<CPropertyInfo> props = target.getProperties();
   1.112 +        FieldOutline[] fr = new FieldOutline[props.size()];
   1.113 +        for( int i=0; i<fr.length; i++ )
   1.114 +            fr[i] = parent().getField(props.get(i));
   1.115 +        return fr;
   1.116 +    }
   1.117 +
   1.118 +    /**
   1.119 +     * Returns the super class of this class, if it has the
   1.120 +     * super class and it is also a JAXB-bound class.
   1.121 +     * Otherwise null.
   1.122 +     */
   1.123 +    public final ClassOutline getSuperClass() {
   1.124 +        CClassInfo s = target.getBaseClass();
   1.125 +        if(s==null)     return null;
   1.126 +        return parent().getClazz(s);
   1.127 +    }
   1.128 +}

mercurial