Search in sources :

Example 1 with AttributesImpl

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());
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 2 with AttributesImpl

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);
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 3 with AttributesImpl

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");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 4 with AttributesImpl

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");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 5 with AttributesImpl

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");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Aggregations

AttributesImpl (org.xml.sax.helpers.AttributesImpl)493 SAXException (org.xml.sax.SAXException)67 Attributes (org.xml.sax.Attributes)50 Test (org.junit.Test)46 ContentHandler (org.xml.sax.ContentHandler)28 IOException (java.io.IOException)25 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)23 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)23 Map (java.util.Map)20 ResultSet (java.sql.ResultSet)19 PreparedStatement (java.sql.PreparedStatement)18 Test (org.junit.jupiter.api.Test)18 TransformerHandler (javax.xml.transform.sax.TransformerHandler)17 PackOut (org.adempiere.pipo.PackOut)16 StreamResult (javax.xml.transform.stream.StreamResult)15 SAXTransformerFactory (javax.xml.transform.sax.SAXTransformerFactory)14 File (java.io.File)12 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)12 SQLException (java.sql.SQLException)11 Iterator (java.util.Iterator)11