本文发表在 rolia.net 枫下论坛/**
* This file is generated by BorlandXML.
*/
package tmp;
import java.util.*;
/**
* The Ruleset class represents the element "ruleset" with the content
* model defined as follows:
* <p>
* <!ELEMENT ruleset (rule*,prcondition*)><br>
*/
public class Ruleset extends com.borland.xml.toolkit.XmlObject
{
/** element-type name of this element. */
public static String _tagName = "ruleset";
/** Defines a list of Rule objects. */
protected ArrayList _objRule = new ArrayList();
/** Defines a list of Prcondition objects. */
protected ArrayList _objPrcondition = new ArrayList();
/** Public identifier. */
protected String publicId = "";
/** System identifier. */
protected String systemId = "";
/** Outputter object to control the format of XML output. */
protected com.borland.xml.toolkit.Outputter _outputter = null;
/**
* Creates an empty Ruleset object
*/
public Ruleset()
{
super();
}
/**
* Returns an array of Rule objects. The length of the returned
* array is zero if the list of Rule object is empty.
*/
public Rule[] getRule()
{
return (Rule[])_objRule.toArray(new Rule[0]);
}
/**
* Replaces all existing Rule objects with a new array of
* Rule objects.
* @param objArray an array of Rule objects.
*/
public void setRule(Rule[] objArray)
{
if( objArray == null || objArray.length == 0 )
this._objRule.clear();
else
{
this._objRule = new ArrayList(Arrays.asList(objArray));
for( int i=0; i<objArray.length; i++ )
{
if( objArray[i] != null )
objArray[i]._setParent(this);
}
}
}
/**
* Gets the Rule object at the specified index.
* @param index index of the returned object.
* @throws IndexOutOfBoundsException if index is out of range.
*/
public Rule getRule(int index)
{
return (Rule)_objRule.get(index);
}
/**
* Replaces an existing Rule object at the specified index with
* a new Rule object.
* @param index index of replaced object.
* @throws IndexOutOfBoundsException if index is out of range.
*/
public void setRule(int index, Rule obj)
{
if( obj == null )
removeRule(index);
else
{
_objRule.set(index, obj);
obj._setParent(this);
}
}
/**
* Returns the number of Rule objects in the list.
*/
public int getRuleCount()
{
return _objRule.size();
}
/**
* Returns <code>true</code> if there is no Rule object in the list; otherwise,
* the method returns <code>false</code>.
*/
public boolean isNoRule()
{
return _objRule.size() == 0;
}
/**
* Returns a read-only list of Rule objects.
*/
public List getRuleList()
{
return Collections.unmodifiableList(_objRule);
}
/**
* Adds a new Rule object at the end of the list.
* @return <code>true</code> if the new object is added to the list; otherwise,
* the method returns <code>false</code>.
*/
public boolean addRule(Rule obj)
{
if( obj==null )
return false;
obj._setParent(this);
return _objRule.add(obj);
}
/**
* Adds a list of new Rule objects at the end of the list.
* @return <code>true</code> if the list was changed; otherwise, the method
* returns <code>false</code>.
*/
public boolean addRule(Collection coRule)
{
if( coRule==null )
return false;
java.util.Iterator it = coRule.iterator();
while( it.hasNext() )
{
Object obj = it.next();
if( obj != null && obj instanceof com.borland.xml.toolkit.XmlObject )
((com.borland.xml.toolkit.XmlObject)obj)._setParent(this);
}
return _objRule.addAll(coRule);
}
/**
* Removes an existing Rule object at the specified index.
* @return The removed object.
*/
public Rule removeRule(int index)
{
return (Rule)_objRule.remove(index);
}
/**
* Removes the specified Rule object.
* @return <code>true</code> if this list contains the object; otherwise,
* the method returns <code>false</code>.
*/
public boolean removeRule(Rule obj)
{
return _objRule.remove(obj);
}
/**
* Clears all Rule objects from the list.
*/
public void clearRuleList()
{
_objRule.clear();
}
/**
* Returns an array of Prcondition objects. The length of the returned
* array is zero if the list of Prcondition object is empty.
*/
public Prcondition[] getPrcondition()
{
return (Prcondition[])_objPrcondition.toArray(new Prcondition[0]);
}
/**
* Replaces all existing Prcondition objects with a new array of
* Prcondition objects.
* @param objArray an array of Prcondition objects.
*/
public void setPrcondition(Prcondition[] objArray)
{
if( objArray == null || objArray.length == 0 )
this._objPrcondition.clear();
else
{
this._objPrcondition = new ArrayList(Arrays.asList(objArray));
for( int i=0; i<objArray.length; i++ )
{
if( objArray[i] != null )
objArray[i]._setParent(this);
}
}
}
/**
* Gets the Prcondition object at the specified index.
* @param index index of the returned object.
* @throws IndexOutOfBoundsException if index is out of range.
*/
public Prcondition getPrcondition(int index)
{
return (Prcondition)_objPrcondition.get(index);
}
/**
* Replaces an existing Prcondition object at the specified index with
* a new Prcondition object.
* @param index index of replaced object.
* @throws IndexOutOfBoundsException if index is out of range.
*/
public void setPrcondition(int index, Prcondition obj)
{
if( obj == null )
removePrcondition(index);
else
{
_objPrcondition.set(index, obj);
obj._setParent(this);
}
}
/**
* Returns the number of Prcondition objects in the list.
*/
public int getPrconditionCount()
{
return _objPrcondition.size();
}
/**
* Returns <code>true</code> if there is no Prcondition object in the list; otherwise,
* the method returns <code>false</code>.
*/
public boolean isNoPrcondition()
{
return _objPrcondition.size() == 0;
}
/**
* Returns a read-only list of Prcondition objects.
*/
public List getPrconditionList()
{
return Collections.unmodifiableList(_objPrcondition);
}
/**
* Adds a new Prcondition object at the end of the list.
* @return <code>true</code> if the new object is added to the list; otherwise,
* the method returns <code>false</code>.
*/
public boolean addPrcondition(Prcondition obj)
{
if( obj==null )
return false;
obj._setParent(this);
return _objPrcondition.add(obj);
}
/**
* Adds a list of new Prcondition objects at the end of the list.
* @return <code>true</code> if the list was changed; otherwise, the method
* returns <code>false</code>.
*/
public boolean addPrcondition(Collection coPrcondition)
{
if( coPrcondition==null )
return false;
java.util.Iterator it = coPrcondition.iterator();
while( it.hasNext() )
{
Object obj = it.next();
if( obj != null && obj instanceof com.borland.xml.toolkit.XmlObject )
((com.borland.xml.toolkit.XmlObject)obj)._setParent(this);
}
return _objPrcondition.addAll(coPrcondition);
}
/**
* Removes an existing Prcondition object at the specified index.
* @return The removed object.
*/
public Prcondition removePrcondition(int index)
{
return (Prcondition)_objPrcondition.remove(index);
}
/**
* Removes the specified Prcondition object.
* @return <code>true</code> if this list contains the object; otherwise,
* the method returns <code>false</code>.
*/
public boolean removePrcondition(Prcondition obj)
{
return _objPrcondition.remove(obj);
}
/**
* Clears all Prcondition objects from the list.
*/
public void clearPrconditionList()
{
_objPrcondition.clear();
}
/**
* Marshals this object to an instance document and outputs it to the specified output stream.
* @param out OutputStream object to receive the instance document.
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.OutputStream out)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( out, elem, getPublicId(), getSystemId(), _outputter );
}
/**
* Marshals this object to an instance document and outputs it to the specified output stream.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the default encoding specified in XmlUtil class </li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param out OutputStream object to receive the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent)
* @see com.borland.xml.toolkit.XmlUtil
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.OutputStream out, String indent)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( out, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent) );
}
/**
* Marshals this object to an instance document and outputs it to the specified output stream.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param out OutputStream object to receive the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param encoding an encoding format, such as UTF-8.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, String encoding)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.OutputStream out, String indent, String encoding)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( out, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, encoding) );
}
/**
* Marshals this object to an instance document and outputs it to the specified output stream.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>newlines</code> is <code>true</code>, elements
* are separated by newlines ("\r\n"). If <code>newlines</code> is <code>false</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration if
* <code>printEncoding</code> is <code>true</code>; no printing, otherwise.</li><br>
* <li>printing the XML declaration if <code>printDeclaration</code> is
* <code>true</code>; no printing, otherwise.</li><br>
* @param out OutputStream object to receive the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param newlines boolean value to specify whether you want to separate
* elements with carriage return and line feed ("\r\n").
* @param encoding an encoding format, such as UTF-8.
* @param printEncoding <code>true</code> to print the "encoding" attribute;
* <code>false</code>, otherwise.
* @param printDeclaration <code>true</code> to print the XML declaration;
* <code>false</code>, otherwise.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, boolean newlines, String encoding,
* boolean printEncoding, boolean printDeclaration)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.OutputStream out, String indent, boolean newlines,
String encoding, boolean printEncoding, boolean printDeclaration)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( out, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, newlines, encoding,
printEncoding,
printDeclaration) );
}
/**
* Marshals this object to an instance document and outputs it to the specified output stream.
* The format of XML output is controlled by the specified outputter.
* @param out OutputStream object to receive the instance document.
* @param outputter Outputter object to control the format of XML output.
* @see com.borland.xml.toolkit.Outputter
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.OutputStream out, com.borland.xml.toolkit.Outputter outputter)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( out, elem, getPublicId(), getSystemId(),
outputter );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* @param fileName file to store the instance document.
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(String fileName)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( fileName, elem, getPublicId(),
getSystemId(), _outputter );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the default encoding specified in XmlUtil class </li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param fileName file to store the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent)
* @see com.borland.xml.toolkit.XmlUtil
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(String fileName, String indent)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( fileName, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent) );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param fileName file to store the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param encoding an encoding format, such as UTF-8.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, String encoding)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(String fileName, String indent, String encoding)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( fileName, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, encoding) );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>newlines</code> is <code>true</code>, elements
* are separated by newlines ("\r\n"). If <code>newlines</code> is <code>false</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration if
* <code>printEncoding</code> is <code>true</code>; no printing, otherwise.</li><br>
* <li>printing the XML declaration if <code>printDeclaration</code> is
* <code>true</code>; no printing, otherwise.</li><br>
* @param fileName file to store the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param newlines boolean value to specify whether you want to separate
* elements with carriage return and line feed ("\r\n").
* @param encoding an encoding format, such as UTF-8.
* @param printEncoding <code>true</code> to print the "encoding" attribute;
* <code>false</code>, otherwise.
* @param printDeclaration <code>true</code> to print the XML declaration;
* <code>false</code>, otherwise.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, boolean newlines, String encoding,
* boolean printEncoding, boolean printDeclaration)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(String fileName, String indent, boolean newlines,
String encoding, boolean printEncoding, boolean printDeclaration)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( fileName, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, newlines, encoding,
printEncoding,
printDeclaration) );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The format of XML output is controlled by the specified outputter.
* @param fileName file to store the instance document.
* @param outputter Outputter object to control the format of XML output.
* @see com.borland.xml.toolkit.Outputter
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(String fileName, com.borland.xml.toolkit.Outputter outputter)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( fileName, elem, getPublicId(),
getSystemId(), outputter );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* @param file File to store the instance document.
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.File file)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( file, elem, getPublicId(),
getSystemId(), _outputter );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the default encoding specified in XmlUtil class </li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param file File to store the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent)
* @see com.borland.xml.toolkit.XmlUtil
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.File file, String indent)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( file, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent) );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param file File to store the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param encoding an encoding format, such as UTF-8.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, String encoding)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.File file, String indent, String encoding)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( file, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, encoding) );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>newlines</code> is <code>true</code>, elements
* are separated by newlines ("\r\n"). If <code>newlines</code> is <code>false</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration if
* <code>printEncoding</code> is <code>true</code>; no printing, otherwise.</li><br>
* <li>printing the XML declaration if <code>printDeclaration</code> is
* <code>true</code>; no printing, otherwise.</li><br>
* @param file File to store the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param newlines boolean value to specify whether you want to separate
* elements with carriage return and line feed ("\r\n").
* @param encoding an encoding format, such as UTF-8.
* @param printEncoding <code>true</code> to print the "encoding" attribute;
* <code>false</code>, otherwise.
* @param printDeclaration <code>true</code> to print the XML declaration;
* <code>false</code>, otherwise.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, boolean newlines, String encoding,
* boolean printEncoding, boolean printDeclaration)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.File file, String indent, boolean newlines,
String encoding, boolean printEncoding, boolean printDeclaration)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( file, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, newlines, encoding,
printEncoding,
printDeclaration) );
}
/**
* Marshals this object to an instance document and stores it in the specified file.
* The format of XML output is controlled by the specified outputter.
* @param file File to store the instance document.
* @param outputter Outputter object to control the format of XML output.
* @see com.borland.xml.toolkit.Outputter
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.File file, com.borland.xml.toolkit.Outputter outputter)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( file, elem, getPublicId(), getSystemId(),
outputter );
}
/**
* Marshals this object to an instance document and outputs it to the specified writer.
* @param writer Writer object to receive the instance document.
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.Writer writer)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( writer, elem, getPublicId(),
getSystemId(), _outputter );
}
/**
* Marshals this object to an instance document and outputs it to the specified writer.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the default encoding specified in XmlUtil class </li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param writer Writer object to receive the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent)
* @see com.borland.xml.toolkit.XmlUtil
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.Writer writer, String indent)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( writer, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent) );
}
/**
* Marshals this object to an instance document and outputs it to the specified writer.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>indent</code> is not <code>null</code>, elements
* are separated by newlines ("\r\n"). If <code>indent</code> is <code>null</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration</li><br>
* <li>printing the XML declaration</li><br>
* @param writer Writer object to receive the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param encoding an encoding format, such as UTF-8.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, String encoding)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.Writer writer, String indent, String encoding)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( writer, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, encoding) );
}
/**
* Marshals this object to an instance document and outputs it to the specified writer.
* The XML output has the following attributes:<br>
* <li>using the specified indent</li><br>
* <li>If the parameter <code>newlines</code> is <code>true</code>, elements
* are separated by newlines ("\r\n"). If <code>newlines</code> is <code>false</code>,
* no newline is generated between elements.</li><br>
* <li>using the specified encoding</li><br>
* <li>printing the "encoding" attribute in the XML declaration if
* <code>printEncoding</code> is <code>true</code>; no printing, otherwise.</li><br>
* <li>printing the XML declaration if <code>printDeclaration</code> is
* <code>true</code>; no printing, otherwise.</li><br>
* @param writer Writer object to receive the instance document.
* @param indent the string (usually white spaces) used to indent elements.
* @param newlines boolean value to specify whether you want to separate
* elements with carriage return and line feed ("\r\n").
* @param encoding an encoding format, such as UTF-8.
* @param printEncoding <code>true</code> to print the "encoding" attribute;
* <code>false</code>, otherwise.
* @param printDeclaration <code>true</code> to print the XML declaration;
* <code>false</code>, otherwise.
* @see com.borland.xml.toolkit.Outputter#Outputter(String indent, boolean newlines, String encoding,
* boolean printEncoding, boolean printDeclaration)
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.Writer writer, String indent, boolean newlines,
String encoding, boolean printEncoding, boolean printDeclaration)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( writer, elem, getPublicId(), getSystemId(),
new com.borland.xml.toolkit.Outputter(indent, newlines, encoding,
printEncoding,
printDeclaration) );
}
/**
* Marshals this object to an instance document and outputs it to the specified writer.
* The format of XML output is controlled by the specified outputter.
* @param writer Writer object to receive the instance document.
* @param outputter Outputter object to control the format of XML output.
* @see com.borland.xml.toolkit.Outputter
* @throws java.io.IOException An IO error occurs when writing out the instance document.
*/
public void marshal(java.io.Writer writer, com.borland.xml.toolkit.Outputter outputter)
throws java.io.IOException
{
com.borland.xml.toolkit.Element elem = marshal();
com.borland.xml.toolkit.XmlUtil.writeDocument( writer, elem, getPublicId(), getSystemId(),
outputter );
}
/**
* Unmarshals an instance document back to a Ruleset object from an input stream.
* @param in The InputStream object to read the instance document.
* @param saxParserClass fully qualified class name to identify a SAX parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.SAXParser</code> is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
* @param entityResolver EntityResolver object to provide customized handling for
* external entities.
* @param dtdHandler DtdHandler object to receive notification of notation
* declaration and unparsed entity declaration events.
* @param errorHandler ErrorHandler object to provide customized error handling.
*/
public static Ruleset unmarshal(java.io.InputStream in, String saxParserClass,
boolean validation,
org.xml.sax.EntityResolver entityResolver,
org.xml.sax.DTDHandler dtdHandler,
org.xml.sax.ErrorHandler errorHandler)
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(in, saxParserClass,
validation, entityResolver,
dtdHandler, errorHandler);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from an input stream.
* @param in The InputStream object to read the instance document.
* @param domParserClass fully qualified class name to identify a DOM parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.DOMParser#xerces</code>
* is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
*/
public static Ruleset unmarshal(java.io.InputStream in, String domParserClass,
boolean validation)
throws com.borland.xml.toolkit.DOMAdapterNotFoundException
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(in, domParserClass,
validation);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from an input stream.
* @param in The InputStream object to read the instance document.
*/
public static Ruleset unmarshal(java.io.InputStream in)
{
return Ruleset.unmarshal(com.borland.xml.toolkit.XmlUtil.getDocRootElement(in));
}
/**
* Unmarshals an instance document back to a Ruleset object from a file.
* @param file A File object, which contains the instance document.
* @param saxParserClass fully qualified class name to identify a SAX parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.SAXParser</code> is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
* @param entityResolver EntityResolver object to provide customized handling for
* external entities.
* @param dtdHandler DtdHandler object to receive notification of notation
* declaration and unparsed entity declaration events.
* @param errorHandler ErrorHandler object to provide customized error handling.
*/
public static Ruleset unmarshal(java.io.File file, String saxParserClass,
boolean validation,
org.xml.sax.EntityResolver entityResolver,
org.xml.sax.DTDHandler dtdHandler,
org.xml.sax.ErrorHandler errorHandler)
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(file, saxParserClass,
validation, entityResolver,
dtdHandler, errorHandler);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from a file.
* @param file A File object, which contains the instance document.
* @param domParserClass fully qualified class name to identify a DOM parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.DOMParser#xerces</code>
* is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
*/
public static Ruleset unmarshal(java.io.File file, String domParserClass,
boolean validation)
throws com.borland.xml.toolkit.DOMAdapterNotFoundException
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(file, domParserClass,
validation);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from a file.
* @param file A File object, which contains the instance document.
*/
public static Ruleset unmarshal(java.io.File file)
{
return Ruleset.unmarshal(com.borland.xml.toolkit.XmlUtil.getDocRootElement(file));
}
/**
* Unmarshals an instance document back to a Ruleset object from a file.
* @param fileName File name of XML document.
* @param saxParserClass fully qualified class name to identify a SAX parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.SAXParser</code> is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
* @param entityResolver EntityResolver object to provide customized handling for
* external entities.
* @param dtdHandler DtdHandler object to receive notification of notation
* declaration and unparsed entity declaration events.
* @param errorHandler ErrorHandler object to provide customized error handling.
*/
public static Ruleset unmarshal(String fileName, String saxParserClass,
boolean validation,
org.xml.sax.EntityResolver entityResolver,
org.xml.sax.DTDHandler dtdHandler,
org.xml.sax.ErrorHandler errorHandler)
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(fileName, saxParserClass,
validation, entityResolver,
dtdHandler, errorHandler);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from a file.
* @param fileName File name of XML document.
* @param domParserClass fully qualified class name to identify a DOM parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.DOMParser#xerces</code>
* is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
*/
public static Ruleset unmarshal(String fileName, String domParserClass,
boolean validation)
throws com.borland.xml.toolkit.DOMAdapterNotFoundException
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(fileName, domParserClass,
validation);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from a file.
* @param fileName File name of XML document.
*/
public static Ruleset unmarshal(String fileName)
{
return Ruleset.unmarshal(com.borland.xml.toolkit.XmlUtil.getDocRootElement(fileName));
}
/**
* Unmarshals an instance document back to a Ruleset object from a URL.
* @param url the URL of the instance document.
* @param saxParserClass fully qualified class name to identify a SAX parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.SAXParser</code> is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
* @param entityResolver EntityResolver object to provide customized handling for
* external entities.
* @param dtdHandler DtdHandler object to receive notification of notation
* declaration and unparsed entity declaration events.
* @param errorHandler ErrorHandler object to provide customized error handling.
*/
public static Ruleset unmarshal(java.net.URL url, String saxParserClass,
boolean validation,
org.xml.sax.EntityResolver entityResolver,
org.xml.sax.DTDHandler dtdHandler,
org.xml.sax.ErrorHandler errorHandler)
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(url, saxParserClass,
validation, entityResolver,
dtdHandler, errorHandler);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from a URL.
* @param url the URL of the instance document.
* @param domParserClass fully qualified class name to identify a DOM parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.DOMParser#xerces</code>
* is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
*/
public static Ruleset unmarshal(java.net.URL url, String domParserClass,
boolean validation)
throws com.borland.xml.toolkit.DOMAdapterNotFoundException
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(url, domParserClass,
validation);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from a URL.
* @param url the URL of the instance document.
*/
public static Ruleset unmarshal(java.net.URL url)
{
return Ruleset.unmarshal(com.borland.xml.toolkit.XmlUtil.getDocRootElement(url));
}
/**
* Unmarshals an instance document back to a Ruleset object from a reader.
* @param reader The Reader object to read the instance document.
* @param saxParserClass fully qualified class name to identify a SAX parser.
* If this parameter is null, the default parser
* <code>org.apache.xerces.parsers.SAXParser</code> is used.
* @param validation <code>true</code> to turn on the validation feature;
* <code>false</code> to turn it off.
* @param entityResolver EntityResolver object to provide customized handling for
* external entities.
* @param dtdHandler DtdHandler object to receive notification of notation
* declaration and unparsed entity declaration events.
* @param errorHandler ErrorHandler object to provide customized error handling.
*/
public static Ruleset unmarshal(java.io.Reader reader, String saxParserClass,
boolean validation,
org.xml.sax.EntityResolver entityResolver,
org.xml.sax.DTDHandler dtdHandler,
org.xml.sax.ErrorHandler errorHandler)
{
com.borland.xml.toolkit.Element elem;
elem = com.borland.xml.toolkit.XmlUtil.getDocRootElement(reader, saxParserClass,
validation, entityResolver,
dtdHandler, errorHandler);
return Ruleset.unmarshal(elem);
}
/**
* Unmarshals an instance document back to a Ruleset object from a reader.
* @param reader The Reader object to read the instance document.
*/
public static Ruleset unmarshal(java.io.Reader reader)
{
return Ruleset.unmarshal(com.borland.xml.toolkit.XmlUtil.getDocRootElement(reader));
}
/**
* Sets the outputter to control the format of XML output.
*/
public void _setOutputter(com.borland.xml.toolkit.Outputter outputter)
{
_outputter = outputter;
}
/**
* Gets the outputter, which controls the format of XML output.
*/
public com.borland.xml.toolkit.Outputter _getOutputter()
{
return _outputter;
}
/**
* Sets the indent string that is used to indent XML output. By default, the
* indent is set to four white spaces. If you pass a null or "" to this method,
* no indentation occurs.
*/
public void _setIndent(String indent)
{
if( _outputter == null )
_outputter = new com.borland.xml.toolkit.Outputter();
_outputter.setIndent(indent);
}
/**
* Sets the number of white spaces used to indent XML output. By default,
* the indent is set to four white spaces.
*/
public void _setIndentSize(int indentSize)
{
if( _outputter == null )
_outputter = new com.borland.xml.toolkit.Outputter();
_outputter.setIndentSize(indentSize);
}
/**
* Declares whether you want to separate elements with carriage return and
* line feed ("\r\n") in the XML output.
* @param newlines <code>true</code> to print newlines; <code>false</code> otherwise.
*/
public void _setNewlines(boolean newlines)
{
if( _outputter == null )
_outputter = new com.borland.xml.toolkit.Outputter();
_outputter.setNewlines(newlines);
}
/**
* Replaces the existing encoding in use for XML output with a new encoding.
*/
public void _setEncoding(String encoding)
{
if( _outputter == null )
_outputter = new com.borland.xml.toolkit.Outputter();
_outputter.setEncoding(encoding);
}
/**
* Declares whether you to want to print the "encoding" attribute in the
* XML declaration.
*/
public void _setPrintEncoding(boolean printEncoding)
{
if( _outputter == null )
_outputter = new com.borland.xml.toolkit.Outputter();
_outputter.setPrintEncoding(printEncoding);
}
/**
* Declares whether you to want to print the XML declaration.
*/
public void _setPrintXMLDeclaration(boolean printXMLDeclaration)
{
if( _outputter == null )
_outputter = new com.borland.xml.toolkit.Outputter();
_outputter.setPrintXMLDeclaration(printXMLDeclaration);
}
/**
* Gets public identifier.
*/
public String getPublicId()
{
return publicId;
}
/**
* Sets public identifier.
*/
public void setPublicId(String publicId)
{
this.publicId = publicId;
}
/**
* Gets system identifier.
*/
public String getSystemId()
{
return systemId;
}
/**
* Sets system identifier.
*/
public void setSystemId(String systemId)
{
this.systemId = systemId;
}
/**
* Marshals this object to an element.
*/
public com.borland.xml.toolkit.Element marshal()
{
com.borland.xml.toolkit.Element elem = new com.borland.xml.toolkit.Element(get_TagName());
/** Marshals a list of Rule objects to elements */
Iterator it1 = _objRule.iterator();
while( it1.hasNext() )
{
Rule obj = (Rule)it1.next();
if( obj != null )
{
elem.addComment(obj._marshalCommentList());
elem.addContent(obj.marshal());
}
}
/** Marshals a list of Prcondition objects to elements */
Iterator it2 = _objPrcondition.iterator();
while( it2.hasNext() )
{
Prcondition obj = (Prcondition)it2.next();
if( obj != null )
{
elem.addComment(obj._marshalCommentList());
elem.addContent(obj.marshal());
}
}
elem.addComment(this._marshalBottomCommentList());
return elem;
}
/**
* Unmarshals the specified "ruleset" element back to a Ruleset object.
*/
public static Ruleset unmarshal(com.borland.xml.toolkit.Element elem)
{
if( elem == null )
return null;
Ruleset __objRuleset = new Ruleset();
ArrayList __comments = null;
Iterator it = elem.getChildObjects().iterator();
while( it.hasNext() )
{
Object __obj = it.next();
if( __obj instanceof com.borland.xml.toolkit.Comment )
{
if( __comments == null )
__comments = new ArrayList(2);
__comments.add(__obj);
}
else if( __obj instanceof com.borland.xml.toolkit.Element )
{
com.borland.xml.toolkit.Element __e = (com.borland.xml.toolkit.Element)__obj;
String __name = __e.getName();
if( __name.equals(Rule._tagName) )
{
/** Unmarshals the child element back to a Rule object */
Rule __objRule = Rule.unmarshal(__e);
__objRuleset.addRule(__objRule);
__objRule._unmarshalCommentList(__comments);
}
if( __name.equals(Prcondition._tagName) )
{
/** Unmarshals the child element back to a Prcondition object */
Prcondition __objPrcondition = Prcondition.unmarshal(__e);
__objRuleset.addPrcondition(__objPrcondition);
__objPrcondition._unmarshalCommentList(__comments);
}
__comments = null;
}
}
__objRuleset._unmarshalBottomCommentList(__comments);
return __objRuleset;
}
/**
* Validates this object. If you pass <code>true</code> to this method, it
* checks for the first error and stops. On the other hand, if you pass
* <code>false</code> to this method, it collects all the errors by
* visiting every available elements.
* @param firstError <code>true</code> to exit this method when the first error
* is found; <code>false</code> to collect all errors.
* @return com.borland.xml.toolkit.ErrorList A list that contains one or more errors.
* @see com.borland.xml.toolkit.XmlObject#validate()
* @see com.borland.xml.toolkit.XmlObject#isValid()
* @see com.borland.xml.toolkit.ErrorList
*/
public com.borland.xml.toolkit.ErrorList validate(boolean firstError)
{
com.borland.xml.toolkit.ErrorList errors = new com.borland.xml.toolkit.ErrorList();
/** Rule is zero or more */
Iterator it1 = _objRule.iterator();
while( it1.hasNext() )
{
Rule obj = (Rule)it1.next();
if( obj != null )
{
errors.add(obj.validate(firstError));
if( firstError && errors.size() > 0 )
return errors;
}
}
/** Prcondition is zero or more */
Iterator it2 = _objPrcondition.iterator();
while( it2.hasNext() )
{
Prcondition obj = (Prcondition)it2.next();
if( obj != null )
{
errors.add(obj.validate(firstError));
if( firstError && errors.size() > 0 )
return errors;
}
}
return errors.size()==0 ? null : errors;
}
/**
* Returns a list containing all child elements. Each element in the list is a subclass
* of XmlObject.
*/
public java.util.List _getChildren()
{
java.util.List children = new java.util.ArrayList();
/** adds _objRule */
if( _objRule != null && _objRule.size() > 0 )
children.add(_objRule);
/** adds _objPrcondition */
if( _objPrcondition != null && _objPrcondition.size() > 0 )
children.add(_objPrcondition);
return children;
}
/**
* Gets the element-type name.
*/
public String get_TagName()
{
return _tagName;
}
}更多精彩文章及讨论,请光临枫下论坛 rolia.net