org.apache.axiom.om.OMCloneOptions Maven / Gradle / Ivy
/*
* 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.axiom.om;
import javax.activation.DataHandler;
import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
public class OMCloneOptions {
private boolean fetchDataHandlers;
private boolean copyOMDataSources;
private boolean preserveModel;
/**
* Determine whether {@link DataHandler} objects should be fetched when cloning {@link OMText}
* nodes. See {@link #setFetchDataHandlers(boolean)} for more information about this option.
*
* @return the current value of this option
*/
public boolean isFetchDataHandlers() {
return fetchDataHandlers;
}
/**
* Specify whether {@link DataHandler} objects should be fetched when cloning {@link OMText}
* nodes. If this option is set to false
(default) then an {@link OMText} node
* backed by a {@link DataHandlerProvider} will be cloned by copying the reference to that
* {@link DataHandlerProvider} to the cloned {@link OMText} node. This implies that if the
* original tree was constructed from an XOP encoded stream, then the clone may become unusable
* if that stream is closed. If this option is set to true
, then
* {@link DataHandlerProvider} references will be replaced by {@link DataHandler} references. In
* addition, the necessary actions are taken to ensure that the content of these
* {@link DataHandler} instances is fetched into memory or temporary storage, so that the clones
* remain usable even after the underlying stream is closed.
*
* @param fetchDataHandlers
* the value to set for this option
*/
public void setFetchDataHandlers(boolean fetchDataHandlers) {
this.fetchDataHandlers = fetchDataHandlers;
}
/**
* Determine whether {@link OMSourcedElement} nodes should be cloned as {@link OMSourcedElement}
* nodes by copying the corresponding {@link OMDataSource} objects. See
* {@link #setCopyOMDataSources(boolean)} for more information about this option.
*
* @return the current value of this option
*/
public boolean isCopyOMDataSources() {
return copyOMDataSources;
}
/**
* Specify whether {@link OMSourcedElement} nodes should be cloned as {@link OMSourcedElement}
* nodes by copying the corresponding {@link OMDataSource} objects. If this option is set to
* false
(default), then all {@link OMSourcedElement} nodes will be cloned as
* simple {@link OMElement} instances, which implies that the original {@link OMSourcedElement}
* nodes will be expanded. If this option is set to true
, then an attempt is made
* to clone {@link OMSourcedElement} nodes as {@link OMSourcedElement} nodes by copying the
* corresponding {@link OMDataSource} instances. Note that there are several cases where this is
* not possible:
*
* - There is no {@link OMDataSource} set.
*
- The {@link OMDataSource} is destructive (or doesn't implement {@link OMDataSourceExt}.
*
- The {@link OMSourcedElement} is expanded.
*
*
* In these cases, {@link OMSourcedElement} nodes will always be cloned as simple
* {@link OMElement} instances.
*
* @param copyOMDataSources
* the value to set for this option
*/
public void setCopyOMDataSources(boolean copyOMDataSources) {
this.copyOMDataSources = copyOMDataSources;
}
/**
* Determine whether domain specific extensions to the object model should be preserved. See
* {@link #setPreserveModel(boolean)} for more information about this option.
*
* @return the current value of this option
*/
public boolean isPreserveModel() {
return preserveModel;
}
/**
* Specify whether domain specific extensions to the object model should be preserved. If this
* option is set to false
(default), then the object model is always cloned as
* plain XML even if the original uses domain specific extensions such as SOAP. If this option
* is set to true
, then domain specific extensions are preserved.
*
* @param preserveModel
* the value to set for this option
*/
public void setPreserveModel(boolean preserveModel) {
this.preserveModel = preserveModel;
}
}