Java Reference
In-Depth Information
}
return absolute(-1);
}
// first look for an attribute matching the columnName,
// then look for a child element
public String getString(String columnName)throws SQLException{
if(currentRow==null)
throw(new SQLException("Invalid row: "+currentRow));
String value = currentRow.getAttribute(columnName);
if(value.length()>0){
return value;
}else{
NodeList cols = currentRow.getElementsByTagName(columnName);
if(cols.getLength()>0){
Node column = cols.item(0);
NodeList children = column.getChildNodes();
for(int i=0;i<children.getLength();i++){
if(children.item(i).getNodeType()==Node.TEXT_NODE){
return (String)children.item(i).getNodeValue();
}
}
}
}
return null;
}
public ResultSetMetaData getMetaData() throws SQLException {
return new XMLResultSetMetaData(this);
}
// utility method for serializing the result set document
public void serializeAsFile(String fileName){
try {
OutputFormat fmt = new OutputFormat("xml",null,true);
XMLSerializer serializer =
new XMLSerializer(new FileWriter(fileName),fmt);
serializer.asDOMSerializer().serialize(xmlDoc);
}
catch (Exception e){
e.printStackTrace();
}
}
Search WWH ::




Custom Search