Source Code Cross Referenced for Member.java in  » Collaboration » JacORB » org » jacorb » idl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » JacORB » org.jacorb.idl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *        JacORB - a free Java ORB
003:         *
004:         *   Copyright (C) 1997-2004 Gerald Brose.
005:         *
006:         *   This library is free software; you can redistribute it and/or
007:         *   modify it under the terms of the GNU Library General Public
008:         *   License as published by the Free Software Foundation; either
009:         *   version 2 of the License, or (at your option) any later version.
010:         *
011:         *   This library is distributed in the hope that it will be useful,
012:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *   Library General Public License for more details.
015:         *
016:         *   You should have received a copy of the GNU Library General Public
017:         *   License along with this library; if not, write to the Free
018:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019:         */
020:
021:        package org.jacorb.idl;
022:
023:        import java.io.PrintWriter;
024:        import java.util.*;
025:
026:        /**
027:         * @author Gerald Brose
028:         * @version $Id: Member.java,v 1.32 2006/06/26 14:37:44 alphonse.bendt Exp $
029:         */
030:        public class Member extends Declaration {
031:            public TypeSpec type_spec;
032:
033:            /**
034:                this list initially set by the parser but later flattened so that
035:                each member only has a single declarator. The list will be null after
036:                calling parse()!
037:             */
038:            SymbolList declarators;
039:
040:            public Vector extendVector;
041:            public TypeDeclaration containingType;
042:
043:            public Declarator declarator;
044:
045:            public Member(int num) {
046:                super (num);
047:            }
048:
049:            public void setPackage(String s) {
050:                s = parser.pack_replace(s);
051:                if (pack_name.length() > 0)
052:                    pack_name = s + "." + pack_name;
053:                else
054:                    pack_name = s;
055:
056:                type_spec.setPackage(s);
057:                if (declarators != null)
058:                    declarators.setPackage(s);
059:            }
060:
061:            public void setEnclosingSymbol(IdlSymbol s) {
062:                enclosing_symbol = s;
063:                type_spec.setEnclosingSymbol(s);
064:                for (Enumeration e = declarators.v.elements(); e
065:                        .hasMoreElements();)
066:                    ((Declarator) e.nextElement()).setEnclosingSymbol(s);
067:            }
068:
069:            public void setContainingType(TypeDeclaration t) {
070:                containingType = t;
071:            }
072:
073:            /**
074:             * must be set by MemberList before parsing
075:             */
076:            public void setExtendVector(Vector v) {
077:                extendVector = v;
078:            }
079:
080:            /**
081:             * Creates a new Member that is similar to this one,
082:             * but only for declarator d.
083:             */
084:            public Member extractMember(Declarator d) {
085:                Member result = new Member(new_num());
086:                result.declarator = d;
087:                return result;
088:            }
089:
090:            /**
091:             * Parsing members means creating new members for definitions
092:             * with more than one declarator.
093:             */
094:            public void parse() {
095:                boolean clone_and_parse = true;
096:
097:                if (extendVector == null) {
098:                    lexer.restorePosition(myPosition);
099:                    parser.fatal_error(
100:                            "Internal Compiler Error: extendVector not set.",
101:                            token);
102:                }
103:
104:                if (type_spec.typeSpec() instanceof  ScopedName) {
105:                    token = type_spec.typeSpec().get_token();
106:                    String name = type_spec.typeSpec().toString();
107:
108:                    type_spec = ((ScopedName) type_spec.typeSpec())
109:                            .resolvedTypeSpec();
110:                    enclosing_symbol.addImportedName(name, type_spec);
111:
112:                    if (type_spec instanceof  AliasTypeSpec) {
113:                        AliasTypeSpec aliasTS = (AliasTypeSpec) type_spec;
114:                        TypeSpec originalType = aliasTS.originalType();
115:                        if (originalType instanceof  SequenceType) {
116:                            SequenceType sequenceTS = (SequenceType) originalType;
117:                            if (sequenceTS.elementTypeSpec().typeName().equals(
118:                                    containingType.typeName())) {
119:                                sequenceTS.setRecursive();
120:                            }
121:                        }
122:                    }
123:
124:                    clone_and_parse = false;
125:                    if (type_spec instanceof  ConstrTypeSpec) {
126:                        if (((ConstrTypeSpec) type_spec.typeSpec()).c_type_spec instanceof  StructType) {
127:                            if (((ConstrTypeSpec) type_spec.typeSpec()).c_type_spec
128:                                    .typeName().equals(
129:                                            containingType.typeName())) {
130:                                parser.fatal_error(
131:                                        "Illegal type recursion (use sequence<"
132:                                                + containingType.typeName()
133:                                                + "> instead)", token);
134:                            }
135:                        }
136:                    }
137:                } else if (type_spec.typeSpec() instanceof  SequenceType) {
138:                    TypeSpec ts = ((SequenceType) type_spec.typeSpec())
139:                            .elementTypeSpec().typeSpec();
140:                    SequenceType seqTs = (SequenceType) type_spec.typeSpec();
141:                    while (ts instanceof  SequenceType) {
142:                        seqTs = (SequenceType) ts;
143:                        ts = ((SequenceType) ts.typeSpec()).elementTypeSpec()
144:                                .typeSpec();
145:                    }
146:
147:                    if (ScopedName.isRecursionScope(ts.typeName())) {
148:                        seqTs.setRecursive();
149:                    }
150:                } else if (type_spec instanceof  ConstrTypeSpec) {
151:                    type_spec.parse();
152:                }
153:
154:                String tokName = null;
155:                if (token != null && token.line_val != null) {
156:                    tokName = token.line_val.trim();
157:                    if (tokName.length() == 0) {
158:                        tokName = null;
159:                    }
160:                }
161:
162:                for (Enumeration e = declarators.v.elements(); e
163:                        .hasMoreElements();) {
164:                    Declarator declarator = (Declarator) e.nextElement();
165:                    String declaratorName = declarator.name();
166:
167:                    if (tokName != null) {
168:                        if (org.jacorb.idl.parser.strict_names) {
169:                            // check for name clashes strictly (i.e. case insensitive)
170:                            if (declaratorName.equalsIgnoreCase(tokName)) {
171:                                parser.fatal_error("Declarator "
172:                                        + declaratorName
173:                                        + " already defined in scope.", token);
174:                            }
175:                        } else {
176:                            // check for name clashes only loosely (i.e. case sensitive)
177:                            if (declaratorName.equals(tokName)) {
178:                                parser.fatal_error("Declarator "
179:                                        + declaratorName
180:                                        + " already defined in scope.", token);
181:                            }
182:                        }
183:                    }
184:
185:                    // we don't parse the declarator itself
186:                    // as that would result in its name getting defined
187:                    // we define the declarator's name as a type name indirectly
188:                    // through the cloned type specs.
189:
190:                    Member m = extractMember(declarator);
191:
192:                    TypeSpec ts = type_spec.typeSpec();
193:
194:                    /* create a separate type spec copy for every declarator
195:                       if the type spec is a new type definition, i.e. a
196:                       struct, enum, union, sequence or the declarator is
197:                       an array declarator
198:                     */
199:
200:                    if (clone_and_parse
201:                            || declarator.d instanceof  ArrayDeclarator) {
202:                        /* arrays need special treatment */
203:
204:                        if (declarator.d instanceof  ArrayDeclarator) {
205:                            ts = new ArrayTypeSpec(new_num(), ts,
206:                                    (ArrayDeclarator) declarator.d, pack_name);
207:                            ts.parse();
208:                        } else if (!(ts instanceof  BaseType)) {
209:                            ts = (TypeSpec) ts.clone();
210:                            if (!(ts instanceof  ConstrTypeSpec)) {
211:                                ts.set_name(declarator.name());
212:                            }
213:
214:                            /* important: only parse type specs once (we do it for the last
215:                               declarator only) */
216:                            if (!e.hasMoreElements()) {
217:                                ts.parse();
218:                            }
219:                        }
220:                    }
221:
222:                    //            else
223:                    if (!(declarator.d instanceof  ArrayDeclarator)) {
224:                        try {
225:                            NameTable.define(containingType + "."
226:                                    + declarator.name(), "declarator");
227:                        } catch (NameAlreadyDefined nad) {
228:                            parser.fatal_error("Declarator "
229:                                    + declarator.name()
230:                                    + " already defined in scope.", token);
231:                        }
232:                    }
233:
234:                    /* if the type spec is a scoped name, it is already parsed and
235:                     * the type name is defined
236:                     */
237:                    m.type_spec = ts;
238:                    m.pack_name = this .pack_name;
239:                    m.name = this .name;
240:                    extendVector.addElement(m);
241:                }
242:                declarators = null;
243:            }
244:
245:            /**
246:             *
247:             */
248:
249:            public void print(PrintWriter ps) {
250:                member_print(ps, "\tpublic ");
251:            }
252:
253:            /**
254:             *
255:             */
256:
257:            public void member_print(PrintWriter ps, String prefix) {
258:                /* only print members that are not interfaces */
259:
260:                if ((type_spec.typeSpec() instanceof  ConstrTypeSpec && !((((ConstrTypeSpec) type_spec
261:                        .typeSpec()).c_type_spec.declaration() instanceof  Interface) || (((ConstrTypeSpec) type_spec
262:                        .typeSpec()).c_type_spec.declaration() instanceof  Value)))
263:                        || type_spec.typeSpec() instanceof  SequenceType
264:                        || type_spec.typeSpec() instanceof  ArrayTypeSpec) {
265:                    type_spec.print(ps);
266:                }
267:
268:                if (type_spec.typeSpec() instanceof  StringType) {
269:                    ps.print(prefix + type_spec.toString() + " "
270:                            + declarator.toString() + " = \"\";");
271:                } else {
272:                    ps.print(prefix + type_spec.toString() + " "
273:                            + declarator.toString() + ";");
274:                }
275:            }
276:
277:            public TypeSpec typeSpec() {
278:                return type_spec.typeSpec();
279:            }
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.