All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.harvard.hul.ois.jhove.module.xml.XmlDeclHandler Maven / Gradle / Ivy

The newest version!
/**********************************************************************
 * Jhove - JSTOR/Harvard Object Validation Environment
 * Copyright 2004 by JSTOR and the President and Fellows of Harvard College
 **********************************************************************/

package edu.harvard.hul.ois.jhove.module.xml;

import java.util.LinkedList;
import java.util.List;

import org.xml.sax.ext.DeclHandler;

/**
 * 
 * This implementation of DeclHandler takes care of
 * collecting entity declarations.
 * 
 * @author Gary McGath
 *
 */
public class XmlDeclHandler implements DeclHandler {

    private List _intEntityDeclarations;
    private List _extEntityDeclarations;
    
    public XmlDeclHandler ()
    {
        _intEntityDeclarations = new LinkedList<> ();
        _extEntityDeclarations = new LinkedList<> ();
    }
    
    
    
    /**
     * Report an element type declaration.
     * Does nothing.
     * @see org.xml.sax.ext.DeclHandler#elementDecl(java.lang.String, java.lang.String)
     */
    @Override
	public void elementDecl(String arg0, String arg1) 
    {
    }

    /**
     *  Adds internal entity declarations to the entity declarations
     *  list in the form of a String[2], with element 0 being the
     *  name and element 1 being the value. 
     */
    @Override
	public void internalEntityDecl(String name, String value) {
        String[] decl = new String[2];
        decl[0] = name;
        decl[1] = value;
        _intEntityDeclarations.add (decl);
    }

    /**
     *  Adds external entity declarations to the entity declarations
     *  list in the form of a String[3], with element 0 being the
     *  name, element 1 the public ID, and 2 the system ID. 
     */
    @Override
	public void externalEntityDecl(String name, String publicID, String systemID) {
        String[] decl = new String[3];
        decl[0] = name;
        decl[1] = publicID;
        decl[2] = systemID;
        _extEntityDeclarations.add (decl);
    }

    /** Report an attribute type declaration.
     *  Does nothing.
     *  @see org.xml.sax.ext.DeclHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
     */
    @Override
	public void attributeDecl(
        String arg0,
        String arg1,
        String arg2,
        String arg3,
        String arg4) 
    {
 
    }


    /**
     *  Returns list of entity declarations.  Each list
     *  is an array String[2], giving the name and
     *  value respectively.
     */
    public List getInternalEntityDeclarations ()
    {
        return _intEntityDeclarations;
    }


    /**
     *  Returns list of entity declarations.  Each list
     *  is an array String[3], giving the name,
     *  public ID, and system ID respectively.
     */
    public List getExternalEntityDeclarations ()
    {
        return _extEntityDeclarations;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy