Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * This file is part of the DiffX library.
   *
   * For licensing information please see the file license.txt included in the release.
   * A copy of this licence can also be found at
   *   http://www.opensource.org/licenses/artistic-license-2.0.php
   */
  package com.topologi.diffx.xml.sax;
  
 import java.util.Map;
 
 
An XMLReader implementation that can be used to parse XMLWritable objects.

Typically, XMLWritable objects are wrapped into an XMLWritableInputSource so that the XMLReader API methods are used; however, it is perfectly possible to parse directly an XMLWritable object.

Author(s):
Christophe Lauret
Version:
27 May 2005
See also:
org.xml.sax.XMLReader
com.topologi.diffx.xml.XMLWritable
XMLWritableInputSource
 
 public final class XMLWritableReader implements XMLReader {

  
The URI of the namespace feature.
 
   private static final String NAMESPACES = "http://xml.org/sax/features/namespaces";

  
The URI of the namespace prefixes feature.
 
   private static final String NS_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";

  
The features used by this XML reader implementation.
 
   private final Map<StringBooleanfeatures = new HashMap<StringBoolean>();

  
The content reader this XMLReader will use.
 
   private ContentHandler handler;

  
Creates a new XML Reader.
 
   public XMLWritableReader() {
     setFeature(true);
     setFeature(false);
   }
 
   // XMLReader methods implementation -----------------------------------------------------
 
  
 
   @Override
     return this.;
   }

  
 
   @Override
   public void setContentHandler(ContentHandler chandler) {
     this. = chandler;
   }

  
Returns null.
 
   @Override
   public ErrorHandler getErrorHandler() {
     return null;
   }

  
Does nothing.
  public void setErrorHandler(ErrorHandler ehandler) {
  }

  
Returns null.
  public DTDHandler getDTDHandler() {
    return null;
  }

  
Does nothing.
  public void setDTDHandler(DTDHandler dhandler) {
  }

  
Returns null.
    return null;
  }

  
Returns null.
  public void setEntityResolver(EntityResolver resolver) {
  }

  
Returns null.
  public Object getProperty(java.lang.String name) {
    return null;
  }

  
Does nothing.
  public void setProperty(java.lang.String namejava.lang.Object value) {
  }

  
  public boolean getFeature(java.lang.String name) {
    // TODO: handling of features
    return this..get(name).booleanValue();
  }

  
  public void setFeature(java.lang.String nameboolean value) {
    // TODO: handling of features
    this..put(name, Boolean.valueOf(value));
  }

  
  public void parse(String systemIdthrows IOExceptionSAXException {
    throw new SAXException(
        this.getClass().getName()
        + " cannot be used with system identifiers (URIs)");
  }

  
  public void parse(InputSource inputthrows IOExceptionSAXException {
    if (input instanceof XMLWritableInputSource) {
      parse((XMLWritableInputSource)input);
    } else
      throw new SAXException("Unsupported InputSource specified. Must be a XMLWritableInputSource");
  }

  
  public void parse(XMLWritableInputSource inputthrows IOExceptionSAXException {
    parse(input.getXMLWritable());
  }

  
  public void parse(XMLWritable xmlthrows IOExceptionSAXException {
    if (xml == null)
      throw new NullPointerException("Parameter projectTeam must not be null");
    if (this. == null)
      throw new IllegalStateException("ContentHandler not set");
    // start handling the document
    this..startDocument();
    XMLWriter xw = new XMLWriterSAX(this.);
    xml.toXML(xw);
    this..endDocument();
  }
New to GrepCode? Check out our FAQ X