下面列出了怎么用org.w3c.dom.ls.LSSerializerFilter的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Obtain a the DOM, level 3, Load/Save serializer {@link LSSerializer} instance from the
* given {@link DOMImplementationLS} instance.
*
* <p>
* The serializer instance will be configured with the parameters passed as the <code>serializerParams</code>
* argument. It will also be configured with an {@link LSSerializerFilter} that shows all nodes to the filter,
* and accepts all nodes shown.
* </p>
*
* @param domImplLS the DOM Level 3 Load/Save implementation to use
* @param serializerParams parameters to pass to the {@link DOMConfiguration} of the serializer
* instance, obtained via {@link LSSerializer#getDomConfig()}. May be null.
*
* @return a new LSSerializer instance
*/
public static LSSerializer getLSSerializer(DOMImplementationLS domImplLS, Map<String, Object> serializerParams) {
LSSerializer serializer = domImplLS.createLSSerializer();
serializer.setFilter(new LSSerializerFilter() {
public short acceptNode(Node arg0) {
return FILTER_ACCEPT;
}
public int getWhatToShow() {
return SHOW_ALL;
}
});
if (serializerParams != null) {
DOMConfiguration serializerDOMConfig = serializer.getDomConfig();
for (String key : serializerParams.keySet()) {
serializerDOMConfig.setParameter(key, serializerParams.get(key));
}
}
return serializer;
}
/**
* Constructor.
* @param contentHandler serialHandler The implemention of the SerializationHandler interface
*/
DOM3TreeWalker(
SerializationHandler serialHandler,
DOMErrorHandler errHandler,
LSSerializerFilter filter,
String newLine) {
fSerializer = serialHandler;
//fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default?
fErrorHandler = errHandler;
fFilter = filter;
fLexicalHandler = null;
fNewLine = newLine;
fNSBinder = new NamespaceSupport();
fLocalNSBinder = new NamespaceSupport();
fDOMConfigProperties = fSerializer.getOutputFormat();
fSerializer.setDocumentLocator(fLocator);
initProperties(fDOMConfigProperties);
}
/**
* Constructor.
* @param contentHandler serialHandler The implemention of the SerializationHandler interface
*/
DOM3TreeWalker(
SerializationHandler serialHandler,
DOMErrorHandler errHandler,
LSSerializerFilter filter,
String newLine) {
fSerializer = serialHandler;
//fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default?
fErrorHandler = errHandler;
fFilter = filter;
fLexicalHandler = null;
fNewLine = newLine;
fNSBinder = new NamespaceSupport();
fLocalNSBinder = new NamespaceSupport();
fDOMConfigProperties = fSerializer.getOutputFormat();
fSerializer.setDocumentLocator(fLocator);
initProperties(fDOMConfigProperties);
}
/**
* Obtain a the DOM, level 3, Load/Save serializer {@link LSSerializer} instance from the
* given {@link DOMImplementationLS} instance.
*
* <p>
* The serializer instance will be configured with the parameters passed as the <code>serializerParams</code>
* argument. It will also be configured with an {@link LSSerializerFilter} that shows all nodes to the filter,
* and accepts all nodes shown.
* </p>
*
* @param domImplLS the DOM Level 3 Load/Save implementation to use
* @param serializerParams parameters to pass to the {@link DOMConfiguration} of the serializer
* instance, obtained via {@link LSSerializer#getDomConfig()}. May be null.
*
* @return a new LSSerializer instance
*/
public static LSSerializer getLSSerializer(
DOMImplementationLS domImplLS, Map<String, Object> serializerParams) {
LSSerializer serializer = domImplLS.createLSSerializer();
serializer.setFilter(
new LSSerializerFilter() {
@Override
public short acceptNode(Node arg0) {
return FILTER_ACCEPT;
}
@Override
public int getWhatToShow() {
return SHOW_ALL;
}
});
if (serializerParams != null) {
DOMConfiguration serializerDOMConfig = serializer.getDomConfig();
for (String key : serializerParams.keySet()) {
serializerDOMConfig.setParameter(key, serializerParams.get(key));
}
}
return serializer;
}
/**
* Constructor.
* @param contentHandler serialHandler The implemention of the SerializationHandler interface
*/
DOM3TreeWalker(
SerializationHandler serialHandler,
DOMErrorHandler errHandler,
LSSerializerFilter filter,
String newLine) {
fSerializer = serialHandler;
//fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default?
fErrorHandler = errHandler;
fFilter = filter;
fLexicalHandler = null;
fNewLine = newLine;
fNSBinder = new NamespaceSupport();
fLocalNSBinder = new NamespaceSupport();
fDOMConfigProperties = fSerializer.getOutputFormat();
fSerializer.setDocumentLocator(fLocator);
initProperties(fDOMConfigProperties);
try {
// Bug see Bugzilla 26741
fLocator.setSystemId(
System.getProperty("user.dir") + File.separator + "dummy.xsl");
} catch (SecurityException se) { // user.dir not accessible from applet
}
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter(){
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter){
serializer.fDOMFilter = filter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter(){
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter){
serializer.fDOMFilter = filter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter(){
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter){
serializer.fDOMFilter = filter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter(){
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter){
serializer.fDOMFilter = filter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter(){
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter){
serializer.fDOMFilter = filter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter(){
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out
* to the filter before serializing each Node. Attribute nodes are never
* passed to the filter. The filter implementation can choose to remove
* the node from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter){
serializer.fDOMFilter = filter;
}
/**
* When the application provides a filter, the serializer will call out to
* the filter before serializing each Node. Attribute nodes are never passed
* to the filter. The filter implementation can choose to remove the node
* from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter() {
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out to
* the filter before serializing each Node. Attribute nodes are never passed
* to the filter. The filter implementation can choose to remove the node
* from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter) {
serializer.fDOMFilter = filter;
}
/**
* Returns the DOMConfiguration of the LSSerializer.
*
* @see org.w3c.dom.ls.LSSerializer#getFilter()
* @since DOM Level 3
* @return A LSSerializerFilter object.
*/
public LSSerializerFilter getFilter() {
return fSerializerFilter;
}
/**
* Set a LSSerilizerFilter on the LSSerializer. When set, the filter is
* called before each node is serialized which depending on its implemention
* determines if the node is to be serialized or not.
*
* @see org.w3c.dom.ls.LSSerializer#setFilter
* @since DOM Level 3
* @param filter A LSSerializerFilter to be applied to the stream to serialize.
*/
public void setFilter(LSSerializerFilter filter) {
fSerializerFilter = filter;
}
/**
* Returns a LSSerializerFilter set on the DOM Level 3 Serializer to filter nodes
* during serialization.
*
* This interface is a public API.
*
* @return The Level 3 LSSerializerFilter
*/
public LSSerializerFilter getNodeFilter() {
return fSerializerFilter;
}
/**
* Sets a LSSerializerFilter on the DOM Level 3 Serializer to filter nodes
* during serialization.
*
* This interface is a public API.
*
* @param filter the Level 3 LSSerializerFilter
*/
public void setNodeFilter(LSSerializerFilter filter) {
fSerializerFilter = filter;
}
/**
* Sets a LSSerializerFilter on the DOM Level 3 Serializer to filter nodes
* during serialization.
*
* This interface is a public API.
*
* @param filter the Level 3 LSSerializerFilter
*/
public void setNodeFilter(LSSerializerFilter filter);
/**
* Returns a LSSerializerFilter set on the DOM Level 3 Serializer to filter nodes
* during serialization.
*
* This interface is a public API.
*
* @return The Level 3 LSSerializerFilter
*/
public LSSerializerFilter getNodeFilter();
/**
* When the application provides a filter, the serializer will call out to
* the filter before serializing each Node. Attribute nodes are never passed
* to the filter. The filter implementation can choose to remove the node
* from the stream or to terminate the serialization early.
*/
public LSSerializerFilter getFilter() {
return serializer.fDOMFilter;
}
/**
* When the application provides a filter, the serializer will call out to
* the filter before serializing each Node. Attribute nodes are never passed
* to the filter. The filter implementation can choose to remove the node
* from the stream or to terminate the serialization early.
*/
public void setFilter(LSSerializerFilter filter) {
serializer.fDOMFilter = filter;
}
/**
* Returns the DOMConfiguration of the LSSerializer.
*
* @see org.w3c.dom.ls.LSSerializer#getFilter()
* @since DOM Level 3
* @return A LSSerializerFilter object.
*/
public LSSerializerFilter getFilter() {
return fSerializerFilter;
}
/**
* Set a LSSerilizerFilter on the LSSerializer. When set, the filter is
* called before each node is serialized which depending on its implemention
* determines if the node is to be serialized or not.
*
* @see org.w3c.dom.ls.LSSerializer#setFilter
* @since DOM Level 3
* @param filter A LSSerializerFilter to be applied to the stream to serialize.
*/
public void setFilter(LSSerializerFilter filter) {
fSerializerFilter = filter;
}
/**
* Returns a LSSerializerFilter set on the DOM Level 3 Serializer to filter nodes
* during serialization.
*
* This interface is a public API.
*
* @return The Level 3 LSSerializerFilter
*/
public LSSerializerFilter getNodeFilter() {
return fSerializerFilter;
}