FileDocCategorySizeDatePackage
Localiser.javaAPI DocGlassfish v2 API5936Fri May 04 22:24:36 BST 2007com.sun.enterprise.config.serverbeans.validation

Localiser

public class Localiser extends DefaultHandler

Fields Summary
private final com.sun.enterprise.util.LocalStringManager
lsm
private final Writer
out
private final Logger
logger
private final String
prefix
private String
message_id
private ArrayList
params
private StringBuffer
textBuffer
Constructors Summary
Localiser(com.sun.enterprise.util.LocalStringManager lsm, Writer out, String prefix)

        this(lsm, out, null, prefix);
    
Localiser(com.sun.enterprise.util.LocalStringManager lsm, Writer out, Logger logger)

        this(lsm, out, logger, null);
    
Localiser(com.sun.enterprise.util.LocalStringManager lsm, Writer out)

        this(lsm, out, null, null);
    
Localiser(com.sun.enterprise.util.LocalStringManager lsm, Writer out, Logger logger, String prefix)

        this.lsm = lsm;
        this.out = out;
        this.logger = logger;
        this.prefix = (prefix == null ? "" : prefix +".");
    
Methods Summary
public voidcharacters(char[] ch, int start, int length)

        if (null != textBuffer){
            textBuffer.append(ch, start, length);
        }
    
public voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)

        if (localName.equals("location")){
            endLocation();
        } else if (localName.equals("message")){
            endMessage();
        } else if (localName.equals("param")) {
            endParam();
        }
    
private voidendLocation()

        if (null != textBuffer && textBuffer.length() > 0){
            try {
                textBuffer.append(" ");
                out.write(textBuffer.toString());
            }
            catch (IOException e){
                throw new SAXException(e);
            }
        }
        textBuffer = null;
    
private voidendMessage()

        final String msg = lsm.getLocalString(null, message_id,
                           "Internal Error, message id  \""+message_id+ "\" not present in localisation file",
                           params.toArray());
        message_id = null;
        
        if (null != logger && msg.startsWith("Internal Error")){
            logger.severe(msg);
            return;
        }
        
        try {
            out.write(msg+"\n");
            out.flush();
        }
        catch (IOException e){
            throw new SAXException(e);
        }
        
            
    
private voidendParam()

        params.add(textBuffer.toString());
        textBuffer = null;
    
public voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)

        if (localName.equals("location")){
            startLocation();
        } else if (localName.equals("message")){
            startMessage(atts);
        } else if (localName.equals("param")) {
            startParam(atts);
        }
    
private voidstartLocation()


      
        textBuffer = new StringBuffer();
    
private voidstartMessage(org.xml.sax.Attributes attr)

        params.clear();
        final String id = attr.getValue("", "id");
        if (null == id || id.length() == 0){
            throw new SAXException("id attribute is either null or empty");
        }
        message_id = prefix + id;
    
private voidstartParam(org.xml.sax.Attributes attr)

        textBuffer = new StringBuffer();