/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jena.riot.adapters;

import java.util.Iterator ;

import org.apache.jena.atlas.web.TypedInputStream ;
import org.apache.jena.riot.RiotException ;
import org.apache.jena.riot.stream.* ;

import com.hp.hpl.jena.sparql.util.Utils ;


class AdapterLib
{
    public static com.hp.hpl.jena.util.TypedStream convert(TypedInputStream in)
    {
        return new com.hp.hpl.jena.util.TypedStream(in, in.getContentType(), in.getCharset()) ;
    }
    
    
    public static LocationMapper copyConvert(com.hp.hpl.jena.util.LocationMapper locMap)
    {
        LocationMapper lmap2 = new LocationMapper() ;
        if ( locMap == null )
            return null ;
        
        Iterator<String> sIter1 = locMap.listAltEntries() ;
        for ( ; sIter1.hasNext() ; )
        {
            String k = sIter1.next(); 
            lmap2.addAltEntry(k, locMap.getAltEntry(k)) ;
        }
        
        Iterator<String> sIter2 = locMap.listAltPrefixes() ;

        for ( ; sIter2.hasNext() ; )
        {
            String k = sIter1.next(); 
            lmap2.addAltEntry(k, locMap.getAltPrefix(k)) ;
        }
        return lmap2 ;
    }

    public static Locator convert(com.hp.hpl.jena.util.Locator oldloc)
    {
        if ( oldloc instanceof com.hp.hpl.jena.util.LocatorFile )
        {
            com.hp.hpl.jena.util.LocatorFile lFile = (com.hp.hpl.jena.util.LocatorFile)oldloc ;
            return new LocatorFile(lFile.getDir()) ;
        }
        if ( oldloc instanceof com.hp.hpl.jena.util.LocatorClassLoader )
        {
            com.hp.hpl.jena.util.LocatorClassLoader classLoc = (com.hp.hpl.jena.util.LocatorClassLoader)oldloc ;
            return new LocatorClassLoader(classLoc.getClassLoader()) ;
        }
        if ( oldloc instanceof com.hp.hpl.jena.util.LocatorURL )
            return new LocatorURL() ;
        if ( oldloc instanceof com.hp.hpl.jena.util.LocatorZip )
        {
            com.hp.hpl.jena.util.LocatorZip zipLoc = (com.hp.hpl.jena.util.LocatorZip)oldloc ;
            return new LocatorZip(zipLoc.getZipFileName()) ;
        }
        
        throw new RiotException("Unrecognized Locator: "+Utils.className(oldloc)) ;
    }
}


@@ -838,16 +838,17 @@
 adapters
+ 
 ;%0A%0Aimpor
@@ -1051,17 +1051,16 @@
 tils ;%0A%0A
-%0A
 class Ad
@@ -1067,17 +1067,17 @@
 apterLib
-%0A
+ 
 %7B%0A    pu
@@ -1149,20 +1149,16 @@
 ream in)
-%0A   
  %7B%0A     
@@ -1254,25 +1254,16 @@
 ;%0A    %7D%0A
-    %0A    
 %0A    pub
@@ -1343,20 +1343,16 @@
  locMap)
-%0A   
  %7B%0A     
@@ -1456,24 +1456,16 @@
  null ;%0A
-        
 %0A       
@@ -1526,25 +1526,24 @@
        for (
- 
 ; sIter1.has
@@ -1544,36 +1544,26 @@
 r1.hasNext()
- ; )%0A       
+;)
  %7B%0A         
@@ -1581,34 +1581,34 @@
  = sIter1.next()
-;
  
+;
 %0A            lma
@@ -1656,32 +1656,24 @@
 ;%0A        %7D%0A
-        
 %0A        Ite
@@ -1736,17 +1736,16 @@
    for (
- 
 ; sIter2
@@ -1758,20 +1758,10 @@
 xt()
- ; )%0A       
+;)
  %7B%0A 
@@ -1791,18 +1791,18 @@
 Iter
-1
+2
 .next()
-;
  
+;
 %0A   
@@ -1967,20 +1967,16 @@
  oldloc)
-%0A   
  %7B%0A     
@@ -2035,24 +2035,16 @@
 orFile )
-%0A       
  %7B%0A     
@@ -2269,24 +2269,16 @@
 Loader )
-%0A       
  %7B%0A     
@@ -2633,24 +2633,16 @@
 torZip )
-%0A       
  %7B%0A     
@@ -2802,24 +2802,16 @@
       %7D%0A
-        
 %0A       
@@ -2863,9 +2863,11 @@
 r: %22
-+
+ + 
 Util
@@ -2897,9 +2897,8 @@
     %7D%0A%7D%0A
-%0A

Fix (provied by Jamie Johnson, users@ email)