use of org.xml.sax.helpers.AttributesImpl in project hadoop by apache.
the class XmlEditsVisitor method start.
/**
* Start visitor (initialization)
*/
@Override
public void start(int version) throws IOException {
try {
contentHandler.startElement("", "", "EDITS_VERSION", new AttributesImpl());
StringBuilder bld = new StringBuilder();
bld.append(version);
addString(bld.toString());
contentHandler.endElement("", "", "EDITS_VERSION");
} catch (SAXException e) {
throw new IOException("SAX error: " + e.getMessage());
}
}
use of org.xml.sax.helpers.AttributesImpl in project hadoop by apache.
the class XMLUtils method addSaxString.
/**
* Add a SAX tag with a string inside.
*
* @param contentHandler the SAX content handler
* @param tag the element tag to use
* @param val the string to put inside the tag
*/
public static void addSaxString(ContentHandler contentHandler, String tag, String val) throws SAXException {
contentHandler.startElement("", "", tag, new AttributesImpl());
char[] c = mangleXmlString(val, false).toCharArray();
contentHandler.characters(c, 0, c.length);
contentHandler.endElement("", "", tag);
}
use of org.xml.sax.helpers.AttributesImpl in project hadoop by apache.
the class FSEditLogOp method permissionStatusToXml.
public static void permissionStatusToXml(ContentHandler contentHandler, PermissionStatus perm) throws SAXException {
contentHandler.startElement("", "", "PERMISSION_STATUS", new AttributesImpl());
XMLUtils.addSaxString(contentHandler, "USERNAME", perm.getUserName());
XMLUtils.addSaxString(contentHandler, "GROUPNAME", perm.getGroupName());
fsPermissionToXml(contentHandler, perm.getPermission());
contentHandler.endElement("", "", "PERMISSION_STATUS");
}
use of org.xml.sax.helpers.AttributesImpl in project hadoop by apache.
the class FSEditLogOp method delegationKeyToXml.
public static void delegationKeyToXml(ContentHandler contentHandler, DelegationKey key) throws SAXException {
contentHandler.startElement("", "", "DELEGATION_KEY", new AttributesImpl());
XMLUtils.addSaxString(contentHandler, "KEY_ID", Integer.toString(key.getKeyId()));
XMLUtils.addSaxString(contentHandler, "EXPIRY_DATE", Long.toString(key.getExpiryDate()));
if (key.getEncodedKey() != null) {
XMLUtils.addSaxString(contentHandler, "KEY", Hex.encodeHexString(key.getEncodedKey()));
}
contentHandler.endElement("", "", "DELEGATION_KEY");
}
use of org.xml.sax.helpers.AttributesImpl in project hadoop by apache.
the class FSEditLogOp method blockToXml.
public static void blockToXml(ContentHandler contentHandler, Block block) throws SAXException {
contentHandler.startElement("", "", "BLOCK", new AttributesImpl());
XMLUtils.addSaxString(contentHandler, "BLOCK_ID", Long.toString(block.getBlockId()));
XMLUtils.addSaxString(contentHandler, "NUM_BYTES", Long.toString(block.getNumBytes()));
XMLUtils.addSaxString(contentHandler, "GENSTAMP", Long.toString(block.getGenerationStamp()));
contentHandler.endElement("", "", "BLOCK");
}
Aggregations