home *** CD-ROM | disk | FTP | other *** search
- package javax.help;
-
- import com.sun.java.help.impl.LangElement;
- import com.sun.java.help.impl.Parser;
- import com.sun.java.help.impl.ParserEvent;
- import com.sun.java.help.impl.ParserListener;
- import com.sun.java.help.impl.Tag;
- import com.sun.java.help.impl.TagProperties;
- import java.io.IOException;
- import java.io.Reader;
- import java.util.Hashtable;
- import java.util.Locale;
- import java.util.Stack;
- import javax.swing.tree.DefaultMutableTreeNode;
-
- class IndexView$IndexParser implements ParserListener {
- private HelpSet currentParseHS;
- private Stack nodeStack;
- private Stack itemStack;
- private Stack tagStack;
- private Locale defaultLocale;
- private Locale lastLocale;
- private boolean startedindex;
- private TreeItemFactory factory;
-
- IndexView$IndexParser(TreeItemFactory var1) {
- this.factory = var1;
- }
-
- synchronized DefaultMutableTreeNode parse(Reader var1, HelpSet var2, Locale var3) throws IOException {
- this.nodeStack = new Stack();
- this.itemStack = new Stack();
- this.tagStack = new Stack();
- if (var3 == null) {
- this.defaultLocale = Locale.getDefault();
- } else {
- this.defaultLocale = var3;
- }
-
- this.lastLocale = this.defaultLocale;
- DefaultMutableTreeNode var4 = new DefaultMutableTreeNode();
- this.nodeStack.push(var4);
- this.currentParseHS = var2;
- Parser var5 = new Parser(var1);
- var5.addParserListener(this);
- var5.parse();
- return var4;
- }
-
- public void tagFound(ParserEvent var1) {
- Locale var2 = null;
- Tag var3 = var1.getTag();
- TagProperties var4 = var3.atts;
- if (var4 != null) {
- String var5 = var4.getProperty("xml:lang");
- var2 = HelpUtilities.localeFromLang(var5);
- }
-
- if (var2 == null) {
- var2 = this.lastLocale;
- }
-
- if (var3.name.equals("indexitem")) {
- if (!this.startedindex) {
- this.factory.reportMessage(HelpUtilities.getText("index.invalidIndexFormat"), false);
- }
-
- if (var3.isEnd && !var3.isEmpty) {
- this.nodeStack.pop();
- this.itemStack.pop();
- this.removeTag(var3);
- return;
- }
-
- Object var9 = null;
-
- try {
- Hashtable var6 = null;
- if (var4 != null) {
- var6 = var4.getHashtable();
- }
-
- var10 = this.factory.createItem("indexitem", var6, this.currentParseHS, var2);
- } catch (Exception var8) {
- if (IndexView.access$000()) {
- String var7 = null;
- if (var4 != null) {
- var7 = var4.getProperty("target");
- }
-
- System.err.println("Failure in IndexItem Creation; ");
- System.err.println(" id: " + var7);
- System.err.println(" hs: " + this.currentParseHS);
- }
-
- var10 = this.factory.createItem();
- }
-
- DefaultMutableTreeNode var12 = new DefaultMutableTreeNode(var10);
- DefaultMutableTreeNode var13 = (DefaultMutableTreeNode)this.nodeStack.peek();
- var13.add(var12);
- if (!var3.isEmpty) {
- this.itemStack.push(var10);
- this.nodeStack.push(var12);
- this.addTag(var3, var2);
- }
- } else if (var3.name.equals("index")) {
- if (!var3.isEnd) {
- if (var4 != null) {
- String var11 = var4.getProperty("version");
- if (var11 != null && var11.compareTo("1.0") != 0) {
- this.factory.reportMessage(HelpUtilities.getText("index.unknownVersion", var11), false);
- }
- }
-
- if (this.startedindex) {
- this.factory.reportMessage(HelpUtilities.getText("index.invalidIndexFormat"), false);
- }
-
- this.startedindex = true;
- this.addTag(var3, var2);
- } else {
- if (this.startedindex) {
- this.startedindex = false;
- }
-
- this.removeTag(var3);
- }
-
- return;
- }
-
- }
-
- public void piFound(ParserEvent var1) {
- }
-
- public void doctypeFound(ParserEvent var1) {
- this.factory.processDOCTYPE(var1.getRoot(), var1.getPublicId(), var1.getSystemId());
- }
-
- public void textFound(ParserEvent var1) {
- if (!this.tagStack.empty()) {
- LangElement var2 = (LangElement)this.tagStack.peek();
- Tag var3 = var2.getTag();
- if (var3.name.equals("indexitem")) {
- IndexItem var4 = (IndexItem)this.itemStack.peek();
- String var5 = var4.getName();
- if (var5 == null) {
- var4.setName(var1.getText().trim());
- } else {
- var4.setName(var5.concat(var1.getText()).trim());
- }
- }
-
- }
- }
-
- public void commentFound(ParserEvent var1) {
- }
-
- public void errorFound(ParserEvent var1) {
- this.factory.reportMessage(var1.getText(), false);
- }
-
- protected void addTag(Tag var1, Locale var2) {
- LangElement var3 = new LangElement(var1, var2);
- this.tagStack.push(var3);
- if (this.lastLocale == null) {
- this.lastLocale = var2;
- } else if (var2 == null) {
- this.lastLocale = var2;
- } else {
- if (!this.lastLocale.equals(var2)) {
- this.lastLocale = var2;
- }
-
- }
- }
-
- protected void removeTag(Tag var1) {
- String var3 = var1.name;
- Locale var4 = null;
-
- while(!this.tagStack.empty()) {
- LangElement var2 = (LangElement)this.tagStack.pop();
- if (!var2.getTag().name.equals(var3)) {
- if (this.tagStack.empty()) {
- var4 = this.defaultLocale;
- } else {
- var2 = (LangElement)this.tagStack.peek();
- var4 = var2.getLocale();
- }
- break;
- }
- }
-
- if (this.lastLocale == null) {
- this.lastLocale = var4;
- } else if (var4 == null) {
- this.lastLocale = var4;
- } else {
- if (!this.lastLocale.equals(var4)) {
- this.lastLocale = var4;
- }
-
- }
- }
- }
-