You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by bs...@apache.org on 2008/05/20 16:10:55 UTC

svn commit: r658255 - /servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java

Author: bsnyder
Date: Tue May 20 07:10:55 2008
New Revision: 658255

URL: http://svn.apache.org/viewvc?rev=658255&view=rev
Log:
SM-1355 - XML escaping converter for SimpleFlatFileMarshaler

Added:
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java   (with props)

Added: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java?rev=658255&view=auto
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java (added)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java Tue May 20 07:10:55 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.servicemix.components.util;
+
+/**
+ *
+ * @author Andrew Skiba <sk...@gmail.com>
+ */
+public class XmlEscapingConverter implements ContentConverter {
+
+    public String convertToXml(String contents) {
+        return contents.replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("&", "&amp;");
+    }
+
+    public String convertToFlatFileContent(String contents) {
+        return contents.replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
+    }
+}

Propchange: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.java
------------------------------------------------------------------------------
    svn:keywords = Id Revision