tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util Strftime.java
Date Sat, 11 May 2002 05:43:56 GMT
billbarker    02/05/10 22:43:56

  Modified:    catalina/src/share/org/apache/catalina/util Strftime.java
  Log:
  Fixing tabs.
  
  I've clearly got to review more carefully if I don't want Jon breathing down my neck. ;-)
  
  Revision  Changes    Path
  1.2       +81 -81    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/Strftime.java
  
  Index: Strftime.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/Strftime.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Strftime.java	11 May 2002 05:06:25 -0000	1.1
  +++ Strftime.java	11 May 2002 05:43:56 -0000	1.2
  @@ -1,8 +1,8 @@
   /*
    * Strftime.java
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/Strftime.java,v
1.1 2002/05/11 05:06:25 billbarker Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/05/11 05:06:25 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/Strftime.java,v
1.2 2002/05/11 05:43:56 billbarker Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/05/11 05:43:56 $
    *
    * ====================================================================
    *
  @@ -87,7 +87,7 @@
    *
    * @author Bip Thelin
    * @author Dan Sandberg
  - * @version $Revision: 1.1 $, $Date: 2002/05/11 05:06:25 $
  + * @version $Revision: 1.2 $, $Date: 2002/05/11 05:43:56 $
    */
   public class Strftime {
       protected static Properties translate;
  @@ -104,8 +104,8 @@
           translate.put("B","MMMM");
           translate.put("c","EEE MMM d HH:mm:ss yyyy");
   
  -	//There's no way to specify the century in SimpleDateFormat.  We don't want to hard-code
  -	//20 since this could be wrong for the pre-2000 files.
  +        //There's no way to specify the century in SimpleDateFormat.  We don't want to
hard-code
  +        //20 since this could be wrong for the pre-2000 files.
           //translate.put("C", "20");
           translate.put("d","dd");
           translate.put("D","MM/dd/yy");
  @@ -126,23 +126,23 @@
           translate.put("P","a");  //will show as pm instead of PM
           translate.put("r","hh:mm:ss a");
           translate.put("R","HH:mm");
  -	//There's no way to specify this with SimpleDateFormat
  +        //There's no way to specify this with SimpleDateFormat
           //translate.put("s","seconds since ecpoch");
           translate.put("S","ss");
           translate.put("t","\t");
           translate.put("T","HH:mm:ss");
  -	//There's no way to specify this with SimpleDateFormat
  +        //There's no way to specify this with SimpleDateFormat
           //translate.put("u","day of week ( 1-7 )");
   
  -	//There's no way to specify this with SimpleDateFormat
  +        //There's no way to specify this with SimpleDateFormat
           //translate.put("U","week in year with first sunday as first day...");
   
           translate.put("V","ww"); //I'm not sure this is always exactly the same
   
  -	//There's no way to specify this with SimpleDateFormat
  +        //There's no way to specify this with SimpleDateFormat
           //translate.put("W","week in year with first monday as first day...");
   
  -	//There's no way to specify this with SimpleDateFormat
  +        //There's no way to specify this with SimpleDateFormat
           //translate.put("w","E");
           translate.put("X","HH:mm:ss");
           translate.put("x","MM/dd/yy");
  @@ -160,8 +160,8 @@
        * @see #Strftime( String, Locale )
        */
       public Strftime( String origFormat ) {
  -	String convertedFormat = convertDateFormat( origFormat );
  -	simpleDateFormat = new SimpleDateFormat( convertedFormat );
  +        String convertedFormat = convertDateFormat( origFormat );
  +        simpleDateFormat = new SimpleDateFormat( convertedFormat );
       }
   
       /**
  @@ -171,8 +171,8 @@
        * @param the locale to use for locale-specific conversions
        */
       public Strftime( String origFormat, Locale locale ) {
  -	String convertedFormat = convertDateFormat( origFormat );
  -	simpleDateFormat = new SimpleDateFormat( convertedFormat, locale );
  +        String convertedFormat = convertDateFormat( origFormat );
  +        simpleDateFormat = new SimpleDateFormat( convertedFormat, locale );
       }
   
       /**
  @@ -182,7 +182,7 @@
        * @return the formatted date
        */
       public String format( Date date ) {
  -	return simpleDateFormat.format( date );
  +        return simpleDateFormat.format( date );
       }
   
       /**
  @@ -191,7 +191,7 @@
        * @return the timezone
        */
       public TimeZone getTimeZone() {
  -	return simpleDateFormat.getTimeZone();
  +        return simpleDateFormat.getTimeZone();
       }
   
       /**
  @@ -200,7 +200,7 @@
        * @see java.util.TimeZone#setTimeZone
        */
       public void setTimeZone( TimeZone timeZone ) {
  -	simpleDateFormat.setTimeZone( timeZone );
  +        simpleDateFormat.setTimeZone( timeZone );
       }
   
       /**
  @@ -214,58 +214,58 @@
       protected String convertDateFormat( String pattern ) {
           boolean inside = false;
           boolean mark = false;
  -	boolean modifiedCommand = false;
  +        boolean modifiedCommand = false;
   
           StringBuffer buf = new StringBuffer();
   
           for(int i = 0; i < pattern.length(); i++) {
  -	    char c = pattern.charAt(i);
  +            char c = pattern.charAt(i);
   
               if ( c=='%' && !mark ) {
                   mark=true;
               } else {
  -		if ( mark ) {
  -		    if ( modifiedCommand ) {
  -			//don't do anything--we just wanted to skip a char
  -			modifiedCommand = false;
  -			mark = false;
  -		    } else {
  -			inside = translateCommand( buf, pattern, i, inside );
  -			//It's a modifier code
  -			if ( c=='O' || c=='E' ) {
  -			    modifiedCommand = true;
  -			} else {
  -			    mark=false;
  -			}
  -		    }
  -		} else {
  -		    if ( !inside && c != ' ' ) {
  -			//We start a literal, which we need to quote
  -			buf.append("'");
  -			inside = true;
  -		    }
  -		    
  -		    buf.append(c);
  -		}
  -	    }
  +                if ( mark ) {
  +                    if ( modifiedCommand ) {
  +                        //don't do anything--we just wanted to skip a char
  +                        modifiedCommand = false;
  +                        mark = false;
  +                    } else {
  +                        inside = translateCommand( buf, pattern, i, inside );
  +                        //It's a modifier code
  +                        if ( c=='O' || c=='E' ) {
  +                            modifiedCommand = true;
  +                        } else {
  +                            mark=false;
  +                        }
  +                    }
  +                } else {
  +                    if ( !inside && c != ' ' ) {
  +                        //We start a literal, which we need to quote
  +                        buf.append("'");
  +                        inside = true;
  +                    }
  +                    
  +                    buf.append(c);
  +                }
  +            }
           }
   
  -	if ( buf.length() > 0 ) {
  -	    char lastChar = buf.charAt( buf.length() - 1 );
  +        if ( buf.length() > 0 ) {
  +            char lastChar = buf.charAt( buf.length() - 1 );
   
  -	    if( lastChar!='\'' && inside ) {
  -		buf.append('\'');
  -	    }
  -	}
  +            if( lastChar!='\'' && inside ) {
  +                buf.append('\'');
  +            }
  +        }
           return buf.toString();
       }
   
       protected String quote( String str, boolean insideQuotes ) {
  -	String retVal = str;
  -	if ( !insideQuotes ) {
  -	    retVal = '\'' + retVal + '\'';
  -	}
  -	return retVal;
  +        String retVal = str;
  +        if ( !insideQuotes ) {
  +            retVal = '\'' + retVal + '\'';
  +        }
  +        return retVal;
       }
   
       /**
  @@ -276,32 +276,32 @@
        * @return The Java formatting rule to use
        */
       protected boolean translateCommand( StringBuffer buf, String pattern, int index, boolean
oldInside ) {
  -	char firstChar = pattern.charAt( index );
  -	boolean newInside = oldInside;
  +        char firstChar = pattern.charAt( index );
  +        boolean newInside = oldInside;
   
  -	//O and E are modifiers, they mean to present an alternative representation of the next
char
  -	//we just handle the next char as if the O or E wasn't there
  -	if ( firstChar == 'O' || firstChar == 'E' ) {
  -	    if ( index + 1 < pattern.length() ) {		
  -		newInside = translateCommand( buf, pattern, index + 1, oldInside );
  -	    } else {
  -		buf.append( quote("%" + firstChar, oldInside ) );
  -	    }
  -	} else {
  -	    String command = translate.getProperty( String.valueOf( firstChar ) );
  -	    
  -	    //If we don't find a format, treat it as a literal--That's what apache does
  -	    if ( command == null ) {
  -		buf.append( quote( "%" + firstChar, oldInside ) );
  -	    } else {
  -		//If we were inside quotes, close the quotes
  -		if ( oldInside ) {
  -		    buf.append( '\'' );
  -		}
  -		buf.append( command );
  -		newInside = false;
  -	    }
  -	}
  -	return newInside;
  +        //O and E are modifiers, they mean to present an alternative representation of
the next char
  +        //we just handle the next char as if the O or E wasn't there
  +        if ( firstChar == 'O' || firstChar == 'E' ) {
  +            if ( index + 1 < pattern.length() ) {               
  +                newInside = translateCommand( buf, pattern, index + 1, oldInside );
  +            } else {
  +                buf.append( quote("%" + firstChar, oldInside ) );
  +            }
  +        } else {
  +            String command = translate.getProperty( String.valueOf( firstChar ) );
  +            
  +            //If we don't find a format, treat it as a literal--That's what apache does
  +            if ( command == null ) {
  +                buf.append( quote( "%" + firstChar, oldInside ) );
  +            } else {
  +                //If we were inside quotes, close the quotes
  +                if ( oldInside ) {
  +                    buf.append( '\'' );
  +                }
  +                buf.append( command );
  +                newInside = false;
  +            }
  +        }
  +        return newInside;
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message