rfscholte commented on a change in pull request #286: [MNG-6656] Introduce base 
for build/consumer process
URL: https://github.com/apache/maven/pull/286#discussion_r330388940
 
 

 ##########
 File path: 
maven-core/src/main/java/org/apache/maven/xml/filter/FastForwardFilter.java
 ##########
 @@ -0,0 +1,128 @@
+package org.apache.maven.xml.filter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLFilter;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/**
+ * This filter will skip all following filters and write directly to the 
output.
+ * Should be used in case of a DOM that should not be effected by other 
filters, even though the elements match 
+ * 
+ * @author Robert Scholte
+ * @since 4.0.0
+ */
+class FastForwardFilter extends XMLFilterImpl
+{
+    /**
+     * DOM elements of pom
+     * 
+     * <ul>
+     *  <li>execution.configuration</li>
+     *  <li>plugin.configuration</li>
+     *  <li>plugin.goals</li>
+     *  <li>profile.reports</li>
+     *  <li>project.reports</li>
+     *  <li>reportSet.configuration</li>
+     * <ul>
+     */
+    private final Deque<String> state = new ArrayDeque<>();
+    
+    private int domDepth = 0;
+    
+    private ContentHandler originalHandler;
+    
+    FastForwardFilter()
+    {
+        super();
+    }
+
+    FastForwardFilter( XMLReader parent )
+    {
+        super( parent );
+    }
+
+    @Override
+    public void startElement( String uri, String localName, String qName, 
Attributes atts )
+        throws SAXException
+    {
+        super.startElement( uri, localName, qName, atts );
+        if ( domDepth > 0 )
 
 Review comment:
   If the XML is invalid, it'll already fail during the first phase. This is 
part of the second phase. This is the best lightwight solution I came up with, 
and there are tests that cover it. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to