vgritsenko    2003/01/24 18:58:58

  Modified:    src/java/org/apache/cocoon/generation
                        LinkStatusGenerator.java ServerPagesGenerator.java
               src/java/org/apache/cocoon/transformation
                        EncodeURLTransformer.java I18nTransformer.java
                        SourceWritingTransformer.java TraxTransformer.java
  Log:
  conf is not null. remove some dead code. realign i18n transformer.
  
  Revision  Changes    Path
  1.8       +2 -2      
xml-cocoon2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java
  
  Index: LinkStatusGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LinkStatusGenerator.java  17 Aug 2002 03:49:51 -0000      1.7
  +++ LinkStatusGenerator.java  25 Jan 2003 02:58:57 -0000      1.8
  @@ -266,7 +266,7 @@
   
           Configuration[] children;
           children = configuration.getChildren(INCLUDE_CONFIG);
  -        if (children != null && children.length > 0) {
  +        if (children.length > 0) {
               includeCrawlingURL = new HashSet();
               for (int i = 0; i < children.length; i++) {
                   String pattern = children[i].getValue();
  @@ -284,7 +284,7 @@
           }
   
           children = configuration.getChildren(EXCLUDE_CONFIG);
  -        if (children != null && children.length > 0) {
  +        if (children.length > 0) {
               excludeCrawlingURL = new HashSet();
               for (int i = 0; i < children.length; i++) {
                   String pattern = children[i].getValue();
  
  
  
  1.25      +2 -4      
xml-cocoon2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java
  
  Index: ServerPagesGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ServerPagesGenerator.java 9 Jan 2003 18:47:47 -0000       1.24
  +++ ServerPagesGenerator.java 25 Jan 2003 02:58:57 -0000      1.25
  @@ -216,9 +216,7 @@
           }
   
           // Give our own logger to the generator so that logs go in the correct 
category
  -        if (generator instanceof LogEnabled) {
  -            ((LogEnabled) generator).enableLogging(getLogger());
  -        }
  +        generator.enableLogging(getLogger());
   
           generator.setup(super.resolver, super.objectModel, super.source, 
super.parameters);
       }
  
  
  
  1.5       +8 -10     
xml-cocoon2/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java
  
  Index: EncodeURLTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EncodeURLTransformer.java 10 Nov 2002 22:39:08 -0000      1.4
  +++ EncodeURLTransformer.java 25 Jan 2003 02:58:58 -0000      1.5
  @@ -122,7 +122,6 @@
    *   description="RE pattern for including attributes from encode URL rewriting"
    *
    */
  -
   public class EncodeURLTransformer
     extends AbstractTransformer
     implements Configurable, CacheableProcessingComponent {
  @@ -215,15 +214,14 @@
        * @since
        */
       public void configure(Configuration configuration) throws 
ConfigurationException {
  -        if (configuration != null) {
  -            Configuration child;
  +        Configuration child;
   
  -            child = configuration.getChild(INCLUDE_NAME);
  -            this.includeNameConfigure = child.getValue(INCLUDE_NAME_DEFAULT);
  +        child = configuration.getChild(INCLUDE_NAME);
  +        this.includeNameConfigure = child.getValue(INCLUDE_NAME_DEFAULT);
  +
  +        child = configuration.getChild(EXCLUDE_NAME);
  +        this.excludeNameConfigure = child.getValue(EXCLUDE_NAME_DEFAULT);
   
  -            child = configuration.getChild(EXCLUDE_NAME);
  -            this.excludeNameConfigure = child.getValue(EXCLUDE_NAME_DEFAULT);
  -        }
           if (this.includeNameConfigure == null) {
               String message = "Configure " + INCLUDE_NAME + "!";
               throw new ConfigurationException(message);
  
  
  
  1.28      +429 -459  
xml-cocoon2/src/java/org/apache/cocoon/transformation/I18nTransformer.java
  
  Index: I18nTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/I18nTransformer.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- I18nTransformer.java      22 Jan 2003 12:42:24 -0000      1.27
  +++ I18nTransformer.java      25 Jan 2003 02:58:58 -0000      1.28
  @@ -212,21 +212,21 @@
    * $Id$
    */
   public class I18nTransformer extends AbstractTransformer
  -    implements CacheableProcessingComponent,
  -               Composable, Configurable, Disposable {
  +        implements CacheableProcessingComponent,
  +        Composable, Configurable, Disposable {
   
       /**
        * The namespace for i18n is "http://apache.org/cocoon/i18n/2.1";.
   
        */
       public static final String I18N_NAMESPACE_URI =
  -        "http://apache.org/cocoon/i18n/2.1";;
  +            "http://apache.org/cocoon/i18n/2.1";;
   
       /**
        * The old namespace for i18n is "http://apache.org/cocoon/i18n/2.0";.
        */
       public static final String I18N_OLD_NAMESPACE_URI =
  -        "http://apache.org/cocoon/i18n/2.0";;
  +            "http://apache.org/cocoon/i18n/2.0";;
   
       //
       // i18n elements
  @@ -489,15 +489,15 @@
   
       /** integer currency element */
       public static final String I18N_INT_CURRENCY_ELEMENT
  -        = "int-currency";
  +            = "int-currency";
   
       /** currency without unit element */
       public static final String I18N_CURRENCY_NO_UNIT_ELEMENT =
  -        "currency-no-unit";
  +            "currency-no-unit";
   
       /** integer currency without unit element */
       public static final String I18N_INT_CURRENCY_NO_UNIT_ELEMENT =
  -        "int-currency-no-unit";
  +            "int-currency-no-unit";
   
       // i18n general attributes
   
  @@ -652,17 +652,13 @@
       // FIXME (KP): Cache validity should be generated by
       // Bundle implementations.
       private static final SourceValidity I18N_NOP_VALIDITY =
  -        new org.apache.excalibur.source.impl.validity.NOPValidity();
  +            new org.apache.excalibur.source.impl.validity.NOPValidity();
   
       // States of the transformer
       private static final int STATE_OUTSIDE                       = 0;
       private static final int STATE_INSIDE_TEXT                   = 10;
       private static final int STATE_INSIDE_PARAM                  = 20;
  -    private static final int STATE_INSIDE_PARAM_NODE             = 21;
       private static final int STATE_INSIDE_TRANSLATE              = 30;
  -    private static final int STATE_INSIDE_TRANSLATE_TEXT         = 31;
  -    private static final int STATE_TRANSLATE_KEY                 = 40;
  -    private static final int STATE_TRANSLATE_TEXT_KEY            = 41;
       private static final int STATE_INSIDE_CHOOSE                 = 50;
       private static final int STATE_INSIDE_WHEN                   = 51;
       private static final int STATE_INSIDE_OTHERWISE              = 52;
  @@ -835,38 +831,36 @@
           if (factory == null) {
               throw new ConfigurationException("BundleFactory component is not 
found.");
           }
  -        if (conf != null) {
  -            // read in the config options from the transformer definition
  +        // read in the config options from the transformer definition
   
  -            // obtain the base name of the message catalogue
  -            Configuration child = conf.getChild(I18N_CATALOGUE_NAME);
  -            catalogueName = child.getValue(null);
  -            debug("Default catalogue name is " + catalogueName);
  -
  -            // obtain the directory location of message catalogues
  -            child = conf.getChild(I18N_CATALOGUE_LOCATION);
  -            catalogueLocation = child.getValue(null);
  -            debug("Default catalogue location is " + catalogueLocation);
  -
  -            // check our mandatory parameters
  -            if (catalogueName == null || catalogueLocation == null)
  -                throw new ConfigurationException(
  +        // obtain the base name of the message catalogue
  +        Configuration child = conf.getChild(I18N_CATALOGUE_NAME);
  +        catalogueName = child.getValue(null);
  +        debug("Default catalogue name is " + catalogueName);
  +
  +        // obtain the directory location of message catalogues
  +        child = conf.getChild(I18N_CATALOGUE_LOCATION);
  +        catalogueLocation = child.getValue(null);
  +        debug("Default catalogue location is " + catalogueLocation);
  +
  +        // check our mandatory parameters
  +        if (catalogueName == null || catalogueLocation == null)
  +            throw new ConfigurationException(
                       "I18nTransformer requires the name and location of " +
                       "the message catalogues"
  -                );
  -
  -            // obtain default text to use for untranslated messages
  -            child = conf.getChild(I18N_UNTRANSLATED);
  -            untranslated = child.getValue(null);
  -            debug("Default untranslated text is '" + untranslated + "'");
  -
  -            // obtain config option, whether to cache messages at startup time
  -            child = conf.getChild(I18N_CACHE_STARTUP);
  -            cacheAtStartup = child.getValueAsBoolean(false);
  -            debug((cacheAtStartup ? "will" : "won't") +
  -                   " cache messages during startup, by default"
               );
  -        }
  +
  +        // obtain default text to use for untranslated messages
  +        child = conf.getChild(I18N_UNTRANSLATED);
  +        untranslated = child.getValue(null);
  +        debug("Default untranslated text is '" + untranslated + "'");
  +
  +        // obtain config option, whether to cache messages at startup time
  +        child = conf.getChild(I18N_CACHE_STARTUP);
  +        cacheAtStartup = child.getValueAsBoolean(false);
  +        debug((cacheAtStartup ? "will" : "won't") +
  +              " cache messages during startup, by default"
  +        );
       }
   
       /**
  @@ -874,7 +868,7 @@
        */
       public void setup(SourceResolver resolver, Map objectModel, String source,
                         Parameters parameters)
  -        throws ProcessingException, SAXException, IOException {
  +            throws ProcessingException, SAXException, IOException {
   
           try {
               // check parameters to see if anything has been locally overloaded
  @@ -885,11 +879,11 @@
   
               if (parameters != null) {
                   localCatLocation =
  -                    parameters.getParameter(I18N_CATALOGUE_LOCATION, null);
  +                        parameters.getParameter(I18N_CATALOGUE_LOCATION, null);
                   localCatName =
  -                    parameters.getParameter(I18N_CATALOGUE_NAME, null);
  +                        parameters.getParameter(I18N_CATALOGUE_NAME, null);
                   localUntranslated =
  -                    parameters.getParameter(I18N_UNTRANSLATED, null);
  +                        parameters.getParameter(I18N_UNTRANSLATED, null);
                   lc = parameters.getParameter(I18N_LOCALE, null);
               }
   
  @@ -902,7 +896,7 @@
   
               // configure the factory
               _setup(resolver, localCatLocation == null ? catalogueLocation
  -                                                      : localCatLocation);
  +                             : localCatLocation);
   
               // Get current locale
               Locale locale = I18nUtils.parseLocale(lc);
  @@ -910,8 +904,8 @@
   
               // setup everything for the current locale
               dictionary = (Bundle)factory.select(
  -                localCatName == null ? catalogueName : localCatName,
  -                locale
  +                    localCatName == null ? catalogueName : localCatName,
  +                    locale
               );
               debug( "selected dictionary " + dictionary );
   
  @@ -921,14 +915,14 @@
               this.current_state      = STATE_OUTSIDE;
               this.prev_state         = STATE_OUTSIDE;
               this.current_key        = null;
  -         this.translate_copy     = false;
  -         this.tr_text_recorder   = null;
  +            this.translate_copy     = false;
  +            this.tr_text_recorder   = null;
               this.text_recorder      = new MirrorRecorder();
  -         this.param_count        = 0;
  -         this.param_name         = null;
  +            this.param_count        = 0;
  +            this.param_name         = null;
               this.param_value        = null;
               this.param_recorder     = null;
  -         this.indexedParams      = new HashMap(3);
  +            this.indexedParams      = new HashMap(3);
               this.formattingParams   = null;
               this.strBuffer          = null;
   
  @@ -949,25 +943,25 @@
        * configuration object directly to XMLResourceBundle.
        */
       private void _setup(SourceResolver resolver, String location)
  -        throws Exception {
  +            throws Exception {
   
           // configure the factory to log correctly and cache catalogues
           DefaultConfiguration configuration =
  -            new DefaultConfiguration("name", "location");
  +                new DefaultConfiguration("name", "location");
           DefaultConfiguration cacheConf =
  -            new DefaultConfiguration(
  -                BundleFactory.ConfigurationKeys.CACHE_AT_STARTUP,
  -                "location"
  -            );
  +                new DefaultConfiguration(
  +                        BundleFactory.ConfigurationKeys.CACHE_AT_STARTUP,
  +                        "location"
  +                );
           cacheConf.setValue(new Boolean(cacheAtStartup).toString());
           configuration.addChild(cacheConf);
   
           // set the root location for message catalogues
           DefaultConfiguration dirConf =
  -            new DefaultConfiguration(
  -                BundleFactory.ConfigurationKeys.ROOT_DIRECTORY,
  -                "location"
  -            );
  +                new DefaultConfiguration(
  +                        BundleFactory.ConfigurationKeys.ROOT_DIRECTORY,
  +                        "location"
  +                );
   
           debug("catalog location:" + location);
           Source source = null;
  @@ -999,36 +993,36 @@
               strBuffer = null;
           }
   
  -     if (I18N_OLD_NAMESPACE_URI.equals(uri)) {
  -            this.getLogger().warn("The namespace " 
  -            + I18N_OLD_NAMESPACE_URI 
  -            + " for i18n is not supported any more, use: " 
  -            + I18N_NAMESPACE_URI); 
  -     }
  +        if (I18N_OLD_NAMESPACE_URI.equals(uri)) {
  +            this.getLogger().warn("The namespace "
  +                                  + I18N_OLD_NAMESPACE_URI
  +                                  + " for i18n is not supported any more, use: "
  +                                  + I18N_NAMESPACE_URI);
  +        }
   
           // Process start element event
           if (I18N_NAMESPACE_URI.equals(uri)) {
               debug("Starting i18n element: " + name);
  -         startI18NElement(name, attr);
  +            startI18NElement(name, attr);
           } else { // We have a non i18n element event
  -         if (current_state == STATE_OUTSIDE) {
  -             super.startElement(uri, name, raw,
  +            if (current_state == STATE_OUTSIDE) {
  +                super.startElement(uri, name, raw,
                                      translateAttributes(name, attr));
  -         } else if (current_state == STATE_INSIDE_PARAM) {
  -             param_recorder.startElement(uri, name, raw, attr);
  -         } else if (current_state == STATE_INSIDE_TEXT) {
  -             text_recorder.startElement(uri, name, raw, attr);
  -         } else if ((current_state == STATE_INSIDE_WHEN ||
  -                        current_state == STATE_INSIDE_OTHERWISE)
  -                        && translate_copy) {
  -
  -             super.startElement(uri, name, raw, attr);
  -         }
  -     }
  +            } else if (current_state == STATE_INSIDE_PARAM) {
  +                param_recorder.startElement(uri, name, raw, attr);
  +            } else if (current_state == STATE_INSIDE_TEXT) {
  +                text_recorder.startElement(uri, name, raw, attr);
  +            } else if ((current_state == STATE_INSIDE_WHEN ||
  +                    current_state == STATE_INSIDE_OTHERWISE)
  +                    && translate_copy) {
  +
  +                super.startElement(uri, name, raw, attr);
  +            }
  +        }
       }
   
       public void endElement(String uri, String name, String raw)
  -        throws SAXException {
  +            throws SAXException {
   
           // Handle previously buffered characters
           if (current_state != STATE_OUTSIDE && strBuffer != null) {
  @@ -1039,13 +1033,13 @@
           if (I18N_NAMESPACE_URI.equals(uri)) {
               endI18NElement(name);
           } else if (current_state == STATE_INSIDE_PARAM) {
  -         param_recorder.endElement(uri, name, raw);
  +            param_recorder.endElement(uri, name, raw);
           } else if (current_state == STATE_INSIDE_TEXT) {
  -         text_recorder.endElement(uri, name, raw);
  -     } else if (current_state == STATE_INSIDE_CHOOSE ||
  -                    (current_state == STATE_INSIDE_WHEN ||
  -                     current_state == STATE_INSIDE_OTHERWISE)
  -                    && !translate_copy) {
  +            text_recorder.endElement(uri, name, raw);
  +        } else if (current_state == STATE_INSIDE_CHOOSE ||
  +                (current_state == STATE_INSIDE_WHEN ||
  +                current_state == STATE_INSIDE_OTHERWISE)
  +                && !translate_copy) {
   
               ; // Output nothing
           } else {
  @@ -1054,11 +1048,11 @@
       }
   
       public void characters(char[] ch, int start, int len)
  -        throws SAXException {
  +            throws SAXException {
   
  -     if (current_state == STATE_OUTSIDE ||
  -           ((current_state == STATE_INSIDE_WHEN ||
  -             current_state == STATE_INSIDE_OTHERWISE) && translate_copy)) {
  +        if (current_state == STATE_OUTSIDE ||
  +                ((current_state == STATE_INSIDE_WHEN ||
  +                current_state == STATE_INSIDE_OTHERWISE) && translate_copy)) {
   
               super.characters(ch, start, len);
           } else {
  @@ -1075,204 +1069,204 @@
       //
   
       private void startI18NElement(String name, Attributes attr)
  -        throws SAXException {
  +            throws SAXException {
   
           debug("Start i18n element: " + name);
   
           if (I18N_TEXT_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE
  -                && current_state != STATE_INSIDE_PARAM
  -                && current_state != STATE_INSIDE_TRANSLATE) {
  +                    && current_state != STATE_INSIDE_PARAM
  +                    && current_state != STATE_INSIDE_TRANSLATE) {
   
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": nested i18n:text elements are not allowed."
  -                    + " Current state: " + current_state
  +                        this.getClass().getName()
  +                        + ": nested i18n:text elements are not allowed."
  +                        + " Current state: " + current_state
                   );
               }
   
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_TEXT;
               current_key = attr.getValue(I18N_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
  -         if (prev_state != STATE_INSIDE_PARAM)
  -             tr_text_recorder = null;
  +            if (prev_state != STATE_INSIDE_PARAM)
  +                tr_text_recorder = null;
   
  -         // Better send an exception to prevent users from this?
  -         if (current_key == null && prev_state == STATE_INSIDE_TRANSLATE) {
  -             debug("WARNING: no key for text in translate! Don't do this!");
  -             /*throw new SAXException(this.getClass().getName()
  -               + ": you must provide a key when using i18n:text"
  -               + " within i18n:translate"
  -               + " Current state: " + current_state);
  -             */
  -         }
  -         else if (current_key != null) {
  -             tr_text_recorder = getMirrorRecorder(current_key, null);
  -             //debug("Got translation: " + tr_text_recorder);
  -         }
  +            // Better send an exception to prevent users from this?
  +            if (current_key == null && prev_state == STATE_INSIDE_TRANSLATE) {
  +                debug("WARNING: no key for text in translate! Don't do this!");
  +                /*throw new SAXException(this.getClass().getName()
  +                + ": you must provide a key when using i18n:text"
  +                + " within i18n:translate"
  +                + " Current state: " + current_state);
  +                */
  +            }
  +            else if (current_key != null) {
  +                tr_text_recorder = getMirrorRecorder(current_key, null);
  +                //debug("Got translation: " + tr_text_recorder);
  +            }
   
   
           } else if (I18N_TRANSLATE_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:translate element must be used "
  -                    + "outside of other i18n elements. Current state: "
  -                    + current_state
  +                        this.getClass().getName()
  +                        + ": i18n:translate element must be used "
  +                        + "outside of other i18n elements. Current state: "
  +                        + current_state
                   );
               }
   
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_TRANSLATE;
           } else if (I18N_PARAM_ELEMENT.equals(name)) {
               if (current_state != STATE_INSIDE_TRANSLATE) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:param element can be used only inside "
  -                    + "i18n:translate element. Current state: "
  -                    + current_state
  +                        this.getClass().getName()
  +                        + ": i18n:param element can be used only inside "
  +                        + "i18n:translate element. Current state: "
  +                        + current_state
                   );
               }
   
  -         param_name = attr.getValue(I18N_PARAM_NAME_ATTRIBUTE);
  -         if (param_name == null) {
  -             param_name = String.valueOf(param_count++);
  +            param_name = attr.getValue(I18N_PARAM_NAME_ATTRIBUTE);
  +            if (param_name == null) {
  +                param_name = String.valueOf(param_count++);
               }
   
  -         param_recorder = new MirrorRecorder();
  +            param_recorder = new MirrorRecorder();
               setFormattingParams(attr);
               current_state = STATE_INSIDE_PARAM;
           } else if (I18N_CHOOSE_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:choose elements cannot be used"
  -                    + "inside of other i18n elements."
  +                        this.getClass().getName()
  +                        + ": i18n:choose elements cannot be used"
  +                        + "inside of other i18n elements."
                   );
               }
   
  -         translate_copy = false;
  +            translate_copy = false;
               translate_end = false;
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_CHOOSE;
           } else if (I18N_WHEN_ELEMENT.equals(name) ||
  -                   I18N_IF_ELEMENT.equals(name)) {
  +                I18N_IF_ELEMENT.equals(name)) {
   
               if (I18N_WHEN_ELEMENT.equals(name) &&
  -                current_state != STATE_INSIDE_CHOOSE) {
  +                    current_state != STATE_INSIDE_CHOOSE) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:when elements are can be used only"
  -                    + "inside of i18n:choose elements."
  +                        this.getClass().getName()
  +                        + ": i18n:when elements are can be used only"
  +                        + "inside of i18n:choose elements."
                   );
               }
   
               if (I18N_IF_ELEMENT.equals(name) &&
  -                current_state != STATE_OUTSIDE) {
  +                    current_state != STATE_OUTSIDE) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:if elements cannot be nested."
  +                        this.getClass().getName()
  +                        + ": i18n:if elements cannot be nested."
                   );
               }
   
  -         String locale = attr.getValue(I18N_LOCALE_ATTRIBUTE);
  -         if (locale == null)
  -             throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:" + name
  -                    + " element cannot be used without 'locale' attribute."
  +            String locale = attr.getValue(I18N_LOCALE_ATTRIBUTE);
  +            if (locale == null)
  +                throw new SAXException(
  +                        this.getClass().getName()
  +                        + ": i18n:" + name
  +                        + " element cannot be used without 'locale' attribute."
                   );
   
  -         if ((!translate_end && current_state == STATE_INSIDE_CHOOSE)
  -                 || current_state == STATE_OUTSIDE) {
  +            if ((!translate_end && current_state == STATE_INSIDE_CHOOSE)
  +                    || current_state == STATE_OUTSIDE) {
   
                   // Perform soft locale matching
  -             if (this.locale.toString().startsWith(locale)) {
  -                 debug("Locale matching: " + locale);
  -                 translate_copy = true;
  -             }
  -         }
  +                if (this.locale.toString().startsWith(locale)) {
  +                    debug("Locale matching: " + locale);
  +                    translate_copy = true;
  +                }
  +            }
   
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_WHEN;
   
           } else if (I18N_OTHERWISE_ELEMENT.equals(name)) {
               if (current_state != STATE_INSIDE_CHOOSE) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:otherwise elements are not allowed "
  -                    + "only inside i18n:choose."
  +                        this.getClass().getName()
  +                        + ": i18n:otherwise elements are not allowed "
  +                        + "only inside i18n:choose."
                   );
  -         }
  +            }
   
  -         debug("Matching any locale");
  -         if (!translate_end)
  -             translate_copy = true;
  +            debug("Matching any locale");
  +            if (!translate_end)
  +                translate_copy = true;
   
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_OTHERWISE;
   
  -     } else if (I18N_DATE_ELEMENT.equals(name)) {
  +        } else if (I18N_DATE_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE
  -             && current_state != STATE_INSIDE_TEXT
  -             && current_state != STATE_INSIDE_PARAM) {
  +                    && current_state != STATE_INSIDE_TEXT
  +                    && current_state != STATE_INSIDE_PARAM) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:date elements are not allowed "
  -                    + "inside of other i18n elements."
  +                        this.getClass().getName()
  +                        + ": i18n:date elements are not allowed "
  +                        + "inside of other i18n elements."
                   );
               }
   
               setFormattingParams(attr);
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_DATE;
           } else if (I18N_DATE_TIME_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE
  -             && current_state != STATE_INSIDE_TEXT
  -             && current_state != STATE_INSIDE_PARAM) {
  +                    && current_state != STATE_INSIDE_TEXT
  +                    && current_state != STATE_INSIDE_PARAM) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:date-time elements are not allowed "
  -                    + "inside of other i18n elements."
  +                        this.getClass().getName()
  +                        + ": i18n:date-time elements are not allowed "
  +                        + "inside of other i18n elements."
                   );
               }
   
               setFormattingParams(attr);
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_DATE_TIME;
           } else if (I18N_TIME_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE
  -             && current_state != STATE_INSIDE_TEXT
  -             && current_state != STATE_INSIDE_PARAM) {
  +                    && current_state != STATE_INSIDE_TEXT
  +                    && current_state != STATE_INSIDE_PARAM) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:date elements are not allowed "
  -                    + "inside of other i18n elements."
  +                        this.getClass().getName()
  +                        + ": i18n:date elements are not allowed "
  +                        + "inside of other i18n elements."
                   );
               }
   
               setFormattingParams(attr);
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_TIME;
           } else if (I18N_NUMBER_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE
  -             && current_state != STATE_INSIDE_TEXT
  -             && current_state != STATE_INSIDE_PARAM) {
  +                    && current_state != STATE_INSIDE_TEXT
  +                    && current_state != STATE_INSIDE_PARAM) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + ": i18n:number elements are not allowed "
  -                    + "inside of other i18n elements."
  +                        this.getClass().getName()
  +                        + ": i18n:number elements are not allowed "
  +                        + "inside of other i18n elements."
                   );
               }
   
               setFormattingParams(attr);
  -         prev_state = current_state;
  +            prev_state = current_state;
               current_state = STATE_INSIDE_NUMBER;
           }
       }
   
       // Get all possible i18n formatting attribute values and store in a Map
  -    private void setFormattingParams(Attributes attr) throws SAXException {
  +    private void setFormattingParams(Attributes attr) {
           formattingParams = new HashMap(3);  // average number of attributes is 3
   
           String attr_value = attr.getValue(I18N_SRC_PATTERN_ATTRIBUTE);
  @@ -1305,52 +1299,52 @@
               formattingParams.put(I18N_TYPE_ATTRIBUTE, attr_value);
           }
   
  -     attr_value = attr.getValue(I18N_FRACTION_DIGITS_ATTRIBUTE);
  +        attr_value = attr.getValue(I18N_FRACTION_DIGITS_ATTRIBUTE);
           if (attr_value != null) {
               formattingParams.put(I18N_FRACTION_DIGITS_ATTRIBUTE, attr_value);
  -     }
  +        }
       }
   
       private void endI18NElement(String name) throws SAXException {
           debug("End i18n element: " + name);
           switch (current_state) {
  -        case STATE_INSIDE_TEXT:
  -            endTextElement();
  -            break;
  -
  -        case STATE_INSIDE_TRANSLATE:
  -            endTranslateElement();
  -            break;
  -
  -        case STATE_INSIDE_CHOOSE:
  -         endChooseElement();
  -         break;
  -
  -        case STATE_INSIDE_WHEN:
  -        case STATE_INSIDE_OTHERWISE:
  -         endWhenElement();
  -         break;
  -
  -        case STATE_INSIDE_PARAM:
  -            endParamElement();
  -            break;
  -
  -        case STATE_INSIDE_DATE:
  -        case STATE_INSIDE_DATE_TIME:
  -        case STATE_INSIDE_TIME:
  -            endDate_TimeElement();
  -            break;
  -
  -        case STATE_INSIDE_NUMBER:
  -            endNumberElement();
  -            break;
  +            case STATE_INSIDE_TEXT:
  +                endTextElement();
  +                break;
  +
  +            case STATE_INSIDE_TRANSLATE:
  +                endTranslateElement();
  +                break;
  +
  +            case STATE_INSIDE_CHOOSE:
  +                endChooseElement();
  +                break;
  +
  +            case STATE_INSIDE_WHEN:
  +            case STATE_INSIDE_OTHERWISE:
  +                endWhenElement();
  +                break;
  +
  +            case STATE_INSIDE_PARAM:
  +                endParamElement();
  +                break;
  +
  +            case STATE_INSIDE_DATE:
  +            case STATE_INSIDE_DATE_TIME:
  +            case STATE_INSIDE_TIME:
  +                endDate_TimeElement();
  +                break;
  +
  +            case STATE_INSIDE_NUMBER:
  +                endNumberElement();
  +                break;
           }
       }
   
       private void i18nCharacters(String textValue)
  -        throws SAXException {
  +            throws SAXException {
   
  -     if (textValue == null) {
  +        if (textValue == null) {
               return;
           }
           // Trim text values to avoid parsing errors.
  @@ -1359,81 +1353,80 @@
           debug( "i18n message text = '" + textValue + "'" );
   
           switch (current_state) {
  -        case STATE_INSIDE_TEXT:
  -         text_recorder.characters(textValue);
  -            break;
  -
  -        case STATE_INSIDE_PARAM:
  -         param_recorder.characters(textValue);
  -            break;
  -
  -     case STATE_INSIDE_WHEN:
  -     case STATE_INSIDE_OTHERWISE:
  -            // Previously handeld to avoid the String() conversion.
  -         break;
  -
  -     case STATE_INSIDE_TRANSLATE:
  -         if(tr_text_recorder == null) {
  -             tr_text_recorder = new MirrorRecorder();
  -         }
  -         tr_text_recorder.characters(textValue);
  -         break;
  -
  -        case STATE_INSIDE_CHOOSE:
  -         // No characters allowed. Send an exception ?
  -         debug("No characters allowed inside <i18n:choose> tags");
  -         break;
  -
  -     case STATE_INSIDE_DATE:
  -        case STATE_INSIDE_DATE_TIME:
  -        case STATE_INSIDE_TIME:
  -        case STATE_INSIDE_NUMBER:
  -            if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null) {
  -                formattingParams.put(I18N_VALUE_ATTRIBUTE, textValue);
  -            } else {
  -                ; // ignore the text inside of date element
  -            }
  -            break;
  +            case STATE_INSIDE_TEXT:
  +                text_recorder.characters(textValue);
  +                break;
  +
  +            case STATE_INSIDE_PARAM:
  +                param_recorder.characters(textValue);
  +                break;
  +
  +            case STATE_INSIDE_WHEN:
  +            case STATE_INSIDE_OTHERWISE:
  +                // Previously handeld to avoid the String() conversion.
  +                break;
  +
  +            case STATE_INSIDE_TRANSLATE:
  +                if(tr_text_recorder == null) {
  +                    tr_text_recorder = new MirrorRecorder();
  +                }
  +                tr_text_recorder.characters(textValue);
  +                break;
  +
  +            case STATE_INSIDE_CHOOSE:
  +                // No characters allowed. Send an exception ?
  +                debug("No characters allowed inside <i18n:choose> tags");
  +                break;
  +
  +            case STATE_INSIDE_DATE:
  +            case STATE_INSIDE_DATE_TIME:
  +            case STATE_INSIDE_TIME:
  +            case STATE_INSIDE_NUMBER:
  +                if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null) {
  +                    formattingParams.put(I18N_VALUE_ATTRIBUTE, textValue);
  +                } else {
  +                    ; // ignore the text inside of date element
  +                }
  +                break;
   
  -        default:
  -            throw new IllegalStateException(
  -                this.getClass().getName()
  -                + " developer's fault: characters not handled"
  -             + "Current state: " + current_state);
  +            default:
  +                throw new IllegalStateException(
  +                        this.getClass().getName()
  +                        + " developer's fault: characters not handled"
  +                        + "Current state: " + current_state);
           }
       }
   
       // Translate all attributes that are listed in i18n:attr attribute
  -    private Attributes translateAttributes(String name, Attributes attr)
  -        throws SAXException {
  +    private Attributes translateAttributes(String name, Attributes attr) {
   
  -     if(attr == null)
  -         return attr;
  +        if(attr == null)
  +            return attr;
   
           AttributesImpl temp_attr = new AttributesImpl(attr);
   
           // Translate all attributes from i18n:attr="name1 name2 ..."
           // using their values as keys
           int i18n_attr_index =
  -         temp_attr.getIndex(I18N_NAMESPACE_URI,I18N_ATTR_ATTRIBUTE);
  +                temp_attr.getIndex(I18N_NAMESPACE_URI,I18N_ATTR_ATTRIBUTE);
   
  -     if (i18n_attr_index != -1) {
  -         StringTokenizer st =
  -             new StringTokenizer(temp_attr.getValue(i18n_attr_index));
  -         // remove the i18n:attr attribute - we don't need it anymore
  +        if (i18n_attr_index != -1) {
  +            StringTokenizer st =
  +                    new StringTokenizer(temp_attr.getValue(i18n_attr_index));
  +            // remove the i18n:attr attribute - we don't need it anymore
               temp_attr.removeAttribute(i18n_attr_index);
   
               // iterate through listed attributes and translate them
               while (st.hasMoreElements()) {
                   String attr_name = st.nextToken();
   
  -             int attr_index = temp_attr.getIndex(attr_name);
  +                int attr_index = temp_attr.getIndex(attr_name);
                   if (attr_index != -1) {
                       String text2translate = temp_attr.getValue(attr_index);
                       String result =
  -                        getString(text2translate, (untranslated == null)
  -                                  ? text2translate
  -                                  : untranslated);
  +                            getString(text2translate, (untranslated == null)
  +                                                      ? text2translate
  +                                                      : untranslated);
   
                       // set the translated value
                       if (result != null) {
  @@ -1444,7 +1437,7 @@
                       }
                   } else {
                       getLogger().warn("i18n attribute '" + attr_name
  -                                      + "' not found in element: " + name);
  +                                     + "' not found in element: " + name);
                   }
               }
   
  @@ -1457,54 +1450,51 @@
   
       private void endTextElement() throws SAXException {
           switch (prev_state) {
  -        case STATE_OUTSIDE:
  -         if (tr_text_recorder == null) {
  -             if (current_key == null) {
  -                 // Use the text as key
  -                 // Really not recommended for big strings, moreover if they
  -                    // include markup.
  -                 tr_text_recorder = getMirrorRecorder(text_recorder.text(),
  -                        (MirrorRecorder) text_recorder);
  -             } else {
  -                 // We have the key, but couldn't find a transltation
  -                 debug("translation not found for key " + current_key);
  -                 tr_text_recorder = text_recorder;
  -             }
  -         }
  -
  -         if (tr_text_recorder != null) {
  -             tr_text_recorder.send(this.contentHandler);
  -         }
  -
  -         text_recorder.recycle();
  -         tr_text_recorder = null;
  -         current_key = null;
  -         break;
  -
  -     case STATE_INSIDE_TRANSLATE:
  -         if (tr_text_recorder == null) {
  -             if (!text_recorder.empty()) {
  -                 tr_text_recorder = (MirrorRecorder) text_recorder.clone();
  -             }
  -         }
  -
  -         text_recorder.recycle();
  -         break;
  -
  -     case STATE_INSIDE_PARAM:
  -         // We send the translated text to the param recorder,after trying to 
translate it.
  -         // Remember you can't give a key when inside a param, that'll be nonsense!
  -         // No need to clone. We just send the events.
  -         if (!text_recorder.empty()) {
  -             getMirrorRecorder(text_recorder.text(),
  -                    (MirrorRecorder) text_recorder).send(param_recorder);
  -
  -             text_recorder.recycle();
  -         }
  -         break;
  -     }
  +            case STATE_OUTSIDE:
  +                if (tr_text_recorder == null) {
  +                    if (current_key == null) {
  +                        // Use the text as key
  +                        // Really not recommended for big strings, moreover if they
  +                        // include markup.
  +                        tr_text_recorder = getMirrorRecorder(text_recorder.text(), 
text_recorder);
  +                    } else {
  +                        // We have the key, but couldn't find a transltation
  +                        debug("translation not found for key " + current_key);
  +                        tr_text_recorder = text_recorder;
  +                    }
  +                }
   
  -     current_state = prev_state;
  +                if (tr_text_recorder != null) {
  +                    tr_text_recorder.send(this.contentHandler);
  +                }
  +
  +                text_recorder.recycle();
  +                tr_text_recorder = null;
  +                current_key = null;
  +                break;
  +
  +            case STATE_INSIDE_TRANSLATE:
  +                if (tr_text_recorder == null) {
  +                    if (!text_recorder.empty()) {
  +                        tr_text_recorder = (MirrorRecorder) text_recorder.clone();
  +                    }
  +                }
  +
  +                text_recorder.recycle();
  +                break;
  +
  +            case STATE_INSIDE_PARAM:
  +                // We send the translated text to the param recorder,after trying 
to translate it.
  +                // Remember you can't give a key when inside a param, that'll be 
nonsense!
  +                // No need to clone. We just send the events.
  +                if (!text_recorder.empty()) {
  +                    getMirrorRecorder(text_recorder.text(), 
text_recorder).send(param_recorder);
  +                    text_recorder.recycle();
  +                }
  +                break;
  +        }
  +
  +        current_state = prev_state;
           prev_state = STATE_OUTSIDE;
       }
   
  @@ -1516,7 +1506,7 @@
   
               debug("Param type: " + paramType);
               if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null &&
  -                param_value != null) {
  +                    param_value != null) {
   
                   debug("Put param value: " + param_value);
                   formattingParams.put(I18N_VALUE_ATTRIBUTE, param_value);
  @@ -1530,60 +1520,59 @@
                   debug("Formatting number param: " + formattingParams);
                   param_value = formatNumber(formattingParams);
               }
  -         debug("Added substitution param: " + param_value);
  +            debug("Added substitution param: " + param_value);
           }
   
  -     param_value = null;
  +        param_value = null;
           current_state = STATE_INSIDE_TRANSLATE;
   
  -     if(param_recorder == null)
  -         return;
  +        if(param_recorder == null)
  +            return;
   
  -     indexedParams.put(param_name, ((MirrorRecorder) param_recorder).clone());
  +        indexedParams.put(param_name, param_recorder.clone());
       }
   
       private void endTranslateElement() throws SAXException {
  -        String result;
  -     if (indexedParams.size() > 0 && tr_text_recorder != null) {
  -         debug("End of translate with params");
  -         debug("Fragment for substitution : " + tr_text_recorder.text());
  -         tr_text_recorder.send(super.contentHandler, indexedParams);
  -         tr_text_recorder = null;
  -         text_recorder.recycle();
  -     }
  -
  -     indexedParams.clear();
  -     param_count = 0;
  -     current_state = STATE_OUTSIDE;
  -    }
  -
  -    private void endChooseElement() throws SAXException {
  -     current_state = STATE_OUTSIDE;
  -    }
  -
  -    private void endWhenElement() throws SAXException {
  -     current_state = prev_state;
  -     if (translate_copy) {
  -         translate_copy = false;
  -         translate_end = true;
  -     }
  +        if (indexedParams.size() > 0 && tr_text_recorder != null) {
  +            debug("End of translate with params");
  +            debug("Fragment for substitution : " + tr_text_recorder.text());
  +            tr_text_recorder.send(super.contentHandler, indexedParams);
  +            tr_text_recorder = null;
  +            text_recorder.recycle();
  +        }
  +
  +        indexedParams.clear();
  +        param_count = 0;
  +        current_state = STATE_OUTSIDE;
  +    }
  +
  +    private void endChooseElement() {
  +        current_state = STATE_OUTSIDE;
  +    }
  +
  +    private void endWhenElement() {
  +        current_state = prev_state;
  +        if (translate_copy) {
  +            translate_copy = false;
  +            translate_end = true;
  +        }
       }
   
       private void endDate_TimeElement() throws SAXException {
           String result = formatDate_Time(formattingParams);
  -     switch(prev_state) {
  -     case STATE_OUTSIDE:
  -         super.contentHandler.characters(result.toCharArray(), 0,
  -                result.length());
  -         break;
  -     case STATE_INSIDE_PARAM:
  -         param_recorder.characters(result.toCharArray(), 0, result.length());
  -         break;
  -     case STATE_INSIDE_TEXT:
  -         text_recorder.characters(result.toCharArray(), 0, result.length());
  -         break;
  -     }
  -     current_state = prev_state;
  +        switch(prev_state) {
  +            case STATE_OUTSIDE:
  +                super.contentHandler.characters(result.toCharArray(), 0,
  +                                                result.length());
  +                break;
  +            case STATE_INSIDE_PARAM:
  +                param_recorder.characters(result.toCharArray(), 0, result.length());
  +                break;
  +            case STATE_INSIDE_TEXT:
  +                text_recorder.characters(result.toCharArray(), 0, result.length());
  +                break;
  +        }
  +        current_state = prev_state;
       }
   
       // Helper method: creates Locale object from a string value in a map
  @@ -1649,31 +1638,31 @@
   
           // Initializing date formatters
           if (current_state == STATE_INSIDE_DATE ||
  -            I18N_DATE_ELEMENT.equals(paramType)) {
  +                I18N_DATE_ELEMENT.equals(paramType)) {
   
               to_fmt = (SimpleDateFormat)DateFormat.getDateInstance(style, loc);
               from_fmt = (SimpleDateFormat)DateFormat.getDateInstance(
  -                srcStyle,
  -                srcLoc
  +                    srcStyle,
  +                    srcLoc
               );
           } else if (current_state == STATE_INSIDE_DATE_TIME ||
  -                   I18N_DATE_TIME_ELEMENT.equals(paramType)) {
  +                I18N_DATE_TIME_ELEMENT.equals(paramType)) {
               to_fmt = (SimpleDateFormat)DateFormat.getDateTimeInstance(
  -                style,
  -                style,
  -                loc
  +                    style,
  +                    style,
  +                    loc
               );
               from_fmt = (SimpleDateFormat)DateFormat.getDateTimeInstance(
  -                srcStyle,
  -                srcStyle,
  -                srcLoc
  +                    srcStyle,
  +                    srcStyle,
  +                    srcLoc
               );
           } else {
               // STATE_INSIDE_TIME or param type='time'
               to_fmt = (SimpleDateFormat)DateFormat.getTimeInstance(style, loc);
               from_fmt = (SimpleDateFormat)DateFormat.getTimeInstance(
  -                srcStyle,
  -                srcLoc
  +                    srcStyle,
  +                    srcLoc
               );
           }
   
  @@ -1697,39 +1686,39 @@
                   dateValue = from_fmt.parse(value);
               } catch (ParseException pe) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + "i18n:date - parsing error.", pe
  +                        this.getClass().getName()
  +                        + "i18n:date - parsing error.", pe
                   );
               }
           }
   
           // we have all necessary data here: do formatting.
           debug("### Formatting date: " + dateValue + " with localized pattern "
  -            + to_fmt.toLocalizedPattern() + " for locale: " + locale);
  +              + to_fmt.toLocalizedPattern() + " for locale: " + locale);
           return to_fmt.format(dateValue);
       }
   
       private void endNumberElement() throws SAXException {
           String result = formatNumber(formattingParams);
  -     switch(prev_state) {
  -     case STATE_OUTSIDE:
  -         super.contentHandler.characters(result.toCharArray(), 0, result.length());
  -         break;
  -     case STATE_INSIDE_PARAM:
  -         param_recorder.characters(result.toCharArray(), 0, result.length());
  -         break;
  -     case STATE_INSIDE_TEXT:
  -         text_recorder.characters(result.toCharArray(), 0, result.length());
  -         break;
  -     }
  -     current_state = prev_state;
  +        switch(prev_state) {
  +            case STATE_OUTSIDE:
  +                super.contentHandler.characters(result.toCharArray(), 0, 
result.length());
  +                break;
  +            case STATE_INSIDE_PARAM:
  +                param_recorder.characters(result.toCharArray(), 0, result.length());
  +                break;
  +            case STATE_INSIDE_TEXT:
  +                text_recorder.characters(result.toCharArray(), 0, result.length());
  +                break;
  +        }
  +        current_state = prev_state;
       }
   
       private String formatNumber(Map params) throws SAXException {
           if (params == null) {
               throw new SAXException(
  -                this.getClass().getName()
  -                + ": i18n:number - error in element attributes."
  +                    this.getClass().getName()
  +                    + ": i18n:number - error in element attributes."
               );
           }
   
  @@ -1747,7 +1736,7 @@
           int fractionDigits = -1;
           try {
               fractionDigits = Integer.parseInt((String)
  -                params.get(I18N_FRACTION_DIGITS_ATTRIBUTE));
  +                    params.get(I18N_FRACTION_DIGITS_ATTRIBUTE));
           }
           catch(NumberFormatException nfe) {
               getLogger().warn("Error in number format", nfe);
  @@ -1795,8 +1784,8 @@
               if (value.charAt(value.length() - 1) == dec) {
                   appendDec = true;
               }
  -     } else if (type.equals( I18N_CURRENCY_ELEMENT )) {
  -             to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(loc);
  +        } else if (type.equals( I18N_CURRENCY_ELEMENT )) {
  +            to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(loc);
           } else if (type.equals( I18N_INT_CURRENCY_ELEMENT )) {
               to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(loc);
               int_currency = 1;
  @@ -1804,9 +1793,9 @@
                   int_currency *= 10;
               }
           } else if ( type.equals( I18N_CURRENCY_NO_UNIT_ELEMENT ) ) {
  -         DecimalFormat tmp = (DecimalFormat) NumberFormat.getCurrencyInstance( loc 
);
  -         to_fmt = (DecimalFormat) NumberFormat.getInstance( loc );
  -         to_fmt.setMinimumFractionDigits(tmp.getMinimumFractionDigits());
  +            DecimalFormat tmp = (DecimalFormat) NumberFormat.getCurrencyInstance( 
loc );
  +            to_fmt = (DecimalFormat) NumberFormat.getInstance( loc );
  +            to_fmt.setMinimumFractionDigits(tmp.getMinimumFractionDigits());
               to_fmt.setMaximumFractionDigits(tmp.getMaximumFractionDigits());
           } else if ( type.equals( I18N_INT_CURRENCY_NO_UNIT_ELEMENT ) ) {
               DecimalFormat tmp = (DecimalFormat) NumberFormat.getCurrencyInstance( 
loc );
  @@ -1820,11 +1809,11 @@
               to_fmt = (DecimalFormat)NumberFormat.getPercentInstance(loc);
           } else {
               throw new SAXException("&lt;i18n:number>: unknown type: " + type);
  -     }
  +        }
   
  -     if(fractionDigits > -1) {
  -         to_fmt.setMinimumFractionDigits(fractionDigits);
  -         to_fmt.setMaximumFractionDigits(fractionDigits);
  +        if(fractionDigits > -1) {
  +            to_fmt.setMinimumFractionDigits(fractionDigits);
  +            to_fmt.setMaximumFractionDigits(fractionDigits);
           }
   
           // pattern overwrites locale format
  @@ -1845,8 +1834,8 @@
                   }
               } catch (ParseException pe) {
                   throw new SAXException(
  -                    this.getClass().getName()
  -                    + "i18n:number - parsing error.", pe
  +                        this.getClass().getName()
  +                        + "i18n:number - parsing error.", pe
                   );
               }
           }
  @@ -1860,22 +1849,16 @@
   
       //-- Dictionary handling routins
   
  -    // Helper method to retrieve a message from the dictionary
  -    // Returnes null if no message is found
  -    private String getString(String key) {
  -        return getString(key, null);
  -    }
  -
       // Helper method to retrieve a message from the dictionary.
       // mattam: now only used for i:attr.
       // A default value is returned if message is not found
       private String getString(String key, String defaultValue) {
  -     try {
  -         Node res = (Node)dictionary.getObject(
  -                I18N_CATALOGUE_PREFIX + "[@key='" + key + "']");
  +        try {
  +            Node res = (Node)dictionary.getObject(
  +                    I18N_CATALOGUE_PREFIX + "[@key='" + key + "']");
   
               String value = getTextValue(res);
  -         return value != null ? value : defaultValue;
  +            return value != null ? value : defaultValue;
           } catch (MissingResourceException e)  {
               return defaultValue;
           }
  @@ -1893,7 +1876,7 @@
               item = list.item(i);
               // only TEXT and CDATA nodes are processed
               if (item.getNodeType() == Node.TEXT_NODE
  -                || item.getNodeType() == Node.CDATA_SECTION_NODE) {
  +                    || item.getNodeType() == Node.CDATA_SECTION_NODE) {
   
                   itemValue.append(item.getNodeValue());
               }
  @@ -1902,35 +1885,25 @@
           return itemValue.toString();
       }
   
  -    // Helper method to retrieve a message from the dictionary
  -    // Returns null if no message is found
  -    private MirrorRecorder getMirrorRecorder(String key) {
  -        return getMirrorRecorder(key, null);
  -    }
  -
       // Helper method to retrieve a message from the dictionary.
       // A default value is returned if message is not found
       private MirrorRecorder getMirrorRecorder(String key, MirrorRecorder 
defaultValue) {
           try {
  -         MirrorRecorder value = new MirrorRecorder (
  -                (Node)dictionary.getObject(
  -                    I18N_CATALOGUE_PREFIX + "[@key='" + key + "']"));
  +            MirrorRecorder value = new MirrorRecorder (
  +                    (Node)dictionary.getObject(
  +                            I18N_CATALOGUE_PREFIX + "[@key='" + key + "']"));
   
  -         if (value == null)
  -             return defaultValue;
  +            if (value == null)
  +                return defaultValue;
   
  -         return value;
  +            return value;
   
           } catch (MissingResourceException e) {
  -         debug("Untraslated key: '" + key + "'");
  +            debug("Untraslated key: '" + key + "'");
               return defaultValue;
           }
       }
   
  -    private void setLocale(Locale locale) {
  -        this.locale = locale;
  -    }
  -
       // Helper method to debug messages
       private void debug(String msg) {
           getLogger().debug("I18nTransformer: " + msg);
  @@ -1939,7 +1912,7 @@
       public void recycle() {
           // restore untranslated-text if necessary
           if (globalUntranslated != null &&
  -         !untranslated.equals(globalUntranslated)) {
  +                !untranslated.equals(globalUntranslated)) {
   
               untranslated = globalUntranslated;
           }
  @@ -1957,35 +1930,32 @@
       }
   
   /*
  -    //
       static public void main(String[] args) {
  -
           Locale locale = null;
           Locale[] locales = Locale.getAvailableLocales();
   
           for (int i = 0; i < locales.length; i++) {
               locale = locales[i];n
               SimpleDateFormat fmt =
  -                (SimpleDateFormat)DateFormat.getDateTimeInstance(
  -                    DateFormat.DEFAULT,
  -                    DateFormat.DEFAULT,
  -                    locale
  -                );
  -
  -        String localized = fmt.format(new Date());
  -        NumberFormat n_fmt = NumberFormat.getCurrencyInstance(locale);
  -        String money = n_fmt.format(1210.5);
  -
  -        System.out.println(
  -            "Locale ["
  -             + locale.getLanguage() + ", "
  -             + locale.getCountry() + ", "
  -             + locale.getVariant() + "] : "
  -             + locale.getDisplayName()
  -             + " \t Date: " + localized
  -             + " \t Money: " + money);
  +                    (SimpleDateFormat)DateFormat.getDateTimeInstance(
  +                            DateFormat.DEFAULT,
  +                            DateFormat.DEFAULT,
  +                            locale
  +                    );
  +
  +            String localized = fmt.format(new Date());
  +            NumberFormat n_fmt = NumberFormat.getCurrencyInstance(locale);
  +            String money = n_fmt.format(1210.5);
  +
  +            System.out.println(
  +                    "Locale ["
  +                    + locale.getLanguage() + ", "
  +                    + locale.getCountry() + ", "
  +                    + locale.getVariant() + "] : "
  +                    + locale.getDisplayName()
  +                    + " \t Date: " + localized
  +                    + " \t Money: " + money);
           }
       }
   */
   }
  -
  
  
  
  1.14      +4 -5      
xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java
  
  Index: SourceWritingTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SourceWritingTransformer.java     15 Jan 2003 10:39:34 -0000      1.13
  +++ SourceWritingTransformer.java     25 Jan 2003 02:58:58 -0000      1.14
  @@ -286,7 +286,6 @@
       /** The current state */
       private static final int STATE_OUTSIDE  = 0;
       private static final int STATE_INSERT   = 1;
  -    private static final int STATE_RESOURCE = 2;
       private static final int STATE_PATH     = 3;
       private static final int STATE_FRAGMENT = 4;
       private static final int STATE_REPLACE  = 5;
  @@ -335,12 +334,12 @@
        * @param uri The Namespace URI, or the empty string if the element has no
        *            Namespace URI or if Namespace
        *            processing is not being performed.
  -     * @param loc The local name (without prefix), or the empty string if
  +     * @param name The local name (without prefix), or the empty string if
        *            Namespace processing is not being performed.
        * @param raw The raw XML 1.0 name (with prefix), or the empty string if
        *            raw names are not available.
  -     * @param a The attributes attached to the element. If there are no
  -     *          attributes, it shall be an empty Attributes object.
  +     * @param attr The attributes attached to the element. If there are no
  +     *            attributes, it shall be an empty Attributes object.
        */
       public void startTransformingElement(String uri, String name, String raw, 
Attributes attr)
       throws SAXException, IOException, ProcessingException {
  @@ -434,7 +433,7 @@
        * @param uri The Namespace URI, or the empty string if the element has no
        *            Namespace URI or if Namespace
        *            processing is not being performed.
  -     * @param loc The local name (without prefix), or the empty string if
  +     * @param name The local name (without prefix), or the empty string if
        *            Namespace processing is not being performed.
        * @param raw The raw XML 1.0 name (with prefix), or the empty string if
        *            raw names are not available.
  
  
  
  1.40      +47 -49    
xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- TraxTransformer.java      22 Jan 2003 05:19:18 -0000      1.39
  +++ TraxTransformer.java      25 Jan 2003 02:58:58 -0000      1.40
  @@ -227,58 +227,56 @@
        */
       public void configure(Configuration conf)
       throws ConfigurationException {
  -        if (conf != null) {
  -            Configuration child;
  +        Configuration child;
   
  -            child = conf.getChild("use-request-parameters");
  -            this.useParameters = child.getValueAsBoolean(false);
  -            this._useParameters = this.useParameters;
  -
  -            child = conf.getChild("use-cookies");
  -            this.useCookies = child.getValueAsBoolean(false);
  -            this._useCookies = this.useCookies;
  -
  -            child = conf.getChild("use-browser-capabilities-db");
  -            this.useBrowserCap = child.getValueAsBoolean(false);
  -            this._useBrowserCap = this.useBrowserCap;
  -
  -            child = conf.getChild("use-session-info");
  -            this.useSessionInfo = child.getValueAsBoolean(false);
  -            this._useSessionInfo = this.useSessionInfo;
  -
  -            child = conf.getChild("use-deli");
  -            this.useDeli = child.getValueAsBoolean(false);
  -            this._useDeli = this.useDeli;
  -            
  -            child = conf.getChild("transformer-factory");
  -
  -            // traxFactory is null, if transformer-factory config is unspecified
  -            this.traxFactory = child.getValue(null);
  -
  -            if (this.getLogger().isDebugEnabled()) {
  -                this.getLogger().debug("Use parameters is " + this.useParameters + 
" for " + this);
  -                this.getLogger().debug("Use cookies is " + this.useCookies + " for 
" + this);
  -                this.getLogger().debug("Use browser capabilities is " + 
this.useBrowserCap + " for " + this);
  -                this.getLogger().debug("Use session info is " + this.useSessionInfo 
+ " for " + this);
  -                this.getLogger().debug("Use DELI is " + this.useDeli + " for " + 
this);
  -
  -                if (this.traxFactory != null) {
  -                    this.getLogger().debug("Use TrAX Transformer Factory " + 
this.traxFactory);
  -                } else {
  -                    this.getLogger().debug("Use default TrAX Transformer Factory.");
  -                }
  +        child = conf.getChild("use-request-parameters");
  +        this.useParameters = child.getValueAsBoolean(false);
  +        this._useParameters = this.useParameters;
  +
  +        child = conf.getChild("use-cookies");
  +        this.useCookies = child.getValueAsBoolean(false);
  +        this._useCookies = this.useCookies;
  +
  +        child = conf.getChild("use-browser-capabilities-db");
  +        this.useBrowserCap = child.getValueAsBoolean(false);
  +        this._useBrowserCap = this.useBrowserCap;
  +
  +        child = conf.getChild("use-session-info");
  +        this.useSessionInfo = child.getValueAsBoolean(false);
  +        this._useSessionInfo = this.useSessionInfo;
  +
  +        child = conf.getChild("use-deli");
  +        this.useDeli = child.getValueAsBoolean(false);
  +        this._useDeli = this.useDeli;
  +
  +        child = conf.getChild("transformer-factory");
  +
  +        // traxFactory is null, if transformer-factory config is unspecified
  +        this.traxFactory = child.getValue(null);
  +
  +        if (this.getLogger().isDebugEnabled()) {
  +            this.getLogger().debug("Use parameters is " + this.useParameters + " 
for " + this);
  +            this.getLogger().debug("Use cookies is " + this.useCookies + " for " + 
this);
  +            this.getLogger().debug("Use browser capabilities is " + 
this.useBrowserCap + " for " + this);
  +            this.getLogger().debug("Use session info is " + this.useSessionInfo + " 
for " + this);
  +            this.getLogger().debug("Use DELI is " + this.useDeli + " for " + this);
  +
  +            if (this.traxFactory != null) {
  +                this.getLogger().debug("Use TrAX Transformer Factory " + 
this.traxFactory);
  +            } else {
  +                this.getLogger().debug("Use default TrAX Transformer Factory.");
               }
  +        }
   
  -            try {
  -                this.xsltProcessor = (XSLTProcessor) 
this.manager.lookup(XSLTProcessor.ROLE);
  -                // override xsltProcessor setting only, in case of
  -                // transformer-factory config is specified
  -                if (this.traxFactory != null) {
  -                  this.xsltProcessor.setTransformerFactory(this.traxFactory);
  -                }
  -            } catch (ComponentException e) {
  -                throw new ConfigurationException("Cannot load XSLT processor", e);
  +        try {
  +            this.xsltProcessor = (XSLTProcessor) 
this.manager.lookup(XSLTProcessor.ROLE);
  +            // override xsltProcessor setting only, in case of
  +            // transformer-factory config is specified
  +            if (this.traxFactory != null) {
  +                this.xsltProcessor.setTransformerFactory(this.traxFactory);
               }
  +        } catch (ComponentException e) {
  +            throw new ConfigurationException("Cannot load XSLT processor", e);
           }
       }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to