< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/DOMEntityResolverWrapper.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.util;
  23 


 125                 String publicId = inputSource.getPublicId();
 126                 String systemId = inputSource.getSystemId();
 127                 String baseSystemId = inputSource.getBaseURI();
 128                 InputStream byteStream = inputSource.getByteStream();
 129                 Reader charStream = inputSource.getCharacterStream();
 130                 String encoding = inputSource.getEncoding();
 131                 String data = inputSource.getStringData();
 132 
 133                 /**
 134                  * An LSParser looks at inputs specified in LSInput in
 135                  * the following order: characterStream, byteStream,
 136                  * stringData, systemId, publicId.
 137                  */
 138                 XMLInputSource xmlInputSource =
 139                     new XMLInputSource(publicId, systemId, baseSystemId, true);
 140 
 141                 if (charStream != null) {
 142                     xmlInputSource.setCharacterStream(charStream);
 143                 }
 144                 else if (byteStream != null) {
 145                     xmlInputSource.setByteStream((InputStream) byteStream);
 146                 }
 147                 else if (data != null && data.length() != 0) {
 148                     xmlInputSource.setCharacterStream(new StringReader(data));
 149                 }
 150                 xmlInputSource.setEncoding(encoding);
 151                 return xmlInputSource;
 152             }
 153         }
 154 
 155         // unable to resolve entity
 156         return null;
 157 
 158     } // resolveEntity(String,String,String):XMLInputSource
 159 
 160     /** Determines the type of resource being resolved **/
 161     private String getType(XMLResourceIdentifier resourceIdentifier) {
 162         if (resourceIdentifier instanceof XMLGrammarDescription) {
 163             XMLGrammarDescription desc = (XMLGrammarDescription) resourceIdentifier;
 164             if (XMLGrammarDescription.XML_SCHEMA.equals(desc.getGrammarType())) {
 165                 return XSD_TYPE;
   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.util;
  23 


 125                 String publicId = inputSource.getPublicId();
 126                 String systemId = inputSource.getSystemId();
 127                 String baseSystemId = inputSource.getBaseURI();
 128                 InputStream byteStream = inputSource.getByteStream();
 129                 Reader charStream = inputSource.getCharacterStream();
 130                 String encoding = inputSource.getEncoding();
 131                 String data = inputSource.getStringData();
 132 
 133                 /**
 134                  * An LSParser looks at inputs specified in LSInput in
 135                  * the following order: characterStream, byteStream,
 136                  * stringData, systemId, publicId.
 137                  */
 138                 XMLInputSource xmlInputSource =
 139                     new XMLInputSource(publicId, systemId, baseSystemId, true);
 140 
 141                 if (charStream != null) {
 142                     xmlInputSource.setCharacterStream(charStream);
 143                 }
 144                 else if (byteStream != null) {
 145                     xmlInputSource.setByteStream(byteStream);
 146                 }
 147                 else if (data != null && data.length() != 0) {
 148                     xmlInputSource.setCharacterStream(new StringReader(data));
 149                 }
 150                 xmlInputSource.setEncoding(encoding);
 151                 return xmlInputSource;
 152             }
 153         }
 154 
 155         // unable to resolve entity
 156         return null;
 157 
 158     } // resolveEntity(String,String,String):XMLInputSource
 159 
 160     /** Determines the type of resource being resolved **/
 161     private String getType(XMLResourceIdentifier resourceIdentifier) {
 162         if (resourceIdentifier instanceof XMLGrammarDescription) {
 163             XMLGrammarDescription desc = (XMLGrammarDescription) resourceIdentifier;
 164             if (XMLGrammarDescription.XML_SCHEMA.equals(desc.getGrammarType())) {
 165                 return XSD_TYPE;
< prev index next >