You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2009/04/22 02:41:46 UTC

svn commit: r767338 - in /myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style: BaseStyle.java cache/FileSystemStyleCache.java

Author: jwaldman
Date: Wed Apr 22 00:41:46 2009
New Revision: 767338

URL: http://svn.apache.org/viewvc?rev=767338&view=rev
Log:
some code cleanup.
Still need to figure out what to do about the ArrayMap based on Blake's code review comments about it not being thread-safe. He thinks we should try ConcurrentHashMap or else write an UnmodifiableArrayMap that is thread-safe and has an optimized copy constructor.

Modified:
    myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/BaseStyle.java
    myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java

Modified: myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/BaseStyle.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/BaseStyle.java?rev=767338&r1=767337&r2=767338&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/BaseStyle.java (original)
+++ myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/BaseStyle.java Wed Apr 22 00:41:46 2009
@@ -40,7 +40,6 @@
    */
   public BaseStyle()
   {
-    // TODO should I leave this null and set to an empty map later?
     _propertiesMap = Collections.emptyMap();
   }
 
@@ -49,18 +48,14 @@
    *
    * @param propertiesMap The properties of this style.  The
    *   name and values must be Strings.
-   *   TODO Should I make sure the property name is all lower case
-   *   like it was in the original code? I'll have to get each 
-   *   property and convert. putting individually (setProperty) does this.
    */
   public BaseStyle(Map<String, String> propertiesMap)
   {
-    if ((propertiesMap != null) && (propertiesMap.size() > 0))
+    if ((propertiesMap != null) && (!propertiesMap.isEmpty()))
     {
       // Initialize the propertiesMap with an ArrayMap implementation.
       // ArrayMap is fast reads.
-      int length = propertiesMap.size() * 2;
-      _propertiesMap = new ArrayMap<String, String>(length);
+      _propertiesMap = new ArrayMap<String, String>(propertiesMap.size());
       
       _propertiesMap.putAll(propertiesMap);
     }
@@ -138,12 +133,10 @@
    */
   public void setProperty(String name, String value)
   {
-    // We store all names/values as lowercase string
-    name = name.toLowerCase();
 
     synchronized (this)
     {
-      if (_propertiesMap == null || _propertiesMap.isEmpty())
+      if (_propertiesMap.isEmpty())
         _propertiesMap = new ArrayMap<String, String>();
       _propertiesMap.put(name, value);
       

Modified: myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?rev=767338&r1=767337&r2=767338&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java (original)
+++ myfaces/trinidad/branches/jwaldman_StyleMap/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java Wed Apr 22 00:41:46 2009
@@ -1401,7 +1401,7 @@
    * StyleNodes to a Map. Only the style selectors and not the aliased (aka named) styles 
    * are added to this map.
    */
-  private class StylesImpl extends Styles
+  private static final class StylesImpl extends Styles
   {
     /**
      * This constructor takes an array of StyleNode Objects where each StyleNode has
@@ -1557,18 +1557,18 @@
 
     }
     
-    private Map<Selector, Style> _unmodifiableResolvedSelectorStyleMap;    
-    private Map<String, String>  _afSelectorMap;
-    private String[]             _namespacePrefixArray;
-    private Map<String, String>  _shortStyleClassMap;
-    boolean                      _compress;
+    private final Map<Selector, Style> _unmodifiableResolvedSelectorStyleMap;    
+    private final Map<String, String>  _afSelectorMap;
+    private final String[]             _namespacePrefixArray;
+    private final Map<String, String>  _shortStyleClassMap;
+    private final boolean              _compress;
   }
   
   private class StyleWriterFactoryImpl
     implements StyleWriterFactory
   {
-    private String _outputDirectory;
-    private String _baseFilename;
+    private final String _outputDirectory;
+    private final String _baseFilename;
     private PrintWriter _out;
     private List<File> _files = new LinkedList<File>();
 
@@ -1611,7 +1611,7 @@
   }
 
   private File   _sourceFile; // The source XSS file
-  private String _targetPath; // The location of the cache
+  private final String _targetPath; // The location of the cache
   private String _baseName;   // The base file name for generated CSS files
 
   /**
@@ -1654,12 +1654,6 @@
   private static final StyleSheetDocument _EMPTY_DOCUMENT =
     new StyleSheetDocument(null, null, StyleSheetDocument.UNKNOWN_TIMESTAMP);
 
-  /**
-   * Style used to represent misses in the StyleMap.
-   * Package private to allow access from nested StyleMapImpl class
-   */
-  static final Style _MISS = new CSSStyle();
-
   /** Prefix to use for short style classes */
   private static final String _SHORT_CLASS_PREFIX = "x";