SequenceEntry.java revision 672:2bb058ce572e
1139823Simp/*
211819Sjulian * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
311819Sjulian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
411819Sjulian *
511819Sjulian * This code is free software; you can redistribute it and/or modify it
611819Sjulian * under the terms of the GNU General Public License version 2 only, as
711819Sjulian * published by the Free Software Foundation.  Oracle designates this
811819Sjulian * particular file as subject to the "Classpath" exception as provided
911819Sjulian * by Oracle in the LICENSE file that accompanied this code.
1011819Sjulian *
1111819Sjulian * This code is distributed in the hope that it will be useful, but WITHOUT
1211819Sjulian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13165899Srwatson * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14165899Srwatson * version 2 for more details (a copy is included in the LICENSE file that
15165899Srwatson * accompanied this code).
16165899Srwatson *
17165899Srwatson * You should have received a copy of the GNU General Public License version
18165899Srwatson * 2 along with this work; if not, write to the Free Software Foundation,
19165899Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20165899Srwatson *
21165899Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22165899Srwatson * or visit www.oracle.com if you need additional information or have any
23165899Srwatson * questions.
24165899Srwatson */
25165899Srwatson/*
26165899Srwatson * COMPONENT_NAME: idl.parser
27165899Srwatson *
28165899Srwatson * ORIGINS: 27
29165899Srwatson *
30165899Srwatson * Licensed Materials - Property of IBM
31165899Srwatson * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
32165899Srwatson * RMI-IIOP v1.0
33165899Srwatson *
34165899Srwatson */
35165899Srwatson
36165899Srwatsonpackage com.sun.tools.corba.se.idl;
37165899Srwatson
38165899Srwatson// NOTES:
3911819Sjulian
4011819Sjulianimport java.io.PrintWriter;
4111819Sjulianimport java.util.Hashtable;
4211819Sjulianimport java.util.Vector;
4311819Sjulian
4411819Sjulianimport com.sun.tools.corba.se.idl.constExpr.Expression;
4511819Sjulian
4611819Sjulian/**
4711819Sjulian * This is the symbol table entry for sequences.
4811819Sjulian **/
4911819Sjulianpublic class SequenceEntry extends SymtabEntry
5011819Sjulian{
5111819Sjulian  protected SequenceEntry ()
5211819Sjulian  {
5311819Sjulian    super ();
5411819Sjulian    repositoryID (Util.emptyID);
5511819Sjulian  } // ctor
5611819Sjulian
5711819Sjulian  protected SequenceEntry (SequenceEntry that)
5811819Sjulian  {
5912057Sjulian    super (that);
6012057Sjulian    _maxSize = that._maxSize;
6150477Speter  } // ctor
6211819Sjulian
6311819Sjulian  protected SequenceEntry (SymtabEntry that, IDLID clone)
6411819Sjulian  {
6512470Sbde    super (that, clone);
6611819Sjulian    if (!(that instanceof SequenceEntry))
6711819Sjulian      // If that is a SequenceEntry, then it is a container of this sequence, but it is not a module of this sequence.  It's name doesn't belong in the module name.
6811819Sjulian      if (module ().equals (""))
6911819Sjulian        module (name ());
7011819Sjulian      else if (!name ().equals (""))
7111819Sjulian        module (module () + "/" + name ());
7211819Sjulian    repositoryID (Util.emptyID);
7311819Sjulian  } // ctor
7425652Sjhay
7525652Sjhay  public Object clone ()
7625652Sjhay  {
7725652Sjhay    return new SequenceEntry (this);
7825652Sjhay  } // clone
7925652Sjhay
8025652Sjhay  public boolean isReferencable()
8125652Sjhay  {
8211819Sjulian    // A sequence is referencable if its component
8311819Sjulian    // type is.
8411819Sjulian    return type().isReferencable() ;
8511819Sjulian  }
8611819Sjulian
8725652Sjhay  public void isReferencable( boolean value )
8825652Sjhay  {
8925652Sjhay    // NO-OP: this cannot be set for a sequence.
9025652Sjhay  }
9125652Sjhay
9225652Sjhay  /** Invoke the sequence generator.
9325652Sjhay      @param symbolTable the symbol table is a hash table whose key is
9425652Sjhay       a fully qualified type name and whose value is a SymtabEntry or
9525652Sjhay       a subclass of SymtabEntry.
9626965Sjhay      @param stream the stream to which the generator should sent its output.
9725652Sjhay      @see SymtabEntry */
9825652Sjhay  public void generate (Hashtable symbolTable, PrintWriter stream)
9925652Sjhay  {
10026965Sjhay    sequenceGen.generate (symbolTable, this, stream);
10125652Sjhay  } // generate
10225652Sjhay
10325652Sjhay  /** Access the sequence generator.
10411819Sjulian      @return an object which implements the SequenceGen interface.
10511819Sjulian      @see SequenceGen */
10611819Sjulian  public Generator generator ()
10711819Sjulian  {
10811819Sjulian    return sequenceGen;
10911819Sjulian  } // generator
11011819Sjulian
11111819Sjulian  /** the constant expression defining the maximum size of the sequence.
11211819Sjulian      If it is null, then the sequence is unbounded. */
11311819Sjulian  public void maxSize (Expression expr)
11411819Sjulian  {
11511819Sjulian    _maxSize = expr;
11611819Sjulian  } // maxSize
11711819Sjulian
118170664Srwatson  /** the constant expression defining the maximum size of the sequence.
11911819Sjulian      If it is null, then the sequence is unbounded. */
12011819Sjulian  public Expression maxSize ()
12111819Sjulian  {
12211819Sjulian    return _maxSize;
12350519Sjhay  } // maxSize
12411819Sjulian
12511819Sjulian  /** Only sequences can be contained within sequences. */
12611819Sjulian  public void addContained (SymtabEntry entry)
12711819Sjulian  {
12811819Sjulian    _contained.addElement (entry);
12911819Sjulian  } // addContained
13011819Sjulian
13111819Sjulian  /** Only sequences can be contained within sequences. */
13211819Sjulian  public Vector contained ()
13311819Sjulian  {
13411819Sjulian    return _contained;
13511819Sjulian  } // contained
13611819Sjulian
13711819Sjulian  static SequenceGen sequenceGen;
13811819Sjulian
13911819Sjulian  private Expression _maxSize   = null;
14011819Sjulian  private Vector     _contained = new Vector ();
14111819Sjulian} // class SequenceEntry
14211819Sjulian