com.bea.p13n.rules.model
Class RuleSetModelDocument

java.lang.Object
  extended by com.bea.p13n.model.DefaultDocumentModel
      extended by com.bea.p13n.rules.model.RuleSetModelDocument
All Implemented Interfaces
DocumentModel, Serializable

public class RuleSetModelDocument
extends DefaultDocumentModel

A default model document for RuleSetModels. This also provides common methods for parsing and writing rule-set xml in the preferred manner.

See Also
Serialized Form

Field Summary
static String DEFAULT_ENCODING
          The default character encoding to use, if document's don't specify one themselves.
static String schemaLocation
          The xsi:schemaLocation value for rule set documents.
static Map<String,String> suggestedPrefixes
          The unmodifiable map of namespace uri to preferred prefix for rule-set xml.
 
Constructor Summary
RuleSetModelDocument(InputStream in)
          Constructor from an input stream.
RuleSetModelDocument(Reader in)
          Constructor from an input reader.
RuleSetModelDocument(RuleSetModel rs)
          Constructor from RuleSetModel.
RuleSetModelDocument(String in)
          Constructor from xml.
 
Method Summary
static org.apache.xmlbeans.XmlOptions getSaveOptions()
          Get default XmlOptions for saving/outputting rule xml.
static RuleSetModel parseRuleSetModel(InputStream xml, Collection errors)
          Parse a rule set model from an input stream
static RuleSetModel parseRuleSetModel(Reader xml, Collection errors)
          Parse a rule set model from a reader.
static RuleSetModel parseRuleSetModel(String xml, Collection errors)
          Parse a rule set model from xml.
static com.bea.p13n.rules.schema.RuleSetDocument prepareForSave(RuleSetModel rs, String encoding, org.apache.xmlbeans.XmlOptions opts)
          Prepare a RuleSetDocument xml object from the RuleSetModel.
static InputStream toInputStream(RuleSetModel rs)
          Get an input stream of the specified RuleSetModel's xml.
static InputStream toInputStream(RuleSetModel rs, String encoding)
          Get an input stream of the specified RuleSetModel's xml.
static Reader toReader(RuleSetModel rs)
          Get a reader of the specified RuleSetModel's xml.
static Reader toReader(RuleSetModel rs, String encoding)
          Get a reader of the specified RuleSetModel's xml.
static String toString(RuleSetModel rs)
          Get the specified RuleSetModel's xml.
static String toString(RuleSetModel rs, String encoding)
          Get the specified RuleSetModel's xml.
 
Methods inherited from class com.bea.p13n.model.DefaultDocumentModel
addChangeListener, getRootModel, modelChildAdded, modelChildRemoved, modelPropertyChanged, removeChangeListener, setRootModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

suggestedPrefixes

public static final Map<String,String> suggestedPrefixes
The unmodifiable map of namespace uri to preferred prefix for rule-set xml.


DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
The default character encoding to use, if document's don't specify one themselves.

See Also
Constants Summary

schemaLocation

public static final String schemaLocation
The xsi:schemaLocation value for rule set documents.

See Also
Constants Summary
Constructor Detail

RuleSetModelDocument

public RuleSetModelDocument(RuleSetModel rs)
Constructor from RuleSetModel.


RuleSetModelDocument

public RuleSetModelDocument(Reader in)
                     throws org.apache.xmlbeans.XmlException,
                            IllegalArgumentException,
                            IOException
Constructor from an input reader.

Throws
org.apache.xmlbeans.XmlException - on a parsing exception
IllegalArgumentException - if the xml is not valid for RuleSetModel.
IOException - on an error reading from the stream.

RuleSetModelDocument

public RuleSetModelDocument(InputStream in)
                     throws org.apache.xmlbeans.XmlException,
                            IllegalArgumentException,
                            IOException
Constructor from an input stream.

Throws
org.apache.xmlbeans.XmlException - on a parsing exception
IllegalArgumentException - if the xml is not valid for RuleSetModel.
IOException - on an error reading from the stream.

RuleSetModelDocument

public RuleSetModelDocument(String in)
                     throws org.apache.xmlbeans.XmlException,
                            IllegalArgumentException
Constructor from xml.

Throws
org.apache.xmlbeans.XmlException - on a parsing exception
IllegalArgumentException - if the xml is not valid for RuleSetModel.
Method Detail

parseRuleSetModel

public static RuleSetModel parseRuleSetModel(String xml,
                                             Collection errors)
                                      throws org.apache.xmlbeans.XmlException,
                                             IllegalArgumentException
Parse a rule set model from xml.

Parameters
xml - the xml string.
errors - a collection to store any XmlErrors from the parse.
Returns
the RuleSetModel, initialized from the xml.
Throws
org.apache.xmlbeans.XmlException - on a parsing exception
IllegalArgumentException - if the xml is not valid for RuleSetModel.

parseRuleSetModel

public static RuleSetModel parseRuleSetModel(Reader xml,
                                             Collection errors)
                                      throws org.apache.xmlbeans.XmlException,
                                             IllegalArgumentException,
                                             IOException
Parse a rule set model from a reader.

Parameters
xml - the xml reader
errors - a collection to store any XmlErrors from the parse.
Returns
the RuleSetModel, initialized from the xml.
Throws
org.apache.xmlbeans.XmlException - on a parsing exception.
IllegalArgumentException - if the xml is not valid for RuleSetModel.
IOException - on an error reading from the stream.

parseRuleSetModel

public static RuleSetModel parseRuleSetModel(InputStream xml,
                                             Collection errors)
                                      throws org.apache.xmlbeans.XmlException,
                                             IllegalArgumentException,
                                             IOException
Parse a rule set model from an input stream

Parameters
xml - the xml input streaml.
errors - a collection to store any XmlErrors from the parse.
Returns
the RuleSetModel, initialize from the xml.
Throws
org.apache.xmlbeans.XmlException - on a parsing exception.
IllegalArgumentException - if the xml is not valid for RuleSetModel.
IOException - on an error reading from the stream.

getSaveOptions

public static org.apache.xmlbeans.XmlOptions getSaveOptions()
Get default XmlOptions for saving/outputting rule xml.

See Also
suggestedPrefixes

prepareForSave

public static com.bea.p13n.rules.schema.RuleSetDocument prepareForSave(RuleSetModel rs,
                                                                       String encoding,
                                                                       org.apache.xmlbeans.XmlOptions opts)
Prepare a RuleSetDocument xml object from the RuleSetModel. This will save the encoding on the xml object and in the XmlOptions. The returned RuleSetDocument and modified XmlOptions can then be used to generate the xml.

Parameters
rm - the rule set model.
encoding - the encoding to use, null for default.
opts - the opts to modify appropriately.

toInputStream

public static InputStream toInputStream(RuleSetModel rs)
Get an input stream of the specified RuleSetModel's xml.


toInputStream

public static InputStream toInputStream(RuleSetModel rs,
                                        String encoding)
Get an input stream of the specified RuleSetModel's xml.


toReader

public static Reader toReader(RuleSetModel rs)
Get a reader of the specified RuleSetModel's xml.


toReader

public static Reader toReader(RuleSetModel rs,
                              String encoding)
Get a reader of the specified RuleSetModel's xml.

Parameters
rs - the rule model.
encoding - the character encoding to use, null for model's default encoding.

toString

public static String toString(RuleSetModel rs)
Get the specified RuleSetModel's xml.


toString

public static String toString(RuleSetModel rs,
                              String encoding)
Get the specified RuleSetModel's xml.

Parameters
rs - the rule set model.
encoding - the character encoding to use, null for model's default encoding.


Copyright © 2011, Oracle. All rights reserved.