cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon2/xdocs i18n-transformer.xml
Date Sat, 08 Sep 2001 11:45:50 GMT
dims        01/09/08 04:45:50

  Modified:    .        build.xml
               src/org/apache/cocoon Cocoon.java
               src/org/apache/cocoon/transformation I18nTransformer.java
               xdocs    i18n-transformer.xml
  Log:
  - Patch for I18nTransformer from Enke Michael <Michael.Enke@wincor-nixdorf.com>
  - Patch for Copy sample java classes for Parent Component Manager from "Leo Sutic" <leo.sutic@inspireinfrastructure.com>
  - Patch for logging active requests from Marcus Crafter <crafterm@fztig938.bank.dresdner.net>
  
  Revision  Changes    Path
  1.58      +1 -0      xml-cocoon2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/build.xml,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- build.xml	2001/09/06 20:56:21	1.57
  +++ build.xml	2001/09/08 11:45:49	1.58
  @@ -438,6 +438,7 @@
       <mkdir dir="${build.war}/WEB-INF/classes"/>
       <copy todir="${build.war}/WEB-INF/classes" filtering="off">
         <fileset dir="${build.dest}" includes="org/apache/cocoon/samples/**"/>
  +      <fileset dir="${build.src}" includes="org/apache/cocoon/samples/**"/>
       </copy>
           
       <copy todir="${build.war}" filtering="on">
  
  
  
  1.25      +104 -64   xml-cocoon2/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Cocoon.java	2001/09/04 12:13:37	1.24
  +++ Cocoon.java	2001/09/08 11:45:49	1.25
  @@ -57,7 +57,7 @@
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Revision: 1.24 $ $Date: 2001/09/04 12:13:37 $
  + * @version CVS $Revision: 1.25 $ $Date: 2001/09/08 11:45:49 $
    */
   public class Cocoon 
           extends AbstractLoggable 
  @@ -109,6 +109,12 @@
       /** flag for disposed or not */
       private boolean disposed = false;
   
  +    /** active request count */
  +    private static int activeRequestCount = 0;
  +
  +    /** maximum request count */
  +    private static int maxRequestCount = 0;
  +
       /** Create a new <code>Cocoon</code> instance. */
       public Cocoon() throws ConfigurationException {
           // Set the system properties needed by Xalan2.
  @@ -389,71 +395,71 @@
       protected void debug(Environment environment,
                            StreamPipeline pipeline,
                            EventPipeline eventPipeline) {
  -        if (this.getLogger().isDebugEnabled() == true) {
  -            String lineSeparator = System.getProperty("line.separator");
  -            Map objectModel = environment.getObjectModel();
  -            Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
  -            Session session = request.getSession(false);
  -            StringBuffer msg = new StringBuffer();
  -            msg.append("DEBUGGING INFORMATION:").append(lineSeparator);
  -            if (pipeline != null && eventPipeline != null) {
  -                msg.append("INTERNAL ");
  +        String lineSeparator = System.getProperty("line.separator");
  +        Map objectModel = environment.getObjectModel();
  +        Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
  +        Session session = request.getSession(false);
  +        StringBuffer msg = new StringBuffer();
  +        msg.append("DEBUGGING INFORMATION:").append(lineSeparator);
  +        if (pipeline != null && eventPipeline != null) {
  +            msg.append("INTERNAL ");
  +        }
  +        msg.append("REQUEST: ").append(request.getRequestURI()).append(lineSeparator).append(lineSeparator);
  +        msg.append("CONTEXT PATH: ").append(request.getContextPath()).append(lineSeparator);
  +        msg.append("SERVLET PATH: ").append(request.getServletPath()).append(lineSeparator);
  +        msg.append("PATH INFO: ").append(request.getPathInfo()).append(lineSeparator).append(lineSeparator);
  +
  +        msg.append("REMOTE HOST: ").append(request.getRemoteHost()).append(lineSeparator);
  +        msg.append("REMOTE ADDRESS: ").append(request.getRemoteAddr()).append(lineSeparator);
  +        msg.append("REMOTE USER: ").append(request.getRemoteUser()).append(lineSeparator);
  +        msg.append("REQUEST SESSION ID: ").append(request.getRequestedSessionId()).append(lineSeparator);
  +        msg.append("REQUEST PREFERRED LOCALE: ").append(request.getLocale().toString()).append(lineSeparator);
  +        msg.append("SERVER HOST: ").append(request.getServerName()).append(lineSeparator);
  +        msg.append("SERVER PORT: ").append(request.getServerPort()).append(lineSeparator).append(lineSeparator);
  +
  +        msg.append("METHOD: ").append(request.getMethod()).append(lineSeparator);
  +        msg.append("CONTENT LENGTH: ").append(request.getContentLength()).append(lineSeparator);
  +        msg.append("PROTOCOL: ").append(request.getProtocol()).append(lineSeparator);
  +        msg.append("SCHEME: ").append(request.getScheme()).append(lineSeparator);
  +        msg.append("AUTH TYPE: ").append(request.getAuthType()).append(lineSeparator).append(lineSeparator);
  +        msg.append("CURRENT ACTIVE REQUESTS: ").append(activeRequestCount).append(lineSeparator);
  +        msg.append("MAXIMUM ACTIVE REQUESTS: ").append(maxRequestCount).append(lineSeparator).append(lineSeparator);
  +
  +        // log all of the request parameters
  +        Enumeration e = request.getParameterNames();
  +
  +        msg.append("REQUEST PARAMETERS:").append(lineSeparator).append(lineSeparator);
  +
  +        while (e.hasMoreElements()) {
  +            String p = (String) e.nextElement();
  +
  +            msg.append("PARAM: '").append(p).append("' ")
  +               .append("VALUES: '");
  +            String[] params = request.getParameterValues(p);
  +            for (int i = 0; i < params.length; i++) {
  +                msg.append("["+params[i]+"]");
  +                if (i != params.length-1) 
  +                msg.append(", ");
               }
  -            msg.append("REQUEST: ").append(request.getRequestURI()).append(lineSeparator).append(lineSeparator);
  -            msg.append("CONTEXT PATH: ").append(request.getContextPath()).append(lineSeparator);
  -            msg.append("SERVLET PATH: ").append(request.getServletPath()).append(lineSeparator);
  -            msg.append("PATH INFO: ").append(request.getPathInfo()).append(lineSeparator).append(lineSeparator);
  -
  -            msg.append("REMOTE HOST: ").append(request.getRemoteHost()).append(lineSeparator);
  -            msg.append("REMOTE ADDRESS: ").append(request.getRemoteAddr()).append(lineSeparator);
  -            msg.append("REMOTE USER: ").append(request.getRemoteUser()).append(lineSeparator);
  -            msg.append("REQUEST SESSION ID: ").append(request.getRequestedSessionId()).append(lineSeparator);
  -            msg.append("REQUEST PREFERRED LOCALE: ").append(request.getLocale().toString()).append(lineSeparator);
  -            msg.append("SERVER HOST: ").append(request.getServerName()).append(lineSeparator);
  -            msg.append("SERVER PORT: ").append(request.getServerPort()).append(lineSeparator).append(lineSeparator);
  -
  -            msg.append("METHOD: ").append(request.getMethod()).append(lineSeparator);
  -            msg.append("CONTENT LENGTH: ").append(request.getContentLength()).append(lineSeparator);
  -            msg.append("PROTOCOL: ").append(request.getProtocol()).append(lineSeparator);
  -            msg.append("SCHEME: ").append(request.getScheme()).append(lineSeparator);
  -            msg.append("AUTH TYPE: ").append(request.getAuthType()).append(lineSeparator).append(lineSeparator);
  +
  +            msg.append("'").append(lineSeparator);
  +        }
   
  -            // log all of the request parameters
  -            Enumeration e = request.getParameterNames();
  +        msg.append(lineSeparator).append("SESSION ATTRIBUTES:").append(lineSeparator).append(lineSeparator);
   
  -            msg.append("REQUEST PARAMETERS:").append(lineSeparator).append(lineSeparator);
  +        // log all of the session attributes
  +        if (session != null) {
  +             e = session.getAttributeNames();
   
               while (e.hasMoreElements()) {
                   String p = (String) e.nextElement();
  -
  -                 msg.append("PARAM: '").append(p).append("' ")
  -                    .append("VALUES: '");
  -		 String[] params = request.getParameterValues(p);
  -		 for (int i = 0; i < params.length; i++) {
  -		     msg.append("["+params[i]+"]");
  -		     if (i != params.length-1) 
  -			 msg.append(", ");
  -		 }
  -		     
  -		 msg.append("'").append(lineSeparator);
  -            }
  -
  -            msg.append(lineSeparator).append("SESSION ATTRIBUTES:").append(lineSeparator).append(lineSeparator);
   
  -            // log all of the session attributes
  -            if (session != null) {
  -                 e = session.getAttributeNames();
  -
  -                while (e.hasMoreElements()) {
  -                    String p = (String) e.nextElement();
  -
  -                    msg.append("PARAM: '").append(p).append("' ")
  -                       .append("VALUE: '").append(session.getAttribute(p)).append("'").append(lineSeparator);
  -                }
  +                msg.append("PARAM: '").append(p).append("' ")
  +                   .append("VALUE: '").append(session.getAttribute(p)).append("'").append(lineSeparator);
               }
  -
  -            getLogger().debug(msg.toString());
           }
  +
  +        getLogger().debug(msg.toString());
       }
   
       /**
  @@ -462,9 +468,18 @@
       public boolean process(Environment environment)
       throws Exception {
           if (disposed) throw new IllegalStateException("You cannot process a Disposed Cocoon
engine.");
  -        this.debug(environment, null, null);
  -        return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName,
  -                 this.checkSitemapReload, this.reloadSitemapAsynchron);
  +
  +	try {
  +            if (this.getLogger().isDebugEnabled()) {
  +                incRequestCount();
  +                this.debug(environment, null, null);
  +            }
  +            return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName,
this.checkSitemapReload, this.reloadSitemapAsynchron);
  +        } finally {
  +            if (this.getLogger().isDebugEnabled()) {
  +                decRequestCount();
  +            }
  +	}
       }
   
       /**
  @@ -474,10 +489,18 @@
       public boolean process(Environment environment, StreamPipeline pipeline, EventPipeline
eventPipeline)
       throws Exception {
           if (disposed) throw new IllegalStateException("You cannot process a Disposed Cocoon
engine.");
  -        this.debug(environment, pipeline, eventPipeline);
  -        return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName,
  -              this.checkSitemapReload, this.reloadSitemapAsynchron,
  -              pipeline, eventPipeline);
  +
  +	try {
  +            if (this.getLogger().isDebugEnabled()) {
  +                incRequestCount();
  +                this.debug(environment, pipeline, eventPipeline);
  +            }
  +            return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName,
this.checkSitemapReload, this.reloadSitemapAsynchron, pipeline, eventPipeline);
  +        } finally {
  +            if (this.getLogger().isDebugEnabled()) {
  +                decRequestCount();
  +            }
  +	}
       }
   
       /**
  @@ -544,4 +567,21 @@
               if (sourceHandler != null) this.componentManager.release((Component) sourceHandler);
           }
       }
  +
  +    /**
  +     * Increment active request count for incoming requests, and save this
  +     * result if it's the maximum.
  +     */
  +    private static synchronized void incRequestCount() {
  +    	if (++activeRequestCount > maxRequestCount)
  +	    maxRequestCount = activeRequestCount;
  +    }
  +
  +    /**
  +     * Decrement active request count.
  +     */
  +    private static synchronized void decRequestCount() {
  +    	--activeRequestCount;
  +    }
  +
   }
  
  
  
  1.19      +29 -1     xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java
  
  Index: I18nTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- I18nTransformer.java	2001/08/30 11:44:45	1.18
  +++ I18nTransformer.java	2001/09/08 11:45:49	1.19
  @@ -245,7 +245,8 @@
   
       /**
        * <code>sub-type</code> attribute is used with <code>i18:number</code>
to
  -     * indicate a sub-type: <code>currency</code> or <code>percent</code>.
  +     * indicate a sub-type: <code>currency</code>, <code>int-currency</code>
  +     * or <code>percent</code>.
        */
       public static final String I18N_SUB_TYPE_ATTRIBUTE = "sub-type";
   
  @@ -1051,6 +1052,8 @@
   
           // src format
           DecimalFormat from_fmt = (DecimalFormat)NumberFormat.getInstance(srcLoc);
  +	int int_currency = 0;
  +
   	// src-pattern overwrites locale format
           if (srcPattern != null) {
               from_fmt.applyPattern(srcPattern);
  @@ -1058,10 +1061,28 @@
   
   	// to format
           DecimalFormat to_fmt = null;
  +        char dec = from_fmt.getDecimalFormatSymbols().getDecimalSeparator();
  +        int decAt = 0;
  +        boolean appendDec = false;
           if (subType == null) {
               to_fmt = (DecimalFormat)NumberFormat.getInstance(loc);
  +            to_fmt.setMaximumFractionDigits(309);
  +            for(int i=value.length()-1;
  +                i>=0 && value.charAt(i)!=dec;i--,decAt++);
  +            if(decAt < value.length()) to_fmt.setMinimumFractionDigits(decAt);
  +            decAt = 0;
  +            for(int i = 0; i < value.length() && value.charAt(i) != dec; i++)
{
  +              if(Character.isDigit(value.charAt(i))) decAt++;
  +            }
  +            to_fmt.setMinimumIntegerDigits(decAt);
  +            if(value.charAt(value.length()-1) == dec) appendDec = true;
           } else if (subType.equals("currency")) {
               to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(loc);
  +        } else if (subType.equals("int-currency")) {
  +            to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(loc);
  +	    int_currency = 1;
  +	    for(int i=0;i<to_fmt.getMaximumFractionDigits();i++)
  +		int_currency *= 10;
           } else if (subType.equals("percent")) {
               to_fmt = (DecimalFormat)NumberFormat.getPercentInstance(loc);
           }
  @@ -1076,6 +1097,12 @@
           } else {
               try {
                   numberValue = from_fmt.parse(value);
  +                if(int_currency > 0)
  +		    numberValue = new Double(numberValue.doubleValue()/
  +					     int_currency);
  +                else {
  +
  +                }
               } catch (ParseException pe) {
                   throw new SAXException(this.getClass().getName()
                                          + "i18n:number - parsing error.", pe);
  @@ -1084,6 +1111,7 @@
   
           // we have all necessary data here: do formatting.
           String result = to_fmt.format(numberValue);
  +        if(appendDec) result = result + dec;
           debug("i18n:number result: " + result);
           return result;
       }
  
  
  
  1.8       +1 -0      xml-cocoon2/xdocs/i18n-transformer.xml
  
  Index: i18n-transformer.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/xdocs/i18n-transformer.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- i18n-transformer.xml	2001/08/14 11:46:08	1.7
  +++ i18n-transformer.xml	2001/09/08 11:45:49	1.8
  @@ -189,6 +189,7 @@
    				</p>
   					<ul>
   						<li><code><![CDATA[<i18n:number sub-type="currency" value="1703.74"
/>]]></code> will result in localized presentation of the <code>value</code>
- $1,703.74 for US locale.</li>
  +						<li><code><![CDATA[<i18n:number sub-type="int-currency" value="170374"
/>]]></code> will result in localized presentation of the <code>value</code>
- $1,703.74 for US locale, 170374 for a currency without subunit.</li>
   						<li><code><![CDATA[<i18n:number sub-type="percent" value="1.2"
/>]]></code> will result in localized percent <code>value</code> -
%120 for most of the locales.</li>
   					</ul>
   				<p>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message