Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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.camel.dataformat.xstream;
 
 
 
 
A data format (org.apache.camel.spi.DataFormat) using XStream to marshal to and from XML

Version:
 
 public class XStreamDataFormat extends AbstractXStreamWrapper  {
     String encoding;
     
     public XStreamDataFormat() {
     }
 
     public XStreamDataFormat(XStream xstream) {
         super(xstream);
     }
     
     public void setEncoding(String encoding) {
         this. = encoding;
     }
     
     public String getEncoding() {
         return ;
     }

    
A factory method which takes a collection of types to be annotated
 
     public static XStreamDataFormat processAnnotations(ClassResolver resolverIterable<Class<?>> types) {
         XStreamDataFormat answer = new XStreamDataFormat();
         XStream xstream = answer.getXStream(resolver);
         for (Class<?> type : types) {
             xstream.processAnnotations(type);
         }
         return answer;
     }

    
A factory method which takes a number of types to be annotated
 
     public static XStreamDataFormat processAnnotations(ClassResolver resolverClass<?>... types) {
         XStreamDataFormat answer = new XStreamDataFormat();
         XStream xstream = answer.getXStream(resolver);
         for (Class<?> type : types) {
             xstream.processAnnotations(type);
         }
         return answer;
     }
     
     // just make sure the exchange property can override the xmlstream encoding setting
     protected void updateCharactorEncodingInfo(Exchange exchange) {
         if (exchange.getProperty(.) == null &&  != null) {
             exchange.setProperty(., IOHelper.normalizeCharset());
         }
     }
 
     protected HierarchicalStreamWriter createHierarchicalStreamWriter(Exchange exchangeObject bodyOutputStream streamthrows XMLStreamException {
         updateCharactorEncodingInfo(exchange);
         if (getXstreamDriver() != null) {
             return getXstreamDriver().createWriter(stream);
         }
         XMLStreamWriter xmlWriter = getStaxConverter().createXMLStreamWriter(streamexchange);
         return new StaxWriter(new QNameMap(), xmlWriter);
    }
        updateCharactorEncodingInfo(exchange);
        if (getXstreamDriver() != null) {
            return getXstreamDriver().createReader(stream);
        }
        XMLStreamReader xmlReader = getStaxConverter().createXMLStreamReader(streamexchange);
        return new StaxReader(new QNameMap(), xmlReader);
    }
New to GrepCode? Check out our FAQ X