001: package org.jacorb.idl;
002:
003: /*
004: * JacORB - a free Java ORB
005: *
006: * Copyright (C) 1997-2004 Gerald Brose.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Library General Public License for more details.
017: *
018: * You should have received a copy of the GNU Library General Public
019: * License along with this library; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: import java.io.PrintWriter;
024: import java.util.*;
025:
026: /**
027: * @author Gerald Brose
028: * @version $Id: ValueInheritanceSpec.java,v 1.15 2006/06/19 10:34:57 alphonse.bendt Exp $
029: */
030:
031: public class ValueInheritanceSpec extends SymbolList {
032: /** the value types (both abstract and stateful) inherited by this
033: value type */
034: //Vector v;
035: /** the IDL interfaces inherited ("supported") by this value type */
036: Vector supports;
037:
038: /** if the value type this spec belongs to is truncatable to the
039: single stateful ancestor value type */
040: Truncatable truncatable = null;
041:
042: public ValueInheritanceSpec(int num) {
043: super (num);
044: //v = new Vector();
045: supports = new Vector();
046: }
047:
048: public String getTruncatableId() {
049: if (truncatable == null) {
050: return null;
051: }
052: return truncatable.getId();
053: }
054:
055: public boolean isEmpty() {
056: return (v.size() == 0 && truncatable == null);
057: }
058:
059: public Enumeration getValueTypes() {
060: return v.elements();
061: }
062:
063: public Enumeration getSupportedInterfaces() {
064: return supports.elements();
065: }
066:
067: public void setPackage(String s) {
068: s = parser.pack_replace(s);
069: if (pack_name.length() > 0)
070: pack_name = s + "." + pack_name;
071: else
072: pack_name = s;
073:
074: if (truncatable != null)
075: truncatable.scopedName.setPackage(s);
076:
077: for (Enumeration e = v.elements(); e.hasMoreElements();)
078: ((IdlSymbol) e.nextElement()).setPackage(s);
079:
080: for (Enumeration e = supports.elements(); e.hasMoreElements();)
081: ((IdlSymbol) e.nextElement()).setPackage(s);
082: }
083:
084: public void parse() {
085: if (truncatable != null) {
086: ScopedName s = truncatable.scopedName;
087: Value v = (Value) ((ConstrTypeSpec) s.resolvedTypeSpec()).c_type_spec;
088: if (v instanceof ValueAbsDecl) {
089: parser.error("truncatable base value " + s.toString()
090: + " must not be abstract", token);
091: }
092: }
093: Enumeration e = v.elements();
094: for (; e.hasMoreElements();) {
095: ((IdlSymbol) e.nextElement()).parse();
096: }
097:
098: }
099:
100: public void print(PrintWriter ps) {
101: ps.print(toString());
102: }
103:
104: public String toString() {
105: StringBuffer sb = new StringBuffer();
106:
107: if (truncatable != null)
108: sb.append(truncatable.toString() + " ");
109:
110: Enumeration e = v.elements();
111:
112: if (e.hasMoreElements())
113: sb.append(e.nextElement() + " ");
114:
115: for (; e.hasMoreElements();) {
116: sb.append("," + e.nextElement() + " ");
117: }
118:
119: Enumeration s = supports.elements();
120: if (s.hasMoreElements()) {
121: sb.append("supports ");
122: ((IdlSymbol) s.nextElement()).toString();
123: }
124:
125: for (; s.hasMoreElements();) {
126: sb.append(',');
127: ((IdlSymbol) s.nextElement()).toString();
128: }
129:
130: return sb.toString();
131: }
132: }
|