001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.iiop.rmi.ir;
023:
024: import org.omg.CORBA.TypeCode;
025: import org.omg.CORBA.TypeCodePackage.BadKind;
026: import org.omg.CORBA.IRObject;
027: import org.omg.CORBA.IDLType;
028: import org.omg.CORBA.IDLTypeHelper;
029: import org.omg.CORBA.DefinitionKind;
030: import org.omg.CORBA.SequenceDef;
031: import org.omg.CORBA.SequenceDefOperations;
032: import org.omg.CORBA.SequenceDefHelper;
033: import org.omg.CORBA.SequenceDefPOATie;
034: import org.omg.CORBA.BAD_INV_ORDER;
035:
036: /**
037: * SequenceDef IR object.
038: *
039: * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
040: * @version $Revision: 57194 $
041: */
042: class SequenceDefImpl extends IDLTypeImpl implements
043: SequenceDefOperations {
044: // Constants -----------------------------------------------------
045:
046: // Attributes ----------------------------------------------------
047:
048: // Static --------------------------------------------------------
049:
050: // Constructors --------------------------------------------------
051:
052: SequenceDefImpl(TypeCode typeCode, RepositoryImpl repository) {
053: super (typeCode, DefinitionKind.dk_Sequence, repository);
054: }
055:
056: // Public --------------------------------------------------------
057:
058: // LocalIRObject implementation ---------------------------------
059:
060: public IRObject getReference() {
061: if (ref == null) {
062: ref = org.omg.CORBA.SequenceDefHelper
063: .narrow(servantToReference(new SequenceDefPOATie(
064: this )));
065: }
066: return ref;
067: }
068:
069: public void allDone() throws IRConstructionException {
070: // Get my element type definition: It should have been created now.
071: try {
072: element_type_def = IDLTypeImpl.getIDLType(type()
073: .content_type(), repository);
074: } catch (BadKind ex) {
075: throw new RuntimeException("Bad kind "
076: + type().kind().value()
077: + " for TypeCode.content_type()");
078: }
079:
080: getReference();
081: }
082:
083: // SequenceDefOperations implementation --------------------------
084:
085: public int bound() {
086: try {
087: return type().length();
088: } catch (BadKind ex) {
089: // should never happen
090: throw new RuntimeException();
091: }
092: }
093:
094: public void bound(int arg) {
095: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
096: }
097:
098: public TypeCode element_type() {
099: try {
100: return type().content_type();
101: } catch (BadKind ex) {
102: // should never happen
103: throw new RuntimeException();
104: }
105: }
106:
107: public IDLType element_type_def() {
108: return IDLTypeHelper.narrow(element_type_def.getReference());
109: }
110:
111: public void element_type_def(IDLType arg) {
112: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
113: }
114:
115: // Package protected ---------------------------------------------
116:
117: // Private -------------------------------------------------------
118:
119: /**
120: * My CORBA reference.
121: */
122: private SequenceDef ref = null;
123:
124: /**
125: * My element type.
126: */
127: private LocalIDLType element_type_def;
128: }
|