001: /*
002: * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: /*
026: * COMPONENT_NAME: idl.parser
027: *
028: * ORIGINS: 27
029: *
030: * Licensed Materials - Property of IBM
031: * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
032: * RMI-IIOP v1.0
033: *
034: * @(#)StructEntry.java 1.20 07/05/05
035: */
036:
037: package com.sun.tools.corba.se.idl;
038:
039: // NOTES:
040:
041: import java.io.PrintWriter;
042: import java.util.Enumeration;
043: import java.util.Hashtable;
044: import java.util.Vector;
045:
046: /**
047: * This is the symbol table entry for structs.
048: **/
049: public class StructEntry extends SymtabEntry {
050: protected StructEntry() {
051: super ();
052: } // ctor
053:
054: protected StructEntry(StructEntry that) {
055: super (that);
056: if (!name().equals("")) {
057: module(module() + name());
058: name("");
059: }
060: _members = (Vector) that._members.clone();
061: _contained = (Vector) that._contained.clone();
062: } // ctor
063:
064: protected StructEntry(SymtabEntry that, IDLID clone) {
065: super (that, clone);
066: if (module().equals(""))
067: module(name());
068: else if (!name().equals(""))
069: module(module() + "/" + name());
070: } // ctor
071:
072: public Object clone() {
073: return new StructEntry(this );
074: } // clone
075:
076: /** Invoke the struct generator.
077: @param symbolTable the symbol table is a hash table whose key is
078: a fully qualified type name and whose value is a SymtabEntry or
079: a subclass of SymtabEntry.
080: @param stream the stream to which the generator should sent its output.
081: @see SymtabEntry */
082: public void generate(Hashtable symbolTable, PrintWriter stream) {
083: structGen.generate(symbolTable, this , stream);
084: } // generate
085:
086: /** Access the struct generator.
087: @returns an object which implements the StructGen interface.
088: @see StructGen */
089: public Generator generator() {
090: return structGen;
091: } // generator
092:
093: /** Add a member to the member list. */
094: public void addMember(TypedefEntry member) {
095: _members.addElement(member);
096: } // addMember
097:
098: /** This is a vector of TypedefEntry's. In this context, only the name,
099: type, and arrayInfo fields hold any meaning. */
100: public Vector members() {
101: return _members;
102: } // members
103:
104: public void addContained(SymtabEntry entry) {
105: _contained.addElement(entry);
106: } // addContained
107:
108: /** This is a vector of SymtabEntry's. It itemizes any types which
109: this struct contains. It is different than the member list.
110: For example:
111: <pre>
112: struct A
113: {
114: long x;
115: Struct B
116: {
117: long a;
118: long b;
119: } y;
120: }
121: </pre>
122: Struct B is contained within struct A.
123: The members vector will contain entries for x and y. */
124: public Vector contained() {
125: return _contained;
126: } // contained
127:
128: private Vector _members = new Vector();
129: private Vector _contained = new Vector();
130:
131: static StructGen structGen;
132: } // class StructEntry
|