jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. |
3 */ |
3 */ |
4 /* |
4 /* |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * contributor license agreements. See the NOTICE file distributed with |
6 * contributor license agreements. See the NOTICE file distributed with |
7 * this work for additional information regarding copyright ownership. |
7 * this work for additional information regarding copyright ownership. |
368 |
368 |
369 /** Entities. */ |
369 /** Entities. */ |
370 protected Map<String, Entity> fEntities = new HashMap<>(); |
370 protected Map<String, Entity> fEntities = new HashMap<>(); |
371 |
371 |
372 /** Entity stack. */ |
372 /** Entity stack. */ |
373 protected Stack fEntityStack = new Stack(); |
373 protected Stack<Entity> fEntityStack = new Stack<>(); |
374 |
374 |
375 /** Current entity. */ |
375 /** Current entity. */ |
376 protected Entity.ScannedEntity fCurrentEntity = null; |
376 protected Entity.ScannedEntity fCurrentEntity = null; |
377 |
377 |
378 /** identify if the InputSource is created by a resolver */ |
378 /** identify if the InputSource is created by a resolver */ |
631 if (xmlInputSource instanceof HTTPInputSource) { |
631 if (xmlInputSource instanceof HTTPInputSource) { |
632 final HttpURLConnection urlConnection = (HttpURLConnection) connect; |
632 final HttpURLConnection urlConnection = (HttpURLConnection) connect; |
633 final HTTPInputSource httpInputSource = (HTTPInputSource) xmlInputSource; |
633 final HTTPInputSource httpInputSource = (HTTPInputSource) xmlInputSource; |
634 |
634 |
635 // set request properties |
635 // set request properties |
636 Iterator propIter = httpInputSource.getHTTPRequestProperties(); |
636 Iterator<Map.Entry<String, String>> propIter = httpInputSource.getHTTPRequestProperties(); |
637 while (propIter.hasNext()) { |
637 while (propIter.hasNext()) { |
638 Map.Entry entry = (Map.Entry) propIter.next(); |
638 Map.Entry<String, String> entry = propIter.next(); |
639 urlConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue()); |
639 urlConnection.setRequestProperty(entry.getKey(), entry.getValue()); |
640 } |
640 } |
641 |
641 |
642 // set preference for redirection |
642 // set preference for redirection |
643 followRedirects = httpInputSource.getFollowHTTPRedirects(); |
643 followRedirects = httpInputSource.getFollowHTTPRedirects(); |
644 if (!followRedirects) { |
644 if (!followRedirects) { |
1055 if(resourceIdentifier == null ) return null; |
1055 if(resourceIdentifier == null ) return null; |
1056 String publicId = resourceIdentifier.getPublicId(); |
1056 String publicId = resourceIdentifier.getPublicId(); |
1057 String literalSystemId = resourceIdentifier.getLiteralSystemId(); |
1057 String literalSystemId = resourceIdentifier.getLiteralSystemId(); |
1058 String baseSystemId = resourceIdentifier.getBaseSystemId(); |
1058 String baseSystemId = resourceIdentifier.getBaseSystemId(); |
1059 String expandedSystemId = resourceIdentifier.getExpandedSystemId(); |
1059 String expandedSystemId = resourceIdentifier.getExpandedSystemId(); |
1060 String namespace = resourceIdentifier.getNamespace(); |
|
1061 |
1060 |
1062 // if no base systemId given, assume that it's relative |
1061 // if no base systemId given, assume that it's relative |
1063 // to the systemId of the current scanned entity |
1062 // to the systemId of the current scanned entity |
1064 // Sometimes the system id is not (properly) expanded. |
1063 // Sometimes the system id is not (properly) expanded. |
1065 // We need to expand the system id if: |
1064 // We need to expand the system id if: |
2065 return null; |
2064 return null; |
2066 } |
2065 } |
2067 |
2066 |
2068 // system id has to be a valid URI |
2067 // system id has to be a valid URI |
2069 if (strict) { |
2068 if (strict) { |
2070 |
|
2071 |
|
2072 // check if there is a system id before |
|
2073 // trying to expand it. |
|
2074 if (systemId == null) { |
|
2075 return null; |
|
2076 } |
|
2077 |
|
2078 try { |
2069 try { |
2079 // if it's already an absolute one, return it |
2070 // if it's already an absolute one, return it |
2080 new URI(systemId); |
2071 new URI(systemId); |
2081 return systemId; |
2072 return systemId; |
2082 } |
2073 } |
2966 if(fCurrentEntity.mayReadChunks || !fCurrentEntity.xmlDeclChunkRead) { |
2957 if(fCurrentEntity.mayReadChunks || !fCurrentEntity.xmlDeclChunkRead) { |
2967 |
2958 |
2968 if (!fCurrentEntity.xmlDeclChunkRead) |
2959 if (!fCurrentEntity.xmlDeclChunkRead) |
2969 { |
2960 { |
2970 fCurrentEntity.xmlDeclChunkRead = true; |
2961 fCurrentEntity.xmlDeclChunkRead = true; |
2971 len = fCurrentEntity.DEFAULT_XMLDECL_BUFFER_SIZE; |
2962 len = DEFAULT_XMLDECL_BUFFER_SIZE; |
2972 } |
2963 } |
2973 return fInputStream.read(b, off, len); |
2964 return fInputStream.read(b, off, len); |
2974 } |
2965 } |
2975 |
2966 |
2976 int returnedVal = read(); |
2967 int returnedVal = read(); |