/**
* Copyright 2011 meltmedia
*
* 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.
*/
package org.xchain.framework.util;
import java.util.Iterator;
import java.util.Map;
/**
* A container class for parsed transformer processing instructions. This is generated by ParserUtil.parseTransformer(String).
*
* @author Christian Trimble
* @author Devon Tackett
*
* @see ParserUtil#parseTransformer(String)
*/
public class ParsedTransformer
{
private Map<String, String> attributes = null;
private Map<String, String> parameters = null;
private Map<String, String> outputProperties = null;
/**
* Set the attribute map.
* @param attributes A mapping of attribute names to attribute values.
*/
public void setAttributes( Map<String, String> attributes ) { this.attributes = attributes; }
/**
* @return A mapping of attribute names to attribute values.
*/
public Map<String, String> getAttributes() { return this.attributes; }
/**
* Set the parameter map.
* @param parameters A mapping of parameter names to parameter values.
*/
public void setParameters( Map<String, String> parameters ) { this.parameters = parameters; }
/**
* @return A mapping of parameter names to parameter values.
*/
public Map<String, String> getParameters() { return this.parameters; }
/**
* Set the output properties map.
* @param outputProperties A mapping of output property names to output property values.
*/
public void setOutputProperties( Map<String, String> outputProperties ) { this.outputProperties = outputProperties; }
/**
* @return A mapping of output property names to output property values.
*/
public Map<String, String> getOutputProperties() { return this.outputProperties; }
public String toString()
{
StringBuilder builder = new StringBuilder();
appendMap(builder, attributes);
if( parameters.keySet().size() > 0 ) {
builder.append(" parameters ");
appendMap(builder, parameters);
}
if( outputProperties.keySet().size() > 0 ) {
builder.append(" output properties ");
appendMap(builder, outputProperties);
}
return builder.toString();
}
private void appendMap( StringBuilder builder, Map<String, String> map )
{
Iterator<Map.Entry<String, String>> entryIterator = map.entrySet().iterator();
while( entryIterator.hasNext() ) {
Map.Entry<String, String> entry = entryIterator.next();
builder.append(entry.getKey()).append(" ").append(entry.getValue());
if( entryIterator.hasNext() ) {
builder.append(" ");
}
}
}
}