Logo Search packages:      
Sourcecode: javahelp2 version File versions  Download package

void javax::help::HelpSet::HelpSetParser::tagFound ( ParserEvent  e  )  [inline]

This tells the listener that a Tag was parsed

Parameters:
e The event

Implements com::sun::java::help::impl::ParserListener.

Definition at line 1302 of file HelpSet.java.

References addTag(), com::sun::java::help::impl::Tag::atts, javax::help::HelpSet::debug, com::sun::java::help::impl::LangElement::getTag(), javax::help::HelpSet::implRegistry, com::sun::java::help::impl::Tag::isEmpty, com::sun::java::help::impl::Tag::isEnd, javax::help::HelpSet::kitTypeRegistry, com::sun::java::help::impl::Tag::name, parsingError(), javax::help::HelpSetFactory::processMapRef(), javax::help::HelpSetFactory::processPresentation(), javax::help::HelpSetFactory::processSubHelpSet(), javax::help::HelpSetFactory::processView(), removeTag(), javax::help::HelpSet::setKeyData(), and javax::help::HelpSet::setLocale().

                                          {
            debug("tagFound " + e.getTag().name);
          Locale locale = null;
          LangElement le;
          Tag tag = e.getTag();
          String name = tag.name;
          int x=0, y=0, width=0, height=0;
          TagProperties attr = tag.atts;
          Hashtable ht = (attr == null) ? null : attr.getHashtable();

          if (attr != null) {
            String lang = attr.getProperty("xml:lang");
            locale = HelpUtilities.localeFromLang(lang);
                viewMergeType = attr.getProperty("mergetype");
            helpActionImage = attr.getProperty("image");
            String value = null;
            value = attr.getProperty("width");
            if (value != null) {
                width = Integer.parseInt(value);
            }
            value = null;
            value = attr.getProperty("height");
            if (value != null) {
                height = Integer.parseInt(value);
            }
            value = null;
            value = attr.getProperty("x");
            if (value != null) {
                x = Integer.parseInt(value);
            }
            value = null;
            value = attr.getProperty("y");
            if (value != null) {
                y = Integer.parseInt(value);
            }
            value = null;
            value = attr.getProperty("default");
            if (value != null && value.equals("true")) {
                defaultPresentation = true;
            }
            value = null;
            value = attr.getProperty("displayviews");
            if (value != null && value.equals("false")) {
                displayViews = false;
            }
            value = null;
            value = attr.getProperty("displayviewimages");
            if (value != null && value.equals("false")) {
                displayViewImages = false;
            }
          }
          if (locale == null) {
            locale = lastLocale;
          }
            
          if (name.equals("helpset")) {
            if (tag.isEnd) {
                removeTag(tag);
            } else {
                // Check and see if the locale is different from the
                // defaultLocale. If it is then reset the locale.
                if (! locale.equals(defaultLocale) &&
                  ! locale.equals(myHSLocale)) {
                  if (locale != null) {
                      myHS.setLocale(locale);
                      defaultLocale = locale;
                  }
                }
                if (attr != null) {
                    String version = attr.getProperty("version");
                  if (version != null && 
                      (version.compareTo("1.0") != 0 &&
                       version.compareTo("2.0") != 0)) {
                      parsingError("helpset.unknownVersion", version);
                  }
                }
                addTag(tag, locale);
            }
            return;
          }

          if (tagStack.empty()) {
            parsingError("helpset.wrongTopLevel", name);
          }

          // Get the parents name
          le = (LangElement) tagStack.peek();
          String pname = ((Tag) le.getTag()).name; // the parent

          if (name.equals("title")) {
            // TITLE tag
            if (tag.isEnd) {
                removeTag(tag);           // processing was done in textFound()
            } else {
                if ((! pname.equals("helpset")) &&
                  (! pname.equals("presentation"))){
                  wrongParent(name, pname);
                }
                if (! locale.equals(defaultLocale) &&
                  ! locale.equals(myHSLocale)) {
                  wrongLocale(locale, defaultLocale, myHSLocale);
                }
                addTag(tag, locale);
            }
          } else if (name.equals("homeID")) {
            // HOMEID tags
            if (tag.isEnd) {
                removeTag(tag);           // processing was done in textFound()
            } else {
                if (! pname.equals("maps")) {
                  wrongParent(name, pname);
                }
                addTag(tag, locale);
            }
          } else if (name.equals("mapref")) {
            // MAPREF tags

            // Remove from stack if an empty tag
            if (tag.isEnd && !tag.isEmpty) {
                removeTag(tag);
            } else {
                if (! pname.equals("maps")) {
                  wrongParent(name, pname);
                }
                // add the tag if not an empty tag
                if (! tag.isEmpty) {
                  addTag(tag, locale);
                }
                // Process the tag
                factory.processMapRef(myHS,
                                ht);
            }
          } else if (name.equals("data")) {
            // DATA tag
            if (tag.isEnd) {
                removeTag(tag);
            } else {
                if (! pname.equals("view")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                }
                htData = ht;
            }
          } else if (name.equals("name") ||
                   name.equals("type") ||
                   name.equals("image")){                           
            // NAME, TYPE, IMAGE tag
            if (tag.isEnd) {
                removeTag(tag);
            } else {
                if ((! pname.equals("view")) && 
                  (! pname.equals("presentation"))) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                }
            }
          } else if (name.equals("label")) {
            // LABEL tag
            // Special processing to check the locale attribute.
            if (tag.isEnd) {
                removeTag(tag);
            } else {
                if (! pname.equals("view")) {
                  wrongParent(name, pname);
                } else {
                  if (! locale.equals(defaultLocale) &&
                      ! locale.equals(myHSLocale)) {
                      wrongLocale(locale, defaultLocale, myHSLocale);
                  }
                  addTag(tag, locale);
                }
            }
          } else if (name.equals("view")) {
            // VIEW tag
            if (tag.isEnd) {
                removeTag(tag);

                    if (tagImage != null) {
                        if (htData == null) {
                            htData = new Hashtable();
                  }
                        htData.put("imageID", tagImage);
                    }
                    
                    if (viewMergeType != null) {
                        if(htData == null) {
                            htData = new Hashtable();
                  }
                        htData.put("mergetype",viewMergeType);
                    }

                factory.processView(myHS,
                              tagName,
                              viewLabel,
                              viewType,
                              ht,
                              viewData,
                              htData,
                              locale);
                    tagName = null;
                    viewLabel = null;
                    viewType = null;
                    tagImage = null;
                    viewData = null;
                    htData = null;
                    viewMergeType = null;

            } else {
                if (! pname.equals("helpset")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                }
            }
          } else if (name.equals("presentation")) {
            // Presentation tag
            if (tag.isEnd) {
                removeTag(tag);

                factory.processPresentation(myHS,
                                    tagName,
                                    defaultPresentation,
                                    displayViews,
                                    displayViewImages,
                                    size,
                                    location,
                                    presentationTitle,
                                    tagImage,
                                    toolbar,
                                    helpActions);

                    tagName = null;
                    defaultPresentation = false;
                    displayViews = true;
                    displayViewImages = true;
                    size = null;
                    location = null;
                    presentationTitle = null;
                tagImage = null;
                toolbar = false;
                helpActions = null;

            } else {
                if (! pname.equals("helpset")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                }
            }
          } else if (name.equals("size")) {
            // DATA tag
            if (tag.isEnd) {
                if (size == null) {
                  size = new Dimension(width, height);
                } else {
                  size.setSize(width, height);
                }
                width = 0;
                height = 0;
                if (!tag.isEmpty) {
                  removeTag(tag);
                }
            } else {
                if (! pname.equals("presentation")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                  size = new Dimension();
                }
            }
          } else if (name.equals("location")) {
            // DATA tag
            if (tag.isEnd) {
                if (location == null) {
                  location = new Point(x, y);
                } else {
                  location.setLocation(x, y);
                }
                x = 0;
                y = 0;
                if (!tag.isEmpty) {
                  removeTag(tag);
                }
            } else {
                if (! pname.equals("presentation")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                  location = new Point();
                }
            }
          } else if (name.equals("toolbar")) {
            // DATA tag
            if (tag.isEnd) {
                removeTag(tag);
            } else {
                if (! pname.equals("presentation")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                  helpActions = new Vector();
                  toolbar = true;
                }
            }
          } else if (name.equals("helpaction")) {
            // DATA tag
            if (tag.isEnd) {
                removeTag(tag);
                if (helpAction != null) {
                  Hashtable tmp = new Hashtable();                
                  helpActions.add(new HelpSetFactory.HelpAction(helpAction, tmp));
                  if (helpActionImage != null) {
                      tmp.put("image", helpActionImage);
                      helpActionImage = null;
                  }
                  helpAction = null;
                }
            } else {
                if (! pname.equals("toolbar")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                }
            }
          } else if (name.equals("maps")) {
            // MAPS tag
            if (tag.isEnd) {
                removeTag(tag);
            } else {
                if (! pname.equals("helpset")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                }
            }
          } else if (name.equals("subhelpset")) {
            // SUBHELPSET tag
            
            // Remove from stack if an empty tag
            if (tag.isEnd && !tag.isEmpty) {
                removeTag(tag);
            } else {
                // Add the tag if it isn't an inline tag
                if (!tag.isEmpty) {
                  addTag(tag, locale);
                }
                // Process the tag
                factory.processSubHelpSet(myHS, ht);
            }
          } else if (name.equals("impl")) {
            // Presentation tag
            if (tag.isEnd) {
                removeTag(tag);
                // Nothing to do here. Everything is done while
                // processing the sub tags
            } else {
                if (! pname.equals("helpset")) {
                  wrongParent(name, pname);
                } else {
                  addTag(tag, locale);
                }
            }
          } else if (name.equals("helpsetregistry")) {
            if (tag.isEnd && !tag.isEmpty) {
                removeTag(tag);
            } else {
                if (! pname.equals("impl")) {
                  wrongParent(name, pname);
                } else {
                  if (!tag.isEnd) {
                      addTag(tag, locale);
                  }
                  if (attr != null) {
                      String hbClass = attr.getProperty("helpbrokerclass");
                      if (hbClass != null) {
                        myHS.setKeyData(implRegistry,
                                    helpBrokerClass, 
                                    hbClass);
                      }
                  }
                }
            }
          } else if (name.equals("viewerregistry")) {
            if (tag.isEnd && !tag.isEmpty) {
                removeTag(tag);
            } else {
                if (! pname.equals("impl")) {
                  wrongParent(name, pname);
                } else {
                  if (!tag.isEnd) {
                      addTag(tag, locale);
                  }
                  if (attr != null) {
                      String viewerType = attr.getProperty("viewertype");
                      String viewerClass = attr.getProperty("viewerclass");
                      if (viewerType != null && viewerClass != null) {
                        ClassLoader cl = HelpSet.class.getClassLoader();
                        myHS.setKeyData(kitTypeRegistry,
                                    viewerType, viewerClass);
                        myHS.setKeyData(kitLoaderRegistry,
                                    viewerType, cl);
                      }
                  }
                }
            }
          }
      }


Generated by  Doxygen 1.6.0   Back to index