Here you can find the source of setEncoding(@Nonnull final Marshaller aMarshaller, @Nullable final Charset aEncoding)
Parameter | Description |
---|---|
aMarshaller | The marshaller to set the property. May not be <code>null</code>. |
aEncoding | the value to be set |
public static void setEncoding(@Nonnull final Marshaller aMarshaller, @Nullable final Charset aEncoding)
//package com.java2s; /**// www. ja va 2 s . com * Copyright (C) 2014-2015 Philip Helger (www.helger.com) * philip[at]helger[dot]com * * Licensed 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.nio.charset.Charset; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.xml.bind.Marshaller; import javax.xml.bind.PropertyException; public class Main { /** * Set the standard property for the encoding charset. * * @param aMarshaller * The marshaller to set the property. May not be <code>null</code>. * @param aEncoding * the value to be set */ public static void setEncoding(@Nonnull final Marshaller aMarshaller, @Nullable final Charset aEncoding) { setEncoding(aMarshaller, aEncoding == null ? null : aEncoding.name()); } /** * Set the standard property for the encoding charset. * * @param aMarshaller * The marshaller to set the property. May not be <code>null</code>. * @param sEncoding * the value to be set */ public static void setEncoding(@Nonnull final Marshaller aMarshaller, @Nullable final String sEncoding) { _setProperty(aMarshaller, Marshaller.JAXB_ENCODING, sEncoding); } private static void _setProperty(@Nonnull final Marshaller aMarshaller, @Nonnull final String sPropertyName, @Nullable final Object aValue) { try { aMarshaller.setProperty(sPropertyName, aValue); } catch (final PropertyException ex) { throw new IllegalArgumentException("Failed to set JAXB property '" + sPropertyName + "' to " + aValue, ex); } } }