olegt       2002/12/22 13:40:08

  Modified:    src/org/apache/fop/render/txt Tag: fop-0_20_2-maintain
                        TXTRenderer.java
  Log:
  Fixed NPE when options or encoding are null.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.12.2.9  +12 -7     xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java
  
  Index: TXTRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java,v
  retrieving revision 1.12.2.8
  retrieving revision 1.12.2.9
  diff -u -r1.12.2.8 -r1.12.2.9
  --- TXTRenderer.java  8 Nov 2002 10:25:29 -0000       1.12.2.8
  +++ TXTRenderer.java  22 Dec 2002 21:40:07 -0000      1.12.2.9
  @@ -46,6 +46,7 @@
        */
       TXTStream currentStream;
       public static final String encodingOptionName = "txt.encoding";
  +    private static final String DEFAULT_ENCODING = "UTF-8";
   
       private int pageHeight = 7920;
   
  @@ -1699,13 +1700,17 @@
       throws IOException {
           log.info("rendering areas to TEXT");
           currentStream = new TXTStream(outputStream);
  -        String encoding = (String)options.get(encodingOptionName);
  -        try {
  -            byte buff[] = " ".getBytes(encoding);
  -        } catch (java.io.UnsupportedEncodingException uee) {
  -            log.warn("Encoding '"+encoding+"' is not a valid Java encoding. Use 
UTF-8.");
  -            encoding = "UTF-8";
  +        String encoding;
  +        if (options != null && 
(encoding=(String)options.get(encodingOptionName))!=null) {
  +            try {
  +                byte buff[] = " ".getBytes(encoding);
  +            } catch (java.io.UnsupportedEncodingException uee) {
  +                log.warn("Encoding '"+encoding+"' is not supported, so defaulted to 
" + DEFAULT_ENCODING);
  +                encoding = DEFAULT_ENCODING;
  +            }
           }
  +        else
  +            encoding = DEFAULT_ENCODING;
           currentStream.setEncoding(encoding);
           firstPage=true;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to