Author: jdonnerstag
Date: Sat May  5 23:46:49 2007
New Revision: 535583

URL: http://svn.apache.org/viewvc?view=rev&rev=535583
Log:
cleanups

Modified:
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java?view=diff&rev=535583&r1=535582&r2=535583
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
 Sat May  5 23:46:49 2007
@@ -77,6 +77,9 @@
        /** True, if attributes have been modified or added */
        private boolean modified = false;
 
+       /** If true, than the MarkupParser will ignore (remove) it. */
+       private boolean ignore = false;
+
        /**
         * In case of inherited markup, the base and the extended markups are 
merged
         * and the information about the tags origin is lost. In some cases like
@@ -398,7 +401,7 @@
                        return tag;
                }
        }
-       
+
        /**
         * Copies all internal properties from this tag to <code>dest</code>.
         * This is basically cloning without instance creation.
@@ -780,5 +783,26 @@
                        return getXmlTag().equalTo(that.getXmlTag());
                }
                return false;
+       }
+
+       /**
+        * Gets ignore.
+        * 
+        * @return If true than MarkupParser will remove it from the markup
+        */
+       public boolean isIgnore()
+       {
+               return this.ignore;
+       }
+
+       /**
+        * Sets ignore.
+        * 
+        * @param ignore
+        *            If true than MarkupParser will remove it from the markup
+        */
+       public void setIgnore(boolean ignore)
+       {
+               this.ignore = ignore;
        }
 }

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java?view=diff&rev=535583&r1=535582&r2=535583
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
 Sat May  5 23:46:49 2007
@@ -177,7 +177,7 @@
                                appendMarkupFilter(new 
HeadForceTagIdHandler(containerInfo.getContainerClass()));
                        }
                }
-               
+
                appendMarkupFilter(new 
PrependContextPathHandler(Application.get()));
                appendMarkupFilter(new EnclosureHandler());
        }
@@ -202,21 +202,24 @@
         */
        public final void appendMarkupFilter(final IMarkupFilter filter)
        {
+               // PrependContextPathHandler should always be close to the end.
+               // It doesn't have to be last though.
                appendMarkupFilter(filter, PrependContextPathHandler.class);
        }
 
        /**
         * Append a new filter to the list of already pre-configured markup 
filters.
+        * Add the new filter before the "beforeFilter" which is identified by 
its
+        * class.
         * 
         * @param filter
         *            The filter to be appended
         * @param beforeFilter
-        *            The filter should be added before the beforeFilter. If
+        *            The filter will be added before the beforeFilter. If
         *            beforeFilter == null or beforeFilter not found than 
append to
         *            the end
         */
-       public final void appendMarkupFilter(final IMarkupFilter filter,
-                       final Class beforeFilter)
+       public final void appendMarkupFilter(final IMarkupFilter filter, final 
Class beforeFilter)
        {
                if ((beforeFilter == null) || (this.markupFilterChain == null))
                {
@@ -236,7 +239,7 @@
                                }
                                current = current.getParent();
                        }
-                       
+
                        if (current == null)
                        {
                                filter.setParent(this.markupFilterChain);
@@ -269,6 +272,17 @@
        }
 
        /**
+        * Get the next tag from the markup file
+        * 
+        * @return The next tag
+        * @throws ParseException
+        */
+       public ComponentTag getNextTag() throws ParseException
+       {
+               return (ComponentTag)this.markupFilterChain.nextTag();
+       }
+
+       /**
         * Scans the given markup and extracts balancing tags.
         * 
         */
@@ -280,11 +294,12 @@
 
                try
                {
-                       // allways remember the latest index (size)
+                       // always remember the latest index (size)
                        int size = this.markup.size();
 
                        // Loop through tags
-                       for (ComponentTag tag; null != (tag = 
(ComponentTag)markupFilterChain.nextTag());)
+                       ComponentTag tag;
+                       while (null != (tag = getNextTag()))
                        {
                                boolean add = (tag.getId() != null);
                                if (!add && tag.getXmlTag().isClose())
@@ -295,9 +310,8 @@
                                // Add tag to list?
                                if (add || tag.isModified())
                                {
+                                       // Add text from last position to the 
current tag position
                                        final CharSequence text = 
xmlParser.getInputFromPositionMarker(tag.getPos());
-
-                                       // Add text from last position to tag 
position
                                        if (text.length() > 0)
                                        {
                                                String rawMarkup = 
text.toString();
@@ -319,10 +333,9 @@
 
                                        if (add)
                                        {
-                                               // Add to list unless preview 
component tag remover
-                                               // flagged
-                                               // as removed
-                                               if 
(!WicketRemoveTagHandler.IGNORE.equals(tag.getId()))
+                                               // Add to the markup unless the 
tag has been flagged as
+                                               // to be removed from the 
markup. (e.g. <wicket:remove>
+                                               if (tag.isIgnore() == false)
                                                {
                                                        
this.markup.addMarkupElement(tag);
                                                }
@@ -335,7 +348,7 @@
                                        xmlParser.setPositionMarker();
                                }
 
-                               // allways remember the latest index (size)
+                               // always remember the latest index (size)
                                size = this.markup.size();
                        }
                }
@@ -380,7 +393,7 @@
                // Make all tags immutable and the list of elements unmodifable
                this.markup.makeImmutable();
        }
-
+       
        /**
         * Remove whitespaces from the raw markup
         * 


Reply via email to