Author: markt
Date: Tue Aug 30 11:48:45 2016
New Revision: 1758369

URL: http://svn.apache.org/viewvc?rev=1758369&view=rev
Log:
Add a feature to the Digester that enables it to pass the encoding of the 
source XML document to the object being populated.

Added:
    tomcat/trunk/java/org/apache/tomcat/util/digester/DocumentProperties.java   
(with props)
Modified:
    tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java?rev=1758369&r1=1758368&r2=1758369&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Tue Aug 30 
11:48:45 2016
@@ -51,6 +51,7 @@ import org.xml.sax.SAXNotSupportedExcept
 import org.xml.sax.SAXParseException;
 import org.xml.sax.XMLReader;
 import org.xml.sax.ext.DefaultHandler2;
+import org.xml.sax.ext.Locator2;
 import org.xml.sax.helpers.AttributesImpl;
 
 
@@ -1129,6 +1130,10 @@ public class Digester extends DefaultHan
             saxLog.debug("startDocument()");
         }
 
+        if (locator instanceof Locator2 && root instanceof 
DocumentProperties.Encoding) {
+            ((DocumentProperties.Encoding) root).setEncoding(((Locator2) 
locator).getEncoding());
+        }
+
         // ensure that the digester is properly configured, as
         // the digester could be used as a SAX ContentHandler
         // rather than via the parse() methods.

Added: tomcat/trunk/java/org/apache/tomcat/util/digester/DocumentProperties.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/DocumentProperties.java?rev=1758369&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/digester/DocumentProperties.java 
(added)
+++ tomcat/trunk/java/org/apache/tomcat/util/digester/DocumentProperties.java 
Tue Aug 30 11:48:45 2016
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+package org.apache.tomcat.util.digester;
+
+/**
+ *
+ * A collection of interfaces, one per property, that enables the object being
+ * populated by the digester to signal to the digester that it supports the
+ * given property and that the digester should populate that property if
+ * available.
+ */
+public interface DocumentProperties {
+
+    /**
+     * The encoding used by the source XMl document.
+     */
+    public interface Encoding {
+        public void setEncoding(String encoding);
+    }
+}

Propchange: 
tomcat/trunk/java/org/apache/tomcat/util/digester/DocumentProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to