1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.bind.v2.model.core;
  27 
  28 import java.util.Collection;
  29 
  30 import javax.xml.bind.JAXBElement;
  31 
  32 /**
  33  * A particular use (specialization) of {@link JAXBElement}.
  34  *
  35  * TODO: is ElementInfo adaptable?
  36  *
  37  * @author Kohsuke Kawaguchi
  38  */
  39 public interface ElementInfo<T,C> extends Element<T,C> {
  40 
  41     /**
  42      * Gets the object that represents the value property.
  43      *
  44      * @return
  45      *      non-null.
  46      */
  47     ElementPropertyInfo<T,C> getProperty();
  48 
  49     /**
  50      * Short for <code>getProperty().ref().get(0)</code>.
  51      *
  52      * The type of the value this element holds.
  53      *
  54      * Normally, this is the T of {@code JAXBElement<T>}.
  55      * But if the property is adapted, this is the on-the-wire type.
  56      *
  57      * Or if the element has a list of values, then this field
  58      * represents the type of the individual item.
  59      *
  60      * @see #getContentInMemoryType()
  61      */
  62     NonElement<T,C> getContentType();
  63 
  64     /**
  65      * T of {@code JAXBElement<T>}.
  66      *
  67      * <p>
  68      * This is tied to the in-memory representation.
  69      *
  70      * @see #getContentType()
  71      */
  72     T getContentInMemoryType();
  73 
  74     /**
  75      * Returns the representation for {@link JAXBElement}&lt;<i>contentInMemoryType</i>&gt;.
  76      *
  77      * <p>
  78      * This returns the signature in Java and thus isn't affected by the adapter.
  79      */
  80     T getType();
  81 
  82     /**
  83      * @inheritDoc
  84      *
  85      * {@link ElementInfo} can only substitute {@link ElementInfo}.
  86      */
  87     ElementInfo<T,C> getSubstitutionHead();
  88 
  89     /**
  90      * All the {@link ElementInfo}s whose {@link #getSubstitutionHead()} points
  91      * to this object.
  92      *
  93      * @return
  94      *      can be empty but never null.
  95      */
  96     Collection<? extends ElementInfo<T,C>> getSubstitutionMembers();
  97 }