home *** CD-ROM | disk | FTP | other *** search
- package javax.help;
-
- 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 com.sun.java.help.impl.XmlReader;
- import java.io.IOException;
- import java.io.Reader;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import java.util.ResourceBundle;
- import java.util.Vector;
-
- public class FlatMap$FlatMapResourceBundle extends ResourceBundle implements ParserListener {
- private Hashtable lookup;
- private boolean startedmap;
- private URL source;
- private Vector messages;
- private boolean validParse;
- // $FF: synthetic field
- private final FlatMap this$0;
-
- public FlatMap$FlatMapResourceBundle(FlatMap var1, URL var2) {
- this.this$0 = var1;
- this.lookup = null;
- this.messages = new Vector();
- this.validParse = true;
- this.source = var2;
-
- try {
- URLConnection var4 = var2.openConnection();
- Reader var3 = XmlReader.createReader(var4);
- this.parse(var3);
- var3.close();
- } catch (Exception var7) {
- this.reportMessage("Exception caught while parsing " + var2 + " " + var7.toString(), false);
- }
-
- this.parsingEnded();
-
- String var5;
- String var6;
- for(Enumeration var8 = this.lookup.keys(); var8.hasMoreElements(); var6 = (String)this.lookup.get(var5)) {
- var5 = (String)var8.nextElement();
- }
-
- }
-
- public final Object handleGetObject(String var1) {
- return this.lookup.get(var1);
- }
-
- public Enumeration getKeys() {
- return this.lookup.keys();
- }
-
- synchronized void parse(Reader var1) throws IOException {
- this.lookup = new Hashtable(10);
- Parser var2 = new Parser(var1);
- var2.addParserListener(this);
- var2.parse();
- }
-
- public void tagFound(ParserEvent var1) {
- Object var2 = null;
- Tag var3 = var1.getTag();
- FlatMap.access$000("TagFound: " + var3.name);
- TagProperties var4 = var3.atts;
- if (var3.name.equals("mapID")) {
- if (!this.startedmap) {
- this.parsingError("map.invalidMapFormat");
- }
-
- String var7 = null;
- String var6 = null;
- if (var4 != null) {
- var7 = var4.getProperty("target");
- var6 = var4.getProperty("url");
- }
-
- if (var7 != null && var6 != null) {
- this.lookup.put(var7, var6);
- } else {
- this.reportMessage("Failure in mapID Creation;", true);
- this.reportMessage(" target: " + var7, true);
- this.reportMessage(" url: " + var6, true);
- }
- } else if (var3.name.equals("map")) {
- if (!var3.isEnd) {
- if (var4 != null) {
- String var5 = var4.getProperty("version");
- if (var5 != null && var5.compareTo("1.0") != 0) {
- this.parsingError("map.unknownVersion", var5);
- }
- }
-
- if (this.startedmap) {
- this.parsingError("map.invalidMapFormat");
- }
-
- this.startedmap = true;
- } else if (this.startedmap) {
- this.startedmap = false;
- }
-
- }
- }
-
- public void piFound(ParserEvent var1) {
- }
-
- public void doctypeFound(ParserEvent var1) {
- String var2 = var1.getPublicId();
- if (var2 == null || !var2.equals("-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN")) {
- this.parsingError("map.wrongPublicID", var2);
- }
-
- }
-
- public void textFound(ParserEvent var1) {
- }
-
- public void commentFound(ParserEvent var1) {
- }
-
- public void errorFound(ParserEvent var1) {
- this.reportMessage(var1.getText(), false);
- }
-
- public void reportMessage(String var1, boolean var2) {
- this.messages.addElement(var1);
- this.validParse = this.validParse && var2;
- }
-
- public Enumeration listMessages() {
- return this.messages.elements();
- }
-
- private void parsingEnded() {
- if (!this.validParse) {
- if (this.lookup != null) {
- this.lookup.clear();
- }
-
- FlatMap.access$000("Parsing failed for " + this.source);
- Enumeration var1 = this.messages.elements();
-
- while(var1.hasMoreElements()) {
- String var2 = (String)var1.nextElement();
- FlatMap.access$000(var2);
- }
- } else {
- this.source = null;
- }
-
- }
-
- private void parsingError(String var1) {
- String var2 = HelpUtilities.getText(var1);
- this.reportMessage(var2, false);
- }
-
- private void parsingError(String var1, String var2) {
- String var3 = HelpUtilities.getText(var1, var2);
- this.reportMessage(var3, false);
- }
- }
-