1 /*
   2  * Copyright (c) 1997, 2010, 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.tools.internal.ws.processor.model.java;
  27 
  28 import com.sun.tools.internal.ws.processor.model.jaxb.JAXBTypeAndAnnotation;
  29 
  30 /**
  31  *
  32  * @author WS Development Team
  33  */
  34 public abstract class JavaType {
  35 
  36     private String name;
  37     private String realName;
  38     private boolean present;
  39     private boolean holder;
  40     private boolean holderPresent;
  41     private String initString;
  42     private String holderName;
  43     private JAXBTypeAndAnnotation type;
  44 
  45     public JavaType() {}
  46 
  47     public JavaType(JAXBTypeAndAnnotation type){
  48         this.type = type;
  49         init(type.getName(), false, null, null);
  50     }
  51 
  52     public JavaType(String name, boolean present, String initString) {
  53         init(name, present, initString, null);
  54     }
  55 
  56     public JavaType(String name, boolean present, String initString,
  57         String holderName) {
  58 
  59         init(name, present, initString, holderName);
  60     }
  61 
  62     public JAXBTypeAndAnnotation getType(){
  63         return type;
  64     }
  65 
  66     private void init(String name, boolean present, String initString,
  67         String holderName) {
  68 
  69         this.realName = name;
  70         this.name = name.replace('$', '.');
  71         this.present = present;
  72         this.initString = initString;
  73         this.holderName = holderName;
  74         holder = holderName != null;
  75     }
  76 
  77     public String getName() {
  78         return name;
  79     }
  80 
  81     public void doSetName(String name) {
  82 
  83         // renamed to avoid creating a "name" property with broken semantics
  84         this.realName = name;
  85         this.name = name.replace('$', '.');
  86     }
  87 
  88     public String getRealName() {
  89         return realName;
  90     }
  91 
  92     /* serialization */
  93     public void setRealName(String s) {
  94         realName = s;
  95     }
  96 
  97     public String getFormalName() {
  98         return name;
  99     }
 100 
 101     public void setFormalName(String s) {
 102         name = s;
 103     }
 104 
 105     public boolean isPresent() {
 106         return present;
 107     }
 108 
 109     /* serialization */
 110     public void setPresent(boolean b) {
 111         present = b;
 112     }
 113 
 114     public boolean isHolder() {
 115         return holder;
 116     }
 117 
 118     public void setHolder(boolean holder) {
 119         this.holder = holder;
 120     }
 121 
 122     public boolean isHolderPresent() {
 123         return holderPresent;
 124     }
 125     public void setHolderPresent(boolean holderPresent) {
 126         this.holderPresent = holderPresent;
 127     }
 128 
 129     public String getInitString() {
 130         return initString;
 131     }
 132 
 133     /* serialization */
 134     public void setInitString(String s) {
 135         initString = s;
 136     }
 137 
 138     public String getHolderName() {
 139         return holderName;
 140     }
 141 
 142     public void setHolderName(String holderName) {
 143         this.holderName = holderName;
 144     }
 145 }