@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);
}
java类org.xml.sax.helpers.AttributeListImpl的实例源码
MongoDBDataSource.java 文件源码
项目:STEM
阅读 35
收藏 0
点赞 0
评论 0
ConfigWriter.java 文件源码
项目:STEM
阅读 45
收藏 0
点赞 0
评论 0
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");
}
ColumnarDataSource.java 文件源码
项目:STEM
阅读 50
收藏 0
点赞 0
评论 0
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");
}
}
ParserAdapterTest.java 文件源码
项目:In-the-Box-Fork
阅读 42
收藏 0
点赞 0
评论 0
@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));
}
ParserAdapterTest.java 文件源码
项目:In-the-Box-Fork
阅读 28
收藏 0
点赞 0
评论 0
@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());
}
MongoDBDataSource.java 文件源码
项目:Duke
阅读 46
收藏 0
点赞 0
评论 0
@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);
}
ConfigWriter.java 文件源码
项目:Duke
阅读 38
收藏 0
点赞 0
评论 0
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");
}
ColumnarDataSource.java 文件源码
项目:Duke
阅读 33
收藏 0
点赞 0
评论 0
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");
}
}
ConfigWriter.java 文件源码
项目:STEM
阅读 42
收藏 0
点赞 0
评论 0
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");
}
SAXParser.java 文件源码
项目:janala2-gradle
阅读 34
收藏 0
点赞 0
评论 0
/**
* 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());
}
AttributeListImplTest.java 文件源码
项目:In-the-Box-Fork
阅读 39
收藏 0
点赞 0
评论 0
@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());
}
}
HandlerBaseTest.java 文件源码
项目:In-the-Box-Fork
阅读 30
收藏 0
点赞 0
评论 0
@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);
}
}
RuntimeConfigurable.java 文件源码
项目:ant
阅读 35
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
ConfigWriter.java 文件源码
项目:Duke
阅读 39
收藏 0
点赞 0
评论 0
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");
}
ConfigWriter.java 文件源码
项目:STEM
阅读 36
收藏 0
点赞 0
评论 0
public void writeStartElement(String name, AttributeListImpl atts) {
pp.startElement(name, atts);
}
ConfigWriter.java 文件源码
项目:Duke
阅读 38
收藏 0
点赞 0
评论 0
public void writeStartElement(String name, AttributeListImpl atts) {
pp.startElement(name, atts);
}