TypedefEntry.java revision 608:7e06bf1dcb09
11590Srgrimes/*
21590Srgrimes * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
31590Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41590Srgrimes *
51590Srgrimes * This code is free software; you can redistribute it and/or modify it
61590Srgrimes * under the terms of the GNU General Public License version 2 only, as
71590Srgrimes * published by the Free Software Foundation.  Oracle designates this
81590Srgrimes * particular file as subject to the "Classpath" exception as provided
91590Srgrimes * by Oracle in the LICENSE file that accompanied this code.
101590Srgrimes *
111590Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
121590Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131590Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
141590Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
151590Srgrimes * accompanied this code).
161590Srgrimes *
171590Srgrimes * You should have received a copy of the GNU General Public License version
181590Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
191590Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
201590Srgrimes *
211590Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
221590Srgrimes * or visit www.oracle.com if you need additional information or have any
231590Srgrimes * questions.
241590Srgrimes */
251590Srgrimes/*
261590Srgrimes * COMPONENT_NAME: idl.parser
271590Srgrimes *
281590Srgrimes * ORIGINS: 27
291590Srgrimes *
3087628Sdwmalone * Licensed Materials - Property of IBM
311590Srgrimes * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
321590Srgrimes * RMI-IIOP v1.0
3328625Ssteve *
3487628Sdwmalone */
351590Srgrimes
3687628Sdwmalonepackage com.sun.tools.corba.se.idl;
3787628Sdwmalone
3887628Sdwmalone// NOTES:
391590Srgrimes
401590Srgrimesimport java.io.PrintWriter;
4191382Sdwmaloneimport java.util.Hashtable;
421590Srgrimesimport java.util.Vector;
431590Srgrimes
441590Srgrimesimport com.sun.tools.corba.se.idl.constExpr.Expression;
4592920Simp
4692920Simp/**
4792920Simp * This is the symbol table entry for typedefs.
4892920Simp **/
491590Srgrimespublic class TypedefEntry extends SymtabEntry
501590Srgrimes{
511590Srgrimes  protected TypedefEntry ()
521590Srgrimes  {
531590Srgrimes    super ();
541590Srgrimes  } // ctor
55100822Sdwmalone
561590Srgrimes  protected TypedefEntry (TypedefEntry that)
571590Srgrimes  {
581590Srgrimes    super (that);
591590Srgrimes    _arrayInfo = (Vector)that._arrayInfo.clone ();
601590Srgrimes  } // ctor
611590Srgrimes
621590Srgrimes  protected TypedefEntry (SymtabEntry that, IDLID clone)
631590Srgrimes  {
641590Srgrimes    super (that, clone);
651590Srgrimes    if (module ().equals (""))
661590Srgrimes      module (name ());
671590Srgrimes    else if (!name ().equals (""))
681590Srgrimes      module (module () + "/" + name ());
691590Srgrimes  } // ctor
701590Srgrimes
711590Srgrimes  /** This method returns a vector of Expressions, each expression
721590Srgrimes      represents a dimension in an array.  A zero-length vector indicates
731590Srgrimes      no array information.*/
741590Srgrimes  public Vector arrayInfo ()
751590Srgrimes  {
761590Srgrimes    return _arrayInfo;
771590Srgrimes  } // arrayInfo
781590Srgrimes
791590Srgrimes  public void addArrayInfo (Expression e)
801590Srgrimes  {
811590Srgrimes    _arrayInfo.addElement (e);
821590Srgrimes  } // addArrayInfo
831590Srgrimes
841590Srgrimes  public Object clone ()
851590Srgrimes  {
861590Srgrimes    return new TypedefEntry (this);
871590Srgrimes  } // clone
881590Srgrimes
891590Srgrimes  /** Invoke the typedef generator.
901590Srgrimes      @param symbolTable the symbol table is a hash table whose key is
911590Srgrimes       a fully qualified type name and whose value is a SymtabEntry or
921590Srgrimes       a subclass of SymtabEntry.
931590Srgrimes      @param stream the stream to which the generator should sent its output.
941590Srgrimes      @see SymtabEntry */
951590Srgrimes  public void generate (Hashtable symbolTable, PrintWriter stream)
961590Srgrimes  {
971590Srgrimes    typedefGen.generate (symbolTable, this, stream);
981590Srgrimes  } // generate
991590Srgrimes
1001590Srgrimes  public boolean isReferencable()
1011590Srgrimes  {
1021590Srgrimes    // A typedef is referencable if its component
1031590Srgrimes    // type is.
1041590Srgrimes    return type().isReferencable() ;
1051590Srgrimes  }
1061590Srgrimes
1071590Srgrimes  public void isReferencable( boolean value )
1081590Srgrimes  {
1091590Srgrimes    // NO-OP: this cannot be set for a typedef.
1101590Srgrimes  }
1111590Srgrimes
1121590Srgrimes  /** Access the typedef generator.
113166503Srse      @returns an object which implements the TypedefGen interface.
1141590Srgrimes      @see TypedefGen */
1151590Srgrimes  public Generator generator ()
1161590Srgrimes  {
1171590Srgrimes    return typedefGen;
1181590Srgrimes  } // generator
1191590Srgrimes
1201590Srgrimes  private Vector _arrayInfo = new Vector ();
1211590Srgrimes
12291189Sgshapiro  static  TypedefGen typedefGen;
12391189Sgshapiro} // class TypedefEntry
1241590Srgrimes