src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/ArrayInfoImpl.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2011, 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  */
    26 package com.sun.xml.internal.bind.v2.model.impl;
    28 import javax.xml.namespace.QName;
    30 import com.sun.xml.internal.bind.v2.TODO;
    31 import com.sun.xml.internal.bind.v2.WellKnownNamespace;
    32 import com.sun.xml.internal.bind.v2.model.annotation.Locatable;
    33 import com.sun.xml.internal.bind.v2.model.core.ArrayInfo;
    34 import com.sun.xml.internal.bind.v2.model.core.NonElement;
    35 import com.sun.xml.internal.bind.v2.runtime.Location;
    36 import com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationException;
    38 /**
    39  *
    40  * <p>
    41  * Public because XJC needs to access it
    42  *
    43  * @author Kohsuke Kawaguchi
    44  */
    45 public class ArrayInfoImpl<TypeT,ClassDeclT,FieldT,MethodT>
    46     extends TypeInfoImpl<TypeT,ClassDeclT,FieldT,MethodT>
    47     implements ArrayInfo<TypeT,ClassDeclT>, Location {
    49     private final NonElement<TypeT,ClassDeclT> itemType;
    51     private final QName typeName;
    53     /**
    54      * The representation of T[] in the underlying reflection library.
    55      */
    56     private final TypeT arrayType;
    58     public ArrayInfoImpl(ModelBuilder<TypeT,ClassDeclT,FieldT,MethodT> builder,
    59                          Locatable upstream, TypeT arrayType) {
    60         super(builder, upstream);
    61         this.arrayType = arrayType;
    62         TypeT componentType = nav().getComponentType(arrayType);
    63         this.itemType = builder.getTypeInfo(componentType, this);
    65         QName n = itemType.getTypeName();
    66         if(n==null) {
    67             builder.reportError(new IllegalAnnotationException(Messages.ANONYMOUS_ARRAY_ITEM.format(
    68                 nav().getTypeName(componentType)),this));
    69             n = new QName("#dummy"); // for error recovery
    70         }
    71         this.typeName = calcArrayTypeName(n);
    72     }
    74     /**
    75      * Computes the type name of the array from that of the item type.
    76      */
    77     public static QName calcArrayTypeName(QName n) {
    78         String uri;
    79         if(n.getNamespaceURI().equals(WellKnownNamespace.XML_SCHEMA)) {
    80             TODO.checkSpec("this URI");
    81             uri = "http://jaxb.dev.java.net/array";
    82         } else
    83             uri = n.getNamespaceURI();
    84         return new QName(uri,n.getLocalPart()+"Array");
    85     }
    87     public NonElement<TypeT, ClassDeclT> getItemType() {
    88         return itemType;
    89     }
    91     public QName getTypeName() {
    92         return typeName;
    93     }
    95     public boolean isSimpleType() {
    96         return false;
    97     }
    99     public TypeT getType() {
   100         return arrayType;
   101     }
   103     /**
   104      * Leaf-type cannot be referenced from IDREF.
   105      *
   106      * @deprecated
   107      *      why are you calling a method whose return value is always known?
   108      */
   109     public final boolean canBeReferencedByIDREF() {
   110         return false;
   111     }
   113     public Location getLocation() {
   114         return this;
   115     }
   116     public String toString() {
   117         return nav().getTypeName(arrayType);
   118     }
   119 }

mercurial