org.mmbase.util.transformers
Class Sql

java.lang.Object
  extended byorg.mmbase.util.transformers.ReaderTransformer
      extended byorg.mmbase.util.transformers.ConfigurableReaderTransformer
          extended byorg.mmbase.util.transformers.Sql
All Implemented Interfaces:
CharTransformer, ConfigurableTransformer, Transformer

public class Sql
extends ConfigurableReaderTransformer
implements CharTransformer

Encodings related to Sql. It can escape quotes, by replacing them by double quotes, as is needed in SQL statements.

Author:
Michiel Meeuwissen, Jaco de Groot

Field Summary
static int ESCAPE_QUOTES
           
 
Fields inherited from class org.mmbase.util.transformers.ConfigurableReaderTransformer
to
 
Constructor Summary
Sql()
           
Sql(int conf)
           
 
Method Summary
 java.lang.String getEncoding()
          Returns the encoding that is currently active
static java.io.Writer singleQuote(java.io.Reader r, java.io.Writer w)
          Escapes single quotes in a string.
static java.io.Writer singleQuoteBack(java.io.Reader r, java.io.Writer w)
          Unescapes single quotes in a string.
 java.io.Writer transform(java.io.Reader r, java.io.Writer w)
           
 java.io.Writer transformBack(java.io.Reader r, java.io.Writer w)
           
 java.util.Map transformers()
          Used when registering this class as a possible Transformer
 
Methods inherited from class org.mmbase.util.transformers.ConfigurableReaderTransformer
configure, toString
 
Methods inherited from class org.mmbase.util.transformers.ReaderTransformer
transform, transform, transformBack, transformBack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.util.transformers.CharTransformer
transform, transform, transformBack, transformBack
 
Methods inherited from interface org.mmbase.util.transformers.Transformer
toString
 

Field Detail

ESCAPE_QUOTES

public static final int ESCAPE_QUOTES
See Also:
Constant Field Values
Constructor Detail

Sql

public Sql()

Sql

public Sql(int conf)
Method Detail

singleQuote

public static java.io.Writer singleQuote(java.io.Reader r,
                                         java.io.Writer w)
Escapes single quotes in a string. Escaping is done by doubling any quotes encountered. Strings that are rendered in such way can more easily be included in a SQL query.

Returns:
the escaped string
Since:
MMBase-1.7

singleQuoteBack

public static java.io.Writer singleQuoteBack(java.io.Reader r,
                                             java.io.Writer w)
Unescapes single quotes in a string. Unescaping is done by replacing two quotes with one quote.

Returns:
the unescaped string
Since:
MMBase-1.7.2

transformers

public java.util.Map transformers()
Used when registering this class as a possible Transformer

Specified by:
transformers in interface ConfigurableTransformer
Specified by:
transformers in class ConfigurableReaderTransformer

transform

public java.io.Writer transform(java.io.Reader r,
                                java.io.Writer w)
Specified by:
transform in interface CharTransformer
Specified by:
transform in class ReaderTransformer

transformBack

public java.io.Writer transformBack(java.io.Reader r,
                                    java.io.Writer w)
Specified by:
transformBack in interface CharTransformer
Overrides:
transformBack in class ReaderTransformer

getEncoding

public java.lang.String getEncoding()
Description copied from interface: ConfigurableTransformer
Returns the encoding that is currently active

Specified by:
getEncoding in interface ConfigurableTransformer
Specified by:
getEncoding in class ConfigurableReaderTransformer


MMBase build 1.7.1.20041002