dsql.value
Class XmlDataValue

java.lang.Object
  extended bydsql.DMExecuted
      extended bydsql.value.Value
          extended bydsql.value.NonScalarValue
              extended bydsql.value.XmlDataValue
All Implemented Interfaces:
DataValue, DotAt
Direct Known Subclasses:
XmlRecordHolder

public class XmlDataValue
extends NonScalarValue
implements DotAt, DataValue

Access to XML structures. External files are read progressively and "on demand", i.e. whenever a "column" is requested the file is read until a matching element is found.


Field Summary
protected  ASTXMLElement buffer
          A buffer to some or all XML elements
protected  ASTXMLElement dataEle
          The original <data> element.
protected  boolean external
          true if data is read from an external file
protected  java.lang.String fileName
          the external file name, or "inline"
protected  Parser parser
          the parser for external file
protected  boolean readColumnFromFile
          If true, read and parse more columns from external file.
protected  XmlRecordHolder recordHolder
          keeps track of record holders, so that we don't reparse documents if user writes $x[0], $x[1]
 
Constructor Summary
XmlDataValue()
          constructor invoked by ASTValue
XmlDataValue(ASTXMLElement _ele)
           
 
Method Summary
protected  boolean allowDSQL()
           
 boolean equals(java.lang.Object obj)
           
 boolean getBoolean()
           
 java.lang.Object getColumn(int col)
           
 java.lang.Object getColumn(java.lang.String name)
           
 int getColumnCount()
           
protected  int getColumnIndex(int col)
           
 java.lang.String getColumnLabel(int col)
           
 java.lang.String getColumnString(int col)
           
 java.lang.String getColumnString(java.lang.String name)
           
 java.lang.Object getField(int i)
          Access an element
 java.lang.Object getField(java.lang.String name)
          Access an element
 ConstructedResults getMeta()
           
 RecordHolder getRecordHolder()
          XmlDataValue uses this to provide an iterator for XML documents
 java.lang.String getString()
           
protected  ASTXMLElement getXmlData()
           
 ASTXMLElement getXmlData(boolean full)
           
protected  void initParser()
          Initialise parser and loads document header
protected  ASTXMLElement parseNext()
          Parse next element.
protected  ASTXMLElement parseNextColumn()
          Parse next column and add it to buffer
 void print(ASTPrint printer)
          Print this value using printer
 void setContents(ASTXMLElement ele)
          Inline
 void setContents(java.lang.String _fileName, ASTXMLElement ele)
          This method sets up but do not open the file for parsing.
 java.lang.Object setField(int i, Value val)
           
 
Methods inherited from class dsql.value.NonScalarValue
getFields, isScalar, setField
 
Methods inherited from class dsql.value.Value
getFloat, getInt, getObject, getObjectClass, getType, getValue, getValue
 
Methods inherited from class dsql.DMExecuted
getCaller, setCaller
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataEle

protected ASTXMLElement dataEle
The original <data> element.


buffer

protected ASTXMLElement buffer
A buffer to some or all XML elements


readColumnFromFile

protected boolean readColumnFromFile
If true, read and parse more columns from external file. If false, the whole structure must be in buffer.


parser

protected Parser parser
the parser for external file


fileName

protected java.lang.String fileName
the external file name, or "inline"


external

protected boolean external
true if data is read from an external file


recordHolder

protected XmlRecordHolder recordHolder
keeps track of record holders, so that we don't reparse documents if user writes $x[0], $x[1]

Constructor Detail

XmlDataValue

public XmlDataValue()
constructor invoked by ASTValue


XmlDataValue

public XmlDataValue(ASTXMLElement _ele)
             throws ExecuteException
Method Detail

getRecordHolder

public RecordHolder getRecordHolder()
                             throws ExecuteException
Description copied from class: Value
XmlDataValue uses this to provide an iterator for XML documents

Overrides:
getRecordHolder in class Value
Throws:
ExecuteException

parseNext

protected ASTXMLElement parseNext()
                           throws ExecuteException
Parse next element.

Returns:
the element read, null otherwise
Throws:
ExecuteException

parseNextColumn

protected ASTXMLElement parseNextColumn()
                                 throws ExecuteException
Parse next column and add it to buffer

Throws:
ExecuteException

initParser

protected void initParser()
                   throws ExecuteException
Initialise parser and loads document header

Throws:
ExecuteException

getXmlData

protected ASTXMLElement getXmlData()
                            throws ExecuteException
Throws:
ExecuteException

getXmlData

public ASTXMLElement getXmlData(boolean full)
                         throws ExecuteException
Throws:
ExecuteException

equals

public boolean equals(java.lang.Object obj)

allowDSQL

protected boolean allowDSQL()
Returns:
true if DSQL scripts and variables are allowed inside this XML; usually true for inline and false for external

setContents

public void setContents(ASTXMLElement ele)
                 throws ExecuteException
Inline

Specified by:
setContents in interface DataValue
Throws:
ExecuteException

setContents

public void setContents(java.lang.String _fileName,
                        ASTXMLElement ele)
                 throws ExecuteException
This method sets up but do not open the file for parsing. This is delayed until the first real access

Specified by:
setContents in interface DataValue
Throws:
ExecuteException

getMeta

public ConstructedResults getMeta()
                           throws ExecuteException
Specified by:
getMeta in class Value
Returns:
meta-information about this Value, e.g. for a table, it returns the names,types,width,etc. of its columns.
Throws:
ExecuteException

getBoolean

public boolean getBoolean()
                   throws ExecuteException
Specified by:
getBoolean in class Value
Returns:
true if this Value is "non-zero", e.g. non-empty string, tables has some record, etc.
Throws:
ExecuteException

getString

public java.lang.String getString()
                           throws ExecuteException
Specified by:
getString in class Value
Returns:
a string representation of this value, to be used within dsql expressions. This is distinct from toString(), which is used to output the object for debugging purposes.
Throws:
ExecuteException

print

public void print(ASTPrint printer)
           throws ExecuteException
Description copied from class: Value
Print this value using printer

Specified by:
print in class Value
Throws:
ExecuteException

getField

public java.lang.Object getField(java.lang.String name)
                          throws ExecuteException
Access an element

Overrides:
getField in class NonScalarValue
Throws:
ExecuteException

getField

public java.lang.Object getField(int i)
                          throws ExecuteException
Access an element

Specified by:
getField in interface DotAt
Throws:
ExecuteException

setField

public java.lang.Object setField(int i,
                                 Value val)
                          throws ExecuteException
Specified by:
setField in interface DotAt
Throws:
ExecuteException

getColumnLabel

public java.lang.String getColumnLabel(int col)
                                throws ExecuteException
Throws:
ExecuteException

getColumnCount

public int getColumnCount()
                   throws ExecuteException
Throws:
ExecuteException

getColumn

public java.lang.Object getColumn(int col)
                           throws ExecuteException
Throws:
ExecuteException

getColumnString

public java.lang.String getColumnString(int col)
                                 throws ExecuteException
Throws:
ExecuteException

getColumn

public java.lang.Object getColumn(java.lang.String name)
                           throws ExecuteException
Throws:
ExecuteException

getColumnString

public java.lang.String getColumnString(java.lang.String name)
                                 throws ExecuteException
Throws:
ExecuteException

getColumnIndex

protected int getColumnIndex(int col)
                      throws ExecuteException
Throws:
ExecuteException