Localiserpublic 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 void | characters(char[] ch, int start, int length)
if (null != textBuffer){
textBuffer.append(ch, start, length);
}
| public void | endElement(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 void | endLocation()
if (null != textBuffer && textBuffer.length() > 0){
try {
textBuffer.append(" ");
out.write(textBuffer.toString());
}
catch (IOException e){
throw new SAXException(e);
}
}
textBuffer = null;
| private void | endMessage()
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 void | endParam()
params.add(textBuffer.toString());
textBuffer = null;
| public void | startElement(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 void | startLocation()
textBuffer = new StringBuffer();
| private void | startMessage(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 void | startParam(org.xml.sax.Attributes attr)
textBuffer = new StringBuffer();
|
|