Source Code Cross Referenced for InterleaveDispatcher.java in  » 6.0-JDK-Modules-com.sun » xws-security » com » sun » xml » wss » saml » internal » saml11 » jaxb10 » impl » runtime » 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 » 6.0 JDK Modules com.sun » xws security » com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.runtime 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.5-b16-fcs 
003:        // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
004:        // Any modifications to this file will be lost upon recompilation of the source schema. 
005:        // Generated on: 2005.09.05 at 03:09:41 PM IST 
006:        //
007:
008:        package com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.runtime;
009:
010:        import java.util.Iterator;
011:
012:        import javax.xml.bind.ValidationEvent;
013:
014:        import org.xml.sax.Attributes;
015:        import org.xml.sax.Locator;
016:        import org.xml.sax.SAXException;
017:
018:        import com.sun.xml.bind.JAXBAssertionError;
019:        import com.sun.xml.bind.unmarshaller.Tracer;
020:
021:        /**
022:         * Splits the unmarshalling events to bracnhes to support
023:         * XML Schema's &lt;all> and RELAX NG's &lt;interleave>
024:         * 
025:         * <p>
026:         * This class will be extended by the generated code.
027:         * 
028:         * @optionalRuntime
029:         * 
030:         * @author
031:         *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
032:         */
033:        public abstract class InterleaveDispatcher implements 
034:                UnmarshallingEventHandler {
035:
036:            /** Parent context. */
037:            private final UnmarshallingContext parent;
038:
039:            /** Branches of an interleave. */
040:            protected final Site[] sites;
041:
042:            /** Set to true while all the branches are joining. */
043:            private boolean isJoining;
044:
045:            /** Counts the depth of the element nesting. */
046:            private int nestLevel = 0;
047:
048:            /** When nestLevel>0, all the events shall be sent to this branch. */
049:            private Site currentSite;
050:
051:            protected InterleaveDispatcher(UnmarshallingContext context,
052:                    int size) {
053:                this .parent = context;
054:                sites = new Site[size];
055:                for (int i = 0; i < size; i++)
056:                    sites[i] = new Site();
057:            }
058:
059:            protected void init(UnmarshallingEventHandler[] handlers) {
060:                for (int i = 0; i < handlers.length; i++)
061:                    sites[i].pushContentHandler(handlers[i], 0);
062:            }
063:
064:            // abstract methods
065:            /**
066:             * Returns the branch number that consumes the given element,
067:             * or -1 if the name is not recognized. 
068:             */
069:            protected abstract int getBranchForElement(String uri, String local);
070:
071:            /**
072:             * Returns the branch number that consumes the given attribute,
073:             * or -1 if the name is not recognized. 
074:             */
075:            protected abstract int getBranchForAttribute(String uri,
076:                    String local);
077:
078:            /**
079:             * Returns the branch number that consumes the text events,
080:             * or -1 if no branch is expected to consume it. 
081:             */
082:            protected abstract int getBranchForText();
083:
084:            public Object owner() {
085:                if (nestLevel > 0)
086:                    return currentSite.getCurrentHandler().owner();
087:                else
088:                    throw new JAXBAssertionError();
089:            }
090:
091:            public void enterElement(String uri, String local, String qname,
092:                    Attributes atts) throws SAXException {
093:                if (nestLevel++ == 0) {
094:                    int idx = getBranchForElement(uri, local);
095:                    if (idx == -1) {
096:                        // unknown element. revert to parent.
097:                        joinByEnterElement(null, uri, local, qname, atts);
098:                        return;
099:                    }
100:                    currentSite = sites[idx];
101:                }
102:
103:                currentSite.getCurrentHandler().enterElement(uri, local, qname,
104:                        atts);
105:            }
106:
107:            private void joinByEnterElement(Site source, String uri,
108:                    String local, String qname, Attributes atts)
109:                    throws SAXException {
110:                if (isJoining)
111:                    return; // during a join, child branches send us tokens we sent them. ignore.
112:                isJoining = true;
113:
114:                // send the token to all the other branches.
115:                // since they don't recognize this token, it should try to move
116:                // to the final state (or report an error)
117:                for (int i = 0; i < sites.length; i++)
118:                    if (sites[i] != source)
119:                        sites[i].getCurrentHandler().enterElement(uri, local,
120:                                qname, atts);
121:
122:                // revert to the parent
123:                parent.popContentHandler();
124:                parent.getCurrentHandler()
125:                        .enterElement(uri, local, qname, atts);
126:            }
127:
128:            public void leaveElement(String uri, String local, String qname)
129:                    throws SAXException {
130:                if (nestLevel == 0)
131:                    joinByLeaveElement(null, uri, local, qname);
132:                else {
133:                    currentSite.getCurrentHandler().leaveElement(uri, local,
134:                            qname);
135:                    // leaveElement invocation might cause some unprocessed attributes
136:                    // to be handled. Therefore, while the execution is in the leaveElement,
137:                    // we need to let the branch maintain the control.
138:                    nestLevel--;
139:                }
140:            }
141:
142:            private void joinByLeaveElement(Site source, String uri,
143:                    String local, String qname) throws SAXException {
144:                if (isJoining)
145:                    return; // during a join, child branches send us tokens we sent them. ignore.
146:                isJoining = true;
147:
148:                // send the token to all the other branches.
149:                // since they don't recognize this token, it should try to move
150:                // to the final state (or report an error)
151:                for (int i = 0; i < sites.length; i++)
152:                    if (sites[i] != source)
153:                        sites[i].getCurrentHandler().leaveElement(uri, local,
154:                                qname);
155:
156:                // revert to the parent
157:                parent.popContentHandler();
158:                parent.getCurrentHandler().leaveElement(uri, local, qname);
159:            }
160:
161:            public void text(String s) throws SAXException {
162:                if (nestLevel == 0) {
163:                    int idx = getBranchForText();
164:                    if (idx == -1) {
165:                        if (s.trim().length() == 0) {
166:                            // if ignorable, just ignore.
167:                        } else {
168:                            joinByText(null, s);
169:                        }
170:                        return;
171:                    }
172:                    currentSite = sites[idx];
173:                }
174:
175:                currentSite.getCurrentHandler().text(s);
176:            }
177:
178:            private void joinByText(Site source, String s) throws SAXException {
179:                if (isJoining)
180:                    return; // during a join, child branches send us tokens we sent them. ignore.
181:                isJoining = true;
182:
183:                // send the token to all the other branches.
184:                // since they don't recognize this token, it should try to move
185:                // to the final state (or report an error)
186:                for (int i = 0; i < sites.length; i++)
187:                    if (sites[i] != source)
188:                        sites[i].getCurrentHandler().text(s);
189:
190:                // revert to the parent
191:                parent.popContentHandler();
192:                parent.getCurrentHandler().text(s);
193:            }
194:
195:            public void enterAttribute(String uri, String local, String qname)
196:                    throws SAXException {
197:                if (nestLevel++ == 0) {
198:                    int idx = getBranchForAttribute(uri, local);
199:                    if (idx == -1) {
200:                        // unknown element. revert to parent.
201:                        joinByEnterAttribute(null, uri, local, qname);
202:                        return;
203:                    }
204:                    currentSite = sites[idx];
205:                }
206:
207:                currentSite.getCurrentHandler().enterAttribute(uri, local,
208:                        qname);
209:            }
210:
211:            private void joinByEnterAttribute(Site source, String uri,
212:                    String local, String qname) throws SAXException {
213:                if (isJoining)
214:                    return; // during a join, child branches send us tokens we sent them. ignore.
215:                isJoining = true;
216:
217:                // send the token to all the other branches.
218:                // since they don't recognize this token, it should try to move
219:                // to the final state (or report an error)
220:                for (int i = 0; i < sites.length; i++)
221:                    if (sites[i] != source)
222:                        sites[i].getCurrentHandler().enterAttribute(uri, local,
223:                                qname);
224:
225:                // revert to the parent
226:                parent.popContentHandler();
227:                parent.getCurrentHandler().enterAttribute(uri, local, qname);
228:            }
229:
230:            public void leaveAttribute(String uri, String local, String qname)
231:                    throws SAXException {
232:                if (nestLevel == 0)
233:                    joinByLeaveAttribute(null, uri, local, qname);
234:                else {
235:                    nestLevel--;
236:                    currentSite.getCurrentHandler().leaveAttribute(uri, local,
237:                            qname);
238:                }
239:            }
240:
241:            private void joinByLeaveAttribute(Site source, String uri,
242:                    String local, String qname) throws SAXException {
243:                if (isJoining)
244:                    return; // during a join, child branches send us tokens we sent them. ignore.
245:                isJoining = true;
246:
247:                // send the token to all the other branches.
248:                // since they don't recognize this token, it should try to move
249:                // to the final state (or report an error)
250:                for (int i = 0; i < sites.length; i++)
251:                    if (sites[i] != source)
252:                        sites[i].getCurrentHandler().leaveAttribute(uri, local,
253:                                qname);
254:
255:                // revert to the parent
256:                parent.popContentHandler();
257:                parent.getCurrentHandler().leaveAttribute(uri, local, qname);
258:            }
259:
260:            public void leaveChild(int nextState) throws SAXException {
261:                // assertion failed. since we don't launch any child
262:                // this method shall never be called.
263:                throw new JAXBAssertionError();
264:            }
265:
266:            //    /** triggers join. */    
267:            //    private final UnmarshallingEventHandler nullHandler = new UnmarshallingEventHandler() {
268:            //        public Object owner() {
269:            //            return null;
270:            //        }
271:            //
272:            //        public void enterElement(String uri, String local, String qname, Attributes atts) throws UnreportedException {
273:            //            join
274:            //        }
275:            //        public void leaveElement(String uri, String local, String qname) throws UnreportedException {
276:            //        }
277:            //        public void text(String s) throws UnreportedException {
278:            //        }
279:            //        public void enterAttribute(String uri, String local, String qname) throws UnreportedException {
280:            //        }
281:            //        public void leaveAttribute(String uri, String local, String qname) throws UnreportedException {
282:            //        }
283:            //        public void leaveChild(int nextState) throws UnreportedException {
284:            //        }
285:            //    };
286:
287:            /**
288:             * This implementation will be passed to branches as
289:             * the {@link UnmarshallingContext} implementation.
290:             * 
291:             * Used to maintain separate handler stacks for each branch.
292:             * 
293:             * As an {@link UnmarshallingEventHandler}, this object
294:             * triggers join.
295:             */
296:            private class Site implements  UnmarshallingContext,
297:                    UnmarshallingEventHandler {
298:
299:                // handler stack implemented as an array        
300:                private UnmarshallingEventHandler[] handlers = new UnmarshallingEventHandler[8];
301:                private int[] mementos = new int[8];
302:                private int handlerLen = 0;
303:
304:                private Site() {
305:                    pushContentHandler(this , 0);
306:                }
307:
308:                public void pushContentHandler(
309:                        UnmarshallingEventHandler handler, int memento) {
310:                    if (handlerLen == handlers.length) {
311:                        // expand buffer
312:                        UnmarshallingEventHandler[] h = new UnmarshallingEventHandler[handlerLen * 2];
313:                        int[] m = new int[handlerLen * 2];
314:                        System.arraycopy(handlers, 0, h, 0, handlerLen);
315:                        System.arraycopy(mementos, 0, m, 0, handlerLen);
316:                        handlers = h;
317:                        mementos = m;
318:                    }
319:                    handlers[handlerLen] = handler;
320:                    mementos[handlerLen] = memento;
321:                    handlerLen++;
322:                }
323:
324:                public void popContentHandler() throws SAXException {
325:                    handlerLen--;
326:                    handlers[handlerLen] = null; // this handler is removed
327:                    getCurrentHandler().leaveChild(mementos[handlerLen]);
328:                }
329:
330:                public UnmarshallingEventHandler getCurrentHandler() {
331:                    return handlers[handlerLen - 1];
332:                }
333:
334:                // UnmarshallingEventHandler impl. triggers the join operation
335:                public Object owner() {
336:                    return null;
337:                }
338:
339:                public void enterElement(String uri, String local,
340:                        String qname, Attributes atts) throws SAXException {
341:                    joinByEnterElement(this , uri, local, qname, atts);
342:                }
343:
344:                public void leaveElement(String uri, String local, String qname)
345:                        throws SAXException {
346:                    joinByLeaveElement(this , uri, local, qname);
347:                }
348:
349:                public void enterAttribute(String uri, String local,
350:                        String qname) throws SAXException {
351:                    joinByEnterAttribute(this , uri, local, qname);
352:                }
353:
354:                public void leaveAttribute(String uri, String local,
355:                        String qname) throws SAXException {
356:                    joinByLeaveAttribute(this , uri, local, qname);
357:                }
358:
359:                public void text(String s) throws SAXException {
360:                    joinByText(this , s);
361:                }
362:
363:                public void leaveChild(int nextState) throws SAXException {
364:                }
365:
366:                // the rest of the methods are just delegations for UnmarshallingContext
367:
368:                public void addPatcher(Runnable job) {
369:                    parent.addPatcher(job);
370:                }
371:
372:                public String addToIdTable(String id) {
373:                    return parent.addToIdTable(id);
374:                }
375:
376:                public void consumeAttribute(int idx) throws SAXException {
377:                    parent.consumeAttribute(idx);
378:                }
379:
380:                public String eatAttribute(int idx) throws SAXException {
381:                    return parent.eatAttribute(idx);
382:                }
383:
384:                public int getAttribute(String uri, String name) {
385:                    return parent.getAttribute(uri, name);
386:                }
387:
388:                public String getBaseUri() {
389:                    return parent.getBaseUri();
390:                }
391:
392:                public GrammarInfo getGrammarInfo() {
393:                    return parent.getGrammarInfo();
394:                }
395:
396:                public Locator getLocator() {
397:                    return parent.getLocator();
398:                }
399:
400:                public String getNamespaceURI(String prefix) {
401:                    return parent.getNamespaceURI(prefix);
402:                }
403:
404:                public Object getObjectFromId(String id) {
405:                    return parent.getObjectFromId(id);
406:                }
407:
408:                public String getPrefix(String namespaceURI) {
409:                    return parent.getPrefix(namespaceURI);
410:                }
411:
412:                public Iterator getPrefixes(String namespaceURI) {
413:                    return parent.getPrefixes(namespaceURI);
414:                }
415:
416:                public Tracer getTracer() {
417:                    return parent.getTracer();
418:                }
419:
420:                public Attributes getUnconsumedAttributes() {
421:                    return parent.getUnconsumedAttributes();
422:                }
423:
424:                public void handleEvent(ValidationEvent event,
425:                        boolean canRecover) throws SAXException {
426:                    parent.handleEvent(event, canRecover);
427:                }
428:
429:                public boolean isNotation(String arg0) {
430:                    return parent.isNotation(arg0);
431:                }
432:
433:                public boolean isUnparsedEntity(String arg0) {
434:                    return parent.isUnparsedEntity(arg0);
435:                }
436:
437:                public void popAttributes() {
438:                    parent.popAttributes();
439:                }
440:
441:                public void pushAttributes(Attributes atts,
442:                        boolean collectTextFlag) {
443:                    parent.pushAttributes(atts, collectTextFlag);
444:                }
445:
446:                public String resolveNamespacePrefix(String prefix) {
447:                    return parent.resolveNamespacePrefix(prefix);
448:                }
449:
450:                public String[] getNewlyDeclaredPrefixes() {
451:                    return parent.getNewlyDeclaredPrefixes();
452:                }
453:
454:                public String[] getAllDeclaredPrefixes() {
455:                    return parent.getAllDeclaredPrefixes();
456:                }
457:
458:            }
459:        }
w_w__w___.__j_av__a__2__s___.__com_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.