/*
 * (C) Copyright IBM Corp. 1997-1998  All rights reserved.
 *
 * US Government Users Restricted Rights Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 * The program is provided "as is" without any warranty express or
 * implied, including the warranty of non-infringement and the implied
 * warranties of merchantibility and fitness for a particular purpose.
 * IBM will not be liable for any damages suffered by you as a result
 * of using the Program. In no event will IBM be liable for any
 * special, indirect or consequential damages or lost profits even if
 * IBM has been advised of the possibility of their occurrence. IBM
 * will not be liable for any third party claims against you.
 */

package com.ibm.xml.parser;

import org.w3c.dom.*;

/**
 * The TXNotation class implements the Notation interface as defined by the Document Object Model (DOM).
 * <p>The Notation Node is used to represent the definition of a notation within a DTD.
 * Notations identify by name the format of external binary entities, or the application to 
 * which a processing instruction is addressed.
 *
 * @version 1.1
 * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt;
 * @see org.w3c.dom.Notation 
 */
public class TXNotation extends Child implements Notation {
    
                String      name        =   null;
                ExternalID  externalID  =   null;

    /**
     * Constructor.
     * @param name          The name of the Notation.
     * @param externalID    The public or system identifier which defines the DTD's notation.
     */
    public TXNotation(String name, ExternalID externalID) {
        this.name       = name;
        this.externalID = externalID;
    }
    
    /**
     * Clone this Notation Node using the appropriate factory.  
     * <p>This method is defined by Child.
     * @return          Cloned Notation Node.
     * @see com.ibm.xml.parser.Child#clone
     */
    public synchronized Object clone() {
        checkFactory();
        TXNotation no = factory.createNotation(this.name, this.externalID);
        no.setFactory(getFactory());
        return no;
    }
    
    /**
     * Returns that this object is a Notation Node.
     * <p>This method is defined by DOM.
     *
     * @return          Node indicator.
     */
    public int getNodeType() {                  
        return Child.NOTATION;
    }

    /**
     * Returns the name of the Notation.
     * @return          The name of the Notation, or <var>null</var> if no name.
     * @see #setName         
     */
    public String getName() {
        return this.name;
    }

    /**
     * Sets the name of the Notation.
     * @param name      The name of the Notation.
     * @see #getName         
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /**
     * Returns if the Notation's external ID is a system ID (or public ID).
     * @return          System ID=true, Public ID=false.
     * @see #getIsPublic         
     * @see #setIsPublic         
     * @see com.ibm.xml.parser.ExternalID#isSystem
     */
    public boolean isSystem() {
        return this.externalID.isSystem();
    }
    
    /**
     * Returns if the Notation's external ID is a public ID (or system ID).
     * @return          Public ID=true, System ID=false.
     * @see #isSystem         
     * @see #setIsPublic         
     * @see com.ibm.xml.parser.ExternalID#isPublic
     */
    public boolean getIsPublic() {
        return this.externalID.isPublic();
    }

    /**
     * Sets if the Notation's external ID is a public ID (or system ID).
     * <p>This method is NOT CURRENTLY IMPLEMENTED.
     * @param   isPublic    Public ID=true, System ID=false.
     * @see #isSystem         
     * @see #getIsPublic         
     * @see com.ibm.xml.parser.ExternalID
     */
    public void setIsPublic(boolean isPublic) {
    }
    
    /**
     * Returns the system identifier of the Notation.  
     * A system identifier is a URI, which may be used to retrieve an external entity's content. 
     * @return          The system identifier, or <var>null</var> if the identifier is not defined.
     * @see #getIsPublic         
     * @see #setSystemIdentifier         
     * @see com.ibm.xml.parser.ExternalID#getSystemLiteral
     */
    public String getSystemIdentifier() {
        return this.externalID.getSystemLiteral();
    }
    
    /**
     * Sets the system identifier of the Notation.  
     * A system identifier is a URI, which may be used to retrieve an external entity's content. 
     * 
     * @param   systemIdentifier    The system identifier. 
     * @see #getIsPublic         
     * @see #setPublicIdentifier         
     * @see com.ibm.xml.parser.ExternalID
     */
    public void setSystemIdentifier(String systemIdentifier) {
        this.externalID = new ExternalID(this.externalID.getPubidLiteral(), systemIdentifier);
    }

    /**
     * Returns the public identifier of the Notation.  This value is only valid if the
     * identifier is defined as <var>public</var> (as opposed to <var>system</var>).
     * Public identifiers may be used to try to generate an alternative URI in order to
     * retrieve the an external entities content.  If retrieval fails using
     * the public identifier, an attempt must be made to retrieve content using the system
     * identifier.
     * @return          The public identifier, or <var>null</var> if the identifier is not defined.
     * @see #getIsPublic         
     * @see #setPublicIdentifier         
     * @see com.ibm.xml.parser.ExternalID
     */
    public String getPublicIdentifier() {
        return this.externalID.getPubidLiteral();
    }

    /**
     * Sets the public identifier of the Notation.  This value is only valid if the
     * identifier is defined as <var>public</var> (as opposed to <var>system</var>).
     * Public identifiers may be used to try to generate an alternative URI in order to
     * retrieve the an external entities content.  If retrieval fails using
     * the public identifier, an attempt must be made to retrieve content using the system
     * identifier.
     *
     * @param   publicIdentifier    The public identifier. 
     * @see #getIsPublic         
     * @see #getPublicIdentifier         
     * @see com.ibm.xml.parser.ExternalID
     */
    public void setPublicIdentifier(String publicIdentifier) {
        this.externalID = new ExternalID(publicIdentifier, this.externalID.getSystemLiteral());
    }

    /**
     * Returns the external ID associated with this Notation Node.  An external ID contains system,
     * and optionally, public identifiers.
     * @return          The external ID associated with this Notation Node.
     * @see com.ibm.xml.parser.ExternalID
     */
    public ExternalID getExternalID() {
        return this.externalID;
    }
}
