Errai 3.0.1-SNAPSHOT

org.jboss.errai.cdi.server.gwt.util
Class SimpleTranslator

java.lang.Object
  extended by org.jboss.errai.cdi.server.gwt.util.SimpleTranslator

public class SimpleTranslator
extends Object

Copies XML file to another location. Can filter out tags with provided names and attributes. Can insert tags into a parent with a given tag name.

Author:
Max Barkley

Nested Class Summary
static class SimpleTranslator.AttributeEntry
          An attribute key-value pair.
static class SimpleTranslator.Tag
          A simple xml tag with a local name and attribute key-value pairs.
 
Constructor Summary
SimpleTranslator()
           
 
Method Summary
 void addFilter(SimpleTranslator.Tag tag)
          Add a description of a tag to be filtered on a subsequent call to translate(InputStream, OutputStream).
 void addNewTag(String parentName, SimpleTranslator.Tag tag)
          Add a description for a new tag to be added on a subsequent call to translate(InputStream, OutputStream).
 void translate(InputStream in, OutputStream out)
          Copy an xml file, removing any xml tags matching those provided with addFilter(Tag) and adding any tags to provided with addNewTag(String, Tag).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTranslator

public SimpleTranslator()
Method Detail

translate

public void translate(InputStream in,
                      OutputStream out)
               throws XMLStreamException
Copy an xml file, removing any xml tags matching those provided with addFilter(Tag) and adding any tags to provided with addNewTag(String, Tag).

Parameters:
in - A stream to an xml file.
out - A stream to an empty file.
Throws:
XMLStreamException

addFilter

public void addFilter(SimpleTranslator.Tag tag)
Add a description of a tag to be filtered on a subsequent call to translate(InputStream, OutputStream). tagA filters out tagB if both tags have the same name (ignoring namespaces) and the set of attribute key-value pairs in tagB is a superset of those in tagA.

Parameters:
tag - The tag description to be filtered.

addNewTag

public void addNewTag(String parentName,
                      SimpleTranslator.Tag tag)
Add a description for a new tag to be added on a subsequent call to translate(InputStream, OutputStream). This tag will be added a child of any tag with given parent name (ignoring namespaces).

Parameters:
parentName - The name (ignoring namespaces) of a parent element, under which to insert a new tag.
tag - The new tag to be inserted.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.