Home » pdfbox-1.1.0-src » org.apache.pdfbox.encoding.conversion » [javadoc | source]

    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   package org.apache.pdfbox.encoding.conversion;
   18   
   19   import java.util.Iterator;
   20   import java.util.HashMap;
   21   
   22   /**
   23    *  EncodingConversionManager maintains relationship between PDF encoding name
   24    *  and respective EncodingConverter instance. Those PDF encoding name like
   25    *  GBK-EUC-H should be converted to java charset name before constructing a
   26    *  java string instance
   27    *  
   28    *  @author  Pin Xue (http://www.pinxue.net), Holly Lee (holly.lee (at) gmail.com)
   29    *  @version $Revision: 1.0 $
   30    */
   31   public class EncodingConversionManager
   32   {
   33          /**
   34           *  Mapping from PDF encoding name to EncodingConverter instance.
   35           */
   36          private static HashMap encodingMap = new HashMap();
   37   
   38          private EncodingConversionManager()
   39          {
   40          }
   41   
   42          /**
   43           *  Initialize the encodingMap before anything calls us.
   44           */
   45          static {
   46   
   47              // Add CJK encodings to map
   48              Iterator it = CJKEncodings.getEncodingIterator();
   49   
   50              while ( it.hasNext() ) 
   51              {
   52                  String encodingName = (String)(it.next());
   53                  encodingMap.put(encodingName, new CJKConverter(encodingName));
   54              }
   55              // If there is any other encoding conversions, please add it here.
   56   
   57          }
   58   
   59          /**
   60           *  Get converter from given encoding name. If no converted defined,
   61           *  a null is returned.
   62           *  
   63           *  @param encoding search for a converter for the given encoding name
   64           *  @return the converter for the given encoding name
   65           */
   66          public static final EncodingConverter getConverter(String encoding)
   67          {
   68              return (EncodingConverter)(encodingMap.get(encoding));
   69          }
   70   
   71   
   72   }

Home » pdfbox-1.1.0-src » org.apache.pdfbox.encoding.conversion » [javadoc | source]