/** * Builds an {@link Attributes} from a {@link Map} * * @param attributes the attributes to wrap * @return the wrapped attributes */ protected static Attributes buildAttributes(final Map attributes) { final AttributesImpl attr = new AttributesImpl(); for (Object o : attributes.entrySet()) { final Map.Entry entry = (Map.Entry) o; final String attributeName = (String) entry.getKey(); final String attributeValue = String.valueOf(entry.getValue()); attr.addAttribute(null, attributeName, attributeName, "CDATA", attributeValue); } return attr; }
/** * Generates XML for a locator */ private void generateLocator(DistributionLocatorConfig config) throws SAXException { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", PORT, "", String.valueOf(config.getPort())); handler.startElement("", LOCATOR, LOCATOR, atts); generateEntityConfig(config); handler.endElement("", LOCATOR, LOCATOR); }
inDocHandler.startElement("", "classes", "classes", new AttributesImpl()); inDocHandler.endElement("", "classes", "classes"); inDocHandler.endDocument();
new org.xml.sax.helpers.AttributesImpl(); i = dtm.getNextAttribute(i)) attrs.addAttribute(dtm.getNamespaceURI(i), dtm.getLocalName(i), dtm.getNodeName(i), this.m_contentHandler.startElement(ns, m_dtm.getLocalName(node), m_dtm.getNodeName(node),
/** * Generate XML for FixedPartitionAttribute element in PartitionedRegion Attributes */ private void generateFixedPartitionAttributes(String kind, List<FixedPartitionAttributes> allStaticAttrs) throws SAXException { for (FixedPartitionAttributes attr : allStaticAttrs) { AttributesImpl sAtts = new AttributesImpl(); sAtts.addAttribute("", "", PARTITION_NAME, "", attr.getPartitionName()); sAtts.addAttribute("", "", IS_PRIMARY, "", String.valueOf(attr.isPrimary())); sAtts.addAttribute("", "", NUM_BUCKETS, "", String.valueOf(attr.getNumBuckets())); handler.startElement("", kind, kind, sAtts); handler.endElement("", kind, kind); } }
@Override public final void visitIincInsn(final int var, final int increment) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "var", "var", "", Integer.toString(var)); attrs.addAttribute("", "inc", "inc", "", Integer.toString(increment)); sa.addElement(Printer.OPCODES[Opcodes.IINC], attrs); }
/** * 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); }
new org.xml.sax.helpers.AttributesImpl(); i = dtm.getNextAttribute(i)) attrs.addAttribute(dtm.getNamespaceURI(i), dtm.getLocalName(i), dtm.getNodeName(i), this.m_contentHandler.startElement(ns, m_dtm.getLocalName(node), m_dtm.getNodeName(node),
private void generate(final Properties props, String elementName) throws SAXException { if (props == null || props.isEmpty()) { return; } if (elementName != null) { handler.startElement("", elementName, elementName, EMPTY); } for (Iterator iter = props.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", NAME, "", name); handler.startElement("", PARAMETER, PARAMETER, atts); if (value instanceof String) { generate((String) value); } else if (value instanceof Declarable) { generate((Declarable) value); } else { // Ignore it } handler.endElement("", PARAMETER, PARAMETER); } if (elementName != null) { handler.endElement("", elementName, elementName); } }
@Override public void visitPackage(String packaze) { AttributesImpl att = new AttributesImpl(); att.addAttribute("", "name", "name", "", packaze); sa.addElement("packages", att); }
/** * 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()); } }
/** * Start the schema fragment for a feature type. * * @param name * @param namespace DOCUMENT ME! * @throws SAXException */ protected final void startSchemaType(String name, String namespace) throws SAXException { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "name", "name", "", name + "_Type"); contentHandler.startElement(SCHEMA_NS, "complexType", "xs:complexType", atts); contentHandler.startElement( SCHEMA_NS, "complexContent", "xs:complexContent", new AttributesImpl()); atts = new AttributesImpl(); atts.addAttribute("", "base", "base", "", "gml:AbstractFeatureType"); contentHandler.startElement(SCHEMA_NS, "extension", "xs:extension", atts); contentHandler.startElement(SCHEMA_NS, "sequence", "xs:sequence", new AttributesImpl()); }
/** * Generates the <code>serializer-registration</code> element. * */ private void generateSerializerRegistration() throws SAXException { final SerializerCreation sc = this.creation.getSerializerCreation(); if (sc == null) { return; } handler.startElement("", TOP_SERIALIZER_REGISTRATION, TOP_SERIALIZER_REGISTRATION, EMPTY); for (Class c : sc.getSerializerRegistrations()) { handler.startElement("", SERIALIZER_REGISTRATION, SERIALIZER_REGISTRATION, EMPTY); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(c.getName().toCharArray(), 0, c.getName().length()); handler.endElement("", CLASS_NAME, CLASS_NAME); handler.endElement("", SERIALIZER_REGISTRATION, SERIALIZER_REGISTRATION); } for (Map.Entry<Class, Integer> e : sc.getInstantiatorRegistrations().entrySet()) { Class c = e.getKey(); Integer i = e.getValue(); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", ID, "", i.toString()); handler.startElement("", INSTANTIATOR_REGISTRATION, INSTANTIATOR_REGISTRATION, atts); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(c.getName().toCharArray(), 0, c.getName().length()); handler.endElement("", CLASS_NAME, CLASS_NAME); handler.endElement("", INSTANTIATOR_REGISTRATION, INSTANTIATOR_REGISTRATION); } handler.endElement("", TOP_SERIALIZER_REGISTRATION, TOP_SERIALIZER_REGISTRATION); }
@Override public void visitOuterClass(final String owner, final String name, final String desc) { AttributesImpl att = new AttributesImpl(); att.addAttribute("", "owner", "owner", "", owner); if (name != null) { att.addAttribute("", "name", "name", "", name); } if (desc != null) { att.addAttribute("", "desc", "desc", "", desc); } sa.addElement("outerclass", att); }
public void outputToXml(ContentHandler contentHandler) throws SAXException { contentHandler.startElement("", "", "RECORD", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "OPCODE", opCode.toString()); contentHandler.startElement("", "", "DATA", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "TXID", "" + txid); toXml(contentHandler); contentHandler.endElement("", "", "DATA"); contentHandler.endElement("", "", "RECORD"); }
public void startFeatureCollection() { try { String element = (getDefaultPrefix() == null) ? fc : (getDefaultPrefix() + ":" + fc); AttributesImpl atts = new AttributesImpl(); if (lockId != null) { atts.addAttribute("", "lockId", "lockId", "", lockId); } contentHandler.startElement("", "", element, atts); } catch (SAXException se) { throw new RuntimeException(se); } }
public static void addDeclarable(final ContentHandler handler, Declarable declarable) throws SAXException { AttributesImpl EMPTY = new AttributesImpl(); handler.startElement("", CLASS_NAME, CLASS_NAME, EMPTY); handler.characters(className.toCharArray(), 0, className.length()); handler.endElement("", CLASS_NAME, CLASS_NAME); Object value = entry.getValue(); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", NAME, "", name); handler.startElement("", PARAMETER, PARAMETER, atts); handler.startElement("", STRING, STRING, EMPTY); handler.characters(sValue.toCharArray(), 0, sValue.length()); handler.endElement("", STRING, STRING); handler.startElement("", DECLARABLE, DECLARABLE, EMPTY); addDeclarable(handler, (Declarable) value); handler.endElement("", DECLARABLE, DECLARABLE);
@Override public final void visitVarInsn(final int opcode, final int var) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "var", "var", "", Integer.toString(var)); sa.addElement(Printer.OPCODES[opcode], attrs); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "TRG", trg); XMLUtils.addSaxString(contentHandler, "TIMESTAMP", Long.toString(timestamp)); contentHandler.startElement("", "", "SOURCES", new AttributesImpl()); for (int i = 0; i < srcs.length; ++i) { XMLUtils.addSaxString(contentHandler, "SOURCE" + (i + 1), srcs[i]); } contentHandler.endElement("", "", "SOURCES"); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { localName = localName.toLowerCase(Locale.US); if (MS_SPREADSHEET_URN.equals(uri)) { if (BODY.equals(localName)) { inBody = true; } else if (TABLE.equals(localName)) { handler.startElement(XHTMLContentHandler.XHTML, TABLE, TABLE, EMPTY_ATTRS); handler.startElement(XHTMLContentHandler.XHTML, TBODY, TBODY, EMPTY_ATTRS); } else if (WORKSHEET.equals(localName)) { String worksheetName = attrs.getValue(MS_SPREADSHEET_URN, "Name"); AttributesImpl xhtmlAttrs = new AttributesImpl(); if (worksheetName != null) { xhtmlAttrs.addAttribute(XHTMLContentHandler.XHTML, NAME_ATTR, NAME_ATTR, CDATA, worksheetName); } handler.startElement(XHTMLContentHandler.XHTML, DIV, DIV, xhtmlAttrs); } else if (ROW.equals(localName)) { handler.startElement(XHTMLContentHandler.XHTML, TR, TR, EMPTY_ATTRS); } else if (CELL.equals(localName)) { href = attrs.getValue(MS_SPREADSHEET_URN, "HRef"); handler.startElement(XHTMLContentHandler.XHTML, TD, TD, EMPTY_ATTRS); } else if (DATA.equals(localName)) { inData = true; } } }