org.mmbase.util.transformers.ConfigurableStringTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mmbase-utils Show documentation
Show all versions of mmbase-utils Show documentation
<p>
MMBase Utils is a part of MMBase, but can also be used in
other projects. It contains several kind of utility
classes.</p>
<p>Highlights:</p>
<ul>
<li>An implementation of 'events'. Threads can use this to
communicate certain things. Using mmbase-clustering,
these events can also be sent to other servers.</li>
<li>A logging framework</li>
<li>A framework for string and byte array transformeration,
plus a whole lot of implemetentations for that.</li>
<li>Several java.util like classes (collections, dateparsing)</li>
<li>File type recognition ('magicfile')</li>
<li>The MMBase resourceloader, a generic fall-back mechanism
for configuration files and similar resources.</li>
<li>...</li>
</ul>
The newest version!
/*
This software is OSI Certified Open Source Software.
OSI Certified is a certification mark of the Open Source Initiative.
The license (Mozilla version 1.0) can be read at the MMBase site.
See http://www.MMBase.org/license
*/
package org.mmbase.util.transformers;
import java.util.Map;
/**
* Some Transformers implement more than one transformation. The instance can be configured.
*
* @author Michiel Meeuwissen
* @since MMBase-1.7
*/
public abstract class ConfigurableStringTransformer extends StringTransformer implements ConfigurableTransformer {
protected int to;
public ConfigurableStringTransformer() {
super();
}
public ConfigurableStringTransformer(int conf) {
super();
configure(conf);
}
@Override
public final void configure(int t) {
//log.info("Setting config to " + t);
to = t;
}
@Override
abstract public Map transformers();
@Override
abstract public String getEncoding();
@Override
public String toString() {
try {
return getEncoding();
} catch (Exception e) {
return "UNCONFIGURED " + super.toString();
}
}
}