src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TR9401CatalogReader.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 // TR9401CatalogReader.java - Read OASIS Catalog files
   6 
   7 /*
   8  * Copyright 2001-2004 The Apache Software Foundation or its licensors,
   9  * as applicable.
  10  *
  11  * Licensed under the Apache License, Version 2.0 (the "License");
  12  * you may not use this file except in compliance with the License.
  13  * You may obtain a copy of the License at
  14  *
  15  *      http://www.apache.org/licenses/LICENSE-2.0
  16  *
  17  * Unless required by applicable law or agreed to in writing, software
  18  * distributed under the License is distributed on an "AS IS" BASIS,
  19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20  * See the License for the specific language governing permissions and
  21  * limitations under the License.
  22  */
  23 
  24 package com.sun.org.apache.xml.internal.resolver.readers;
  25 
  26 import java.io.InputStream;
  27 import java.io.IOException;
  28 import java.net.MalformedURLException;
  29 import java.util.Vector;
  30 import com.sun.org.apache.xml.internal.resolver.Catalog;
  31 import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
  32 import com.sun.org.apache.xml.internal.resolver.CatalogException;





  33 
  34 /**
  35  * Parses OASIS Open Catalog files.
  36  *
  37  * <p>This class reads OASIS Open Catalog files, returning a stream
  38  * of tokens.</p>
  39  *
  40  * <p>This code interrogates the following non-standard system properties:</p>
  41  *
  42  * <dl>
  43  * <dt><b>xml.catalog.debug</b></dt>
  44  * <dd><p>Sets the debug level. A value of 0 is assumed if the
  45  * property is not set or is not a number.</p></dd>
  46  * </dl>
  47  *
  48  * @see Catalog
  49  *
  50  * @author Norman Walsh
  51  * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
  52  *


  80     Vector unknownEntry = null;
  81 
  82     try {
  83       while (true) {
  84         String token = nextToken();
  85 
  86         if (token == null) {
  87           if (unknownEntry != null) {
  88             catalog.unknownEntry(unknownEntry);
  89             unknownEntry = null;
  90           }
  91           catfile.close();
  92           catfile = null;
  93           return;
  94         }
  95 
  96         String entryToken = null;
  97         if (caseSensitive) {
  98           entryToken = token;
  99         } else {
 100           entryToken = token.toUpperCase();
 101         }
 102 
 103         if (entryToken.equals("DELEGATE")) {
 104           entryToken = "DELEGATE_PUBLIC";
 105         }
 106 
 107         try {
 108           int type = CatalogEntry.getEntryType(entryToken);
 109           int numArgs = CatalogEntry.getEntryArgCount(type);
 110           Vector args = new Vector();
 111 
 112           if (unknownEntry != null) {
 113             catalog.unknownEntry(unknownEntry);
 114             unknownEntry = null;
 115           }
 116 
 117           for (int count = 0; count < numArgs; count++) {
 118             args.addElement(nextToken());
 119           }
 120 


   1 /*
   2  * Licensed to the Apache Software Foundation (ASF) under one or more
   3  * contributor license agreements.  See the NOTICE file distributed with
   4  * this work for additional information regarding copyright ownership.
   5  * The ASF licenses this file to You under the Apache License, Version 2.0
   6  * (the "License"); you may not use this file except in compliance with
   7  * the License.  You may obtain a copy of the License at


   8  *




   9  *      http://www.apache.org/licenses/LICENSE-2.0
  10  *
  11  * Unless required by applicable law or agreed to in writing, software
  12  * distributed under the License is distributed on an "AS IS" BASIS,
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14  * See the License for the specific language governing permissions and
  15  * limitations under the License.
  16  */
  17 
  18 package com.sun.org.apache.xml.internal.resolver.readers;
  19 




  20 import com.sun.org.apache.xml.internal.resolver.Catalog;
  21 import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
  22 import com.sun.org.apache.xml.internal.resolver.CatalogException;
  23 import java.io.IOException;
  24 import java.io.InputStream;
  25 import java.net.MalformedURLException;
  26 import java.util.Locale;
  27 import java.util.Vector;
  28 
  29 /**
  30  * Parses OASIS Open Catalog files.
  31  *
  32  * <p>This class reads OASIS Open Catalog files, returning a stream
  33  * of tokens.</p>
  34  *
  35  * <p>This code interrogates the following non-standard system properties:</p>
  36  *
  37  * <dl>
  38  * <dt><b>xml.catalog.debug</b></dt>
  39  * <dd><p>Sets the debug level. A value of 0 is assumed if the
  40  * property is not set or is not a number.</p></dd>
  41  * </dl>
  42  *
  43  * @see Catalog
  44  *
  45  * @author Norman Walsh
  46  * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
  47  *


  75     Vector unknownEntry = null;
  76 
  77     try {
  78       while (true) {
  79         String token = nextToken();
  80 
  81         if (token == null) {
  82           if (unknownEntry != null) {
  83             catalog.unknownEntry(unknownEntry);
  84             unknownEntry = null;
  85           }
  86           catfile.close();
  87           catfile = null;
  88           return;
  89         }
  90 
  91         String entryToken = null;
  92         if (caseSensitive) {
  93           entryToken = token;
  94         } else {
  95           entryToken = token.toUpperCase(Locale.ENGLISH);
  96         }
  97 
  98         if (entryToken.equals("DELEGATE")) {
  99           entryToken = "DELEGATE_PUBLIC";
 100         }
 101 
 102         try {
 103           int type = CatalogEntry.getEntryType(entryToken);
 104           int numArgs = CatalogEntry.getEntryArgCount(type);
 105           Vector args = new Vector();
 106 
 107           if (unknownEntry != null) {
 108             catalog.unknownEntry(unknownEntry);
 109             unknownEntry = null;
 110           }
 111 
 112           for (int count = 0; count < numArgs; count++) {
 113             args.addElement(nextToken());
 114           }
 115