Search in sources :

Example 6 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project groovy by apache.

the class SAXBuilder method createNode.

protected Object createNode(Object name, Map attributeMap, Object text) {
    AttributesImpl attributes = new AttributesImpl();
    for (Iterator iter = attributeMap.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry entry = (Map.Entry) iter.next();
        Object key = entry.getKey();
        Object value = entry.getValue();
        String uri = "";
        String localName = null;
        String qualifiedName = "";
        String valueText = (value != null) ? value.toString() : "";
        if (key instanceof QName) {
            QName qname = (QName) key;
            uri = qname.getNamespaceURI();
            localName = qname.getLocalPart();
            qualifiedName = qname.getQualifiedName();
        } else {
            localName = key.toString();
            qualifiedName = localName;
        }
        attributes.addAttribute(uri, localName, qualifiedName, "CDATA", valueText);
    }
    doStartElement(name, attributes);
    if (text != null) {
        doText(text);
    }
    return name;
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) Iterator(java.util.Iterator) Map(java.util.Map)

Example 7 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 8 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 9 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 10 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)

Aggregations

AttributesImpl (org.xml.sax.helpers.AttributesImpl)310 SAXException (org.xml.sax.SAXException)53 Test (org.junit.Test)34 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)23 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)23 ContentHandler (org.xml.sax.ContentHandler)21 Attributes (org.xml.sax.Attributes)17 PreparedStatement (java.sql.PreparedStatement)16 ResultSet (java.sql.ResultSet)16 Map (java.util.Map)16 PackOut (org.adempiere.pipo.PackOut)16 IOException (java.io.IOException)15 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)12 Iterator (java.util.Iterator)11 TransformerHandler (javax.xml.transform.sax.TransformerHandler)11 StreamResult (javax.xml.transform.stream.StreamResult)11 Metadata (org.apache.tika.metadata.Metadata)11 File (java.io.File)9 SAXTransformerFactory (javax.xml.transform.sax.SAXTransformerFactory)9 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)9