1 31 package org.pdfbox.encoding; 32 33 import java.io.IOException ; 34 35 import java.util.HashMap ; 36 import java.util.Map ; 37 38 import org.pdfbox.cos.COSName; 39 40 46 public class EncodingManager 47 { 48 private static final Map ENCODINGS = new HashMap (); 49 50 static 51 { 52 ENCODINGS.put( COSName.MAC_ROMAN_ENCODING, new MacRomanEncoding() ); 53 ENCODINGS.put( COSName.PDF_DOC_ENCODING, new PdfDocEncoding() ); 54 ENCODINGS.put( COSName.STANDARD_ENCODING, new StandardEncoding() ); 55 ENCODINGS.put( COSName.WIN_ANSI_ENCODING, new WinAnsiEncoding() ); 56 } 57 58 63 public Encoding getStandardEncoding() 64 { 65 return (Encoding)ENCODINGS.get( COSName.STANDARD_ENCODING ); 66 } 67 68 77 public Encoding getEncoding( COSName name ) throws IOException 78 { 79 Encoding encoding = (Encoding)ENCODINGS.get( name ); 80 if( encoding == null ) 81 { 82 throw new IOException ( "Unknown encoding for '" + name.getName() + "'" ); 83 } 84 return encoding; 85 } 86 } | Popular Tags |