Java 类org.xml.sax.helpers.AttributeListImpl 实例源码

项目:STEM    文件:MongoDBDataSource.java   
@Override
  public void writeConfig(ConfigWriter cw) {
      final String name = "data-source";
      String klass = getClass().getName();

      AttributeListImpl attribs = new AttributeListImpl();
      attribs.addAttribute("class", "CDATA", klass);
      cw.writeStartElement(name, attribs);

      cw.writeParam("server-address", getServerAddress());
      cw.writeParam("port-number", getPortNumber());
      cw.writeParam("user-name", getUserName());
      cw.writeParam("password", getPassword());
      cw.writeParam("db-auth", getDbAuth());
      cw.writeParam("database", getDatabase());
      cw.writeParam("cursor-notimeout", getCursorNotimeout());
      cw.writeParam("collection", getCollection());
      cw.writeParam("query", getQuery());
      cw.writeParam("projection", getProjection());

    cw.writeEndElement(name);
}
项目:STEM    文件:ConfigWriter.java   
private void writeProperty(Property prop) {
  AttributeListImpl atts = new AttributeListImpl();
  if (prop.isIdProperty())
    atts.addAttribute("type", "CDATA", "id");
  else if (prop.isIgnoreProperty())
    atts.addAttribute("type", "CDATA", "ignore");

  if (!prop.isIdProperty() &&
      prop.getLookupBehaviour() != Property.Lookup.DEFAULT) {
    String value = prop.getLookupBehaviour().toString().toLowerCase();
    atts.addAttribute("lookup", "CDATA", value);
  }

  pp.startElement("property", atts);
  writeElement("name", prop.getName());
  if (prop.getComparator() != null)
    writeElement("comparator", prop.getComparator().getClass().getName());
  if (prop.getLowProbability() != 0.0)
    writeElement("low", "" + prop.getLowProbability());
  if (prop.getHighProbability() != 0.0)
    writeElement("high", "" + prop.getHighProbability());
  pp.endElement("property");
}
项目:STEM    文件:ColumnarDataSource.java   
protected void writeColumnsConfig(ConfigWriter cw) {
  // FIXME: this breaks the order...
  for (Column col : getColumns()) {
    AttributeListImpl atts = new AttributeListImpl();
    atts.addAttribute("name", "CDATA", col.getName());
    atts.addAttribute("property", "CDATA", col.getProperty());
    if (col.getPrefix() != null)
      atts.addAttribute("prefix", "CDATA", col.getPrefix());
    // FIXME: cleaner really requires object support ... :-(
    if (col.getCleaner() != null)
      atts.addAttribute("cleaner", "CDATA", col.getCleaner().getClass().getName());
    if (col.isSplit())
      atts.addAttribute("split-on", "CDATA", col.getSplitOn());

    cw.writeStartElement("column", atts);
    cw.writeEndElement("column");
  }
}
项目:In-the-Box-Fork    文件:ParserAdapterTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "startElement",
    args = { String.class, AttributeList.class }
)
public void testStartElement() {
    AttributeListImpl atts = new AttributeListImpl();
    atts.addAttribute("john:doe", "int", "42");

    try {
        adapter.startDocument();
        adapter.startElement("foo:bar", atts);
    } catch (SAXException e) {
        throw new RuntimeException("Unexpected exception", e);
    }

    assertEquals("startElement", logger.getMethod());
    assertEquals("", logger.getArgs()[0]);
    assertEquals("", logger.getArgs()[1]);
    assertEquals("foo:bar", logger.getArgs()[2]);
    assertEquals("john:doe", ((Attributes)logger.getArgs()[3]).getQName(0));
}
项目:In-the-Box-Fork    文件:ParserAdapterTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "endElement",
    args = { String.class }
)
public void testEndElement() {
    AttributeListImpl atts = new AttributeListImpl();
    atts.addAttribute("john:doe", "int", "42");

    try {
        adapter.startDocument();
        adapter.startElement("foo:bar", atts);
        adapter.endElement("foo:bar");
    } catch (SAXException e) {
        throw new RuntimeException("Unexpected exception", e);
    }

    assertEquals("endElement", logger.getMethod());
    assertEquals(new String[] { "", "", "foo:bar" }, logger.getArgs());
}
项目:Duke    文件:MongoDBDataSource.java   
@Override
  public void writeConfig(ConfigWriter cw) {
      final String name = "data-source";
      String klass = getClass().getName();

      AttributeListImpl attribs = new AttributeListImpl();
      attribs.addAttribute("class", "CDATA", klass);
      cw.writeStartElement(name, attribs);

      cw.writeParam("server-address", getServerAddress());
      cw.writeParam("port-number", getPortNumber());
      cw.writeParam("user-name", getUserName());
      cw.writeParam("password", getPassword());
      cw.writeParam("db-auth", getDbAuth());
      cw.writeParam("database", getDatabase());
      cw.writeParam("cursor-notimeout", getCursorNotimeout());
      cw.writeParam("collection", getCollection());
      cw.writeParam("query", getQuery());
      cw.writeParam("projection", getProjection());

    cw.writeEndElement(name);
}
项目:Duke    文件:ConfigWriter.java   
private void writeProperty(Property prop) {
  AttributeListImpl atts = new AttributeListImpl();
  if (prop.isIdProperty())
    atts.addAttribute("type", "CDATA", "id");
  else if (prop.isIgnoreProperty())
    atts.addAttribute("type", "CDATA", "ignore");

  if (!prop.isIdProperty() &&
      prop.getLookupBehaviour() != Property.Lookup.DEFAULT) {
    String value = prop.getLookupBehaviour().toString().toLowerCase();
    atts.addAttribute("lookup", "CDATA", value);
  }

  pp.startElement("property", atts);
  writeElement("name", prop.getName());
  if (prop.getComparator() != null)
    writeElement("comparator", prop.getComparator().getClass().getName());
  if (prop.getLowProbability() != 0.0)
    writeElement("low", "" + prop.getLowProbability());
  if (prop.getHighProbability() != 0.0)
    writeElement("high", "" + prop.getHighProbability());
  pp.endElement("property");
}
项目:Duke    文件:ColumnarDataSource.java   
protected void writeColumnsConfig(ConfigWriter cw) {
  // FIXME: this breaks the order...
  for (Column col : getColumns()) {
    AttributeListImpl atts = new AttributeListImpl();
    atts.addAttribute("name", "CDATA", col.getName());
    atts.addAttribute("property", "CDATA", col.getProperty());
    if (col.getPrefix() != null)
      atts.addAttribute("prefix", "CDATA", col.getPrefix());
    // FIXME: cleaner really requires object support ... :-(
    if (col.getCleaner() != null)
      atts.addAttribute("cleaner", "CDATA", col.getCleaner().getClass().getName());
    if (col.isSplit())
      atts.addAttribute("split-on", "CDATA", col.getSplitOn());

    cw.writeStartElement("column", atts);
    cw.writeEndElement("column");
  }
}
项目:STEM    文件:ConfigWriter.java   
public void writeParam(String name, String value) {
  if (value == null)
    return;

  AttributeListImpl atts = new AttributeListImpl();
  atts.addAttribute("name", "CDATA", name);
  atts.addAttribute("value", "CDATA", value);
  pp.startElement("param", atts);
  pp.endElement("param");
}
项目:janala2-gradle    文件:SAXParser.java   
/**
 * Handles a subtree of the parsed XML data structure.
 *
 * @exception org.xml.sax.SAXException
 *     if one of the handlers throw such exception
 */
private void handleSubTree(XMLElement element,
                           SAXLocator locator)
   throws SAXException
{
   AttributeListImpl attrList = new AttributeListImpl();
   locator.setLineNr(element.getLineNr());
   Enumeration enum2 = element.enumeratePropertyNames();

   while (enum2.hasMoreElements())
      {
         String key = (String)(enum2.nextElement());
         String value = element.getProperty(key);
         attrList.addAttribute(key, "CDATA", value);
      }

   this.documentHandler.startElement(element.getTagName(), attrList);

   if (element.getContents() == null)
      {
         enum2 = element.enumerateChildren();

         while (enum2.hasMoreElements())
            {
               this.handleSubTree((XMLElement)(enum2.nextElement()),
                                  locator);
            }
      }
   else
      {
         char[] chars = element.getContents().toCharArray();
         this.documentHandler.characters(chars, 0, chars.length);
      }

   locator.setLineNr(-1);
   this.documentHandler.endElement(element.getTagName());
}
项目:In-the-Box-Fork    文件:AttributeListImplTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "setAttributeList",
    args = { AttributeList.class }
)
public void testSetAttributeList() {
    // Ordinary cases
    AttributeListImpl attrs = new AttributeListImpl();
    attrs.addAttribute("doe", "boolean", "false");

    attrs.setAttributeList(empty);
    assertEquals(0, attrs.getLength());

    attrs.setAttributeList(multi);
    assertEquals(multi.getLength(), attrs.getLength());

    for (int i = 0; i < multi.getLength(); i++) {
        assertEquals(multi.getName(i), attrs.getName(i));
        assertEquals(multi.getType(i), attrs.getType(i));
        assertEquals(multi.getValue(i), attrs.getValue(i));
    }

    // null case
    try {
        attrs.setAttributeList(null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
        // Expected, must still have old elements
        assertEquals(3, attrs.getLength());
    }
}
项目:In-the-Box-Fork    文件:HandlerBaseTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "startElement",
    args = { String.class, AttributeList.class }
)
public void testStartElement() {
    try {
        h.startElement("name", new AttributeListImpl());
    } catch (SAXException e) {
        throw new RuntimeException(e);
    }
}
项目:ant    文件:RuntimeConfigurable.java   
/**
 * Sets the attributes for the wrapped element.
 *
 * @param attributes List of attributes defined in the XML for this
 *                   element. May be <code>null</code>.
 * @deprecated since 1.6.x.
 */
@Deprecated
public synchronized void setAttributes(AttributeList attributes) {
    this.attributes = new AttributeListImpl(attributes);
    for (int i = 0; i < attributes.getLength(); i++) {
        setAttribute(attributes.getName(i), attributes.getValue(i));
    }
}
项目:Duke    文件:ConfigWriter.java   
public void writeParam(String name, String value) {
  if (value == null)
    return;

  AttributeListImpl atts = new AttributeListImpl();
  atts.addAttribute("name", "CDATA", name);
  atts.addAttribute("value", "CDATA", value);
  pp.startElement("param", atts);
  pp.endElement("param");
}
项目:STEM    文件:ConfigWriter.java   
public void writeStartElement(String name, AttributeListImpl atts) {
  pp.startElement(name, atts);
}
项目:Duke    文件:ConfigWriter.java   
public void writeStartElement(String name, AttributeListImpl atts) {
  pp.startElement(name, atts);
}