src/main/java/org/jboss/util/xml/catalog/Catalog.java
protected synchronized void parseCatalogFile(String fileName)
    throws MalformedURLException, IOException, CatalogException {

    // The base-base is the cwd. If the catalog file is specified
    // with a relative path, this assures that it gets resolved
    // properly...
    try {
      // tack on a basename because URLs point to files not dirs
      String userdir = fixSlashes(System.getProperty("user.dir"));
      catalogCwd = new URL("file:" + userdir + "/basename");
    } catch (MalformedURLException e) {
      String userdir = fixSlashes(System.getProperty("user.dir"));
      catalogManager.debug.message(1, "Malformed URL on cwd", userdir);
      catalogCwd = null;
    }

    // The initial base URI is the location of the catalog file
    try {
      base = new URL(catalogCwd, fixSlashes(fileName));
    } catch (MalformedURLException e) {
      try {
	base = new URL("file:" + fixSlashes(fileName));
      } catch (MalformedURLException e2) {
	catalogManager.debug.message(1, "Malformed URL on catalog filename",
		      fixSlashes(fileName));
	base = null;
      }
    }

    catalogManager.debug.message(2, "Loading catalog", fileName);
    catalogManager.debug.message(4, "Default BASE", base.toString());

    fileName = base.toString();

    DataInputStream inStream = null;
    boolean parsed = false;
    boolean notFound = false;

    for (int count = 0; !parsed && count < readerArr.size(); count++) {
      CatalogReader reader = (CatalogReader) readerArr.get(count);

      try {
	notFound = false;
	inStream = new DataInputStream(base.openStream());
      } catch (FileNotFoundException fnfe) {
	// No catalog; give up!
	notFound = true;
	break;
      }

      try {
	reader.readCatalog(this, inStream);
	parsed = true;
      } catch (CatalogException ce) {
	if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
	  // give up!
	  break;
	} else {
	  // try again!
	}
      }

      try {
	inStream.close();
      } catch (IOException e) {
	//nop
      }
    }

    if (!parsed) {
      if (notFound) {
	catalogManager.debug.message(3, "Catalog does not exist", fileName);
      } else {
	catalogManager.debug.message(1, "Failed to parse catalog", fileName);
      }
    }
  }
protected synchronized void parseCatalogFile(String fileName)
    throws MalformedURLException, IOException, CatalogException {

    // The base-base is the cwd. If the catalog file is specified
    // with a relative path, this assures that it gets resolved
    // properly...
    try {
      // tack on a basename because URLs point to files not dirs
      String userdir = fixSlashes(System.getProperty("user.dir"));
      catalogCwd = new URL("file:" + userdir + "/basename");
    } catch (MalformedURLException e) {
      String userdir = fixSlashes(System.getProperty("user.dir"));
      catalogManager.debug.message(1, "Malformed URL on cwd", userdir);
      catalogCwd = null;
    }

    // The initial base URI is the location of the catalog file
    try {
      base = new URL(catalogCwd, fixSlashes(fileName));
    } catch (MalformedURLException e) {
      try {
	base = new URL("file:" + fixSlashes(fileName));
      } catch (MalformedURLException e2) {
	catalogManager.debug.message(1, "Malformed URL on catalog filename",
		      fixSlashes(fileName));
	base = null;
      }
    }

    catalogManager.debug.message(2, "Loading catalog", fileName);
    catalogManager.debug.message(4, "Default BASE", base.toString());

    fileName = base.toString();

    DataInputStream inStream = null;
    boolean parsed = false;
    boolean notFound = false;

    for (int count = 0; !parsed && count < readerArr.size(); count++) {
      CatalogReader reader = (CatalogReader) readerArr.get(count);

      try {
	notFound = false;
	inStream = new DataInputStream(base.openStream());
      } catch (FileNotFoundException fnfe) {
	// No catalog; give up!
	notFound = true;
	break;
      }

      try {
	reader.readCatalog(this, inStream);
	parsed = true;
      } catch (CatalogException ce) {
	if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
	  // give up!
	  break;
	} else {
	  // try again!
	}
      }

      try {
	inStream.close();
      } catch (IOException e) {
	//nop
      }
    }

    if (!parsed) {
      if (notFound) {
	catalogManager.debug.message(3, "Catalog does not exist", fileName);
      } else {
	catalogManager.debug.message(1, "Failed to parse catalog", fileName);
      }
    }
  }
protected synchronized void parseCatalogFile ( String fileName ) throws MalformedURLException , IOException , CatalogException { // The base-base is the cwd. If the catalog file is specified // with a relative path, this assures that it gets resolved // properly... try { // tack on a basename because URLs point to files not dirs String userdir = fixSlashes ( System . getProperty ( "user.dir" ) ) ; catalogCwd = new URL ( "file:" + userdir + "/basename" ) ; } catch ( MalformedURLException e ) { String userdir = fixSlashes ( System . getProperty ( "user.dir" ) ) ; catalogManager . debug . message ( 1 , "Malformed URL on cwd" , userdir ) ; catalogCwd = null ; } // The initial base URI is the location of the catalog file try { base = new URL ( catalogCwd , fixSlashes ( fileName ) ) ; } catch ( MalformedURLException e ) { try { base = new URL ( "file:" + fixSlashes ( fileName ) ) ; } catch ( MalformedURLException e2 ) { catalogManager . debug . message ( 1 , "Malformed URL on catalog filename" , fixSlashes ( fileName ) ) ; base = null ; } } catalogManager . debug . message ( 2 , "Loading catalog" , fileName ) ; catalogManager . debug . message ( 4 , "Default BASE" , base . toString ( ) ) ; fileName = base . toString ( ) ; DataInputStream inStream = null ; boolean parsed = false ; boolean notFound = false ; for ( int count = 0 ; ! parsed && count < readerArr . size ( ) ; count ++ ) { CatalogReader reader = ( CatalogReader ) readerArr . get ( count ) ; try { notFound = false ; inStream = new DataInputStream ( base . openStream ( ) ) ; } catch ( FileNotFoundException fnfe ) { // No catalog; give up! notFound = true ; break ; } try { reader . readCatalog ( this , inStream ) ; parsed = true ; } catch ( CatalogException ce ) { if ( ce . getExceptionType ( ) == CatalogException . PARSE_FAILED ) { // give up! break ; } else { // try again! } } try { inStream . close ( ) ; } catch ( IOException e ) { //nop } } if ( ! parsed ) { if ( notFound ) { catalogManager . debug . message ( 3 , "Catalog does not exist" , fileName ) ; } else { catalogManager . debug . message ( 1 , "Failed to parse catalog" , fileName ) ; } } }
Parse a single catalog file, augmenting internal data structures.

@param fileName The filename of the catalog file to process

@throws MalformedURLException The fileName cannot be turned into
a valid URL.
@throws IOException Error reading catalog file.
@throws CatalogException for any error
Parse a single catalog file augmenting internal data structures .