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  */
  25 
  26 package com.sun.tools.internal.xjc.model;
  27 
  28 import com.sun.tools.internal.xjc.model.nav.NClass;
  29 import com.sun.tools.internal.xjc.model.nav.NType;
  30 import com.sun.xml.internal.bind.v2.model.core.EnumConstant;
  31 
  32 import com.sun.xml.internal.xsom.XSComponent;
  33 import org.xml.sax.Locator;
  34 
  35 /**
  36  * Enumeration constant.
  37  *
  38  * @author Kohsuke Kawaguchi
  39  */
  40 public final class CEnumConstant implements EnumConstant<NType,NClass>, CCustomizable {
  41     /** Name of the constant. */
  42     public final String name;
  43     /** Javadoc comment. Can be null. */
  44     public final String javadoc;
  45     /** Lexical representation of this enum constant. Always non-null. */
  46     private final String lexical;
  47 
  48     private CEnumLeafInfo parent;
  49 
  50     private final XSComponent source;
  51 
  52     private final CCustomizations customizations;
  53 
  54     private final Locator locator;
  55 
  56     /**
  57      * @param name
  58      */
  59     public CEnumConstant(String name, String javadoc, String lexical, XSComponent source, CCustomizations customizations, Locator loc) {
  60         assert name!=null;
  61         this.name = name;
  62         this.javadoc = javadoc;
  63         this.lexical = lexical;
  64         this.source = source;
  65         this.customizations = customizations;
  66         this.locator = loc;
  67     }
  68 
  69     public CEnumLeafInfo getEnclosingClass() {
  70         return parent;
  71     }
  72 
  73     /*package*/ void setParent(CEnumLeafInfo parent) {
  74         this.parent = parent;
  75     }
  76 
  77     public String getLexicalValue() {
  78         return lexical;
  79     }
  80 
  81     public String getName() {
  82         return name;
  83     }
  84 
  85     public XSComponent getSchemaComponent() {
  86         return source;
  87     }
  88 
  89     public CCustomizations getCustomizations() {
  90         return customizations;
  91     }
  92 
  93     public Locator getLocator() {
  94         return locator;
  95     }
  96 }