Class TextMapping

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--TextMapping
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class TextMapping
extends org.xml.sax.helpers.DefaultHandler

A TextMapping represents a reversible relation between two texts (a master and a slave). The mapping file itself more generally represents m-to-n relations between any number of texts.

Version:
$2007-02-14 01:38:41 mdh$
Author:
Malcolm D. Hyman

Field Summary
static int SOURCE
           
static int TARGET
           
 
Constructor Summary
TextMapping(java.net.URL mapURL, ContentOwner master, ContentOwner slave)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          This is part of the ContentHandler interface.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          This is part of the ContentHandler interface.
 java.util.List map(org.w3c.dom.Node source)
          Returns the list of target nodes mapped to the specified source node.
 void parseMapping(java.net.URL url)
          Parses the XML textmap and builds a hash that maps source IDs to target IDs.
 void put(org.w3c.dom.Node source, java.util.List targets)
          Adds a node to list-of-nodes mapping.
 void remove(org.w3c.dom.Node source)
          Removes the given node from the mapping.
 int size()
          Returns the number if items in the mapping.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          This is part of the ContentHandler interface.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE

public static final int SOURCE

TARGET

public static final int TARGET
Constructor Detail

TextMapping

public TextMapping(java.net.URL mapURL,
                   ContentOwner master,
                   ContentOwner slave)
            throws MappingParseException
Method Detail

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
This is part of the ContentHandler interface.
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
This is part of the ContentHandler interface.
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
This is part of the ContentHandler interface.
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

parseMapping

public void parseMapping(java.net.URL url)
                  throws MappingParseException
Parses the XML textmap and builds a hash that maps source IDs to target IDs.
Parameters:
url - URL for textmap

map

public java.util.List map(org.w3c.dom.Node source)
Returns the list of target nodes mapped to the specified source node.
Parameters:
source - source node
Returns:
list of target nodes

remove

public void remove(org.w3c.dom.Node source)
Removes the given node from the mapping.
Parameters:
source - source node

put

public void put(org.w3c.dom.Node source,
                java.util.List targets)
Adds a node to list-of-nodes mapping.
Parameters:
source - source node
targets - list of target nodes

size

public int size()
Returns the number if items in the mapping.
Returns:
number of items in mapping